You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

145 lines
5.3 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
using DSWeb.EntityDA;
using DSWeb.Models;
using JsonHelper;
using System.Xml;
namespace DSWeb.WMS_ZX
{
public partial class WmsZXOutList : System.Web.UI.Page
{
public string strUserID;//用户GID
public string strCompanyID;//公司GID
public string strShowName;//用户显示名
public string strDeptName;//部门名称
protected void Page_Load(object sender, EventArgs e)
{
if (Session["USERID"] != null)
{
strUserID = Session["USERID"].ToString().Trim();
}
else
{
Server.Transfer("~/Error/FriendError.aspx");
return;
}
if (Session["SHOWNAME"] != null)
{
strShowName = Session["SHOWNAME"].ToString();
}
if (Session["COMPANYID"] != null)
{
strCompanyID = Session["COMPANYID"].ToString();
}
if (Session["DEPTNAME"] != null)
{
strDeptName = Session["DEPTNAME"].ToString();
}
if (Request.QueryString["id"] != null)
{
this.h_bsno.Value = Request.QueryString["id"].ToString();
}
else
{
this.h_bsno.Value = "";
}
//
T_ALL_DA T_ALL_DA = new T_ALL_DA();
tbislockdate.Text = T_ALL_DA.GetStrSQL("rq", "select convert(char(10),getdate(),20) as rq");
}
#region 导出Excel
protected void btExcel1_Click(object sender, EventArgs e)
{
setExcelReport();
}
protected void setExcelReport()
{
StringWriter sw = new StringWriter();
string sSQL = "";
//sw.WriteLine("结算单位\t委托编号\t主提单号\t分提单号\t船名\t航次\tETD\t目的港\t揽货人\t应收RMB\t实收RMB\t应收USD\t实收USD\t余额");
sw.WriteLine(this.hdNAMES.Value.Trim());
T_ALL_DA T_ALL_DA = new T_ALL_DA();
DataSet DS = T_ALL_DA.GetAllSQL(this.hdSQL.Value.Trim());
if (DS != null)
{
foreach (DataTable myTable in DS.Tables)
{
foreach (DataRow myRow in myTable.Rows)//遍历表
{
sSQL = "";
for (int i = 0; i < myTable.Columns.Count; i++)
{
if (sSQL.Trim() != "")
{
sSQL += "\t";
}
if (myRow[i].ToString() == null || myRow[i].ToString() == "")
{
sSQL += "";
if (sSQL.Trim() == "")
{
sSQL += "\t";
}
}
else
{
string ls = myRow[i].ToString();
if (i == 9)
{
ls = ls.Replace(" ", "");
ls = ls.Replace("\r\n", "。");
}
sSQL += ls.Trim();
}
}
sw.WriteLine(sSQL);
}
}
//
sw.Close();
switch ("MUEXCEL")
{
case "MUEXCEL":
Response.AddHeader("Content-Disposition", "attachment; filename=report.xls");
Response.ContentType = "application/ms-excel";
break;
case "MUTEXT":
Response.AddHeader("Content-Disposition", "attachment; filename=report.txt");
Response.ContentType = "application/txt";
break;
case "MUWORD":
Response.AddHeader("Content-Disposition", "attachment; filename=report.doc");
Response.ContentType = "application/ms-word";
break;
case "MUPDF":
Response.AddHeader("Content-Disposition", "attachment; filename=report.pdf");
Response.ContentType = "application/pdf";
break;
case "MUXML":
Response.AddHeader("Content-Disposition", "attachment; filename=report.xml");
Response.ContentType = "application/xml";
break;
}
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
Response.Write(sw);
Response.End();
}
}
#endregion
}
}