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.

168 lines
6.2 KiB
C#

10 months ago
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.SeaiFee
{
public partial class WmsOutList : 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();
//txt_bsno.Value = this.h_bsno.Value;
//txt_bsno.Disabled = true;
h_showPm.Value = "0";
}
else
{
this.h_bsno.Value = "";
//txt_bsno.Value = "";
//txt_bsno.Disabled = false;
h_showPm.Value="1";
}
//权限可视范围
RangeDA RangeDA = new RangeDA();
this.hdRangeV.Value = RangeDA.GetVISIBLERANGE(strUserID.Trim(), "modWmsOutList");
this.hdRangeO.Value = RangeDA.GetOPERATERANGE(strUserID.Trim(), "modWmsOutList");
}
#region 导出Excel
protected void btExcel1_Click(object sender, EventArgs e)
{
//setExcelReport();
setExcelReport2();
}
protected void setExcelReport2()
{
if (this.hdSQL.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)
{
ExcelDA ExcelDA = new EntityDA.ExcelDA();
MemoryStream ms = ExcelDA.RenderToExcel(DS.Tables[0], this.hdNAMES.Value.Trim());
ExcelDA.RenderToBrowser(ms, Context, "report.xls");
}
}
}
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
}
}