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.

2126 lines
82 KiB
C#

10 months ago
using System;
using System.Data;
using System.Configuration;
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 DSWeb.DataAccess;
using DSWeb.Models;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Collections;
namespace DSWeb.EntityDA
{
public class EDIExportDA
{
/// <summary>
/// 是否数字
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public bool IsNumeric(string s)
{
int inum = 0;
bool bReturn = true;
try
{
inum = int.Parse(s);
}
catch
{
inum = 0;
bReturn = false;
}
return bReturn;
}
/// <summary>
/// 格式替换
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public string getEDIFormat(string str)
{
str = str.Replace("?", "??");
str = str.Replace("'", "?'");
str = str.Replace("+", "?+");
str = str.Replace(":", "?:");
return str;
}
/// <summary>
/// 格式截取符号
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public int getEDISUB(string str, int iold)
{
//' ', ';', ',', '.', ':', '/', '(', ')', '?', '+', '-'
int ii = 0;
int inum = 0;
ii = str.LastIndexOf(" ");
inum = ii;
ii = str.LastIndexOf(";");
if (ii > inum)
{
inum = ii;
}
ii = str.LastIndexOf(",");
if (ii > inum)
{
inum = ii;
}
ii = str.LastIndexOf(".");
if (ii > inum)
{
inum = ii;
}
ii = str.LastIndexOf(":");
if (ii > inum)
{
inum = ii;
}
ii = str.LastIndexOf("/");
if (ii > inum)
{
inum = ii;
}
ii = str.LastIndexOf("-");
if (ii > inum)
{
inum = ii;
}
ii = str.LastIndexOf("+");
if (ii > inum)
{
inum = ii;
}
ii = str.LastIndexOf("(");
if (ii > inum)
{
inum = ii;
}
ii = str.LastIndexOf(")");
if (ii > inum)
{
inum = ii;
}
if (inum == -1)
{
inum = iold;
}
if (iold - inum > 15)
{
inum = iold;
}
return inum;
}
/// <summary>
/// 数字补位例如001
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public string getEDINUM(string snum)
{
if (snum.Trim().Length == 1)
{
snum = "00" + snum;
}
else if (snum.Trim().Length == 2)
{
snum = "0" + snum;
}
return snum;
}
/// <summary>
/// 航次去掉“.”之前的数据
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public string CutVoyNo(string str)
{
int ii = str.Trim().IndexOf(".");
if (ii > -1)
{
str = str.Trim().Substring(ii);
}
return str.Trim();
}
/// <summary>
/// 当前服务器时间
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public string getdate(string str,int ii)
{
T_ALL_DA T_ALL_DA = new T_ALL_DA();
if (str.Trim() == "")
{
str = T_ALL_DA.GetStrSQL("sdate", "select getdate() as sdate ").Trim();//文件建立时间
}
if (ii == 1)
{
str = DateTime.Parse(str).ToString("yyyyMMdd").Trim();
}
else if (ii == 2)
{
str = DateTime.Parse(str).ToString("yyMMdd").Trim() + ":" + DateTime.Parse(str).ToString("hhmmss").Trim();
}
return str.Trim();
}
/// <summary>
/// 文本中是否存在中文字符
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public bool getISCN(string str)
{
string TmmP;
for (int i = 0; i < str.Length; i++)
{
TmmP = str.Substring(i, 1);
byte[] sarr = System.Text.Encoding.GetEncoding("gb2312").GetBytes(TmmP);
if (sarr.Length == 2)
{
return true;
}
}
return false;
}
#region 整箱
/// <summary>
/// 00头记录
/// </summary>
/// <returns></returns>
public string GetNpsesa00(TopSeaeEntity TopSeaeEntity,string rblFILEFUNCTION,string tbSENDERCODE,string tbRECEIVERCODE)
{
//00头记录
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = "";
string ls = getEDIFormat(rblFILEFUNCTION.Trim());
alt = "00:IFTMBF:BOOKING:" + ls.Trim() + ":";
ls = getEDIFormat(tbSENDERCODE.Trim());//发送方代码
alt += ls + ":";
ls = getEDIFormat(tbRECEIVERCODE.Trim());//接收方代码
alt += ls + ":";
ls = T_ALL_DA.GetStrSQL("sdate", "select getdate() as sdate ").Trim();//文件建立时间
ls = DateTime.Parse(ls).ToString("yyMMddhhmmss").Trim();
alt += ls + ":";
ls = getEDIFormat(TopSeaeEntity.PORTLOADID.ToString().Trim());//发送港代码
alt += ls + ":";
ls = getEDIFormat(TopSeaeEntity.PORTDISCHARGEID.ToString().Trim());//接收港代码
alt += ls + ":2.0'\r\n";
return alt;
}
/// <summary>
/// 10船舶信息
/// </summary>
/// <returns></returns>
public string GetNpsesa10(TopSeaeEntity TopSeaeEntity)
{
//10船舶信息
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = "";
string ls = getEDIFormat(TopSeaeEntity.VESSELID.ToString().Trim());//EDI船舶呼号
alt += "10:" + ls.Trim() + ":";
ls = getEDIFormat(TopSeaeEntity.VESSEL.ToString().Trim());//船名
alt += ls + ":";
ls = getEDIFormat(TopSeaeEntity.VOYNO.ToString().Trim());//航次
alt += ls + ":";
ls = "";//船公司(承运人)代码
alt += ls + ":";
ls = getEDIFormat(TopSeaeEntity.CARRIER.ToString().Trim());//船公司(承运人)
alt += ls + ":";
ls = T_ALL_DA.GetStrSQL("EDICODE", "select EDICODE from code_lanes where LANE='" + TopSeaeEntity.LANE.ToString().Trim() + "'").Trim();//航线代码
alt += ls + ":";
ls = getEDIFormat(TopSeaeEntity.LANE.ToString().Trim());//航线
alt += ls + "'\r\n";
return alt;
}
/// <summary>
/// 12港口信息
/// </summary>
/// <returns></returns>
public string GetNpsesa12(TopSeaeEntity TopSeaeEntity)
{
//12港口信息
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = "";
string ls = getEDIFormat(TopSeaeEntity.PORTLOADID.ToString().Trim());//装货港代码
alt += "12:" + ls.Trim() + ":";
ls = getEDIFormat(TopSeaeEntity.PORTLOAD.ToString().Trim());//装货港
alt += ls + ":";
ls = getEDIFormat(TopSeaeEntity.PORTDISCHARGEID.ToString().Trim());//卸货港代码
alt += ls + ":";
ls = getEDIFormat(TopSeaeEntity.PORTDISCHARGE.ToString().Trim());//卸货港
alt += ls + ":";
ls = getEDIFormat(TopSeaeEntity.PLACEDELIVERYID.ToString().Trim());//交货地代码
alt += ls + ":";
ls = getEDIFormat(TopSeaeEntity.PLACEDELIVERY.ToString().Trim());//交货地
alt += ls + ":";
ls = getEDIFormat(TopSeaeEntity.DESTINATIONID.ToString().Trim());//目的地代码
alt += ls + ":";
ls = getEDIFormat(TopSeaeEntity.DESTINATION.ToString().Trim());//目的地
alt += ls + ":";
ls = "";//中转地点代码
alt += ls + ":";
ls = "";//中转地点
alt += ls + ":";
ls = "";//中转目的地代码
alt += ls + ":";
ls = "";//中转目的地
alt += ls + ":";
ls = "";//货物装载运输工具时间
alt += ls + ":";
ls = "";//到达卸货地日期
alt += ls + ":";
ls = "";//货物托运的地点或者国家代码
alt += ls + "'\r\n";
return alt;
}
/// <summary>
/// //14订舱号
/// </summary>
/// <returns></returns>
public string GetNpsesa14(TopSeaeEntity TopSeaeEntity, string rblFILEFUNCTION, string tbISSUEPARTYCODE)
{
//14订舱号
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = "";
string ls = getEDIFormat(tbISSUEPARTYCODE.Trim());//订舱人代码
alt += "14:" + ls.Trim() + ":";
ls = "";//舱位互用标识
alt += ls + ":";
ls = rblFILEFUNCTION.Trim();//订舱号标识//货代向船公司订舱时即标记3订舱号标识R1404为F货代向船代订舱时标记9、标记5/4订舱号标识R1404为B
if (ls.Trim() == "3")
{
alt += "F:";
ls = getEDIFormat(TopSeaeEntity.ORDERNO.ToString().Trim());//订舱号
alt += ls + ":";
}
else
{
alt += "B:";
ls = getEDIFormat(TopSeaeEntity.MBLNO.ToString().Trim());//提单号
alt += ls + ":";
}
ls = "";//询价的单位代码
alt += ls + ":";
ls = "";//签协议的单位代码
alt += ls + ":";
ls = "";//国外订舱单位
alt += ls + ":";
ls = getEDIFormat(TopSeaeEntity.SERVICE.ToString().Trim());//交货条款
alt += ls + ":";
ls = T_ALL_DA.GetStrSQL("EDICODE", "select EDICODE from code_frt where FRT='" + TopSeaeEntity.BLFRT.ToString().Trim() + "'").Trim();//付款方式
alt += ls + ":";
ls = "";//运费协议号
alt += ls + ":";
ls = "";//服务合同号
alt += ls + ":";
ls = "";//检疫代码
alt += ls + ":";
ls = "";//费率本代码
alt += ls + ":";
ls = "";//币种
alt += ls + ":";
ls = "";//托运货物价值
alt += ls + ":";
ls = "";//汇率
alt += ls + ":";
ls = getEDIFormat(TopSeaeEntity.MBLNO.ToString().Trim());//总提单号
alt += ls + ":";
ls = "";//船公司代码
alt += ls + "'\r\n";
return alt;
}
/// <summary>
/// 20发货人
/// </summary>
/// <returns></returns>
public string GetNpsesa20(TopSeaeEntity TopSeaeEntity)
{
//20发货人
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = "";
string ls = "";//发货人代码
alt += "20:" + ls.Trim() + ":";
ls = getEDIFormat(TopSeaeEntity.SHIPPER.ToString().Trim());//发货人内容
//
ls = ls.Replace("\r\n", "\n ");
for(int j=0;j<2;j++)
{
if (ls.Length < 71)
{
alt += ls + ":";
ls = "";
}
else
{
string sls = ls.Trim().Substring(0, 70);
int ils = getEDISUB(sls, 70);
sls = sls.Trim().Substring(0, ils);
alt += sls + ":";//
ls = ls.Trim().Substring(ils);
}
}
for(int j=0;j<3;j++)
{
if (ls.Length < 36)
{
alt += ls + ":";
ls = "";
}
else
{
string sls = ls.Trim().Substring(0, 35);
int ils = getEDISUB(sls, 35);
sls = sls.Trim().Substring(0, ils);
alt += sls + ":";//
ls = ls.Trim().Substring(ils);
}
}
//
//string[] itms = ls.Trim().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
//if (itms.Length > 0)
//{
// if (itms[0].Length < 71)
// {
// alt += itms[0].ToString().Trim() + ":";//发货人名称
// }
// else
// {
// ls = itms[0].ToString().Trim().Substring(0, 70);
// int ii = getEDISUB(ls, 70);
// string lss = ls.Substring(0, ii);
// alt += lss + ":";//发货人名称
// itms[1] = ls.Substring(ii) + itms[1];
// }
// //
// if (itms[1].Length < 71)
// {
// alt += itms[1].ToString().Trim() + ":";//发货人详细地址
// }
// else
// {
// ls = itms[1].ToString().Trim().Substring(0, 70);
// int ii = getEDISUB(ls, 70);
// string lss = ls.Substring(0,ii);
// alt += lss + ":";//发货人详细地址
// //itms[2] = ls.Substring(ls.LastIndexOf(" ")) + itms[2];
// }
////
//if (itms[2].Length < 36)
//{
// alt += itms[2].ToString().Trim() + ":";//发货人电话号码TE
//}
//else
//{
// ls = itms[2].ToString().Trim().Substring(0, 35);
// string lss = ls.Substring(0, ls.LastIndexOf(" "));
// alt += lss + ":";//发货人电话号码TE
// itms[3] = ls.Substring(ls.LastIndexOf(" ")) + itms[3];
//}
////
//if (itms[3].Length < 36)
//{
// alt += itms[3].ToString().Trim() + ":";//发货人EMAIL地址EM
//}
//else
//{
// ls = itms[3].ToString().Trim().Substring(0, 35);
// string lss = ls.Substring(0, ls.LastIndexOf(" "));
// alt += lss + ":";//发货人EMAIL地址EM
// //itmSHIPPER[4] = ls.Substring(ls.LastIndexOf(" ")) + itmSHIPPER[4];
//}
//}
//alt += ":";//发货人电话号码TE
//alt += ":";//发货人EMAIL地址EM
//alt += ":";//发货人电传号码FX
alt += ":";//City name 城市名称
alt += ":";//省份代码
alt += ":";//省份名称
alt += ":";//邮政编码
alt += "'\r\n";//国家代码
return alt;
}
/// <summary>
/// 21收货人
/// </summary>
/// <returns></returns>
public string GetNpsesa21(TopSeaeEntity TopSeaeEntity)
{
//21收货人
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = "";
string ls = "";//收货人代码
alt += "21:" + ls.Trim() + ":";
ls = getEDIFormat(TopSeaeEntity.CONSIGNEE.ToString().Trim());//收货人内容
//
ls = ls.Replace("\r\n", "\n ");
for (int j = 0; j < 2; j++)
{
if (ls.Length < 71)
{
alt += ls + ":";
ls = "";
}
else
{
string sls = ls.Trim().Substring(0, 70);
int ils = getEDISUB(sls, 70);
sls = sls.Trim().Substring(0, ils);
alt += sls + ":";//
ls = ls.Trim().Substring(ils);
}
}
for (int j = 0; j < 3; j++)
{
if (ls.Length < 36)
{
alt += ls + ":";
ls = "";
}
else
{
string sls = ls.Trim().Substring(0, 35);
int ils = getEDISUB(sls, 35);
sls = sls.Trim().Substring(0, ils);
alt += sls + ":";//
ls = ls.Trim().Substring(ils);
}
}
//
//string[] itms = ls.Trim().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
//if (itms.Length > 0)
//{
// if (itms[0].Length < 71)
// {
// alt += itms[0].ToString().Trim() + ":";//收货人名称
// }
// else
// {
// ls = itms[0].ToString().Trim().Substring(0, 70);
// int ii = getEDISUB(ls, 70);
// string lss = ls.Substring(0,ii);
// alt += lss + ":";//收货人名称
// itms[1] = ls.Substring(ii) + itms[1];
// }
// //
// if (itms[1].Length < 71)
// {
// alt += itms[1].ToString().Trim() + ":";//收货人详细地址
// }
// else
// {
// ls = itms[1].ToString().Trim().Substring(0, 70);
// int ii = getEDISUB(ls, 70);
// string lss = ls.Substring(0,ii);
// alt += lss + ":";//收货人详细地址
// //itms[2] = ls.Substring(ls.LastIndexOf(" ")) + itms[2];
// }
// //
// //if (itms[2].Length < 36)
// //{
// // alt += itms[2].ToString().Trim() + ":";//收货人电话号码TE
// //}
// //else
// //{
// // ls = itms[2].ToString().Trim().Substring(0, 35);
// // string lss = ls.Substring(0, ls.LastIndexOf(" "));
// // alt += lss + ":";//收货人电话号码TE
// // itms[3] = ls.Substring(ls.LastIndexOf(" ")) + itms[3];
// //}
// ////
// //if (itms[3].Length < 36)
// //{
// // alt += itms[3].ToString().Trim() + ":";//收货人EMAIL地址EM
// //}
// //else
// //{
// // ls = itms[3].ToString().Trim().Substring(0, 35);
// // string lss = ls.Substring(0, ls.LastIndexOf(" "));
// // alt += lss + ":";//收货人EMAIL地址EM
// // //itmSHIPPER[4] = ls.Substring(ls.LastIndexOf(" ")) + itmSHIPPER[4];
// //}
//}
//alt += ":";//收货人电话号码TE
//alt += ":";//收货人EMAIL地址EM
//alt += ":";//收货人电传号码FX
alt += ":";//City name 城市名称
alt += ":";//省份代码
alt += ":";//省份名称
alt += ":";//邮政编码
alt += ":";//国家代码
alt += ":";//具体联系人名称
alt += ":";//具体联系人EMAIL地址EM
alt += ":";//具体联系人电传号码FX
alt += "'\r\n";//具体联系人电话号码TE
return alt;
}
/// <summary>
/// 22通知人
/// </summary>
/// <returns></returns>
public string GetNpsesa22(TopSeaeEntity TopSeaeEntity)
{
//22通知人
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = "";
string ls = "";//通知人代码
alt += "22:1:" + ls.Trim() + ":";
ls = getEDIFormat(TopSeaeEntity.NOTIFYPARTY.ToString().Trim());//通知人内容
//
ls = ls.Replace("\r\n", "\n ");
for (int j = 0; j < 2; j++)
{
if (ls.Length < 71)
{
alt += ls + ":";
ls = "";
}
else
{
string sls = ls.Trim().Substring(0, 70);
int ils = getEDISUB(sls, 70);
sls = sls.Trim().Substring(0, ils);
alt += sls + ":";//
ls = ls.Trim().Substring(ils);
}
}
for (int j = 0; j < 3; j++)
{
if (ls.Length < 36)
{
alt += ls + ":";
ls = "";
}
else
{
string sls = ls.Trim().Substring(0, 35);
int ils = getEDISUB(sls, 35);
sls = sls.Trim().Substring(0, ils);
alt += sls + ":";//
ls = ls.Trim().Substring(ils);
}
}
//string[] itms = ls.Trim().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
//if (itms.Length > 0)
//{
// if (itms[0].Length < 71)
// {
// alt += itms[0].ToString().Trim() + ":";//通知人名称
// }
// else
// {
// ls = itms[0].ToString().Trim().Substring(0, 70);
// int ii = getEDISUB(ls, 70);
// string lss = ls.Substring(0,ii);
// alt += lss + ":";//通知人名称
// itms[1] = ls.Substring(ii) + itms[1];
// }
// //
// if (itms[1].Length < 71)
// {
// alt += itms[1].ToString().Trim() + ":";//通知人详细地址
// }
// else
// {
// ls = itms[1].ToString().Trim().Substring(0, 70);
// int ii = getEDISUB(ls, 70);
// string lss = ls.Substring(0,ii);
// alt += lss + ":";//通知人详细地址
// //itms[2] = ls.Substring(ls.LastIndexOf(" ")) + itms[2];
// }
// //
// //if (itms[2].Length < 36)
// //{
// // alt += itms[2].ToString().Trim() + ":";//通知人电话号码TE
// //}
// //else
// //{
// // ls = itms[2].ToString().Trim().Substring(0, 35);
// // string lss = ls.Substring(0, ls.LastIndexOf(" "));
// // alt += lss + ":";//通知人电话号码TE
// // itms[3] = ls.Substring(ls.LastIndexOf(" ")) + itms[3];
// //}
// ////
// //if (itms[3].Length < 36)
// //{
// // alt += itms[3].ToString().Trim() + ":";//通知人EMAIL地址EM
// //}
// //else
// //{
// // ls = itms[3].ToString().Trim().Substring(0, 35);
// // string lss = ls.Substring(0, ls.LastIndexOf(" "));
// // alt += lss + ":";//通知人EMAIL地址EM
// // //itmSHIPPER[4] = ls.Substring(ls.LastIndexOf(" ")) + itmSHIPPER[4];
// //}
//}
//alt += ":";//通知人电话号码TE
//alt += ":";//通知人EMAIL地址EM
//alt += ":";//通知人电传号码FX
alt += ":";//City name 城市名称
alt += ":";//省份代码
alt += ":";//省份名称
alt += ":";//邮政编码
alt += "'\r\n";//国家代码
return alt;
}
/// <summary>
/// 40订舱预配箱
/// </summary>
/// <returns></returns>
public string GetNpsesa40(TopSeaeEntity TopSeaeEntity, string rblFILEFUNCTION,string strHBL)
{
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = "";
string ls = "";
DataSet ds = T_ALL_DA.GetAllSQL("select CTNALL,EDICODE=isnull((select EDICODE from code_ctn where ctn=op_ctn.CTNALL),CTNALL),count(CTNALL) as hj from op_ctn where BSNO='" + TopSeaeEntity.BSNO.ToString().Trim() + "' group by CTNALL order by CTNALL");//EDI船舶呼号
if (strHBL.Trim() == "0")//整箱
{
if (ds != null)
{
int k = 0;
foreach (DataTable myTable in ds.Tables)
{
foreach (DataRow myRow in myTable.Rows)//遍历表
{
k = k + 1;
ls = getEDIFormat(myRow["EDICODE"].ToString().Trim());//集装箱尺寸类型
alt += "40:"+k+":" + ls.Trim() + ":";
ls = getEDIFormat(myRow["hj"].ToString().Trim());//集装箱箱数
alt += ls + ":";
alt += "F:::";//集装箱状态//拼箱号//装箱地点代码
ls = getEDIFormat(TopSeaeEntity.ISCONTAINERSOC.ToString().Trim());//货主箱标志(是否自有箱)
if (bool.Parse(ls.Trim()))
{
alt += "Y:";
}
else
{
alt += "N:";
}
ls = "";//拼箱人代码
alt += ls + "'\r\n";
}
}
}
}
else
{
if (ds != null)
{
int k = 0;
string px = "";
//拼箱号
ls = rblFILEFUNCTION.Trim();//订舱号标识//货代向船公司订舱时即标记3订舱号标识R1404为F货代向船代订舱时标记9、标记5/4订舱号标识R1404为B
if (ls.Trim() == "3")
{
px = getEDIFormat(TopSeaeEntity.ORDERNO.ToString().Trim());//订舱号
}
else
{
px = getEDIFormat(TopSeaeEntity.MBLNO.ToString().Trim());//提单号
}
//
foreach (DataTable myTable in ds.Tables)
{
foreach (DataRow myRow in myTable.Rows)//遍历表
{
k = k + 1;
ls = getEDIFormat(myRow["EDICODE"].ToString().Trim());//集装箱尺寸类型
alt += "40:"+k+":" + ls.Trim() + ":";
ls = getEDIFormat(myRow["hj"].ToString().Trim());//集装箱箱数
alt += ls + ":";
alt += "L:";//集装箱状态//拼箱号//装箱地点代码
if (k == 1)
{
ls = "";//拼箱号
alt += ls + ":";
}
else
{
alt += px + ":";//拼箱号
}
ls = "";//装箱地点代码
alt += ls + ":";
ls = getEDIFormat(TopSeaeEntity.ISCONTAINERSOC.ToString().Trim());//货主箱标志(是否自有箱)
if (bool.Parse(ls.Trim()))
{
alt += "Y:";
}
else
{
alt += "N:";
}
ls = "";//拼箱人代码
alt += ls + "'\r\n";
}
}
}
}
return alt;
}
/// <summary>
/// 41订舱货物
/// </summary>
/// <returns></returns>
public string GetNpsesa41(TopSeaeEntity TopSeaeEntity)
{
//41订舱货物
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = "";
string ls = "";
int k = 0;
DataSet ds = T_ALL_DA.GetAllSQL("select *,pkEDICODE1=(select EDICODE from code_package where PKGS=op_seae_hs.KINDPKGS1),pkEDICODE2=(select EDICODE from code_package where PKGS=op_seae_hs.KINDPKGS2) from op_seae_hs where bsno='" + TopSeaeEntity.BSNO.ToString().Trim() + "'");//
if (ds != null)
{
foreach (DataTable myTable in ds.Tables)
{
foreach (DataRow myRow in myTable.Rows)//遍历表
{
k = k + 1;
ls = getEDINUM(k.ToString());//货物序号
alt += "41:" + ls.Trim() + ":";
ls = getEDIFormat(myRow["CARGOCODE"].ToString().Trim());//货类代码,海关HS码
alt += ls + ":";
ls = getEDIFormat(myRow["CARGOID"].ToString().Trim());//货物标识
alt += ls + ":";
ls = getEDIFormat(myRow["PKGS1"].ToString().Trim());//第一层包装件数
if (int.Parse(ls) == 0)
{
ls = "";
}
alt += ls + ":";
ls = getEDIFormat(myRow["pkEDICODE1"].ToString().Trim());//第一层包装类型
alt += ls + ":";
ls = getEDIFormat(myRow["NOPKGS1"].ToString().Trim());//第一层包装说明
alt += ls + ":";
ls = getEDIFormat(myRow["CARGOGROSSWT1"].ToString().Trim());//第一层包装皮重
if (Decimal.Parse(ls) == 0)
{
ls = "";
}
alt += ls + ":";
ls = getEDIFormat(myRow["CARGOMEASUREMENT1"].ToString().Trim());//第一层包装尺码
if (Decimal.Parse(ls) == 0)
{
ls = "";
}
alt += ls + ":";
ls = getEDIFormat(myRow["PKGS2"].ToString().Trim());//第二层包装件数
if (int.Parse(ls) == 0)
{
ls = "";
}
alt += ls + ":";
ls = getEDIFormat(myRow["pkEDICODE2"].ToString().Trim());//第二层包装类型
alt += ls + ":";
ls = getEDIFormat(myRow["NOPKGS2"].ToString().Trim());//第二层包装说明
alt += ls + ":";
ls = getEDIFormat(myRow["CARGOGROSSWT2"].ToString().Trim());//第一层包装皮重
if (Decimal.Parse(ls) == 0)
{
ls = "";
}
alt += ls + ":";
ls = getEDIFormat(myRow["CARGOMEASUREMENT2"].ToString().Trim());//第二层包装尺码
if (Decimal.Parse(ls) == 0)
{
ls = "";
}
alt += ls + ":";
ls = getEDIFormat(myRow["KGS"].ToString().Trim());//货净重
if (Decimal.Parse(ls) == 0)
{
ls = "0";
}
alt += ls + ":";
ls = getEDIFormat(myRow["CBM"].ToString().Trim());//货物体积
if (Decimal.Parse(ls) == 0)
{
ls = "";
}
alt += ls + ":";
ls = getEDIFormat(myRow["CONSIGNMENTNO"].ToString().Trim());//托运编号
alt += ls + ":";
ls = getEDIFormat(myRow["COUNTRYCODE"].ToString().Trim());//货物原产国代码
alt += ls + "'\r\n";
}
}
}
//else
//{
// ls = getEDINUM("1");//货物序号
// alt += "41:" + ls.Trim() + ":";
// ls = getEDIFormat(myRow["CARGOCODE"].ToString().Trim());//货类代码,海关HS码
// alt += ls + ":";
// ls = getEDIFormat(TopSeaeEntity.CARGOID.ToString().Trim());//货物标识
// alt += ls + ":";
// ls = getEDIFormat(TopSeaeEntity.PKGS.ToString().Trim());//第一层包装件数
// alt += ls + ":";
// ls = getEDIFormat(TopSeaeEntity.KINDPKGS.ToString().Trim());//第一层包装类型
// alt += ls + ":";
// ls = getEDIFormat(TopSeaeEntity.NOPKGS.ToString().Trim());//第一层包装说明
// alt += ls + ":";
// ls = "";//第一层包装皮重
// alt += ls + ":";
// ls = getEDIFormat(TopSeaeEntity.CBM.ToString().Trim());//第一层包装尺码
// alt += ls + ":";
// ls = "";//第二层包装件数
// alt += ls + ":";
// ls = "";//第二层包装类型
// alt += ls + ":";
// ls = "";//第二层包装说明
// alt += ls + ":";
// ls = "";//第一层包装皮重
// alt += ls + ":";
// ls = "";//第二层包装尺码
// alt += ls + ":";
// ls = getEDIFormat(TopSeaeEntity.KGS.ToString().Trim());//货净重
// alt += ls + ":";
// ls = getEDIFormat(TopSeaeEntity.CBM.ToString().Trim());//货物体积
// alt += ls + ":";
// ls = "";//托运编号
// alt += ls + ":";
// ls = "";//货物原产国代码
// alt += ls + "'\r\n";
//}
return alt;
}
/// <summary>
/// 43危险品,冷藏和超标信息
/// </summary>
/// <returns></returns>
public string GetNpsesa43(TopSeaeEntity TopSeaeEntity)
{
//43危险品,冷藏和超标信息
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = "";
string ls = getEDINUM("1");//货物序号
alt += "43:" + ls.Trim() + ":";
ls = getEDIFormat(TopSeaeEntity.DCLASS.ToString().Trim());//危险品分类
alt += ls + ":";
ls = "";//危险品页号
alt += ls + ":";
ls = getEDIFormat(TopSeaeEntity.DUNNO.ToString().Trim());//联合国危险品编号
alt += ls + ":";
ls = "";//危险品标签
alt += ls + ":";
ls = "";//危险货物闪点
alt += ls + ":";
ls = "";//船运危险品应急措施号
alt += ls + ":";
ls = "";//医疗急救指南号
alt += ls + ":";
ls = "";//海运污染
alt += ls + ":";
ls = "";//应急联系
alt += ls + ":";
ls = getEDIFormat(TopSeaeEntity.TEMPID.ToString().Trim());//温度计量单位C=摄氏 F=华氏
alt += ls + ":";
ls = getEDIFormat(TopSeaeEntity.TEMPSET.ToString().Trim());//设置温度
alt += ls + ":";
ls = getEDIFormat(TopSeaeEntity.TEMPMIN.ToString().Trim());//冷藏最低温度
alt += ls + ":";
ls = getEDIFormat(TopSeaeEntity.TEMPMAX.ToString().Trim());//冷藏最高温度
alt += ls + ":";
ls = "";//前超
alt += ls + ":";
ls = "";//后超
alt += ls + ":";
ls = "";//左超
alt += ls + ":";
ls = "";//右超
alt += ls + ":";
ls = "";//超高
alt += ls + ":";
ls = "";//危险品联系人姓名
alt += ls + ":";
ls = "";//危险品联系人EMAIL
alt += ls + ":";
ls = "";//危险品联系人电传
alt += ls + "'\r\n";
return alt;
}
/// <summary>
/// 44唛头
/// </summary>
/// <returns></returns>
public string GetNpsesa44(TopSeaeEntity TopSeaeEntity)
{
//44唛头
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = "";
string ls = "";
//
ls = getEDIFormat(TopSeaeEntity.MARKS.ToString().Trim());//唛头
//
ls = ls.Replace("\r\n", "\n ");
for (int i = 0; i < 5; i++)
{
alt += "44:" + getEDINUM((i + 1).ToString()) + ":";//货物序号
for(int j=0;j<5;j++)
{
if (ls.Length < 36)
{
alt += ls + ":";
ls = "";
}
else
{
string sls = ls.Trim().Substring(0, 35);
int ils = getEDISUB(sls, 35);
sls = sls.Trim().Substring(0, ils);
alt += sls + ":";//唛头1
ls = ls.Trim().Substring(ils);
}
}
alt = alt.Trim().Substring(0, alt.Trim().Length - 1);
alt += "'\r\n";
if (ls == "")
{
break;
}
}
//
//string[] itms = ls.Trim().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
//ArrayList aList = new ArrayList();
//for (int k = 0; k < itms.Length; k++)
//{
// ls = itms[k].ToString().Trim();
// for (int n = 0; n < (ls.Length / 35 + 1); n++)
// {
// if (ls.Length < 36)
// {
// aList.Add(ls);
// }
// else
// {
// string sls = ls.Trim().Substring(0, 35);
// int ils = getEDISUB(sls, 35);
// sls = sls.Trim().Substring(0, ils);
// aList.Add(sls);//唛头1
// ls = ls.Trim().Substring(ils);
// }
// }
//}
////
//int ilength = aList.Count;
//int iCMOD = ilength % 5;
//if (iCMOD != 0)
//{
// iCMOD = ilength / 5 + 1;
//}
////
//if (iCMOD > 5)
//{
// iCMOD = 5;
//}
////
//for (int a = 0; a < iCMOD; a++)
//{
// alt += "44:" + getEDINUM((a + 1).ToString()) + ":";//货物序号
// for (int m = 0; m < 5; m++)
// {
// try
// {
// alt += aList[m + a * 5].ToString().Trim() + ":";
// }
// catch (Exception e)
// {
// alt += ":";
// }
// }
// alt = alt.Trim().Substring(0, alt.Trim().Length - 1);
// alt += "'\r\n";
//}
//
return alt;
}
/// <summary>
/// 47货物描述
/// </summary>
/// <returns></returns>
public string GetNpsesa47(TopSeaeEntity TopSeaeEntity)
{
//47货物描述
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = "";
string ls = "";
//
ls = getEDIFormat(TopSeaeEntity.DESCRIPTION.ToString().Trim());//货物描述
//
ls = ls.Replace("\r\n", "\n ");
for (int i = 0; i < 5; i++)
{
alt += "47:" + getEDINUM((i + 1).ToString()) + ":";//货物序号
for (int j = 0; j < 5; j++)
{
if (ls.Length < 36)
{
alt += ls + ":";
ls = "";
}
else
{
string sls = ls.Trim().Substring(0, 35);
int ils = getEDISUB(sls, 35);
sls = sls.Trim().Substring(0, ils);
alt += sls + ":";//唛头1
ls = ls.Trim().Substring(ils);
}
}
alt = alt.Trim().Substring(0, alt.Trim().Length - 1);
alt += "'\r\n";
if (ls == "")
{
break;
}
}
//
//string[] itms = ls.Trim().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
//ArrayList aList = new ArrayList();
//for (int k = 0; k < itms.Length; k++)
//{
// ls = itms[k].ToString().Trim();
// for (int n = 0; n < (ls.Length / 35 + 1); n++)
// {
// if (ls.Length < 36)
// {
// aList.Add(ls);
// }
// else
// {
// string sls = ls.Trim().Substring(0, 35);
// int ils = getEDISUB(sls, 35);
// sls = sls.Trim().Substring(0, ils);
// aList.Add(sls);//唛头1
// ls = ls.Trim().Substring(ils);
// }
// }
//}
////
//int ilength = aList.Count;
//int iCMOD = ilength % 5;
//if (iCMOD != 0)
//{
// iCMOD = ilength / 5 + 1;
//}
////
//if (iCMOD > 5)
//{
// iCMOD = 5;
//}
////
//for (int a = 0; a < iCMOD; a++)
//{
// alt += "47:" + getEDINUM((a + 1).ToString()) + ":";//货物序号
// for (int m = 0; m < 5; m++)
// {
// try
// {
// alt += aList[m + a * 5].ToString().Trim() + ":";
// }
// catch (Exception e)
// {
// alt += ":";
// }
// }
// alt = alt.Trim().Substring(0, alt.Trim().Length - 1);
// alt += "'\r\n";
//}
//
return alt;
}
/// <summary>
/// 48集装箱细目
/// </summary>
/// <returns></returns>
public string GetNpsesa48(TopSeaeEntity TopSeaeEntity)
{
//48集装箱细目
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = "";
string ls = "";
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)//遍历表
{
ls = getEDIFormat(myRow["CNTRNO"].ToString().Trim());//箱号
alt += "48:" + ls.Trim() + ":";
ls = getEDIFormat(myRow["SEALNO"].ToString().Trim());//铅封号
alt += ls + ":";
ls = getEDIFormat(myRow["EDICODE"].ToString().Trim());//集装箱尺寸类型
alt += ls + ":";
alt += "F:";//集装箱尺寸类型
ls = getEDIFormat(myRow["PKGS"].ToString().Trim());//货物件数
alt += ls + ":";
ls = getEDIFormat(myRow["pkEDICODE"].ToString().Trim());//包装类型代码
alt += ls + ":";
ls = getEDIFormat(myRow["KGS"].ToString().Trim());//箱内货重
alt += ls + ":";
ls = getEDIFormat(myRow["TAREWEIGHT"].ToString().Trim());//箱皮重
alt += ls + ":";
ls = getEDIFormat(myRow["CBM"].ToString().Trim());//箱内货物体积
alt += ls + ":";
ls = "";//集装箱(器)来源代码
alt += ls + "'\r\n";
}
}
}
return alt;
}
/// <summary>
/// 60运费条款
/// </summary>
/// <returns></returns>
public string GetNpsesa60(TopSeaeEntity TopSeaeEntity)
{
//60运费条款
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = "";
string ls = T_ALL_DA.GetStrSQL("EDICODE", "select EDICODE from code_frt where FRT='" + TopSeaeEntity.BLFRT.ToString().Trim() + "'").Trim();//运费条款代码
alt += "60:" + ls.Trim() + ":";
ls = getEDIFormat(TopSeaeEntity.BLFRT.ToString().Trim());//运费条款
alt += ls + "'\r\n";
return alt;
}
/// <summary>
/// 71提单信息
/// </summary>
/// <returns></returns>
public string GetNpsesa71(TopSeaeEntity TopSeaeEntity)
{
//71提单信息
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = "";
string ls = getEDIFormat(TopSeaeEntity.ISSUETYPE.ToString().Trim());//签单方式
alt += "71:" + ls.Trim() + ":";
ls = getEDIFormat(TopSeaeEntity.ISSUEPLACEID.ToString().Trim()).Trim();//提单签发地代码
alt += ls.Trim() + ":";
ls = TopSeaeEntity.ISSUEDATE.ToString().Trim();//签发日期
ls = DateTime.Parse(ls).ToString("yyyyMMdd").Trim();
alt += ls.Trim() + ":";
ls = getEDIFormat(TopSeaeEntity.NOBILL.ToString().Trim());//正本提单份数
if(ls.Trim()=="ZERO")
{
ls = "0";
}
else if(ls.Trim()=="ONE")
{
ls = "1";
}
else if(ls.Trim()=="TWO")
{
ls = "2";
}
else if(ls.Trim()=="THREE")
{
ls = "3";
}
else if(ls.Trim()=="FOUR")
{
ls = "4";
}
else if(ls.Trim()=="FIVE")
{
ls = "5";
}
else if(ls.Trim()=="SIX")
{
ls = "6";
}
else if(ls.Trim()=="SEVEN")
{
ls = "7";
}
else if(ls.Trim()=="EIGHT")
{
ls = "8";
}
else if(ls.Trim()=="NINE")
{
ls = "9";
}
else if(ls.Trim()=="TEN")
{
ls = "10";
}
alt += ls.Trim() + ":";
ls = getEDIFormat(TopSeaeEntity.PREPARDAT.ToString().Trim());//预付地点
alt += ls.Trim() + ":";
ls = getEDIFormat(TopSeaeEntity.PAYABLEAT.ToString().Trim());//到付地点
alt += ls.Trim() + "'\r\n";
return alt;
}
#endregion
#region 分票
/// <summary>
/// 00头记录
/// </summary>
/// <returns></returns>
public string GetNpsesa00(TopSeaeBillmanageEntity TopSeaeBillmanageEntity,TopSeaeEntity TopSeaeEntity, string rblFILEFUNCTION, string tbSENDERCODE, string tbRECEIVERCODE)
{
//00头记录
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = "";
string ls = getEDIFormat(rblFILEFUNCTION.Trim());
alt = "00:IFTMBF:BOOKING:" + ls.Trim() + ":";
ls = getEDIFormat(tbSENDERCODE.Trim());//发送方代码
alt += ls + ":";
ls = getEDIFormat(tbRECEIVERCODE.Trim());//接收方代码
alt += ls + ":";
ls = T_ALL_DA.GetStrSQL("sdate", "select getdate() as sdate ").Trim();//文件建立时间
ls = DateTime.Parse(ls).ToString("yyMMddhhmmss").Trim();
alt += ls + ":";
ls = getEDIFormat(TopSeaeBillmanageEntity.PORTLOADID.ToString().Trim());//发送港代码
alt += ls + ":";
ls = getEDIFormat(TopSeaeBillmanageEntity.PORTDISCHARGEID.ToString().Trim());//接收港代码
alt += ls + ":2.0'\r\n";
return alt;
}
/// <summary>
/// 10船舶信息
/// </summary>
/// <returns></returns>
public string GetNpsesa10(TopSeaeBillmanageEntity TopSeaeBillmanageEntity, TopSeaeEntity TopSeaeEntity)
{
//10船舶信息
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = "";
string ls = getEDIFormat(TopSeaeEntity.VESSELID.ToString().Trim());//EDI船舶呼号
alt += "10:" + ls.Trim() + ":";
ls = getEDIFormat(TopSeaeBillmanageEntity.VESSEL.ToString().Trim());//船名
alt += ls + ":";
ls = getEDIFormat(TopSeaeBillmanageEntity.VOYNO.ToString().Trim());//航次
alt += ls + ":";
ls = "";//船公司(承运人)代码
alt += ls + ":";
ls = getEDIFormat(TopSeaeEntity.CARRIER.ToString().Trim());//船公司(承运人)
alt += ls + ":";
ls = T_ALL_DA.GetStrSQL("EDICODE", "select EDICODE from code_lanes where LANE='" + TopSeaeEntity.LANE.ToString().Trim() + "'").Trim();//航线代码
alt += ls + ":";
ls = getEDIFormat(TopSeaeEntity.LANE.ToString().Trim());//航线
alt += ls + "'\r\n";
return alt;
}
/// <summary>
/// 12港口信息
/// </summary>
/// <returns></returns>
public string GetNpsesa12(TopSeaeBillmanageEntity TopSeaeBillmanageEntity,TopSeaeEntity TopSeaeEntity)
{
//12港口信息
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = "";
string ls = getEDIFormat(TopSeaeBillmanageEntity.PORTLOADID.ToString().Trim());//装货港代码
alt += "12:" + ls.Trim() + ":";
ls = getEDIFormat(TopSeaeBillmanageEntity.PORTLOAD.ToString().Trim());//装货港
alt += ls + ":";
ls = getEDIFormat(TopSeaeBillmanageEntity.PORTDISCHARGEID.ToString().Trim());//卸货港代码
alt += ls + ":";
ls = getEDIFormat(TopSeaeBillmanageEntity.PORTDISCHARGE.ToString().Trim());//卸货港
alt += ls + ":";
ls = getEDIFormat(TopSeaeBillmanageEntity.PLACEDELIVERYID.ToString().Trim());//交货地代码
alt += ls + ":";
ls = getEDIFormat(TopSeaeBillmanageEntity.PLACEDELIVERY.ToString().Trim());//交货地
alt += ls + ":";
ls = getEDIFormat(TopSeaeBillmanageEntity.DESTINATIONID.ToString().Trim());//目的地代码
alt += ls + ":";
ls = getEDIFormat(TopSeaeBillmanageEntity.DESTINATION.ToString().Trim());//目的地
alt += ls + ":";
ls = "";//中转地点代码
alt += ls + ":";
ls = "";//中转地点
alt += ls + ":";
ls = "";//中转目的地代码
alt += ls + ":";
ls = "";//中转目的地
alt += ls + ":";
ls = "";//货物装载运输工具时间
alt += ls + ":";
ls = "";//到达卸货地日期
alt += ls + ":";
ls = "";//货物托运的地点或者国家代码
alt += ls + "'\r\n";
return alt;
}
/// <summary>
/// //14订舱号
/// </summary>
/// <returns></returns>
public string GetNpsesa14(TopSeaeBillmanageEntity TopSeaeBillmanageEntity,TopSeaeEntity TopSeaeEntity, string rblFILEFUNCTION, string tbISSUEPARTYCODE)
{
//14订舱号
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = "";
string ls = getEDIFormat(tbISSUEPARTYCODE.Trim());//订舱人代码
alt += "14:" + ls.Trim() + ":";
ls = "";//舱位互用标识
alt += ls + ":";
ls = rblFILEFUNCTION.Trim();//订舱号标识//货代向船公司订舱时即标记3订舱号标识R1404为F货代向船代订舱时标记9、标记5/4订舱号标识R1404为B
if (ls.Trim() == "3")
{
alt += "F:";
ls = getEDIFormat(TopSeaeEntity.ORDERNO.ToString().Trim());//订舱号
alt += ls + ":";
}
else
{
alt += "B:";
ls = getEDIFormat(TopSeaeBillmanageEntity.MBLNO.ToString().Trim());//提单号
alt += ls + ":";
}
ls = "";//询价的单位代码
alt += ls + ":";
ls = "";//签协议的单位代码
alt += ls + ":";
ls = "";//国外订舱单位
alt += ls + ":";
ls = getEDIFormat(TopSeaeEntity.SERVICE.ToString().Trim());//交货条款_分单页面没有
alt += ls + ":";
ls = T_ALL_DA.GetStrSQL("EDICODE", "select EDICODE from code_frt where FRT='" + TopSeaeEntity.BLFRT.ToString().Trim() + "'").Trim();//付款方式_分单页面没有
alt += ls + ":";
ls = "";//运费协议号
alt += ls + ":";
ls = "";//服务合同号
alt += ls + ":";
ls = "";//检疫代码
alt += ls + ":";
ls = "";//费率本代码
alt += ls + ":";
ls = "";//币种
alt += ls + ":";
ls = "";//托运货物价值
alt += ls + ":";
ls = "";//汇率
alt += ls + ":";
ls = getEDIFormat(TopSeaeBillmanageEntity.MBLNO.ToString().Trim());//总提单号
alt += ls + ":";
ls = "";//船公司代码
alt += ls + "'\r\n";
return alt;
}
/// <summary>
/// 20发货人
/// </summary>
/// <returns></returns>
public string GetNpsesa20(TopSeaeBillmanageEntity TopSeaeBillmanageEntity)
{
//20发货人
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = "";
string ls = "";//发货人代码
alt += "20:" + ls.Trim() + ":";
ls = getEDIFormat(TopSeaeBillmanageEntity.SHIPPER.ToString().Trim());//发货人内容
//
ls = ls.Replace("\r\n", "\n ");
for (int j = 0; j < 2; j++)
{
if (ls.Length < 71)
{
alt += ls + ":";
ls = "";
}
else
{
string sls = ls.Trim().Substring(0, 70);
int ils = getEDISUB(sls, 70);
sls = sls.Trim().Substring(0, ils);
alt += sls + ":";//
ls = ls.Trim().Substring(ils);
}
}
for (int j = 0; j < 3; j++)
{
if (ls.Length < 36)
{
alt += ls + ":";
ls = "";
}
else
{
string sls = ls.Trim().Substring(0, 35);
int ils = getEDISUB(sls, 35);
sls = sls.Trim().Substring(0, ils);
alt += sls + ":";//
ls = ls.Trim().Substring(ils);
}
}
//
//string[] itms = ls.Trim().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
//if (itms.Length > 0)
//{
// if (itms[0].Length < 71)
// {
// alt += itms[0].ToString().Trim() + ":";//发货人名称
// }
// else
// {
// ls = itms[0].ToString().Trim().Substring(0, 70);
// int ii = getEDISUB(ls, 70);
// string lss = ls.Substring(0,ii);
// alt += lss + ":";//发货人名称
// itms[1] = ls.Substring(ii) + itms[1];
// }
// //
// if (itms[1].Length < 71)
// {
// alt += itms[1].ToString().Trim() + ":";//发货人详细地址
// }
// else
// {
// ls = itms[1].ToString().Trim().Substring(0, 70);
// int ii = getEDISUB(ls, 70);
// string lss = ls.Substring(0,ii);
// alt += lss + ":";//发货人详细地址
// //itms[2] = ls.Substring(ls.LastIndexOf(" ")) + itms[2];
// }
// ////
// //if (itms[2].Length < 36)
// //{
// // alt += itms[2].ToString().Trim() + ":";//发货人电话号码TE
// //}
// //else
// //{
// // ls = itms[2].ToString().Trim().Substring(0, 35);
// // string lss = ls.Substring(0, ls.LastIndexOf(" "));
// // alt += lss + ":";//发货人电话号码TE
// // itms[3] = ls.Substring(ls.LastIndexOf(" ")) + itms[3];
// //}
// ////
// //if (itms[3].Length < 36)
// //{
// // alt += itms[3].ToString().Trim() + ":";//发货人EMAIL地址EM
// //}
// //else
// //{
// // ls = itms[3].ToString().Trim().Substring(0, 35);
// // string lss = ls.Substring(0, ls.LastIndexOf(" "));
// // alt += lss + ":";//发货人EMAIL地址EM
// // //itmSHIPPER[4] = ls.Substring(ls.LastIndexOf(" ")) + itmSHIPPER[4];
// //}
//}
//alt += ":";//发货人电话号码TE
//alt += ":";//发货人EMAIL地址EM
//alt += ":";//发货人电传号码FX
alt += ":";//City name 城市名称
alt += ":";//省份代码
alt += ":";//省份名称
alt += ":";//邮政编码
alt += "'\r\n";//国家代码
return alt;
}
/// <summary>
/// 21收货人
/// </summary>
/// <returns></returns>
public string GetNpsesa21(TopSeaeBillmanageEntity TopSeaeBillmanageEntity)
{
//21收货人
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = "";
string ls = "";//收货人代码
alt += "21:" + ls.Trim() + ":";
ls = getEDIFormat(TopSeaeBillmanageEntity.CONSIGNEE.ToString().Trim());//收货人内容
//
ls = ls.Replace("\r\n", "\n ");
for (int j = 0; j < 2; j++)
{
if (ls.Length < 71)
{
alt += ls + ":";
ls = "";
}
else
{
string sls = ls.Trim().Substring(0, 70);
int ils = getEDISUB(sls, 70);
sls = sls.Trim().Substring(0, ils);
alt += sls + ":";//
ls = ls.Trim().Substring(ils);
}
}
for (int j = 0; j < 3; j++)
{
if (ls.Length < 36)
{
alt += ls + ":";
ls = "";
}
else
{
string sls = ls.Trim().Substring(0, 35);
int ils = getEDISUB(sls, 35);
sls = sls.Trim().Substring(0, ils);
alt += sls + ":";//
ls = ls.Trim().Substring(ils);
}
}
//
//string[] itms = ls.Trim().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
//if (itms.Length > 0)
//{
// if (itms[0].Length < 71)
// {
// alt += itms[0].ToString().Trim() + ":";//收货人名称
// }
// else
// {
// ls = itms[0].ToString().Trim().Substring(0, 70);
// int ii = getEDISUB(ls, 70);
// string lss = ls.Substring(0,ii);
// alt += lss + ":";//收货人名称
// itms[1] = ls.Substring(ls.LastIndexOf(" ")) + itms[1];
// }
// //
// if (itms[1].Length < 71)
// {
// alt += itms[1].ToString().Trim() + ":";//收货人详细地址
// }
// else
// {
// ls = itms[1].ToString().Trim().Substring(0, 70);
// int ii = getEDISUB(ls, 70);
// string lss = ls.Substring(0, ii);
// alt += lss + ":";//收货人详细地址
// //itms[2] = ls.Substring(ls.LastIndexOf(" ")) + itms[2];
// }
// //
// //if (itms[2].Length < 36)
// //{
// // alt += itms[2].ToString().Trim() + ":";//收货人电话号码TE
// //}
// //else
// //{
// // ls = itms[2].ToString().Trim().Substring(0, 35);
// // string lss = ls.Substring(0, ls.LastIndexOf(" "));
// // alt += lss + ":";//收货人电话号码TE
// // itms[3] = ls.Substring(ls.LastIndexOf(" ")) + itms[3];
// //}
// ////
// //if (itms[3].Length < 36)
// //{
// // alt += itms[3].ToString().Trim() + ":";//收货人EMAIL地址EM
// //}
// //else
// //{
// // ls = itms[3].ToString().Trim().Substring(0, 35);
// // string lss = ls.Substring(0, ls.LastIndexOf(" "));
// // alt += lss + ":";//收货人EMAIL地址EM
// // //itmSHIPPER[4] = ls.Substring(ls.LastIndexOf(" ")) + itmSHIPPER[4];
// //}
//}
//alt += ":";//收货人电话号码TE
//alt += ":";//收货人EMAIL地址EM
//alt += ":";//收货人电传号码FX
alt += ":";//City name 城市名称
alt += ":";//省份代码
alt += ":";//省份名称
alt += ":";//邮政编码
alt += ":";//国家代码
alt += ":";//具体联系人名称
alt += ":";//具体联系人EMAIL地址EM
alt += ":";//具体联系人电传号码FX
alt += "'\r\n";//具体联系人电话号码TE
return alt;
}
/// <summary>
/// 22通知人
/// </summary>
/// <returns></returns>
public string GetNpsesa22(TopSeaeBillmanageEntity TopSeaeBillmanageEntity)
{
//22通知人
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = "";
string ls = "";//通知人代码
alt += "22:1:" + ls.Trim() + ":";
ls = getEDIFormat(TopSeaeBillmanageEntity.NOTIFYPARTY.ToString().Trim());//通知人内容
//
ls = ls.Replace("\r\n", "\n ");
for (int j = 0; j < 2; j++)
{
if (ls.Length < 71)
{
alt += ls + ":";
ls = "";
}
else
{
string sls = ls.Trim().Substring(0, 70);
int ils = getEDISUB(sls, 70);
sls = sls.Trim().Substring(0, ils);
alt += sls + ":";//
ls = ls.Trim().Substring(ils);
}
}
for (int j = 0; j < 3; j++)
{
if (ls.Length < 36)
{
alt += ls + ":";
ls = "";
}
else
{
string sls = ls.Trim().Substring(0, 35);
int ils = getEDISUB(sls, 35);
sls = sls.Trim().Substring(0, ils);
alt += sls + ":";//
ls = ls.Trim().Substring(ils);
}
}
//string[] itms = ls.Trim().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
//if (itms.Length > 0)
//{
// if (itms[0].Length < 71)
// {
// alt += itms[0].ToString().Trim() + ":";//通知人名称
// }
// else
// {
// ls = itms[0].ToString().Trim().Substring(0, 70);
// int ii = getEDISUB(ls, 70);
// string lss = ls.Substring(0,ii);
// alt += lss + ":";//通知人名称
// itms[1] = ls.Substring(ii) + itms[1];
// }
// //
// if (itms[1].Length < 71)
// {
// alt += itms[1].ToString().Trim() + ":";//通知人详细地址
// }
// else
// {
// ls = itms[1].ToString().Trim().Substring(0, 70);
// int ii = getEDISUB(ls, 70);
// string lss = ls.Substring(0,ii);
// alt += lss + ":";//通知人详细地址
// //itms[2] = ls.Substring(ls.LastIndexOf(" ")) + itms[2];
// }
// //
// //if (itms[2].Length < 36)
// //{
// // alt += itms[2].ToString().Trim() + ":";//通知人电话号码TE
// //}
// //else
// //{
// // ls = itms[2].ToString().Trim().Substring(0, 35);
// // string lss = ls.Substring(0, ls.LastIndexOf(" "));
// // alt += lss + ":";//通知人电话号码TE
// // itms[3] = ls.Substring(ls.LastIndexOf(" ")) + itms[3];
// //}
// ////
// //if (itms[3].Length < 36)
// //{
// // alt += itms[3].ToString().Trim() + ":";//通知人EMAIL地址EM
// //}
// //else
// //{
// // ls = itms[3].ToString().Trim().Substring(0, 35);
// // string lss = ls.Substring(0, ls.LastIndexOf(" "));
// // alt += lss + ":";//通知人EMAIL地址EM
// // //itmSHIPPER[4] = ls.Substring(ls.LastIndexOf(" ")) + itmSHIPPER[4];
// //}
//}
//alt += ":";//通知人电话号码TE
//alt += ":";//通知人EMAIL地址EM
//alt += ":";//通知人电传号码FX
alt += ":";//City name 城市名称
alt += ":";//省份代码
alt += ":";//省份名称
alt += ":";//邮政编码
alt += "'\r\n";//国家代码
return alt;
}
/// <summary>
/// 40订舱预配箱
/// </summary>
/// <returns></returns>
public string GetNpsesa40(TopSeaeBillmanageEntity TopSeaeBillmanageEntity,TopSeaeEntity TopSeaeEntity, string rblFILEFUNCTION, string strHBL)
{
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = "";
string ls = "";
DataSet ds = T_ALL_DA.GetAllSQL("select CTNALL,EDICODE=isnull((select EDICODE from code_ctn where ctn=op_ctn.CTNALL),CTNALL),count(CTNALL) as hj from op_ctn where BSNO='" + TopSeaeBillmanageEntity.BSNO.ToString().Trim() + "' group by CTNALL order by CTNALL");//EDI船舶呼号
if (strHBL.Trim() == "0")//整箱
{
if (ds != null)
{
int k = 0;
foreach (DataTable myTable in ds.Tables)
{
foreach (DataRow myRow in myTable.Rows)//遍历表
{
k = k + 1;
ls = getEDIFormat(myRow["EDICODE"].ToString().Trim());//集装箱尺寸类型
alt += "40:" + k + ":" + ls.Trim() + ":";
ls = getEDIFormat(myRow["hj"].ToString().Trim());//集装箱箱数
alt += ls + ":";
alt += "F:::";//集装箱状态//拼箱号//装箱地点代码
ls = getEDIFormat(TopSeaeEntity.ISCONTAINERSOC.ToString().Trim());//货主箱标志(是否自有箱)
if (bool.Parse(ls.Trim()))
{
alt += "Y:";
}
else
{
alt += "N:";
}
ls = "";//拼箱人代码
alt += ls + "'\r\n";
}
}
}
}
else
{
if (ds != null)
{
int k = 0;
string px = "";
//拼箱号
ls = rblFILEFUNCTION.Trim();//订舱号标识//货代向船公司订舱时即标记3订舱号标识R1404为F货代向船代订舱时标记9、标记5/4订舱号标识R1404为B
if (ls.Trim() == "3")
{
px = getEDIFormat(TopSeaeEntity.ORDERNO.ToString().Trim());//订舱号
}
else
{
px = getEDIFormat(TopSeaeBillmanageEntity.MBLNO.ToString().Trim());//提单号
}
//
foreach (DataTable myTable in ds.Tables)
{
foreach (DataRow myRow in myTable.Rows)//遍历表
{
k = k + 1;
ls = getEDIFormat(myRow["EDICODE"].ToString().Trim());//集装箱尺寸类型
alt += "40:" + k + ":" + ls.Trim() + ":";
ls = getEDIFormat(myRow["hj"].ToString().Trim());//集装箱箱数
alt += ls + ":";
alt += "L:";//集装箱状态//拼箱号//装箱地点代码
if (k == 1)
{
ls = "";//拼箱号
alt += ls + ":";
}
else
{
alt += px + ":";//拼箱号
}
ls = "";//装箱地点代码
alt += ls + ":";
ls = getEDIFormat(TopSeaeEntity.ISCONTAINERSOC.ToString().Trim());//货主箱标志(是否自有箱)
if (bool.Parse(ls.Trim()))
{
alt += "Y:";
}
else
{
alt += "N:";
}
ls = "";//拼箱人代码
alt += ls + "'\r\n";
}
}
}
}
return alt;
}
/// <summary>
/// 44唛头
/// </summary>
/// <returns></returns>
public string GetNpsesa44(TopSeaeBillmanageEntity TopSeaeBillmanageEntity)
{
//44唛头
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = "";
string ls = "";
//
ls = getEDIFormat(TopSeaeBillmanageEntity.MARKS.ToString().Trim());//唛头
//
ls = ls.Replace("\r\n", "\n ");
for (int i = 0; i < 5; i++)
{
alt += "44:" + getEDINUM((i + 1).ToString()) + ":";//货物序号
for (int j = 0; j < 5; j++)
{
if (ls.Length < 36)
{
alt += ls + ":";
ls = "";
}
else
{
string sls = ls.Trim().Substring(0, 35);
int ils = getEDISUB(sls, 35);
sls = sls.Trim().Substring(0, ils);
alt += sls + ":";//唛头1
ls = ls.Trim().Substring(ils);
}
}
alt = alt.Trim().Substring(0, alt.Trim().Length - 1);
alt += "'\r\n";
if (ls == "")
{
break;
}
}
//
//string[] itms = ls.Trim().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
//ArrayList aList = new ArrayList();
//for (int k = 0; k < itms.Length; k++)
//{
// ls = itms[k].ToString().Trim();
// for (int n = 0; n < (ls.Length / 35 + 1); n++)
// {
// if (ls.Length < 36)
// {
// aList.Add(ls);
// }
// else
// {
// string sls = ls.Trim().Substring(0, 35);
// int ils = getEDISUB(sls, 35);
// sls = sls.Trim().Substring(0, ils);
// aList.Add(sls);//唛头1
// ls = ls.Trim().Substring(ils);
// }
// }
//}
////
//int ilength = aList.Count;
//int iCMOD = ilength % 5;
//if (iCMOD != 0)
//{
// iCMOD = ilength/5+1;
//}
////
//if (iCMOD > 5)
//{
// iCMOD = 5;
//}
////
//for (int a = 0; a < iCMOD; a++)
//{
// alt += "44:" + getEDINUM((a+1).ToString()) + ":";//货物序号
// for (int m = 0; m < 5; m++)
// {
// try
// {
// alt += aList[m + a * 5].ToString().Trim() + ":";
// }
// catch (Exception e)
// {
// alt += ":";
// }
// }
// alt = alt.Trim().Substring(0, alt.Trim().Length - 1);
// alt += "'\r\n";
//}
//
return alt;
}
/// <summary>
/// 47货物描述
/// </summary>
/// <returns></returns>
public string GetNpsesa47(TopSeaeBillmanageEntity TopSeaeBillmanageEntity)
{
//47货物描述
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = "";
string ls = "";
//
ls = getEDIFormat(TopSeaeBillmanageEntity.DESCRIPTION.ToString().Trim());//货物描述
//
ls = ls.Replace("\r\n", "\n ");
for (int i = 0; i < 5; i++)
{
alt += "47:" + getEDINUM((i + 1).ToString()) + ":";//货物序号
for (int j = 0; j < 5; j++)
{
if (ls.Length < 36)
{
alt += ls + ":";
ls = "";
}
else
{
string sls = ls.Trim().Substring(0, 35);
int ils = getEDISUB(sls, 35);
sls = sls.Trim().Substring(0, ils);
alt += sls + ":";//唛头1
ls = ls.Trim().Substring(ils);
}
}
alt = alt.Trim().Substring(0, alt.Trim().Length - 1);
alt += "'\r\n";
if (ls == "")
{
break;
}
}
//
//string[] itms = ls.Trim().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
//ArrayList aList = new ArrayList();
//for (int k = 0; k < itms.Length; k++)
//{
// ls = itms[k].ToString().Trim();
// for (int n = 0; n < (ls.Length / 35 + 1); n++)
// {
// if (ls.Length < 36)
// {
// aList.Add(ls);
// }
// else
// {
// string sls = ls.Trim().Substring(0, 35);
// int ils = getEDISUB(sls, 35);
// sls = sls.Trim().Substring(0, ils);
// aList.Add(sls);//唛头1
// ls = ls.Trim().Substring(ils);
// }
// }
//}
////
//int ilength = aList.Count;
//int iCMOD = ilength % 5;
//if (iCMOD != 0)
//{
// iCMOD = ilength / 5 + 1;
//}
////
//if (iCMOD > 5)
//{
// iCMOD = 5;
//}
////
//for (int a = 0; a < iCMOD; a++)
//{
// alt += "47:" + getEDINUM((a + 1).ToString()) + ":";//货物序号
// for (int m = 0; m < 5; m++)
// {
// try
// {
// alt += aList[m + a * 5].ToString().Trim() + ":";
// }
// catch (Exception e)
// {
// alt += ":";
// }
// }
// alt = alt.Trim().Substring(0, alt.Trim().Length - 1);
// alt += "'\r\n";
//}
//
return alt;
}
/// <summary>
/// 71提单信息
/// </summary>
/// <returns></returns>
public string GetNpsesa71(TopSeaeBillmanageEntity TopSeaeBillmanageEntity, TopSeaeEntity TopSeaeEntity)
{
//71提单信息
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = "";
string ls = getEDIFormat(TopSeaeEntity.ISSUETYPE.ToString().Trim());//签单方式
alt += "71:" + ls.Trim() + ":";
ls = getEDIFormat(TopSeaeEntity.ISSUEPLACEID.ToString().Trim()).Trim();//提单签发地代码
alt += ls.Trim() + ":";
ls = TopSeaeBillmanageEntity.ISSUEDATE.ToString().Trim();//签发日期
ls = DateTime.Parse(ls).ToString("yyyyMMdd").Trim();
alt += ls.Trim() + ":";
ls = getEDIFormat(TopSeaeBillmanageEntity.NOBILL.ToString().Trim());//正本提单份数
if (ls.Trim() == "ZERO")
{
ls = "0";
}
else if (ls.Trim() == "ONE")
{
ls = "1";
}
else if (ls.Trim() == "TWO")
{
ls = "2";
}
else if (ls.Trim() == "THREE")
{
ls = "3";
}
else if (ls.Trim() == "FOUR")
{
ls = "4";
}
else if (ls.Trim() == "FIVE")
{
ls = "5";
}
else if (ls.Trim() == "SIX")
{
ls = "6";
}
else if (ls.Trim() == "SEVEN")
{
ls = "7";
}
else if (ls.Trim() == "EIGHT")
{
ls = "8";
}
else if (ls.Trim() == "NINE")
{
ls = "9";
}
else if (ls.Trim() == "TEN")
{
ls = "10";
}
alt += ls.Trim() + ":";
ls = getEDIFormat(TopSeaeEntity.PREPARDAT.ToString().Trim());//预付地点_分单页面没有
alt += ls.Trim() + ":";
ls = getEDIFormat(TopSeaeEntity.PAYABLEAT.ToString().Trim());//到付地点_分单页面没有
alt += ls.Trim() + "'\r\n";
return alt;
}
#endregion
/// <summary>
/// 99尾记录
/// </summary>
/// <returns></returns>
public string GetNpsesa99(int rtof)
{
//99尾记录
string alt = "";
alt += "99:" + rtof + "'\r\n";//记录总数
return alt;
}
//------------
}
}