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.Text; using System.Data.SqlClient; using System.Collections.Generic; using System.Xml; using DSWeb.Models; using DSWeb.EntityDA; using System.IO; namespace DSWeb.FeeCodes { public partial class NpsesaEDIExportAdapter : System.Web.UI.Page { public string shandle = ""; public string strPortName = ""; public string strUserID = ""; public string strGIDS = ""; public string rblFILEFUNCTION = ""; public string strHBL = ""; public string strBSNO = ""; 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 (Request.QueryString["handle"] != null) { shandle = Request.QueryString["handle"].ToString(); } if (Request.QueryString["ids"] != null) { strGIDS = Request.QueryString["ids"].ToString(); } if (Request.QueryString["rblFILEFUNCTION"] != null) { rblFILEFUNCTION = Request.QueryString["rblFILEFUNCTION"].ToString(); } if (Request.QueryString["ishbl"] != null) { strHBL = Request.QueryString["ishbl"].ToString(); } if (Request.QueryString["bsno"] != null) { strBSNO = Request.QueryString["bsno"].ToString(); } // UnicodeEncoding unicode = new UnicodeEncoding(); if (shandle.Trim() != "") { if (shandle.Trim()=="isexport")//判断是否为空 { if (strHBL == "0") { strPortName = isExport(); } else { strPortName = isExportHBL(); } } } Response.Write(strPortName); } protected string isExportHBL() { TopSeaeBillmanageDA TopSeaeBillmanageDA = new TopSeaeBillmanageDA(); TopSeaeBillmanageEntity TopSeaeBillmanageEntity = new TopSeaeBillmanageEntity(); SeaExportInfoDA SeaExportInfoDA = new SeaExportInfoDA(); TopSeaeEntity TopSeaeEntity = new TopSeaeEntity(); TopSeaeEntity = SeaExportInfoDA.GetID(strBSNO.Trim()); T_ALL_DA T_ALL_DA = new T_ALL_DA(); // string alt0 = ""; string alt2 = ""; string ls = ""; string sVESSEL = ""; string sVOYNO = ""; string[] itmGIDS = strGIDS.Trim().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < itmGIDS.Length; i++) { string alt = ""; TopSeaeBillmanageEntity = TopSeaeBillmanageDA.GetID(itmGIDS[i].ToString().Trim()); // if (TopSeaeBillmanageEntity.MBLNO.ToString().Trim() == "")//主提单号 { alt += "主提单号、"; } // if (TopSeaeBillmanageEntity.HBLNO.ToString().Trim() == "")//分提单号 { alt += "分提单号、"; } // if (TopSeaeBillmanageEntity.VESSEL.ToString().Trim() == "")//10船名 { alt += "船名、"; } else { if (i == 0) { sVESSEL = TopSeaeBillmanageEntity.VESSEL.ToString().Trim(); } else { if (sVESSEL.Trim() != TopSeaeBillmanageEntity.VESSEL.ToString().Trim()) { alt = "请注意:只能导出同一船名、航次的业务!"; return alt; } } } // if (TopSeaeBillmanageEntity.VOYNO.ToString().Trim() == "")//10航次 { alt += "航次、"; } else { if (i == 0) { sVOYNO = TopSeaeBillmanageEntity.VOYNO.ToString().Trim(); } else { if (sVOYNO.Trim() != TopSeaeBillmanageEntity.VOYNO.ToString().Trim()) { alt = "请注意:只能导出同一船名、航次的业务!"; return alt; } } } // if (TopSeaeEntity.VESSELID.ToString().Trim() == "")//10船舶呼号 { alt += "船舶呼号、"; } // if (TopSeaeBillmanageEntity.PORTLOADID.ToString().Trim() == "")//12装货港代码 { alt += "装货港代码、"; } // if (TopSeaeBillmanageEntity.PORTDISCHARGEID.ToString().Trim() == "")//12卸货港代码 { alt += "卸货港代码、"; } // if (TopSeaeBillmanageEntity.PLACEDELIVERYID.ToString().Trim() == "")//12交货地代码 { alt += "交货地代码、"; } // if (TopSeaeBillmanageEntity.DESTINATIONID.ToString().Trim() == "")//12目的地代码 { alt += "目的地代码、"; } // if (TopSeaeBillmanageEntity.PORTLOAD.ToString().Trim() == "")//12装货港 { alt += "装货港、"; } // if (TopSeaeBillmanageEntity.PORTDISCHARGE.ToString().Trim() == "")//12卸货港 { alt += "卸货港、"; } // if (TopSeaeBillmanageEntity.PLACEDELIVERY.ToString().Trim() == "")//12交货地 { alt += "交货地、"; } // if (rblFILEFUNCTION.Trim() == "3")//订舱号标识//货代向船公司订舱时(即标记3),订舱号标识(R1404)为F,货代向船代订舱时(标记9、标记5/4),订舱号标识(R1404)为B { if (TopSeaeEntity.ORDERNO.ToString().Trim() == "")//14订舱号 { alt += "订舱号、"; } } else { if (TopSeaeBillmanageEntity.MBLNO.ToString().Trim() == "")//14提单号 { alt += "主提单号、"; } } // if (TopSeaeBillmanageEntity.SERVICE.ToString().Trim() == "")//14交货条款 { alt += "交货条款、"; } // ls = T_ALL_DA.GetStrSQL("EDICODE", "select EDICODE from code_frt where FRT='" + TopSeaeEntity.BLFRT.ToString().Trim() + "'").Trim();//14付款方式 if (ls.Trim() == "")//14付款方式 { alt += "付款方式代码、"; } //20发货人 if (TopSeaeBillmanageEntity.SHIPPER.ToString().Trim() == "")//20发货人内容 { alt += "发货人内容、"; } else { ls = TopSeaeBillmanageEntity.SHIPPER.ToString().Trim();//发货人内容 string[] itms = ls.Trim().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); if (itms.Length<2) { alt = "请注意发货人、收货人、通知人的内容格式为,第一行填写名称(必填),第二行填写地址(必填)。"; } } //21收货人 if (TopSeaeBillmanageEntity.CONSIGNEE.ToString().Trim() == "")//21收货人内容 { alt += "收货人内容、"; } else { ls = TopSeaeBillmanageEntity.CONSIGNEE.ToString().Trim();//收货人内容 string[] itms = ls.Trim().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); if (itms.Length < 2) { alt = "请注意发货人、收货人、通知人的内容格式为,第一行填写名称(必填),第二行填写地址(必填)。"; } } //22通知人 if (TopSeaeBillmanageEntity.NOTIFYPARTY.ToString().Trim() == "")//21通知人内容 { alt += "通知人内容、"; } else { ls = TopSeaeBillmanageEntity.NOTIFYPARTY.ToString().Trim();//通知人内容 string[] itms = ls.Trim().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); if (itms.Length < 2) { alt = "请注意发货人、收货人、通知人的内容格式为,第一行填写名称(必填),第二行填写地址(必填)。"; } } //41订舱货物 //DataSet ds = T_ALL_DA.GetAllSQL(""); //if (ds != null) //{ // foreach (DataTable myTable in ds.Tables) // { // foreach (DataRow myRow in myTable.Rows)//遍历表 // { // } // } //} //else //{ // if (TopSeaeEntity.CARGOID.ToString().Trim() == "")//41货物标识 // { // alt += "货物标识、"; // } // if (TopSeaeBillmanageEntity.PKGS.ToString().Trim() == "")//41包装件数 // { // alt += "包装件数、"; // } // if (TopSeaeBillmanageEntity.KINDPKGS.ToString().Trim() == "")//41包装类型 // { // alt += "包装类型、"; // } // if (TopSeaeBillmanageEntity.NOPKGS.ToString().Trim() == "")//41包装说明 // { // alt += "包装说明、"; // } // if (TopSeaeBillmanageEntity.CBM.ToString().Trim() == "")//41包装尺码 // { // alt += "包装尺码、"; // } // if (TopSeaeBillmanageEntity.KGS.ToString().Trim() == "")//41货净重 // { // alt += "货净重、"; // } // if (TopSeaeBillmanageEntity.CBM.ToString().Trim() == "")//41货净重 // { // alt += "货物体积、"; // } //} //43危险品,冷藏和超标信息 if (TopSeaeEntity.CARGOID.ToString().Trim() == "R")//冷冻 { if (TopSeaeEntity.DCLASS.ToString().Trim() == "")//41危险品分类 { alt += "危险品分类、"; } if (TopSeaeEntity.DUNNO.ToString().Trim() == "")//41联合国危险品编号 { alt += "联合国危险品编号、"; } //危险品页号 //危险品标签 } else if (TopSeaeEntity.CARGOID.ToString().Trim() == "D")//危险 { if (TopSeaeEntity.TEMPID.ToString().Trim() == "")//温度计量单位,C=摄氏 F=华氏 { alt += "温度计量单位、"; } if (TopSeaeEntity.TEMPSET.ToString().Trim() == "")//温度计量单位,C=摄氏 F=华氏 { alt += "设置温度、"; } if (TopSeaeEntity.TEMPMIN.ToString().Trim() == "")//冷藏最低温度 { alt += "冷藏最低温度、"; } if (TopSeaeEntity.TEMPMAX.ToString().Trim() == "")//冷藏最高温度 { alt += "冷藏最高温度、"; } } //44唛头 if (TopSeaeBillmanageEntity.MARKS.ToString().Trim() == "")//唛头 { alt += "唛头、"; } //47货物描述 if (TopSeaeBillmanageEntity.DESCRIPTION.ToString().Trim() == "")//货物描述 { alt += "唛头、"; } // if (rblFILEFUNCTION.Trim() == "3")//订舱号标识//货代向船公司订舱时(即标记3),订舱号标识(R1404)为F,货代向船代订舱时(标记9、标记5/4),订舱号标识(R1404)为B { if (TopSeaeEntity.ORDERNO.ToString().Trim() == "")//14订舱号 { alt += "订舱号、"; } } else { if (TopSeaeBillmanageEntity.MBLNO.ToString().Trim() == "")//14提单号 { alt += "主提单号、"; } } // if (rblFILEFUNCTION.Trim() == "3")//订舱号标识//货代向船公司订舱时(即标记3),订舱号标识(R1404)为F,货代向船代订舱时(标记9、标记5/4),订舱号标识(R1404)为B { } else { //48集装箱细目 string alt3 = ""; DataSet ds = T_ALL_DA.GetAllSQL("select *,EDICODE=isnull((select EDICODE from code_ctn where ctn=op_ctn.CTNALL),CTNALL),pkEDICODE=(select EDICODE from code_package where pkgs=op_ctn.KINDPKGS) from op_ctn where BSNO='" + TopSeaeBillmanageEntity.BSNO.ToString().Trim() + "' order by CTNALL"); if (ds != null) { foreach (DataTable myTable in ds.Tables) { foreach (DataRow myRow in myTable.Rows)//遍历表 { alt3 = ""; if (myRow["CNTRNO"].ToString().Trim() == "")//箱号 { alt3 += "集装箱箱号、"; } if (myRow["EDICODE"].ToString().Trim() == "")//集装箱尺寸类型 { alt3 += "集装箱尺寸类型、"; } if (myRow["PKGS"].ToString().Trim() == "")//货物件数 { alt3 += "集装箱货物件数、"; } if (myRow["pkEDICODE"].ToString().Trim() == "")//包装类型代码 { alt3 += "集装箱包装类型代码、"; } if (myRow["KGS"].ToString().Trim() == "")//箱内货重 { alt3 += "集装箱箱内货重、"; } if (myRow["TAREWEIGHT"].ToString().Trim() == "")//箱皮重 { alt3 += "集装箱箱皮重、"; } ls = "";//集装箱(器)来源代码 } } } alt += alt3; } //60运费条款 if (TopSeaeBillmanageEntity.BLFRT.ToString().Trim() == "")//运费条款 { alt += "运费条款、"; } //71提单信息 if (TopSeaeEntity.BLTYPE.ToString().Trim() == "")//提单类型 { alt += "提单类型、"; } if (TopSeaeEntity.ISSUEPLACEID.ToString().Trim() == "")//提单签发地代码 { alt += "提单签发地代码、"; } if (TopSeaeBillmanageEntity.ISSUEDATE.ToString().Trim() == "")//签发日期 { alt += "签发日期、"; } if (TopSeaeBillmanageEntity.NOBILL.ToString().Trim() == "")//正本提单份数 { alt += "正本提单份数、"; } //尾部 if (alt.Trim() != "") { alt = alt.Trim().Substring(0, alt.Trim().Length - 1); alt = "主提单号:" + TopSeaeBillmanageEntity.MBLNO.ToString().Trim() + ",分提单号:" + TopSeaeBillmanageEntity.HBLNO.ToString().Trim() + ",其中"+ alt+"不能为空!" + alt2 + "\r\n"; } alt0 += alt; } return alt0; } protected string isExport() { SeaExportInfoDA SeaExportInfoDA = new SeaExportInfoDA(); T_ALL_DA T_ALL_DA = new T_ALL_DA(); // string alt0 = ""; string alt2 = ""; string ls = ""; string sVESSEL = ""; string sVOYNO = ""; string[] itmGIDS = strGIDS.Trim().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < itmGIDS.Length; i++) { string alt = ""; TopSeaeEntity TopSeaeEntity = new TopSeaeEntity(); TopSeaeEntity = SeaExportInfoDA.GetID(itmGIDS[i].ToString().Trim()); // if (TopSeaeEntity.MBLNO.ToString().Trim() == "")//主提单号 { alt += "主提单号、"; } // if (TopSeaeEntity.VESSEL.ToString().Trim() == "")//10船名 { alt += "船名、"; } else { if (i == 0) { sVESSEL = TopSeaeEntity.VESSEL.ToString().Trim(); } else { if (sVESSEL.Trim() != TopSeaeEntity.VESSEL.ToString().Trim()) { alt = "请注意:只能导出同一船名、航次的业务!"; return alt; } } } // if (TopSeaeEntity.VOYNO.ToString().Trim() == "")//10航次 { alt += "航次、"; } else { if (i == 0) { sVOYNO = TopSeaeEntity.VOYNO.ToString().Trim(); } else { if (sVOYNO.Trim() != TopSeaeEntity.VOYNO.ToString().Trim()) { alt = "请注意:只能导出同一船名、航次的业务!"; return alt; } } } // if (TopSeaeEntity.VESSELID.ToString().Trim() == "")//10船舶呼号 { alt += "船舶呼号、"; } // if (TopSeaeEntity.PORTLOADID.ToString().Trim() == "")//12装货港代码 { alt += "装货港代码、"; } // if (TopSeaeEntity.PORTDISCHARGEID.ToString().Trim() == "")//12卸货港代码 { alt += "卸货港代码、"; } // if (TopSeaeEntity.PLACEDELIVERYID.ToString().Trim() == "")//12交货地代码 { alt += "交货地代码、"; } // if (TopSeaeEntity.DESTINATIONID.ToString().Trim() == "")//12目的地代码 { alt += "目的地代码、"; } // if (TopSeaeEntity.PORTLOAD.ToString().Trim() == "")//12装货港 { alt += "装货港、"; } // if (TopSeaeEntity.PORTDISCHARGE.ToString().Trim() == "")//12卸货港 { alt += "卸货港、"; } // if (TopSeaeEntity.PLACEDELIVERY.ToString().Trim() == "")//12交货地 { alt += "交货地、"; } // if (rblFILEFUNCTION.Trim() == "3")//订舱号标识//货代向船公司订舱时(即标记3),订舱号标识(R1404)为F,货代向船代订舱时(标记9、标记5/4),订舱号标识(R1404)为B { if (TopSeaeEntity.ORDERNO.ToString().Trim() == "")//14订舱号 { alt += "订舱号、"; } } else { if (TopSeaeEntity.MBLNO.ToString().Trim() == "")//14提单号 { alt += "主提单号、"; } } // if (TopSeaeEntity.SERVICE.ToString().Trim() == "")//14交货条款 { alt += "交货条款、"; } // ls = T_ALL_DA.GetStrSQL("EDICODE", "select EDICODE from code_frt where FRT='" + TopSeaeEntity.BLFRT.ToString().Trim() + "'").Trim();//14付款方式 if (ls.Trim() == "")//14付款方式 { alt += "付款方式代码、"; } //20发货人 if (TopSeaeEntity.SHIPPER.ToString().Trim() == "")//20发货人内容 { alt += "发货人内容、"; } else { ls = TopSeaeEntity.SHIPPER.ToString().Trim();//发货人内容 string[] itms = ls.Trim().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); if (itms.Length<2) { alt = "请注意发货人、收货人、通知人的内容格式为,第一行填写名称(必填),第二行填写地址(必填)。"; } } //21收货人 if (TopSeaeEntity.CONSIGNEE.ToString().Trim() == "")//21收货人内容 { alt += "收货人内容、"; } else { ls = TopSeaeEntity.CONSIGNEE.ToString().Trim();//收货人内容 string[] itms = ls.Trim().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); if (itms.Length < 2) { alt = "请注意发货人、收货人、通知人的内容格式为,第一行填写名称(必填),第二行填写地址(必填)。"; } } //22通知人 if (TopSeaeEntity.NOTIFYPARTY.ToString().Trim() == "")//21通知人内容 { alt += "通知人内容、"; } else { ls = TopSeaeEntity.NOTIFYPARTY.ToString().Trim();//通知人内容 string[] itms = ls.Trim().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); if (itms.Length < 2) { alt = "请注意发货人、收货人、通知人的内容格式为,第一行填写名称(必填),第二行填写地址(必填)。"; } } //41订舱货物 //DataSet ds = T_ALL_DA.GetAllSQL(""); //if (ds != null) //{ // foreach (DataTable myTable in ds.Tables) // { // foreach (DataRow myRow in myTable.Rows)//遍历表 // { // } // } //} //else //{ // if (TopSeaeEntity.CARGOID.ToString().Trim() == "")//41货物标识 // { // alt += "货物标识、"; // } // if (TopSeaeEntity.PKGS.ToString().Trim() == "")//41包装件数 // { // alt += "包装件数、"; // } // if (TopSeaeEntity.KINDPKGS.ToString().Trim() == "")//41包装类型 // { // alt += "包装类型、"; // } // if (TopSeaeEntity.NOPKGS.ToString().Trim() == "")//41包装说明 // { // alt += "包装说明、"; // } // if (TopSeaeEntity.CBM.ToString().Trim() == "")//41包装尺码 // { // alt += "包装尺码、"; // } // if (TopSeaeEntity.KGS.ToString().Trim() == "")//41货净重 // { // alt += "货净重、"; // } // if (TopSeaeEntity.CBM.ToString().Trim() == "")//41货净重 // { // alt += "货物体积、"; // } //} //43危险品,冷藏和超标信息 if (TopSeaeEntity.CARGOID.ToString().Trim() == "R")//冷冻 { if (TopSeaeEntity.DCLASS.ToString().Trim() == "")//41危险品分类 { alt += "危险品分类、"; } if (TopSeaeEntity.DUNNO.ToString().Trim() == "")//41联合国危险品编号 { alt += "联合国危险品编号、"; } //危险品页号 if (TopSeaeEntity.DPAGE.ToString().Trim() == "")//危险品页号 { alt += "危险品页号、"; } //危险品标签 if (TopSeaeEntity.DLABEL.ToString().Trim() == "")//危险品标签 { alt += "危险品标签、"; } //危险品联系人 if (TopSeaeEntity.LINKMAN.ToString().Trim() == "")//危险品联系人 { alt += "危险品联系人、"; } } else if (TopSeaeEntity.CARGOID.ToString().Trim() == "D")//危险 { if (TopSeaeEntity.TEMPID.ToString().Trim() == "")//温度计量单位,C=摄氏 F=华氏 { alt += "温度计量单位、"; } if (TopSeaeEntity.TEMPSET.ToString().Trim() == "")//温度计量单位,C=摄氏 F=华氏 { alt += "设置温度、"; } if (TopSeaeEntity.TEMPMIN.ToString().Trim() == "")//冷藏最低温度 { alt += "冷藏最低温度、"; } if (TopSeaeEntity.TEMPMAX.ToString().Trim() == "")//冷藏最高温度 { alt += "冷藏最高温度、"; } } //44唛头 if (TopSeaeEntity.MARKS.ToString().Trim() == "")//唛头 { alt += "唛头、"; } //47货物描述 if (TopSeaeEntity.DESCRIPTION.ToString().Trim() == "")//货物描述 { alt += "唛头、"; } //48集装箱细目 string alt3 = ""; DataSet ds = T_ALL_DA.GetAllSQL("select *,EDICODE=isnull((select EDICODE from code_ctn where ctn=op_ctn.CTNALL),CTNALL),pkEDICODE=(select EDICODE from code_package where pkgs=op_ctn.KINDPKGS) from op_ctn where BSNO='" + TopSeaeEntity.BSNO.ToString().Trim() + "' order by CTNALL"); if (ds != null) { foreach (DataTable myTable in ds.Tables) { foreach (DataRow myRow in myTable.Rows)//遍历表 { alt3 = ""; if (myRow["CNTRNO"].ToString().Trim() == "")//箱号 { alt3 += "集装箱箱号、"; } if (myRow["EDICODE"].ToString().Trim() == "")//集装箱尺寸类型 { alt3 += "集装箱尺寸类型、"; } if (myRow["PKGS"].ToString().Trim() == "")//货物件数 { alt3 += "集装箱货物件数、"; } if (myRow["pkEDICODE"].ToString().Trim() == "")//包装类型代码 { alt3 += "集装箱包装类型代码、"; } if (myRow["KGS"].ToString().Trim() == "")//箱内货重 { alt3 += "集装箱箱内货重、"; } if (myRow["TAREWEIGHT"].ToString().Trim() == "")//箱皮重 { alt3 += "集装箱箱皮重、"; } if (TopSeaeEntity.SOURCECODE.ToString().Trim() == "")//集装箱(器)来源代码 { alt3 += "集装箱箱皮重、"; } } } } alt += alt3; //60运费条款 if (TopSeaeEntity.BLFRT.ToString().Trim() == "")//运费条款 { alt += "运费条款、"; } //71提单信息 if (TopSeaeEntity.BLTYPE.ToString().Trim() == "")//提单类型 { alt += "提单类型、"; } if (TopSeaeEntity.ISSUEPLACEID.ToString().Trim() == "")//提单签发地代码 { alt += "提单签发地代码、"; } if (TopSeaeEntity.ISSUEDATE.ToString().Trim() == "")//签发日期 { alt += "签发日期、"; } if (TopSeaeEntity.NOBILL.ToString().Trim() == "")//正本提单份数 { alt += "正本提单份数、"; } //尾部 if (alt.Trim() != "") { alt = alt.Trim().Substring(0, alt.Trim().Length - 1); alt = "主提单号:" + TopSeaeEntity.MBLNO.ToString().Trim() + ",其中"+ alt+"不能为空!" + alt2 + "\r\n"; } alt0 += alt; } return alt0; } // } }