using System; using System.Data; using System.Collections.Generic; using System.Text; using DSWeb.MvcShipping.Models.MsOpSeai; using Microsoft.Practices.EnterpriseLibrary.Data; using DSWeb.EntityDA; using DSWeb.Areas.CommMng.Models; using HcUtility.Comm; using System.Data.SqlClient; using DSWeb.DataAccess; using HcUtility.Core; using System.IO; using DSWeb.Areas.CommMng.DAL; using DSWeb.MvcShipping.Models.FtpSet; using DSWeb.MvcShipping.DAL.MsCodeCtnEdi; using DSWeb.MvcShipping.Models.MsOpSeaeToSeai; using DSWeb.MvcShipping.DAL.MsSysParamSet; using Terminal_CDMA; using System.Data.Common; using DSWeb.MvcShipping.Models.CompanyDef; using DSWeb.MvcShipping.Models.MsOpApply; using Attribute = com.sun.tools.javac.code.Attribute; using DSWeb.MvcShipping.Models.WMSNew; using DSWeb.MvcShipping.DAL.MsSysBillNoSet; using System.Configuration; using NPOI.POIFS.Storage; using DSWeb.Common.DB; using System.Linq; namespace DSWeb.MvcShipping.DAL.MsOpSeaiDAL { public class MsOpSeaiDAL { #region 查询 static public List GetDataList(string strCondition, string userid, string usercode, string companyid,string sort = null) { var rangstr = GetRangDAStr("index", userid, usercode, companyid); if (!string.IsNullOrEmpty(rangstr)) { if (!string.IsNullOrEmpty(strCondition)) { strCondition = strCondition + " and " + rangstr; } else { strCondition = rangstr; } } // var strSql = new StringBuilder(); strSql.Append("SELECT VW_OP_SEAI.*"); strSql.Append(",0 as FENPIAO ,(SELECT TOP 1 BLSTATUS FROM op_blissue WHERE BSNO=VW_OP_SEAI.BSNO) BLISSUESTATUS "); strSql.Append(",dbo.F_GetBillDrFeeStatus(VW_OP_SEAI.BSNO) DRFEESTATUS"); strSql.Append(",dbo.F_GetBillCrFeeStatus(VW_OP_SEAI.BSNO) CRFEESTATUS"); strSql.Append(",I.TTLDR,I.TTLINVDR,I.TTLDUIDR,I.TTLCR,I.TTLINVCR,I.TTLDUICR"); strSql.Append(",(SELECT COUNT(*) FROM OP_APPLY WHERE MASTERNO=VW_OP_SEAI.BSNO) as APPLYCOUNT "); strSql.Append(",(SELECT COUNT(*) FROM OP_AMEND WHERE PARENTID=VW_OP_SEAI.BSNO) as AMENDCOUNT "); strSql.Append(",(SELECT SUM(CTNNUM) FROM OP_CTN WHERE BSNO=VW_OP_SEAI.BSNO) as CTNNUM "); strSql.Append(",(SELECT COUNT(DISTINCT CNTRNO) FROM wms_in WHERE ISNULL(CNTRNO,'')<>'' AND ASSOCIATEDNO=VW_OP_SEAI.BSNO) as WMSCTNNUM "); strSql.Append(",(select TOP 1 COLOR FROM code_op_status_detail WITH(NOLOCK) WHERE OPSTATUS =VW_OP_SEAI.OPSTATUS) as OPSTATUSCOLOR "); strSql.Append(",v.CHANGEDOCSTATUS,v.CUSTOMSSTATUS,v.CANGDANSTATUS"); //strSql.Append(",(CASE FEESTATUS WHEN 1 THEN '锁定' else '' end) as FEESTATUSREF "); strSql.Append(" from VW_OP_SEAI LEFT JOIN v_op_gain_dr_INV I ON (I.BSNO=VW_OP_SEAI.BSNO) "); strSql.Append(" left join (select bsno, sum(case when[status] = '换单' then 1 else 0 end) CHANGEDOCSTATUS, sum(case when [status] = '海关放行' then 1 else 0 end) CUSTOMSSTATUS"); strSql.Append(", sum(case when [status] = '舱单' then 1 else 0 end) CANGDANSTATUS from op_status WITH (NOLOCK) GROUP BY BSNO) as v on(v.bsno = VW_OP_SEAI.BSNO) "); strSql.Append(" where VW_OP_SEAI.MASTERNO=VW_OP_SEAI.BSNO "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" AND EXISTS ( select 1 from VW_OP_SEAI B WHERE VW_OP_SEAI.BSNO=B.MASTERNO AND " + strCondition + " )"); } // var sortstring = DatasetSort.Getsortstring(sort); if (!string.IsNullOrEmpty(sortstring)) { strSql.Append(" order by " + sortstring); } else { var SeaeDefaultSort = MsSysParamSetDAL.GetData("PARAMNAME='SeaiDefaultSort'"); if (SeaeDefaultSort.PARAMVALUE != "") strSql.Append(" order by " + SeaeDefaultSort.PARAMVALUE); else strSql.Append(" order by ETD desc,MBLNO,BSDATE desc"); } return SetData(strSql); } static public List GetDataList(int start, int limit, string strCondition, string userid, string usercode, string companyid, string sort = null) { var rangstr = GetRangDAStr("index", userid, usercode, companyid); if (!string.IsNullOrEmpty(rangstr)) { if (!string.IsNullOrEmpty(strCondition)) { strCondition = strCondition + " and " + rangstr; } else { strCondition = rangstr; } } // var strSql = new StringBuilder(); strSql.Append(@"SELECT * from (SELECT row_number() over ("); var sortstring = DatasetSort.Getsortstring(sort); if (!string.IsNullOrEmpty(sortstring)) { if (sortstring.ToUpper().IndexOf("DRFEESTATUS") >= 0) strSql.Append(" order by " + sortstring.Replace("DRFEESTATUS", " dbo.F_GetBillDrFeeStatus(VW_OP_SEAI.BSNO) ")); else if (sortstring.ToUpper().IndexOf("CRFEESTATUS") >= 0) strSql.Append(" order by " + sortstring.Replace("CRFEESTATUS", " dbo.F_GetBillCrFeeStatus(VW_OP_SEAI.BSNO) ")); else if (sortstring.ToUpper().IndexOf("AMEND") >= 0) strSql.Append(" order by " + sortstring.Replace("AMEND", " CASE WHEN (SELECT COUNT(*) FROM OP_AMEND WHERE PARENTID=VW_OP_SEAI.BSNO)>0 THEN 1 ELSE 0 END ")); else if (sortstring.ToUpper().IndexOf("DRINVSTATUS") >= 0) strSql.Append(" order by " + sortstring.Replace("DRINVSTATUS", " CASE WHEN ISNULL(I.TTLINVDR,0)=0 THEN '未开票' ELSE CASE WHEN ISNULL(I.TTLINVDR,0)=ISNULL(I.TTLDR,0) THEN '已开票' ELSE '部分开票' END END ")); else if (sortstring.ToUpper().IndexOf("DRDUISTATUS") >= 0) strSql.Append(" order by " + sortstring.Replace("DRDUISTATUS", " CASE WHEN ISNULL(I.TTLDUIDR,0)=0 THEN '未对账' ELSE CASE WHEN ISNULL(I.TTLDUIDR,0)=ISNULL(I.TTLDR,0) THEN '已对账' ELSE '部分对账' END END ")); else { strSql.Append(" order by " + sortstring); } } else { var SeaeDefaultSort = MsSysParamSetDAL.GetData("PARAMNAME='SeaiDefaultSort'"); if (SeaeDefaultSort.PARAMVALUE != "") strSql.Append(" order by " + SeaeDefaultSort.PARAMVALUE ); else strSql.Append(" order by ETD desc,MBLNO,BSDATE desc"); } strSql.Append(@") as num , "); strSql.Append(" VW_OP_SEAI.*"); strSql.Append(",0 as FENPIAO,(SELECT TOP 1 BLSTATUS FROM op_blissue WHERE BSNO=VW_OP_SEAI.BSNO) BLISSUESTATUS "); strSql.Append(",dbo.F_GetBillDrFeeStatus(VW_OP_SEAI.BSNO) DRFEESTATUS"); strSql.Append(",dbo.F_GetBillCrFeeStatus(VW_OP_SEAI.BSNO) CRFEESTATUS"); strSql.Append(",I.TTLDR,I.TTLINVDR,I.TTLDUIDR,I.TTLCR,I.TTLINVCR,I.TTLDUICR"); strSql.Append(",(SELECT COUNT(*) FROM OP_APPLY WHERE MASTERNO=VW_OP_SEAI.BSNO) as APPLYCOUNT "); strSql.Append(",(SELECT COUNT(*) FROM OP_AMEND WHERE PARENTID=VW_OP_SEAI.BSNO) as AMENDCOUNT "); strSql.Append(",(SELECT SUM(CTNNUM) FROM OP_CTN WHERE BSNO=VW_OP_SEAI.BSNO) as CTNNUM "); strSql.Append(",(SELECT COUNT(DISTINCT CNTRNO) FROM wms_in WHERE ISNULL(CNTRNO,'')<>'' AND ASSOCIATEDNO=VW_OP_SEAI.BSNO) as WMSCTNNUM "); strSql.Append(",(select TOP 1 COLOR FROM code_op_status_detail WITH(NOLOCK) WHERE OPSTATUS =VW_OP_SEAI.OPSTATUS) as OPSTATUSCOLOR "); strSql.Append(",v.CHANGEDOCSTATUS,v.CUSTOMSSTATUS,v.CANGDANSTATUS"); //strSql.Append(",dbo.trimdate(DEST_RTCNT_TIME) DEST_RTCNT_TIME "); strSql.Append(" from VW_OP_SEAI LEFT JOIN v_op_gain_dr_INV I ON (I.BSNO=VW_OP_SEAI.BSNO) "); strSql.Append(" left join (select bsno, sum(case when[status] = '换单' then 1 else 0 end) CHANGEDOCSTATUS, sum(case when [status] = '海关放行' then 1 else 0 end) CUSTOMSSTATUS"); strSql.Append(", sum(case when [status] = '舱单' then 1 else 0 end) CANGDANSTATUS from op_status WITH (NOLOCK) GROUP BY BSNO) as v on(v.bsno = VW_OP_SEAI.BSNO) "); strSql.Append(" where VW_OP_SEAI.MASTERNO=VW_OP_SEAI.BSNO "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" AND EXISTS ( select 1 from VW_OP_SEAI B WHERE VW_OP_SEAI.BSNO=B.MASTERNO AND " + strCondition + " )"); } // strSql.Append(@")as t "); strSql.Append(string.Format("where t.num>{0} and t.num<={1} order by t.num ", start, start + limit)); // return SetData(strSql); } public static int getTotalCount(string strCondition, string userid, string usercode, string companyid) { var rangstr = GetRangDAStr("index", userid, usercode, companyid); if (!string.IsNullOrEmpty(rangstr)) { if (!string.IsNullOrEmpty(strCondition)) { strCondition = strCondition + " and " + rangstr; } else { strCondition = rangstr; } } StringBuilder strSql = new StringBuilder(); strSql.Append("select count(*) "); strSql.Append(" from VW_OP_SEAI "); strSql.Append(" LEFT JOIN v_op_gain_dr_INV I ON (I.BSNO=VW_OP_SEAI.BSNO) where VW_OP_SEAI.MASTERNO=VW_OP_SEAI.BSNO "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" AND EXISTS ( select 1 from VW_OP_SEAI B WHERE VW_OP_SEAI.BSNO=B.MASTERNO AND " + strCondition + " )"); } int cnt = 0; Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { cnt = Convert.ToInt32(reader[0]); } } return cnt; } static public List GetSaleDataList(string strCondition, string username, string companyid, string sort = null,string userid="") { var rangstr = GetSaleRangDAStr("index", userid, username, companyid); if (!string.IsNullOrEmpty(rangstr)) { if (!string.IsNullOrEmpty(strCondition)) { strCondition = strCondition + " and " + rangstr; } else { strCondition = rangstr; } } var strSql = new StringBuilder(); strSql.Append("SELECT B.*"); strSql.Append(",0 as FENPIAO,(SELECT TOP 1 BLSTATUS FROM op_blissue WHERE BSNO=B.BSNO) BLISSUESTATUS "); strSql.Append(",dbo.F_GetBillDrFeeStatus(B.BSNO) DRFEESTATUS"); strSql.Append(",dbo.F_GetBillCrFeeStatus(B.BSNO) CRFEESTATUS"); strSql.Append(",I.TTLDR,I.TTLINVDR,I.TTLDUIDR,I.TTLCR,I.TTLINVCR,I.TTLDUICR,0 APPLYCOUNT,0 AMENDCOUNT "); strSql.Append(",0 as CTNNUM "); strSql.Append(",0 as WMSCTNNUM "); strSql.Append(",'' as OPSTATUSCOLOR "); strSql.Append(",0 CHANGEDOCSTATUS,0 CUSTOMSSTATUS,0 CANGDANSTATUS"); strSql.Append(" from VW_OP_SEAI B LEFT JOIN v_op_gain_dr_INV I ON (I.BSNO=B.BSNO) "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } var sortstring = DatasetSort.Getsortstring(sort); if (!string.IsNullOrEmpty(sortstring)) { strSql.Append(" order by " + sortstring); } else { var SeaeDefaultSort = MsSysParamSetDAL.GetData("PARAMNAME='SeaiDefaultSort'"); if (SeaeDefaultSort.PARAMVALUE != "") strSql.Append(" order by " + SeaeDefaultSort.PARAMVALUE); else strSql.Append(" order by ETD desc,MBLNO,BSDATE desc"); } return SetData(strSql); } #region 更改单 static public List GetAmendDataList(int start, int limit, string strCondition, string userid, string usercode, string companyid, string sort = null, string load = null) { var rangstr = GetRangDAStr("index", userid, usercode, companyid); if (!string.IsNullOrEmpty(rangstr)) { if (!string.IsNullOrEmpty(strCondition)) { strCondition = strCondition + " and " + rangstr; } else { strCondition = rangstr; } } var strSql = new StringBuilder(); strSql.Append(@"SELECT * from (SELECT row_number() over ("); var sortstring = DatasetSort.Getsortstring(sort); if (!string.IsNullOrEmpty(sortstring)) { strSql.Append(" order by " + sortstring); } else { strSql.Append(" order by BSDATE desc"); } strSql.Append(@") as num , "); strSql.Append(" B.*"); strSql.Append(",0 as FENPIAO ,(SELECT TOP 1 BLSTATUS FROM op_blissue WHERE BSNO=B.BSNO) BLISSUESTATUS "); strSql.Append(",dbo.F_GetBillDrFeeStatus(B.BSNO) DRFEESTATUS"); strSql.Append(",dbo.F_GetBillCrFeeStatus(B.BSNO) CRFEESTATUS"); strSql.Append(",0 APPLYCOUNT "); strSql.Append(",0 AMENDCOUNT "); strSql.Append(",0 as CTNNUM "); strSql.Append(",0 as WMSCTNNUM "); strSql.Append(",'' as OPSTATUSCOLOR "); strSql.Append(",0 CHANGEDOCSTATUS,0 CUSTOMSSTATUS,0 CANGDANSTATUS"); strSql.Append(" FROM VW_OP_SEAI_AMEND B "); strSql.Append(" WHERE B.BSSTATUS IS NOT NULL "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" AND " + strCondition); } strSql.Append(@")as t "); strSql.Append(string.Format("where t.num>={0} and t.num<={1} order by t.num", start, start + limit)); // return SetData(strSql); } public static int getAmendTotalCount(string strCondition, string userid, string usercode, string companyid) { var rangstr = GetRangDAStr("index", userid, usercode, companyid); if (!string.IsNullOrEmpty(rangstr)) { if (!string.IsNullOrEmpty(strCondition)) { strCondition = strCondition + " and " + rangstr; } else { strCondition = rangstr; } } StringBuilder strSql = new StringBuilder(); strSql.Append("select count(*) "); strSql.Append(" from VW_OP_SEAI_AMEND B "); strSql.Append(" WHERE B.BSSTATUS IS NOT NULL "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" AND " + strCondition); } int cnt = 0; Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { cnt = Convert.ToInt32(reader[0]); } } return cnt; } #endregion static public DBResult GetAmendDataStr(string strCondition, string userid, string usercode, string companyid, string sort = null, string load = null) { var result = new DBResult(); var rangstr = GetRangDAStr("index", userid, usercode, companyid); if (!string.IsNullOrEmpty(rangstr)) { if (!string.IsNullOrEmpty(strCondition)) { strCondition = strCondition + " and " + rangstr; } else { strCondition = rangstr; } } var strSql = new StringBuilder(); strSql.Append("SELECT VW_OP_SEAI_AMEND.*"); strSql.Append(",0 as FENPIAO,'' BLISSUESTATUS "); strSql.Append(",dbo.F_GetBillDrFeeStatus(VW_OP_SEAI.BSNO) DRFEESTATUS"); strSql.Append(",dbo.F_GetBillCrFeeStatus(VW_OP_SEAI.BSNO) CRFEESTATUS"); strSql.Append(",(SELECT COUNT(*) FROM OP_APPLY WHERE MASTERNO=VW_OP_SEAI.BSNO) as APPLYCOUNT "); strSql.Append(",(SELECT COUNT(*) FROM OP_AMEND WHERE PARENTID=VW_OP_SEAI.BSNO) as AMENDCOUNT "); strSql.Append(" FROM VW_OP_SEAI_AMEND B "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } var sortstring = DatasetSort.Getsortstring(sort); if (!string.IsNullOrEmpty(sortstring)) { strSql.Append(" order by " + sortstring); } else { strSql.Append(" order by BSDATE desc"); } result.Data = strSql.ToString(); result.Message = strCondition; return result; } static public List GetFenList(string strCondition, string userid, string usercode, string companyid, string sort = null) { var rangstr = GetRangDAStr("index", userid, usercode, companyid); if (!string.IsNullOrEmpty(rangstr)) { if (!string.IsNullOrEmpty(strCondition)) { strCondition = strCondition + " and " + rangstr; } else { strCondition = rangstr; } } // var strSql = new StringBuilder(); strSql.Append("SELECT *"); strSql.Append(",0 as FENPIAO,(SELECT TOP 1 BLSTATUS FROM op_blissue WHERE BSNO=B.BSNO) BLISSUESTATUS "); strSql.Append(",dbo.F_GetBillDrFeeStatus(B.BSNO) DRFEESTATUS"); strSql.Append(",dbo.F_GetBillCrFeeStatus(B.BSNO) CRFEESTATUS,0 TTLDR,0 TTLINVDR,0 TTLDUIDR,0 TTLCR,0 TTLINVCR,0 TTLDUICR,0 APPLYCOUNT,0 AMENDCOUNT"); strSql.Append(",0 as CTNNUM "); strSql.Append(",0 as WMSCTNNUM "); strSql.Append(",'' as OPSTATUSCOLOR "); strSql.Append(",0 CHANGEDOCSTATUS,0 CUSTOMSSTATUS,0 CANGDANSTATUS"); //strSql.Append(",(CASE FEESTATUS WHEN 1 THEN '锁定' else '' end) as FEESTATUSREF "); strSql.Append(" from VW_OP_SEAI B where 1=1 "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" and " + strCondition); } // var sortstring = DatasetSort.Getsortstring(sort); if (!string.IsNullOrEmpty(sortstring)) { strSql.Append(" order by " + sortstring); } else { strSql.Append(" order by BSDATE desc"); } return SetData(strSql); } static public string GetDataListStr(string strCondition, string userid, string usercode, string companyid, string sort = null) { var rangstr = GetRangDAStr("index", userid, usercode, companyid); if (!string.IsNullOrEmpty(rangstr)) { if (!string.IsNullOrEmpty(strCondition)) { strCondition = strCondition + " and " + rangstr; } else { strCondition = rangstr; } } // var strSql = new StringBuilder(); strSql.Append("SELECT * "); strSql.Append(",CASE WHEN ISNULL(TTLINVDR,0)=0 THEN '未开票' WHEN ISNULL(TTLINVDR,0)=ISNULL(TTLDR,0) THEN '已开票' WHEN ISNULL(TTLINVDR,0)!=ISNULL(TTLDR,0) THEN '部分开票' END DRINVSTATUS "); strSql.Append(",CASE WHEN ISNULL(TTLDUIDR,0)=0 THEN '未对账' WHEN ISNULL(TTLDUIDR,0)=ISNULL(TTLDR,0) THEN '已对账' WHEN ISNULL(TTLDUIDR,0)!=ISNULL(TTLDR,0) THEN '部分对账' END DRDUISTATUS "); strSql.Append(",APPLYCOUNT ISAPPLY,AMENDCOUNT AMEND from ("); strSql.Append("SELECT "); strSql.Append(" VW_OP_SEAI.*"); strSql.Append(",0 as FENPIAO,(SELECT TOP 1 BLSTATUS FROM op_blissue WHERE BSNO=VW_OP_SEAI.BSNO) BLISSUESTATUS "); strSql.Append(",dbo.F_GetBillDrFeeStatus(VW_OP_SEAI.BSNO) DRFEESTATUS"); strSql.Append(",dbo.F_GetBillCrFeeStatus(VW_OP_SEAI.BSNO) CRFEESTATUS"); strSql.Append(",I.TTLDR,I.TTLINVDR,I.TTLDUIDR,I.TTLCR,I.TTLINVCR,I.TTLDUICR"); strSql.Append(",(SELECT COUNT(*) FROM OP_APPLY WHERE MASTERNO=VW_OP_SEAI.BSNO) as APPLYCOUNT "); strSql.Append(",(SELECT COUNT(*) FROM OP_AMEND WHERE PARENTID=VW_OP_SEAI.BSNO) as AMENDCOUNT "); strSql.Append(",(SELECT SUM(CTNNUM) FROM OP_CTN WHERE BSNO=VW_OP_SEAI.BSNO) as CTNNUM "); strSql.Append(",(SELECT COUNT(DISTINCT CNTRNO) FROM wms_in WHERE ISNULL(CNTRNO,'')<>'' AND ASSOCIATEDNO=VW_OP_SEAI.BSNO) as WMSCTNNUM "); strSql.Append(",(select TOP 1 COLOR FROM code_op_status_detail WITH(NOLOCK) WHERE OPSTATUS =VW_OP_SEAI.OPSTATUS) as OPSTATUSCOLOR "); strSql.Append(",v.CHANGEDOCSTATUS,v.CUSTOMSSTATUS,v.CANGDANSTATUS"); //strSql.Append(",dbo.trimdate(DEST_RTCNT_TIME) DEST_RTCNT_TIME "); strSql.Append(" from VW_OP_SEAI LEFT JOIN v_op_gain_dr_INV I ON (I.BSNO=VW_OP_SEAI.BSNO) "); strSql.Append(" left join (select bsno, sum(case when[status] = '换单' then 1 else 0 end) CHANGEDOCSTATUS, sum(case when [status] = '海关放行' then 1 else 0 end) CUSTOMSSTATUS"); strSql.Append(", sum(case when [status] = '舱单' then 1 else 0 end) CANGDANSTATUS from op_status WITH (NOLOCK) GROUP BY BSNO) as v on(v.bsno = VW_OP_SEAI.BSNO) "); strSql.Append(" where VW_OP_SEAI.MASTERNO=VW_OP_SEAI.BSNO "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" AND EXISTS ( select 1 from VW_OP_SEAI B WHERE VW_OP_SEAI.BSNO=B.MASTERNO AND " + strCondition + " )"); } strSql.Append(" ) as T "); // var sortstring = DatasetSort.Getsortstring(sort); if (!string.IsNullOrEmpty(sortstring)) { strSql.Append(" order by " + sortstring); } else { strSql.Append(" order by BSDATE desc"); } return strSql.ToString(); } static public MsOpSeai GetData(string condition) { //var strSql = new StringBuilder(); //strSql.Append("SELECT B.*,'' BLISSUESTATUS"); //strSql.Append(",(SELECT COUNT(*) FROM OP_SEAI WHERE BSNO<>MASTERNO AND MASTERNO=B.BSNO) as FENPIAO "); //strSql.Append(",'' DRFEESTATUS"); //strSql.Append(",'' CRFEESTATUS,0 TTLDR,0 TTLINVDR,0 TTLDUIDR,0 TTLCR,0 TTLINVCR,0 TTLDUICR,0 APPLYCOUNT,0 AMENDCOUNT"); //strSql.Append(",0 as CTNNUM "); //strSql.Append(",0 as WMSCTNNUM "); //strSql.Append(",(select top 1 COUNTRYID from code_country where B.COUNTRYOFORIGIN=COUNTRY) as COUNTRYID "); //strSql.Append(",'' as OPSTATUSCOLOR "); //strSql.Append(",0 CHANGEDOCSTATUS,0 CUSTOMSSTATUS,0 CANGDANSTATUS"); ////strSql.Append(",(CASE FEESTATUS WHEN 1 THEN '锁定' else '未锁定' end) as FEESTATUSREF "); //strSql.Append(" from VW_OP_SEAI B where 1=1 "); //if (!string.IsNullOrEmpty(condition)) //{ // strSql.Append(" and " + condition); //} //var list=SetData(strSql); var list = GetDataAll(condition); if (list.Count > 0) return list[0]; return new MsOpSeai(); } static public List GetDataAll(string condition) { var strSql = new StringBuilder(); strSql.Append("SELECT B.*,'' BLISSUESTATUS"); strSql.Append(",(SELECT COUNT(*) FROM OP_SEAI WHERE BSNO<>MASTERNO AND MASTERNO=B.BSNO) as FENPIAO "); strSql.Append(",'' DRFEESTATUS"); strSql.Append(",'' CRFEESTATUS,0 TTLDR,0 TTLINVDR,0 TTLDUIDR,0 TTLCR,0 TTLINVCR,0 TTLDUICR,0 APPLYCOUNT,0 AMENDCOUNT"); strSql.Append(",0 as CTNNUM "); strSql.Append(",0 as WMSCTNNUM "); strSql.Append(",(select top 1 COUNTRYID from code_country where B.COUNTRYOFORIGIN=COUNTRY) as COUNTRYID "); strSql.Append(",'' as OPSTATUSCOLOR "); strSql.Append(",0 CHANGEDOCSTATUS,0 CUSTOMSSTATUS,0 CANGDANSTATUS"); //strSql.Append(",(CASE FEESTATUS WHEN 1 THEN '锁定' else '未锁定' end) as FEESTATUSREF "); strSql.Append(" from VW_OP_SEAI B where 1=1 "); if (!string.IsNullOrEmpty(condition)) { strSql.Append(" and " + condition); } var list = SetData(strSql); //if (list.Count > 0) // return list[0]; //return new MsOpSeai(); return list; } static public CountryModel GetCountryModelData(string condition) { var strSql = new StringBuilder(); strSql.Append("SELECT B.*,'' BLISSUESTATUS"); strSql.Append(",(SELECT COUNT(*) FROM OP_SEAI WHERE BSNO<>MASTERNO AND MASTERNO=B.BSNO) as FENPIAO "); strSql.Append(",'' DRFEESTATUS"); strSql.Append(",'' CRFEESTATUS,0 TTLDR,0 TTLINVDR,0 APPLYCOUNT,0 AMENDCOUNT"); strSql.Append(",0 as CTNNUM "); strSql.Append(",0 as WMSCTNNUM "); strSql.Append(",(select COUNTRYID from code_country where B.COUNTRYOFORIGIN=COUNTRY) as COUNTRYID "); //strSql.Append(",(CASE FEESTATUS WHEN 1 THEN '锁定' else '未锁定' end) as FEESTATUSREF "); strSql.Append(" from VW_OP_SEAI B where BSNO not like 'topseailcl%'"); if (!string.IsNullOrEmpty(condition)) { strSql.Append(" and " + condition); } var countrydata = new CountryModel(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { countrydata.country = (reader["COUNTRYOFORIGIN"] == null? "": Convert.ToString(reader["COUNTRYOFORIGIN"])); countrydata.countryid = (reader["COUNTRYID"] == null? "": Convert.ToString(reader["COUNTRYID"])); } } return countrydata; } private static List SetData(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { MsOpSeai data = new MsOpSeai(); #region Set DB data to Object data.BillFeeStatus = Convert.ToString(reader["BillFeeStatus"]); //if (data.BSDATE != null) // data.BSDATE = Convert.ToDateTime(reader["BSDATE"]);// 接单日期 data.BSNO = (reader["BSNO"] == null ? "" : Convert.ToString(reader["BSNO"]));//业务编号 data.ORDERTYPE = (reader["ORDERTYPE"] == null ? "" : Convert.ToString(reader["ORDERTYPE"]));//委托方式 data.MASTERNO = (reader["MASTERNO"] == null ? "" : Convert.ToString(reader["MASTERNO"]));//主编号 data.CUSTNO = (reader["CUSTNO"] == null ? "" : Convert.ToString(reader["CUSTNO"]));//委托编号 data.MBLNO = (reader["MBLNO"] == null ? "" : Convert.ToString(reader["MBLNO"]));//主提单号 data.HBLNO = (reader["HBLNO"] == null ? "" : Convert.ToString(reader["HBLNO"]));//分提单号 data.APPLYNO = Convert.ToString(reader["APPLYNO"]);//放箱申请单号 if (reader["AMENDCOUNT"] != DBNull.Value) data.AMEND = Convert.ToString(reader["AMENDCOUNT"]);//是否有更改单 data.DRFEESTATUS = getfeestatus(Convert.ToString(reader["DRFEESTATUS"])); data.CRFEESTATUS = getfeestatus(Convert.ToString(reader["CRFEESTATUS"])); data.BSSTATUS = ((reader["BSSTATUS"] == null || reader["BSSTATUS"].ToString().Trim() == "") ? false : Convert.ToBoolean(reader["BSSTATUS"]));//业务状态 data.FEESTATUS = ((reader["FEESTATUS"] == null || reader["FEESTATUS"].ToString().Trim() == "") ? false : Convert.ToBoolean(reader["FEESTATUS"]));//费用状态 data.BSSTATUSREF = (reader["BSSTATUSREF"] == null ? "" : Convert.ToString(reader["BSSTATUSREF"]));//业务状态 data.FEESTATUSREF = (reader["FEESTATUSREF"] == null ? "" : Convert.ToString(reader["FEESTATUSREF"]));//费用状态 data.BSDATE = ((reader["BSDATE"] == null || reader["BSDATE"].ToString().Trim().IndexOf("0001")>-1 || reader["BSDATE"].ToString().Trim().IndexOf("1900")>-1) ? "" : Convert.ToString(reader["BSDATE"]));//接单日期 data.ACCDATE = (reader["ACCDATE"] == null ? "" : Convert.ToString(reader["ACCDATE"]));//会计期间 data.CUSTOMERNAME = (reader["CUSTOMERNAME"] == null ? "" : Convert.ToString(reader["CUSTOMERNAME"]));//委托单位 data.BSSOURCE = (reader["BSSOURCE"] == null ? "" : Convert.ToString(reader["BSSOURCE"]));//业务来源 data.BSSOURCEDETAIL = (reader["BSSOURCEDETAIL"] == null ? "" : Convert.ToString(reader["BSSOURCEDETAIL"]));//来源明细 data.INPUTBY = (reader["INPUTBY"] == null ? "" : Convert.ToString(reader["INPUTBY"]));//录入人 data.OP = (reader["OP"] == null ? "" : Convert.ToString(reader["OP"]));//操作员 data.CUSTSERVICE = (reader["CUSTSERVICE"] == null ? "" : Convert.ToString(reader["CUSTSERVICE"]));//客服员 data.FRCUSTSERVICE = (reader["FRCUSTSERVICE"] == null ? "" : Convert.ToString(reader["FRCUSTSERVICE"]));//客服员 data.SALE = (reader["SALE"] == null ? "" : Convert.ToString(reader["SALE"]));//揽货人 data.CORPID = (reader["CORPID"] == null ? "" : Convert.ToString(reader["CORPID"]));//分公司代码 data.SALEDEPT = (reader["SALEDEPT"] == null ? "" : Convert.ToString(reader["SALEDEPT"]));//所属部门 data.CREATETIME = ((reader["CREATETIME"] == null || reader["CREATETIME"].ToString().Trim().IndexOf("0001") > -1 || reader["CREATETIME"].ToString().Trim().IndexOf("1900") > -1) ? "" : Convert.ToString(reader["CREATETIME"]));//创建时间 data.VESSEL = (reader["VESSEL"] == null ? "" : Convert.ToString(reader["VESSEL"]));//船名 data.VOYNO = (reader["VOYNO"] == null ? "" : Convert.ToString(reader["VOYNO"]));//航次 data.ETD = ((reader["ETD"] == null || reader["ETD"].ToString().Trim().IndexOf("0001") > -1 || reader["ETD"].ToString().Trim().IndexOf("1900") > -1) ? "" : Convert.ToString(reader["ETD"]));//到港日期 data.PORTLOADID = (reader["PORTLOADID"] == null ? "" : Convert.ToString(reader["PORTLOADID"]));//装货港代码 data.PORTLOAD = (reader["PORTLOAD"] == null ? "" : Convert.ToString(reader["PORTLOAD"]));//装货港 data.PORTDISCHARGEID = (reader["PORTDISCHARGEID"] == null ? "" : Convert.ToString(reader["PORTDISCHARGEID"]));//卸货港代码 data.PORTDISCHARGE = (reader["PORTDISCHARGE"] == null ? "" : Convert.ToString(reader["PORTDISCHARGE"]));//卸货港 data.CNTRNO = ((reader["CNTRNO"] == null || reader["CNTRNO"].ToString().Trim() == "") ? "" : Convert.ToString(reader["CNTRNO"]));//集装箱大写 data.CNTR1 = ((reader["CNTR1"] == null || reader["CNTR1"].ToString().Trim() == "") ? 0 : Convert.ToInt32(reader["CNTR1"]));//箱型1 data.CNTR2 = ((reader["CNTR2"] == null || reader["CNTR2"].ToString().Trim() == "") ? 0 : Convert.ToInt32(reader["CNTR2"]));//箱型2 data.CNTR3 = ((reader["CNTR3"] == null || reader["CNTR3"].ToString().Trim() == "") ? 0 : Convert.ToInt32(reader["CNTR3"]));//箱型3 data.CNTR4 = ((reader["CNTR4"] == null || reader["CNTR4"].ToString().Trim() == "") ? 0 : Convert.ToInt32(reader["CNTR4"]));//箱型4 data.CNTR5 = ((reader["CNTR5"] == null || reader["CNTR5"].ToString().Trim() == "") ? 0 : Convert.ToInt32(reader["CNTR5"]));//箱型5 data.CNTR6 = ((reader["CNTR6"] == null || reader["CNTR6"].ToString().Trim() == "") ? 0 : Convert.ToInt32(reader["CNTR6"]));//箱型6 data.CNTR7 = ((reader["CNTR7"] == null || reader["CNTR7"].ToString().Trim() == "") ? 0 : Convert.ToInt32(reader["CNTR7"]));//箱型7 data.CNTR8 = ((reader["CNTR8"] == null || reader["CNTR8"].ToString().Trim() == "") ? 0 : Convert.ToInt32(reader["CNTR8"]));//箱型8 data.CNTR9 = ((reader["CNTR9"] == null || reader["CNTR9"].ToString().Trim() == "") ? 0 : Convert.ToInt32(reader["CNTR9"]));//箱型9 data.CNTR10 = ((reader["CNTR10"] == null || reader["CNTR10"].ToString().Trim() == "") ? 0 : Convert.ToInt32(reader["CNTR10"]));//箱型10 data.OTCNTR = ((reader["OTCNTR"] == null || reader["OTCNTR"].ToString().Trim() == "") ? 0 : Convert.ToInt32(reader["OTCNTR"]));//其他箱型 data.TEU = ((reader["TEU"] == null || reader["TEU"].ToString().Trim() == "") ? 0 : Convert.ToInt32(reader["TEU"]));//箱TEU data.CNTRTOTAL = (reader["CNTRTOTAL"] == null ? "" : Convert.ToString(reader["CNTRTOTAL"]));//集装箱全部内容 data.GOODSNAME = (reader["GOODSNAME"] == null ? "" : Convert.ToString(reader["GOODSNAME"]));//品名 data.COUNTRYOFORIGIN = (reader["COUNTRYOFORIGIN"] == null ? "" : Convert.ToString(reader["COUNTRYOFORIGIN"]));//原产地 data.NUMBERPLATE = (reader["NUMBERPLATE"] == null ? "" : Convert.ToString(reader["NUMBERPLATE"]));//牌号 data.CONTRACTNO = (reader["CONTRACTNO"] == null ? "" : Convert.ToString(reader["CONTRACTNO"]));//合同号 data.UNITS = (reader["UNITS"] == null ? "" : Convert.ToString(reader["UNITS"]));//单位 data.BALES = (reader["BALES"] == null ? "" : Convert.ToString(reader["BALES"]));//包装(散货/托盘)数 data.KGS = ((reader["KGS"] == null || reader["KGS"].ToString().Trim() == "") ? 0 : Convert.ToDecimal(reader["KGS"]));//毛重 data.NETWEIGHT = ((reader["NETWEIGHT"] == null || reader["NETWEIGHT"].ToString().Trim() == "") ? 0 : Convert.ToDecimal(reader["NETWEIGHT"]));//净重 data.MT = ((reader["MT"] == null || reader["MT"].ToString().Trim() == "") ? 0 : Convert.ToDecimal(reader["MT"]));//净重和毛重哪一个数大,则存哪一个 data.CUSTOMSER = (reader["CUSTOMSER"] == null ? "" : Convert.ToString(reader["CUSTOMSER"]));//报关行 data.ENTERP = (reader["ENTERP"] == null ? "" : Convert.ToString(reader["ENTERP"]));//经营单位 data.CUSTOMNO = (reader["CUSTOMNO"] == null ? "" : Convert.ToString(reader["CUSTOMNO"]));//报关单号 // data.CUSTOMDATE = ((reader["CUSTOMDATE"] == null || reader["CUSTOMDATE"].ToString().Trim().IndexOf("0001") > -1 || reader["CUSTOMDATE"].ToString().Trim().IndexOf("1900") > -1) ? "" : Convert.ToString(reader["CUSTOMDATE"]));//通关日期 data.INSPECTION = (reader["INSPECTION"] == null ? "" : Convert.ToString(reader["INSPECTION"]));//报检 data.INSPECTIONNO = (reader["INSPECTIONNO"] == null ? "" : Convert.ToString(reader["INSPECTIONNO"]));//报检单号 data.INSPECTIONDATE = ((reader["INSPECTIONDATE"] == null || reader["INSPECTIONDATE"].ToString().Trim().IndexOf("0001") > -1 || reader["INSPECTIONDATE"].ToString().Trim().IndexOf("1900") > -1) ? "" : Convert.ToString(reader["INSPECTIONDATE"]));//报检日期 data.FBP = ((reader["FBP"] == null || reader["FBP"].ToString().Trim() == "") ? 0 : Convert.ToInt32(reader["FBP"]));//免箱期 data.BMDDATE = ((reader["BMDDATE"] == null || reader["BMDDATE"].ToString().Trim().IndexOf("0001") > -1 || reader["BMDDATE"].ToString().Trim().IndexOf("1900") > -1) ? "" : Convert.ToString(reader["BMDDATE"]));//箱使到期日期 data.MDTDATE = ((reader["MDTDATE"] == null || reader["MDTDATE"].ToString().Trim().IndexOf("0001") > -1 || reader["MDTDATE"].ToString().Trim().IndexOf("1900") > -1) ? "" : Convert.ToString(reader["MDTDATE"]));//搬倒日期 data.UNITOFWEIGHT = (reader["UNITOFWEIGHT"] == null ? "" : Convert.ToString(reader["UNITOFWEIGHT"]));//计费单位 data.PKGS = ((reader["PKGS"] == null || reader["PKGS"].ToString().Trim() == "") ? 0 : Convert.ToInt32(reader["PKGS"]));//件数 data.ISVOU = ((reader["ISVOU"] == null || reader["ISVOU"].ToString().Trim() == "") ? false : Convert.ToBoolean(reader["ISVOU"]));//是否生成凭证 data.VOUNO = (reader["VOUNO"] == null ? "" : Convert.ToString(reader["VOUNO"]));//凭证号 data.KINDPKGS = (reader["KINDPKGS"] == null ? "" : Convert.ToString(reader["KINDPKGS"]));//件数包装 data.TRADINGAGENCY = (reader["TRADINGAGENCY"] == null ? "" : Convert.ToString(reader["TRADINGAGENCY"]));//贸易代理 data.TRADETYPE = (reader["TRADETYPE"] == null ? "" : Convert.ToString(reader["TRADETYPE"]));//贸易方式 data.TRADETERM = Convert.ToString(reader["TRADETERM"]);//贸易条款 data.GOODSTYPENAME = (reader["GOODSTYPENAME"] == null ? "" : Convert.ToString(reader["GOODSTYPENAME"]));//品名类型名称 data.SHOWNAME = (reader["SHOWNAME"] == null ? "" : Convert.ToString(reader["SHOWNAME"]));//委托单位联系人 data.EMAIL = (reader["EMAIL"] == null ? "" : Convert.ToString(reader["EMAIL"]));//委托单位EMAIL data.TEL = (reader["TEL"] == null ? "" : Convert.ToString(reader["TEL"]));//委托单位TEL data.FAX = (reader["FAX"] == null ? "" : Convert.ToString(reader["FAX"]));//委托单位FAX data.TARRIFSPAIEDTIEM = ((reader["TARRIFSPAIEDTIEM"] == null || reader["TARRIFSPAIEDTIEM"].ToString().Trim().IndexOf("0001") > -1 || reader["TARRIFSPAIEDTIEM"].ToString().Trim().IndexOf("1900") > -1) ? "" : Convert.ToString(reader["TARRIFSPAIEDTIEM"]));//交关税时间 data.APPROVENO = (reader["APPROVENO"] == null ? "" : Convert.ToString(reader["APPROVENO"]));//审批单号 data.REMARK = (reader["REMARK"] == null ? "" : Convert.ToString(reader["REMARK"]));//备注 data.REMARK2 = (reader["REMARK2"] == null ? "" : Convert.ToString(reader["REMARK2"]));//备注 data.YARD = (reader["YARD"] == null ? "" : Convert.ToString(reader["YARD"]));//场站/靠泊码头 data.STORAGENAME = (reader["STORAGENAME"] == null ? "" : Convert.ToString(reader["STORAGENAME"]));//仓库名称 data.GRADE = (reader["GRADE"] == null ? "" : Convert.ToString(reader["GRADE"]));//品位 data.NOR = ((reader["NOR"] == null || reader["NOR"].ToString().Trim().IndexOf("0001") > -1 || reader["NOR"].ToString().Trim().IndexOf("1900") > -1) ? "" : Convert.ToString(reader["NOR"]));//具体到时间 data.ISFORCEDTODESPATCH = (reader["ISFORCEDTODESPATCH"] == null ? false : Convert.ToBoolean(reader["ISFORCEDTODESPATCH"]));//强制速遣费(是否缴纳) data.BSKGS = ((reader["BSKGS"] == null || reader["BSKGS"].ToString().Trim() == "") ? 0 : Convert.ToDecimal(reader["BSKGS"]));//提单吨数 data.ACTUALKGS = ((reader["ACTUALKGS"] == null || reader["ACTUALKGS"].ToString().Trim() == "") ? 0 : Convert.ToDecimal(reader["ACTUALKGS"]));//实际发货吨数 data.DRAFTKGS = ((reader["DRAFTKGS"] == null || reader["DRAFTKGS"].ToString().Trim() == "") ? 0 : Convert.ToDecimal(reader["DRAFTKGS"]));//水尺数 data.WHARFSKGS = ((reader["WHARFSKGS"] == null || reader["WHARFSKGS"].ToString().Trim() == "") ? 0 : Convert.ToDecimal(reader["WHARFSKGS"]));//码头数 data.WMSINKGS = ((reader["WMSINKGS"] == null || reader["WMSINKGS"].ToString().Trim() == "") ? 0 : Convert.ToDecimal(reader["WMSINKGS"]));//入库数 data.WMSOUTKGS = ((reader["WMSOUTKGS"] == null || reader["WMSOUTKGS"].ToString().Trim() == "") ? 0 : Convert.ToDecimal(reader["WMSOUTKGS"]));//出库数 data.DIFFERENCEKGS = ((reader["DIFFERENCEKGS"] == null || reader["DIFFERENCEKGS"].ToString().Trim() == "") ? 0 : Convert.ToDecimal(reader["DIFFERENCEKGS"]));//(水尺数-出库数 data.WATERCONTENT = (reader["WATERCONTENT"] == null ? "" : Convert.ToString(reader["WATERCONTENT"]));//水含量 data.WATERDENSITY = (reader["WATERDENSITY"] == null ? "" : Convert.ToString(reader["WATERDENSITY"]));//水密度 data.BLTYPE = (reader["BLTYPE"] == null ? "" : Convert.ToString(reader["BLTYPE"]));//装运方式 data.CBM = ((reader["CBM"] == null || reader["CBM"].ToString().Trim() == "") ? 0 : Convert.ToDecimal(reader["CBM"]));//立方数/尺码 data.IMPORTVALUE = ((reader["IMPORTVALUE"] == null || reader["IMPORTVALUE"].ToString().Trim() == "") ? 0 : Convert.ToDecimal(reader["IMPORTVALUE"]));//货值 data.UNITPRICE = ((reader["UNITPRICE"] == null || reader["UNITPRICE"].ToString().Trim() == "") ? 0 : Convert.ToDecimal(reader["UNITPRICE"]));//单价 data.CURRENCY = (reader["CURRENCY"] == null ? "" : Convert.ToString(reader["CURRENCY"]));//币别 // data.UPDATETIME = ((reader["UPDATETIME"] == null || reader["UPDATETIME"].ToString().Trim().IndexOf("0001") > -1 || reader["UPDATETIME"].ToString().Trim().IndexOf("1900") > -1) ? "" : Convert.ToString(reader["UPDATETIME"]));//申报日期 data.PARENTID = (reader["PARENTID"] == null ? "" : Convert.ToString(reader["PARENTID"]));//父公司GID data.LEVELS = ((reader["LEVELS"] == null || reader["LEVELS"].ToString().Trim() == "") ? 0 : Convert.ToInt32(reader["LEVELS"]));//分单等级 data.BSTYPE = (reader["BSTYPE"] == null ? "" : Convert.ToString(reader["BSTYPE"]));//单据类型 data.WMSTYPE = (reader["WMSTYPE"] == null ? "" : Convert.ToString(reader["WMSTYPE"]));//仓储类型 data.CNTRSEALNO = (reader["CNTRSEALNO"] == null ? "" : Convert.ToString(reader["CNTRSEALNO"]));//箱号封号 data.CARRIER = (reader["CARRIER"] == null ? "" : Convert.ToString(reader["CARRIER"]));//船公司 data.TRUCKER = (reader["TRUCKER"] == null ? "" : Convert.ToString(reader["TRUCKER"]));//承运车队 data.CUSTOMSNUM = ((reader["CUSTOMSNUM"] == null || reader["CUSTOMSNUM"].ToString().Trim() == "") ? 0 : Convert.ToInt32(reader["CUSTOMSNUM"]));//报关票数 if (reader["PRERECORD"] != DBNull.Value) data.PRERECORD = Convert.ToInt32(reader["PRERECORD"]);//报关票数 data.NOPKGS = (reader["NOPKGS"] == null ? "" : Convert.ToString(reader["NOPKGS"]));//件数包装 data.GROSSWEIGHT = (reader["GROSSWEIGHT"] == null ? "" : Convert.ToString(reader["GROSSWEIGHT"]));//货物毛重 data.MEASUREMENT = (reader["MEASUREMENT"] == null ? "" : Convert.ToString(reader["MEASUREMENT"]));//货物尺码 data.DESCRIPTION = (reader["DESCRIPTION"] == null ? "" : Convert.ToString(reader["DESCRIPTION"]));//货物描述 data.TOTALNO = (reader["TOTALNO"] == null ? "" : Convert.ToString(reader["TOTALNO"]));//件数大写 data.TRANSNO = (reader["TRANSNO"] == null ? "" : Convert.ToString(reader["TRANSNO"]));//运单号 data.SHIPPERID = (reader["SHIPPERID"] == null ? "" : Convert.ToString(reader["SHIPPERID"]));//发货人 data.CONSIGNEEID = (reader["CONSIGNEEID"] == null ? "" : Convert.ToString(reader["CONSIGNEEID"]));//收货人 data.NOTIFYPARTYID = (reader["NOTIFYPARTYID"] == null ? "" : Convert.ToString(reader["NOTIFYPARTYID"]));//通知人 data.SHIPPER = (reader["SHIPPER"] == null ? "" : Convert.ToString(reader["SHIPPER"]));//发货人内容 data.CONSIGNEE = (reader["CONSIGNEE"] == null ? "" : Convert.ToString(reader["CONSIGNEE"]));//收货人内容 data.NOTIFYPARTY = (reader["NOTIFYPARTY"] == null ? "" : Convert.ToString(reader["NOTIFYPARTY"]));//通知人内容 data.MSHIPPERID = Convert.ToString(reader["MSHIPPERID"]);//发货人 data.MCONSIGNEEID = Convert.ToString(reader["MCONSIGNEEID"]);//收货人 data.MNOTIFYPARTYID = Convert.ToString(reader["MNOTIFYPARTYID"]);//通知人 data.MSHIPPER = Convert.ToString(reader["MSHIPPER"]).Replace(@"\\\\", "\n").Replace(@"^", "\'");//发货人内容 data.MCONSIGNEE = Convert.ToString(reader["MCONSIGNEE"]).Replace(@"\\\\", "\n").Replace(@"^", "\'");//收货人内容 data.MNOTIFYPARTY = Convert.ToString(reader["MNOTIFYPARTY"]).Replace(@"\\\\", "\n").Replace(@"^", "\'");//通知人内容 data.AGENTID = (reader["AGENTID"] == null ? "" : Convert.ToString(reader["AGENTID"]));//国外代理 data.AGENT = (reader["AGENT"] == null ? "" : Convert.ToString(reader["AGENT"]));//国外代理内容 data.CLOSINGDATE = ((reader["CLOSINGDATE"] == null || reader["CLOSINGDATE"].ToString().Trim().IndexOf("0001") > -1 || reader["CLOSINGDATE"].ToString().Trim().IndexOf("1900") > -1) ? "" : Convert.ToString(reader["CLOSINGDATE"]));//截港日期 data.PlACERECEIPT = (reader["PlACERECEIPT"] == null ? "" : Convert.ToString(reader["PlACERECEIPT"]));//收货地 data.PLACEDELIVERYID = (reader["PLACEDELIVERYID"] == null ? "" : Convert.ToString(reader["PLACEDELIVERYID"]));//交货地代码 data.PLACEDELIVERY = (reader["PLACEDELIVERY"] == null ? "" : Convert.ToString(reader["PLACEDELIVERY"]));//交货地 data.DESTINATIONID = (reader["DESTINATIONID"] == null ? "" : Convert.ToString(reader["DESTINATIONID"]));//目的地代码 data.DESTINATION = (reader["DESTINATION"] == null ? "" : Convert.ToString(reader["DESTINATION"]));//目的地 data.NOBILL = (reader["NOBILL"] == null ? "" : Convert.ToString(reader["NOBILL"]));//提单份数 data.ISSUETYPE = (reader["ISSUETYPE"] == null ? "" : Convert.ToString(reader["ISSUETYPE"]));//签单方式 data.ISSUEDATE = ((reader["ISSUEDATE"] == null || reader["ISSUEDATE"].ToString().Trim().IndexOf("0001") > -1 || reader["ISSUEDATE"].ToString().Trim().IndexOf("1900") > -1) ? "" : Convert.ToString(reader["ISSUEDATE"]));//签单日期 data.ISSUEPLACE = (reader["ISSUEPLACE"] == null ? "" : Convert.ToString(reader["ISSUEPLACE"]));//签单地点 data.BLFRT = (reader["BLFRT"] == null ? "" : Convert.ToString(reader["BLFRT"]));//付费方式 data.PREPARDAT = (reader["PREPARDAT"] == null ? "" : Convert.ToString(reader["PREPARDAT"]));//预付地点 data.PAYABLEAT = (reader["PAYABLEAT"] == null ? "" : Convert.ToString(reader["PAYABLEAT"]));//到付地点 data.SERVICE = (reader["SERVICE"] == null ? "" : Convert.ToString(reader["SERVICE"]));//运输条款 data.MARKS = (reader["MARKS"] == null ? "" : Convert.ToString(reader["MARKS"]));//唛头 data.LANE = (reader["LANE"] == null ? "" : Convert.ToString(reader["LANE"]));//航线 data.FORWARDER = (reader["FORWARDER"] == null ? "" : Convert.ToString(reader["FORWARDER"]));//订舱公司 data.INVNO = (reader["INVNO"] == null ? "" : Convert.ToString(reader["INVNO"]));//发票号 data.CARGOID = (reader["CARGOID"] == null ? "" : Convert.ToString(reader["CARGOID"]));//货物标识 data.DCLASS = (reader["DCLASS"] == null ? "" : Convert.ToString(reader["DCLASS"]));//危险品分类/等级 data.DUNNO = (reader["DUNNO"] == null ? "" : Convert.ToString(reader["DUNNO"]));//危险品编号 data.REEFERF = (reader["REEFERF"] == null ? "" : Convert.ToString(reader["REEFERF"]));//冷藏通风量 data.TEMPID = (reader["TEMPID"] == null ? "" : Convert.ToString(reader["TEMPID"]));//温度单位 data.TEMPSET = (reader["TEMPSET"] == null ? "" : Convert.ToString(reader["TEMPSET"]));//设置温度 data.TEMPMAX = (reader["TEMPMAX"] == null ? "" : Convert.ToString(reader["TEMPMAX"]));//最高温度 data.TEMPMIN = (reader["TEMPMIN"] == null ? "" : Convert.ToString(reader["TEMPMIN"]));//最低温度 data.ORDTYPE = (reader["ORDTYPE"] == null ? "" : Convert.ToString(reader["ORDTYPE"]));//订舱类型 data.ORDERNO = (reader["ORDERNO"] == null ? "" : Convert.ToString(reader["ORDERNO"]));//订舱编号 data.INSURANCEER = (reader["INSURANCEER"] == null ? "" : Convert.ToString(reader["INSURANCEER"]));//保险人 data.INSURANCENO = (reader["INSURANCENO"] == null ? "" : Convert.ToString(reader["INSURANCENO"]));//保险单号 data.INAMOUT = ((reader["INAMOUT"] == null || reader["INAMOUT"].ToString().Trim() == "") ? 0 : Convert.ToDecimal(reader["INAMOUT"]));//保险金额 data.STATUS1 = ((reader["STATUS1"] == null || reader["STATUS1"].ToString().Trim() == "") ? false : Convert.ToBoolean(reader["STATUS1"]));//状态1 data.STATUS2 = ((reader["STATUS2"] == null || reader["STATUS2"].ToString().Trim() == "") ? false : Convert.ToBoolean(reader["STATUS2"]));//状态2 data.STATUS3 = ((reader["STATUS3"] == null || reader["STATUS3"].ToString().Trim() == "") ? false : Convert.ToBoolean(reader["STATUS3"]));//状态3 data.STATUS4 = ((reader["STATUS4"] == null || reader["STATUS4"].ToString().Trim() == "") ? false : Convert.ToBoolean(reader["STATUS4"]));//状态4 data.STATUS5 = ((reader["STATUS5"] == null || reader["STATUS5"].ToString().Trim() == "") ? false : Convert.ToBoolean(reader["STATUS5"]));//状态5 data.ISFUMIGATION = ((reader["ISFUMIGATION"] == null || reader["ISFUMIGATION"].ToString().Trim() == "") ? false : Convert.ToBoolean(reader["ISFUMIGATION"]));//熏蒸 data.ISSTORAGE = ((reader["ISSTORAGE"] == null || reader["ISSTORAGE"].ToString().Trim() == "") ? false : Convert.ToBoolean(reader["ISSTORAGE"]));//仓储 data.ISLAND = ((reader["ISLAND"] == null || reader["ISLAND"].ToString().Trim() == "") ? false : Convert.ToBoolean(reader["ISLAND"]));//陆运 data.ISCUSTOMS = ((reader["ISCUSTOMS"] == null || reader["ISCUSTOMS"].ToString().Trim() == "") ? false : Convert.ToBoolean(reader["ISCUSTOMS"]));//报关 data.ISINSPECTION = ((reader["ISINSPECTION"] == null || reader["ISINSPECTION"].ToString().Trim() == "") ? false : Convert.ToBoolean(reader["ISINSPECTION"]));//报检 data.ISBOOKING = ((reader["ISBOOKING"] == null || reader["ISBOOKING"].ToString().Trim() == "") ? false : Convert.ToBoolean(reader["ISBOOKING"]));//订舱 data.ISAGENT = ((reader["ISAGENT"] == null || reader["ISAGENT"].ToString().Trim() == "") ? false : Convert.ToBoolean(reader["ISAGENT"]));//使用代理 data.ISHBLNO = ((reader["ISHBLNO"] == null || reader["ISHBLNO"].ToString().Trim() == "") ? false : Convert.ToBoolean(reader["ISHBLNO"]));//分单签单 data.SERVICE9 = ((reader["SERVICE9"] == null || reader["SERVICE9"].ToString().Trim() == "") ? false : Convert.ToBoolean(reader["SERVICE9"]));//服务项目9 data.SERVICE10 = ((reader["SERVICE10"] == null || reader["SERVICE10"].ToString().Trim() == "") ? false : Convert.ToBoolean(reader["SERVICE10"]));//服务项目10 data.DOC = (reader["DOC"] == null ? "" : Convert.ToString(reader["DOC"]));//单证 data.PACKINGTYPE = (reader["PACKINGTYPE"] == null ? "" : Convert.ToString(reader["PACKINGTYPE"]));//装箱类型 data.WAREHOUSE = (reader["WAREHOUSE"] == null ? "" : Convert.ToString(reader["WAREHOUSE"]));//仓库 data.CLOSEDOCDATE = ((reader["CLOSEDOCDATE"] == null || reader["CLOSEDOCDATE"].ToString().Trim().IndexOf("0001") > -1 || reader["CLOSEDOCDATE"].ToString().Trim().IndexOf("1900") > -1) ? "" : Convert.ToString(reader["CLOSEDOCDATE"]));//截单日期 data.INTOPORTDATE = ((reader["INTOPORTDATE"] == null || reader["INTOPORTDATE"].ToString().Trim().IndexOf("0001") > -1 || reader["INTOPORTDATE"].ToString().Trim().IndexOf("1900") > -1) ? "" : Convert.ToString(reader["INTOPORTDATE"]));//集港日期 data.MBLFRT = (reader["MBLFRT"] == null ? "" : Convert.ToString(reader["MBLFRT"]));//MBL付费方式 data.STLNAME = (reader["STLNAME"] == null ? "" : Convert.ToString(reader["STLNAME"]));//结算方式 data.STLDATE = ((reader["STLDATE"] == null || reader["STLDATE"].ToString().Trim().IndexOf("0001") > -1 || reader["STLDATE"].ToString().Trim().IndexOf("1900") > -1) ? "" : Convert.ToString(reader["STLDATE"]));//结算时间 data.OPERATORCODE = (reader["OPERATORCODE"] == null ? "" : Convert.ToString(reader["OPERATORCODE"]));//客户操作代码 data.OPERATOR = (reader["OPERATOR"] == null ? "" : Convert.ToString(reader["OPERATOR"]));//客户操作名称 data.OPERATOREMAIL = (reader["OPERATOREMAIL"] == null ? "" : Convert.ToString(reader["OPERATOREMAIL"]));//操作电子邮箱 data.OPERATORTEL = (reader["OPERATORTEL"] == null ? "" : Convert.ToString(reader["OPERATORTEL"]));//操作电话 data.OPERATORFAX = (reader["OPERATORFAX"] == null ? "" : Convert.ToString(reader["OPERATORFAX"]));//操作传真 data.FINANCIALSTAFFCODE = (reader["FINANCIALSTAFFCODE"] == null ? "" : Convert.ToString(reader["FINANCIALSTAFFCODE"]));//客户财务代码 data.FINANCIALSTAFF = (reader["FINANCIALSTAFF"] == null ? "" : Convert.ToString(reader["FINANCIALSTAFF"]));//客户财务名称 data.FINANCIALSTAFFEMAIL = (reader["FINANCIALSTAFFEMAIL"] == null ? "" : Convert.ToString(reader["FINANCIALSTAFFEMAIL"]));//财务电子邮箱 data.FINANCIALSTAFFTEL = (reader["FINANCIALSTAFFTEL"] == null ? "" : Convert.ToString(reader["FINANCIALSTAFFTEL"]));//财务电话 data.FINANCIALSTAFFFAX = (reader["FINANCIALSTAFFFAX"] == null ? "" : Convert.ToString(reader["FINANCIALSTAFFFAX"]));//财务传真 data.SOURCECODE = (reader["SOURCECODE"] == null ? "" : Convert.ToString(reader["SOURCECODE"]));//集装箱(器)来源代码 data.ISCONTAINERSOC = ((reader["ISCONTAINERSOC"] == null || reader["ISCONTAINERSOC"].ToString().Trim() == "") ? false : Convert.ToBoolean(reader["ISCONTAINERSOC"]));//货主箱标志,是否自有箱 data.DPAGE = (reader["DPAGE"] == null ? "" : Convert.ToString(reader["DPAGE"]));//危险品页号 data.DLABEL = (reader["DLABEL"] == null ? "" : Convert.ToString(reader["DLABEL"]));//危险品标签 data.LINKMAN = (reader["LINKMAN"] == null ? "" : Convert.ToString(reader["LINKMAN"]));//危险品联系人 data.VESSELID = (reader["VESSELID"] == null ? "" : Convert.ToString(reader["VESSELID"]));//船舶呼号 data.ISSUEPLACEID = (reader["ISSUEPLACEID"] == null ? "" : Convert.ToString(reader["ISSUEPLACEID"]));//提单签发地代码 data.OPSTATUS = (reader["OPSTATUS"] == null ? "" : Convert.ToString(reader["OPSTATUS"]));//船舶呼号 if (reader["CHANGEDOCDATE"] != DBNull.Value) data.CHANGEDOCDATE = Convert.ToDateTime(reader["CHANGEDOCDATE"]).ToString("yyyy-MM-dd HH:mm:ss");// if (reader["CUSTOMDATE"] != DBNull.Value) data.CUSTOMDATE = Convert.ToDateTime(reader["CUSTOMDATE"]).ToString("yyyy-MM-dd HH:mm:ss");// if (reader["UPDATETIME"] != DBNull.Value) data.UPDATETIME = Convert.ToDateTime(reader["UPDATETIME"]).ToString("yyyy-MM-dd HH:mm:ss");// if (Convert.ToString(reader["BLTYPE"]) == "拼箱主票") data.FENPIAO = "1";//件数 else data.FENPIAO = "0";//件数 data.INSPECTSERVICE = Convert.ToString(reader["INSPECTSERVICE"]);//经营单位代码 if (reader["ISMOREGOOD"] != DBNull.Value) data.ISMOREGOOD = Convert.ToBoolean(reader["ISMOREGOOD"]);//多品名 data.ISPRINTPR = Convert.ToString(reader["ISPRINTPR"]); decimal ttldr = 0; if (reader["TTLDR"] != DBNull.Value) ttldr = Convert.ToDecimal(reader["TTLDR"]); decimal ttlinvdr = 0; if (reader["TTLDR"] != DBNull.Value) ttlinvdr = Convert.ToDecimal(reader["TTLINVDR"]); if (ttlinvdr == 0) data.DRINVSTATUS = "未开票"; else if (ttlinvdr == ttldr) data.DRINVSTATUS = "已开票"; else if (ttlinvdr != ttldr) data.DRINVSTATUS = "部分开票"; decimal ttlcr = 0; if (reader["TTLCR"] != DBNull.Value) ttlcr = Convert.ToDecimal(reader["TTLCR"]); decimal ttlinvcr = 0; if (reader["TTLINVCR"] != DBNull.Value) ttlinvcr = Convert.ToDecimal(reader["TTLINVCR"]); if (ttlinvcr == 0) data.CRINVSTATUS = "未开票"; else if (ttlinvcr == ttlcr) data.CRINVSTATUS = "已开票"; else if (ttlinvcr != ttlcr) data.CRINVSTATUS = "部分开票"; decimal ttlduidr = 0; if (reader["TTLDUIDR"] != DBNull.Value) ttlduidr = Convert.ToDecimal(reader["TTLDUIDR"]); if (ttlduidr == 0) data.DRDUISTATUS = "未对账"; else if (ttlduidr == ttldr) data.DRDUISTATUS = "已对账"; else if (ttlduidr != ttldr) data.DRDUISTATUS = "部分对账"; if (reader["ETA"] != DBNull.Value) data.ETA = Convert.ToDateTime(reader["ETA"]).ToString("yyyy-MM-dd");//到港日期 if (reader["APPLYCOUNT"] != DBNull.Value) data.ISAPPLY = Convert.ToString(reader["APPLYCOUNT"]);//是否生成报关 data.TRANSKINDPKGS = Convert.ToString(reader["TRANSKINDPKGS"]); data.SHIPAGENCY = Convert.ToString(reader["SHIPAGENCY"]); data.ISBONDED = Convert.ToString(reader["ISBONDED"]);//是否保税业务 if (data.ISBONDED == "") data.ISBONDED = "0"; //需求编号:SR2017071700004 if (reader["SJYHDATE"] == null || reader["SJYHDATE"].ToString().Trim().IndexOf("0001") > -1 || reader["SJYHDATE"].ToString().Trim().IndexOf("1900") > -1 || reader["SJYHDATE"].ToString().Trim() == "") { data.SJYHDATE = ""; } else { data.SJYHDATE = Convert.ToDateTime(reader["SJYHDATE"]).ToString("yyyy-MM-dd"); } if (reader["YaXiangDate"] == null || reader["YaXiangDate"].ToString().Trim().IndexOf("0001") > -1 || reader["YaXiangDate"].ToString().Trim().IndexOf("1900") > -1 || reader["YaXiangDate"].ToString().Trim()=="") { data.YaXiangDate = ""; } else { data.YaXiangDate = Convert.ToDateTime(reader["YaXiangDate"]).ToString("yyyy-MM-dd"); } data.SJCYXL = Convert.ToString(reader["SJCYXL"]); data.YaXiangDiDian = Convert.ToString(reader["YaXiangDiDian"]); data.YaXiangJinE = Convert.ToDecimal(reader["YaXiangJinE"]); data.MaTou = Convert.ToString(reader["MaTou"]); data.BLISSUESTATUS = Convert.ToString(reader["BLISSUESTATUS"]);// 费用状态 data.SALECORPID = Convert.ToString(reader["SALECORPID"]);// 费用状态 data.SALECORP = Convert.ToString(reader["SALECORP"]);// 费用状态 if (reader["CTNNUM"] != DBNull.Value) data.CTNNUM = Convert.ToInt32(reader["CTNNUM"]); if (reader["WMSCTNNUM"] != DBNull.Value) data.WMSCTNNUM = Convert.ToInt32(reader["WMSCTNNUM"]); data.SHIPPERCODE = Convert.ToString(reader["SHIPPERCODE"]);// data.SHIPPERCOUNTRY = Convert.ToString(reader["SHIPPERCOUNTRY"]);// data.SHIPPERATTN = Convert.ToString(reader["SHIPPERATTN"]);// data.SHIPPERTEL = Convert.ToString(reader["SHIPPERTEL"]);// data.SHIPPEREMAIL = Convert.ToString(reader["SHIPPEREMAIL"]);// data.CONSIGNEECODE = Convert.ToString(reader["CONSIGNEECODE"]);// data.CONSIGNEECOUNTRY = Convert.ToString(reader["CONSIGNEECOUNTRY"]);// data.CONSIGNEEATTN = Convert.ToString(reader["CONSIGNEEATTN"]);// data.CONSIGNEETEL = Convert.ToString(reader["CONSIGNEETEL"]);// data.CONSIGNEEEMAIL = Convert.ToString(reader["CONSIGNEEEMAIL"]);// data.NOTIFYPARTYCODE = Convert.ToString(reader["NOTIFYPARTYCODE"]);// data.NOTIFYPARTYCOUNTRY = Convert.ToString(reader["NOTIFYPARTYCOUNTRY"]);// data.NOTIFYPARTYATTN = Convert.ToString(reader["NOTIFYPARTYATTN"]);// data.NOTIFYPARTYTEL = Convert.ToString(reader["NOTIFYPARTYTEL"]);// data.NOTIFYPARTYEMAIL = Convert.ToString(reader["NOTIFYPARTYEMAIL"]);// //data.SJLCEVALIDITY = ((reader["SJLCEVALIDITY"] == null || reader["SJLCEVALIDITY"].ToString().Trim().IndexOf("0001") > -1 || reader["SJLCEVALIDITY"].ToString().Trim().IndexOf("1900") > -1) ? "" : Convert.ToString(reader["SJLCEVALIDITY"]));//商检证书有效期 if (reader["SJLCEVALIDITY"] == null || reader["SJLCEVALIDITY"].ToString().Trim().IndexOf("0001") > -1 || reader["SJLCEVALIDITY"].ToString().Trim().IndexOf("1900") > -1 || reader["SJLCEVALIDITY"].ToString().Trim() == "") { data.SJLCEVALIDITY = ""; } else { data.SJLCEVALIDITY = Convert.ToDateTime(reader["SJLCEVALIDITY"]).ToString("yyyy-MM-dd"); } if (reader["TIHUOTIME"] != DBNull.Value) data.TIHUOTIME = Convert.ToDateTime(reader["TIHUOTIME"]).ToString("yyyy-MM-dd HH:mm:ss");//提货时间 if (BasicDataRefDAL.ReadFieldExist(reader, "DEST_RTCNT_TIME")) { data.DEST_RTCNT_TIME = Convert.ToString(reader["DEST_RTCNT_TIME"]); } data.OPSTATUSCOLOR = Convert.ToString(reader["OPSTATUSCOLOR"]);// if (reader["HGCYDATE"] != DBNull.Value) data.HGCYDATE = Convert.ToDateTime(reader["HGCYDATE"]).ToString("yyyy-MM-dd");// if (reader["CONTRACTDATE"] != DBNull.Value) data.CONTRACTDATE = Convert.ToDateTime(reader["CONTRACTDATE"]).ToString("yyyy-MM-dd");// data.HGCYXL = Convert.ToString(reader["HGCYXL"]);// data.TARIFFS = Convert.ToString(reader["TARIFFS"]);// data.VAT = Convert.ToString(reader["VAT"]);// data.MARGIN = Convert.ToString(reader["MARGIN"]);// if (reader["CHANGEDOCSTATUS"] != DBNull.Value) data.CHANGEDOCSTATUS = Convert.ToInt32(reader["CHANGEDOCSTATUS"]); if (reader["CUSTOMSSTATUS"] != DBNull.Value) data.CUSTOMSSTATUS = Convert.ToInt32(reader["CUSTOMSSTATUS"]); if (reader["CANGDANSTATUS"] != DBNull.Value) data.CANGDANSTATUS = Convert.ToInt32(reader["CANGDANSTATUS"]); data.MDESCRIPTION = Convert.ToString(reader["MDESCRIPTION"]); #endregion headList.Add(data); } reader.Close(); } SetWMSData(ref headList); return headList; } public static string getfeestatus(string feestatusint) { var result = ""; if (feestatusint == "0:") { return "审核通过"; } else if (feestatusint == "1:") { return "录入状态"; } else if (feestatusint == "2:") { return "提交审核"; } else if (feestatusint == "8:") { return "部分结算"; } else if (feestatusint == "9:") { return "结算完毕"; } else if (feestatusint == "") { return "未录入"; } else if (feestatusint == "3:") { return "申请修改"; } else if (feestatusint == "4:") { return "申请删除"; } else if (feestatusint == "6:") { return "驳回提交"; } else if (feestatusint == "7:") { return "驳回申请"; } else if (feestatusint.IndexOf("9:") > -1) { return "部分结算"; } else if (feestatusint.IndexOf("8:") > -1) { return "部分结算"; } else if (feestatusint.IndexOf("0:") > -1) { return "部分审核"; } else if (feestatusint.IndexOf("2:") > -1) { return "部分提交"; } else if (feestatusint.IndexOf("6:") > -1) { return "驳回提交"; } else if (feestatusint.IndexOf("7:") > -1) { return "驳回申请"; } return result; } public static void SetWMSData(ref List headList) { if (headList == null || headList.Count == 0) return; if (ConfigurationManager.AppSettings["COMPANYCODE"] != null) { if (ConfigurationManager.AppSettings["COMPANYCODE"] == "JGWL") { //根据海运进口业务的报关单号,查找库存 视图 VW_WMSIOSUM_BYCUSTOMNO var cdc = new CommonDataContext(); var customnoList = headList.Select(s => s.CUSTOMNO).ToList(); var WMSIOList = cdc.VW_WMSIOSUM_BYCUSTOMNO.Where(x => customnoList.Contains(x.CUSTOMNO) && x.CHANGETYPE == "入库").ToList(); foreach (var item in headList) { if (WMSIOList.Exists(x => x.CUSTOMNO == item.CUSTOMNO)) { item.OPWMS_IN_COUNT = WMSIOList.FirstOrDefault(x => x.CUSTOMNO == item.CUSTOMNO).STORAGEUNITCOUNT; } } } } return; } #endregion #region 明细表 static public List GetBodyList(string strCondition) { var strSql = new StringBuilder(); strSql.Append("SELECT [CTN_ID],[BSNO],isnull(CTNCODE,1) as [CTNCODE],[SIZE],[CTN],[CTNNUM],[TEU],[CTNALL],[CNTRNO],[SEALNO],[PKGS],[KGS],[CBM],[REMARK],[KINDPKGS],[TAREWEIGHT],[GOODSNAME],MTMC,convert(varchar(100),SJRGSJ,20) AS SJRGSJ,convert(varchar(100),SJCGSJ,20) AS SJCGSJ"); strSql.Append(" ,AREANAME,ISWMS,convert(char(10),WMSDATE,20) AS WMSDATE,TRUCKER,TRUCKNO,TRUCKFEE,FREESTORAGEDAY,STORAGEDAY,STORAGEPRICE,STORAGEFEE,FREECTNDAY,CTNDAY,CTNPRICE,CTNFEE,CTNSTATUS,ISTEMP,TiXiangShiJian from op_ctn"); //if (strCondition.Trim() != String.Empty) if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } strSql.Append(" order by BSNO,CTNCODE,CTNALL"); return SetBodyData(strSql); } private static List SetBodyData(StringBuilder strSql) { var bodyList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { MsOpSeaiDetail data = new MsOpSeaiDetail(); #region Set DB data to Object data.CTN_ID = Convert.ToString(reader["CTN_ID"]);//编号 data.BSNO = Convert.ToString(reader["BSNO"]);//业务编号 data.CTNCODE = Convert.ToString(reader["CTNCODE"]);//箱型代码 data.SIZE = Convert.ToString(reader["SIZE"]);//尺寸 data.CTN = Convert.ToString(reader["CTN"]);//箱型 data.CTNNUM = Convert.ToInt32(reader["CTNNUM"]);//箱量 data.TEU = Convert.ToInt32(reader["TEU"]);//TEU data.CTNALL = Convert.ToString(reader["CTNALL"]);//表现形式 data.CNTRNO = Convert.ToString(reader["CNTRNO"]);//箱号 data.SEALNO = Convert.ToString(reader["SEALNO"]);//封号 if (reader["PKGS"] != DBNull.Value) data.PKGS = Convert.ToInt32(reader["PKGS"]);//件数 if (reader["KGS"] != DBNull.Value) data.KGS = Convert.ToDecimal(reader["KGS"]);//重量(货重) if (reader["CBM"] != DBNull.Value) data.CBM = Convert.ToDecimal(reader["CBM"]);//尺码 data.REMARK = Convert.ToString(reader["REMARK"]);//备注 data.KINDPKGS = Convert.ToString(reader["KINDPKGS"]);//包装类型 if (reader["TAREWEIGHT"] != DBNull.Value) data.TAREWEIGHT = Convert.ToDecimal(reader["TAREWEIGHT"]);//箱皮重 data.GOODSNAME = Convert.ToString(reader["GOODSNAME"]);//品名 data.TRUCKER = Convert.ToString(reader["TRUCKER"]); data.TRUCKNO = Convert.ToString(reader["TRUCKNO"]); if (reader["FREECTNDAY"] != DBNull.Value) data.FREECTNDAY = Convert.ToString(reader["FREECTNDAY"]); if (reader["CTNDAY"] != DBNull.Value) data.CTNDAY = Convert.ToString(reader["CTNDAY"]); if (reader["TRUCKFEE"] != DBNull.Value) data.TRUCKFEE = Convert.ToString(reader["TRUCKFEE"]); if (reader["CTNPRICE"] != DBNull.Value) data.CTNPRICE = Convert.ToString(reader["CTNPRICE"]); if (reader["CTNFEE"] != DBNull.Value) data.CTNFEE = Convert.ToString(reader["CTNFEE"]); data.CTNSTATUS = Convert.ToString(reader["CTNSTATUS"]);//包装类型 if (reader["MTMC"] != DBNull.Value) data.MTMC = Convert.ToString(reader["MTMC"]); data.SJRGSJ = ((reader["SJRGSJ"] == null || reader["SJRGSJ"].ToString().Trim().IndexOf("0001") > -1 || reader["SJRGSJ"].ToString().Trim().IndexOf("1900") > -1) ? "" : Convert.ToString(reader["SJRGSJ"])); data.SJCGSJ = ((reader["SJCGSJ"] == null || reader["SJCGSJ"].ToString().Trim().IndexOf("0001") > -1 || reader["SJCGSJ"].ToString().Trim().IndexOf("1900") > -1) ? "" : Convert.ToString(reader["SJCGSJ"])); data.WMSDATE = ((reader["WMSDATE"] == null || reader["WMSDATE"].ToString().Trim().IndexOf("0001") > -1 || reader["WMSDATE"].ToString().Trim().IndexOf("1900") > -1) ? "" : Convert.ToString(reader["WMSDATE"])); if (reader["ISWMS"] != DBNull.Value) data.ISWMS = Convert.ToString(reader["ISWMS"]); if (reader["AREANAME"] != DBNull.Value) data.AREANAME = Convert.ToString(reader["AREANAME"]); data.ISTEMP = Convert.ToString(reader["ISTEMP"]); data.TIXIANGSHIJIAN = Convert.ToString(reader["TiXiangShiJian"]); #endregion bodyList.Add(data); } reader.Close(); } return bodyList; } #endregion #region Excel导入数据 //更新集装箱件数重量入库时间 public static DBResult UpdateCtrnDetail( List bodyList) { var result = new DBResult(); Database db = DatabaseFactory.CreateDatabase(); using (var conn = db.CreateConnection()) { conn.Open(); var tran = conn.BeginTransaction(); try { if (bodyList != null) { foreach (var enumValue in bodyList) { { var cmdUpdate = db.GetSqlStringCommand(@"update op_ctn set PKGS='" + enumValue.PKGS + "',KGS=" + enumValue.KGS + ",WMSDATE='" + enumValue.WMSDATE + "',AREANAME='" + enumValue.AREANAME + "' " + " where BSNO='" + enumValue.BSNO + "' AND CTN_ID='" + enumValue.CTN_ID + "'"); db.ExecuteNonQuery(cmdUpdate, tran); } //n++; } } // tran.Commit(); } catch (Exception ee) { tran.Rollback(); result.Success = false; result.Message = "保存出现错误,请重试或联系系统管理员"; return result; } } result.Success = true; result.Message = "保存成功" + result.Message; return result; } //更新集装箱入库状态 public static DBResult UpdateCtrnWMSState(List bodyList) { var result = new DBResult(); if (bodyList.Count == 0) return result; Database db = DatabaseFactory.CreateDatabase(); using (var conn = db.CreateConnection()) { conn.Open(); var tran = conn.BeginTransaction(); try { if (bodyList != null) { foreach (var enumValue in bodyList) { { var cmdUpdate = db.GetSqlStringCommand(@"update op_ctn set ISWMS='" + enumValue.ISWMS + "' " + " where BSNO='" + enumValue.BSNO + "' AND CTN_ID='" + enumValue.CTN_ID + "'"); db.ExecuteNonQuery(cmdUpdate, tran); } //n++; } } // tran.Commit(); } catch (Exception) { tran.Rollback(); result.Success = false; result.Message = "保存出现错误,请重试或联系系统管理员"; return result; } } result.Success = true; result.Message = "保存成功" + result.Message; return result; } //生产入库单 /// /// 当前有多少入库单号 /// /// /// public static int CtrnToWMS_DATENUM(string bsno) { int num = 0; T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); DataSet ds = T_ALL_DA.GetAllSQL("select distinct(wmsdate) from op_ctn where bsno = '"+bsno+"' and (ISWMS = '0' or ISWMS is null)"); if (ds != null) { num = ds.Tables[0].Rows.Count; } return num; } static public List CtrnToWMS_List(string strCondition) { var strSql = new StringBuilder(); strSql.Append("SELECT [CTN_ID],[BSNO],isnull(CTNCODE,1) as [CTNCODE],[SIZE],[CTN],[CTNNUM],[TEU],[CTNALL],[CNTRNO],[SEALNO],[PKGS],[KGS],[CBM],[REMARK],[KINDPKGS],[TAREWEIGHT],[GOODSNAME],MTMC,convert(varchar(100),SJRGSJ,20) AS SJRGSJ,convert(varchar(100),SJCGSJ,20) AS SJCGSJ"); strSql.Append(" ,ISWMS,convert(varchar(100),WMSDATE,120) AS WMSDATE,TRUCKER,TRUCKNO,TRUCKFEE,FREESTORAGEDAY,STORAGEDAY,STORAGEPRICE,STORAGEFEE,FREECTNDAY,CTNDAY,CTNPRICE,CTNFEE,CTNSTATUS,TiXiangShiJian "); strSql.Append(" FROM (SELECT *, Row_Number() OVER (partition by wmsdate ORDER BY cntrno desc) rownum FROM op_ctn) t"); //if (strCondition.Trim() != String.Empty) if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } strSql.Append(" order by BSNO,CTNCODE,CTNALL"); return SetBodyData(strSql); } public static DBResult CtrnToWMS(List ctrnList,string companyID) { var result = new DBResult(); Database db = DatabaseFactory.CreateDatabase(); using (var conn = db.CreateConnection()) { conn.Open(); var tran = conn.BeginTransaction(); try { if (ctrnList != null) { foreach (var enumValue in ctrnList) { { if (enumValue.ISWMS == "0") { WMSNew wms = new WMSNew(); wms.GID = "Wms" + Guid.NewGuid().ToString().Replace("-", ""); ;//获取管理费单号 wms.WMSDATE = enumValue.WMSDATE; wms.ACCDATE = enumValue.WMSDATE.Substring(0, 7); var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='仓储入库'", companyID); wms.WMSNO = MsSysBillNoSetDAL.GetBillNo(billnoset, enumValue.WMSDATE.ToString().Trim(), wms.ACCDATE.ToString().Trim()); enumValue.ISWMS = "1"; } // var cmdUpdate = db.GetSqlStringCommand(@"update op_ctn set PKGS='" + enumValue.PKGS + "',KGS=" + enumValue.KGS + ",WMSDATE='" + enumValue.SJCGSJ + "' " // + " where BSNO='" + enumValue.BSNO + "' AND CTN_ID='" + enumValue.CTN_ID + "'"); // db.ExecuteNonQuery(cmdUpdate, tran); } //n++; } } // tran.Commit(); } catch (Exception) { tran.Rollback(); result.Success = false; result.Message = "入库保存保存出现错误,请重试或联系系统管理员"; return result; } } result.Success = true; result.Message = "入库成功" + result.Message; return result; } #endregion #region 保存明细 public static DBResult SaveDetail(MsOpSeai headData, List bodyList, string userid) { var result = new DBResult(); Database db = DatabaseFactory.CreateDatabase(); using (var conn = db.CreateConnection()) { conn.Open(); var tran = conn.BeginTransaction(); try { //var cmdInsert = db.GetSqlStringCommand(@"insert into op_ctn (CTN_ID,BSNO,CTNCODE,SIZE,CTN,CTNNUM,TEU,CTNALL,CNTRNO,SEALNO,PKGS,KGS,CBM,REMARK,KINDPKGS,TAREWEIGHT,GOODSNAME) values (newid(),@BSNO,@CTNCODE,@SIZE,@CTN,@CTNNUM,@TEU,@CTNALL,@CNTRNO,@SEALNO,@PKGS,@KGS,@CBM,@REMARK,@KINDPKGS,@TAREWEIGHT,@GOODSNAME) "); //var cmdUpdate = db.GetSqlStringCommand(@"update op_ctn set CTNCODE=@CTNCODE,SIZE=@SIZE,CTN=@CTN,CTNNUM=@CTNNUM,TEU=@TEU,CTNALL=@CTNALL,CNTRNO=@CNTRNO,SEALNO=@SEALNO,PKGS=@PKGS,KGS=@KGS,CBM=@CBM,REMARK=@REMARK,KINDPKGS=@KINDPKGS,TAREWEIGHT=@TAREWEIGHT where BSNO=@BSNO AND CTN_ID=@CTN_ID "); if (bodyList != null) { //int n = 1; //int ln = bodyList.Count; foreach (var enumValue in bodyList) { var SIZE = enumValue.CTNALL.ToString().Trim().Substring(0, 2); string CTN = enumValue.CTNALL.ToString().Trim().Substring(2); int TEU = enumValue.CTNNUM; var iTEU = enumValue.CTNALL.ToString().Trim().Substring(0, 1); if (iTEU == "4") { TEU = TEU * 2; } else if (iTEU == "L") { TEU = 0; } if (enumValue.TRUCKFEE == "") enumValue.TRUCKFEE = "0"; if (enumValue.FREECTNDAY == "") enumValue.FREECTNDAY = "0"; if (enumValue.CTNDAY == "") enumValue.CTNDAY = "0"; if (enumValue.CTNPRICE == "") enumValue.CTNPRICE = "0"; if (enumValue.CTNFEE == "") enumValue.CTNFEE = "0"; if (enumValue.CTN_ID == "*") { var cmdInsert = db.GetSqlStringCommand(@"insert into op_ctn (CTN_ID,BSNO,CTNCODE,[SIZE],CTN,CTNNUM,TEU,CTNALL,CNTRNO,SEALNO,PKGS,KGS,CBM,REMARK,KINDPKGS,TAREWEIGHT,GOODSNAME,TRUCKER,TRUCKNO,TRUCKFEE,FREECTNDAY,CTNDAY,CTNPRICE,CTNFEE,CTNSTATUS,MTMC,SJRGSJ,SJCGSJ,WMSDATE,AREANAME,ISTEMP,TIXIANGSHIJIAN) values (newid(),'" + headData.BSNO + "','" + enumValue.CTNCODE + "','" + SIZE + "','" + CTN + "'," + enumValue.CTNNUM + "," + TEU + ",'" + enumValue.CTNALL + "','" + enumValue.CNTRNO + "','" + enumValue.SEALNO + "','" + enumValue.PKGS + "'," + enumValue.KGS + "," + enumValue.CBM + ",'" + enumValue.REMARK + "','" + enumValue.KINDPKGS + "'," + enumValue.TAREWEIGHT + ",'" + enumValue.GOODSNAME + "','" + enumValue.TRUCKER + "','" + enumValue.TRUCKNO + "'," + enumValue.TRUCKFEE + "," + enumValue.FREECTNDAY + "," + enumValue.CTNDAY + "," + enumValue.CTNPRICE + "," + enumValue.CTNFEE + ",'" + enumValue.CTNSTATUS + "','" + enumValue.MTMC + "','" + enumValue.SJRGSJ + "','" + enumValue.SJCGSJ + "','" + enumValue.WMSDATE + "','"+enumValue.AREANAME+ "','" + enumValue.ISTEMP + "','" + enumValue.TIXIANGSHIJIAN + "')"); db.ExecuteNonQuery(cmdInsert, tran); } else { var cmdUpdate = db.GetSqlStringCommand(@"update op_ctn set CTNCODE='"+enumValue.CTNCODE+"',[SIZE]='"+SIZE+"',CTN='"+CTN+"',CTNNUM="+enumValue.CTNNUM+",TEU="+TEU+",CTNALL='"+enumValue.CTNALL+"',CNTRNO='"+enumValue.CNTRNO + "',SEALNO='" + enumValue.SEALNO + "',PKGS='" + enumValue.PKGS + "',KGS=" + enumValue.KGS + ",CBM=" + enumValue.CBM + ",REMARK='" + enumValue.REMARK + "',KINDPKGS='" + enumValue.KINDPKGS + "',TAREWEIGHT=" + enumValue.TAREWEIGHT + ",TRUCKER='" + enumValue.TRUCKER + "',TRUCKNO='" + enumValue.TRUCKNO + "',TRUCKFEE=" + enumValue.TRUCKFEE + ",FREECTNDAY=" + enumValue.FREECTNDAY + ",CTNDAY=" + enumValue.CTNDAY + ",CTNPRICE=" + enumValue.CTNPRICE + ",CTNFEE=" + enumValue.CTNFEE + ",CTNSTATUS='" + enumValue.CTNSTATUS + "',MTMC='" + enumValue.MTMC + "',SJRGSJ='" + enumValue.SJRGSJ + "',SJCGSJ='" + enumValue.SJCGSJ + "',WMSDATE='" + enumValue.WMSDATE + "',AREANAME='" + enumValue.AREANAME + "',ISTEMP='" + enumValue.ISTEMP + "',TIXIANGSHIJIAN='"+ enumValue.TIXIANGSHIJIAN + "' " + " where BSNO='"+enumValue.BSNO+"' AND CTN_ID='"+enumValue.CTN_ID+"'"); db.ExecuteNonQuery(cmdUpdate, tran); } //n++; } } // tran.Commit(); } catch (Exception) { tran.Rollback(); result.Success = false; result.Message = "保存出现错误,请重试或联系系统管理员"; return result; } } // getCNTRTOTAL(headData.BSNO, "op_seai"); // result.Success = true; result.Message = "保存成功" + result.Message; return result; } //合计当前业务的集装箱信息,更新op_seai中的CNTRTOTAL,CNTRSEALNO两个字段 public static void getCNTRTOTAL(string strBSNO, string bstype) { int iTEU = 0; string strCNTRTOTAL = ""; string strCNTRNO = ""; string str = ""; T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); DataSet dsDisp = T_ALL_DA.GetAllSQL("select * from code_ctn_disp");// where CORPID = '" + strCORPID + "'"; DataSet ds = T_ALL_DA.GetAllSQL("select * from op_ctn where BSNO='" + strBSNO.Trim() + "'"); str = "update " + bstype + " set CNTR1=0,CNTR2=0,CNTR3=0,CNTR4=0,CNTR5=0,CNTR6=0,CNTR7=0,CNTR8=0,CNTR9=0,CNTR10=0,OTCNTR=0 where BSNO='" + strBSNO + "'"; bool bl3 = T_ALL_DA.GetExecuteSqlCommand(str); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { foreach (DataTable myTable in ds.Tables) { foreach (DataRow myRow in myTable.Rows)//遍历表 { strCNTRNO += myRow["CNTRNO"].ToString().Trim() + "/" + myRow["SEALNO"].ToString().Trim() + "/" + myRow["CTNALL"].ToString().Trim() + "\r\n"; iTEU += int.Parse(myRow["TEU"].ToString().Trim()); } } // // str = "select CTNALL,sum(CTNNUM) as hj from op_ctn where BSNO='" + strBSNO.Trim() + "' group by CTNALL order by CTNALL"; ds = T_ALL_DA.GetAllSQL(str); foreach (DataTable myTable in ds.Tables) { foreach (DataRow myRow in myTable.Rows)//遍历表 { strCNTRTOTAL += myRow["CTNALL"].ToString().Trim() + "*" + myRow["hj"].ToString().Trim() + " / "; // if (dsDisp == null) { string sHJ = T_ALL_DA.GetStrSQL("hj", "select sum(CTNNUM) as hj from op_ctn where BSNO='" + strBSNO.Trim() + "'"); str = "update " + bstype + " set OTCNTR=OTCNTR+" + myRow["hj"].ToString().Trim() + " where BSNO='" + strBSNO + "'"; bool bl2 = T_ALL_DA.GetExecuteSqlCommand(str); } else { int j = 0; for (int i = 1; i < 11; i++) { if (dsDisp.Tables[0].Rows[0][i].ToString().Trim().Equals(myRow["CTNALL"].ToString().Trim())) { str = "update " + bstype + " set CNTR" + i + "=CNTR" + i + "+" + myRow["hj"].ToString().Trim() + " where BSNO='" + strBSNO + "'"; j = j + 1; break; } } if (j == 0) { str = "update " + bstype + " set OTCNTR=OTCNTR+" + myRow["hj"].ToString().Trim() + " where BSNO='" + strBSNO + "'"; } bool bl2 = T_ALL_DA.GetExecuteSqlCommand(str); } } } strCNTRTOTAL = strCNTRTOTAL.Trim().Substring(0, strCNTRTOTAL.Trim().Length - 1); } } str = "update op_seai set CNTRTOTAL='" + strCNTRTOTAL + "',CNTRSEALNO='" + strCNTRNO + "',TEU=" + iTEU + " where BSNO='" + strBSNO.Trim() + "'"; bool bl = T_ALL_DA.GetExecuteSqlCommand(str); } //判断单号是否重复 static public int GetRdCount(string strCondition) { var strSql = new StringBuilder(); strSql.Append("SELECT Count(BSNO) AS CT from op_seai"); if (strCondition.Trim() != String.Empty) { strSql.Append(" where " + strCondition); } var ct=0; Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { ct = Convert.ToInt16(reader["CT"]); } reader.Close(); } return ct; } #endregion public static DBResult SaveGoodsDetail(MsOpSeai headData, List bodyList, string userid) { var result = new DBResult(); Database db = DatabaseFactory.CreateDatabase(); using (var conn = db.CreateConnection()) { conn.Open(); var tran = conn.BeginTransaction(); try { var cmdInsert = db.GetSqlStringCommand( @"insert into op_apply_detail (BSNO, SerialNo,GOODSCODE,GOODSNAME,PKGS,PRICE,TOTAL,CURRENCY,Remark,WMSNO,WMSIN_GID,GOODSMODEL,GOODSSTANDARD,GOODSNUM,PICINO,PONO,KGS,KINDPKGS) values (@BSNO, @SerialNo, @GOODSCODE, @GOODSNAME,@PKGS, @PRICE, @TOTAL, @CURRENCY,@Remark,@WMSNO,@WMSIN_GID,@GOODSMODEL,@GOODSSTANDARD,@GOODSNUM,@PICINO,@PONO,@KGS,@KINDPKGS) "); var cmdUpdate = db.GetSqlStringCommand( @"update op_apply_detail set GOODSCODE=@GOODSCODE,GOODSNAME=@GOODSNAME,PKGS=@PKGS,PRICE=@PRICE,TOTAL=@TOTAL,CURRENCY=@CURRENCY,Remark=@Remark ,WMSNO=@WMSNO,WMSIN_GID=@WMSIN_GID,GOODSMODEL=@GOODSMODEL,GOODSSTANDARD=@GOODSSTANDARD,GOODSNUM=@GOODSNUM,PICINO=@PICINO,PONO=@PONO,KGS=@KGS,KINDPKGS=@KINDPKGS where BSNO=@BSNO AND SerialNo=@SerialNo "); var StrSerialNo = "(1000"; if (bodyList != null) { foreach (var enumValue in bodyList) { StrSerialNo = StrSerialNo + "," + Convert.ToString(enumValue.SerialNo); if (enumValue.BsNo == "*") { cmdInsert.Parameters.Clear(); db.AddInParameter(cmdInsert, "@BSNO", DbType.String, headData.BSNO); db.AddInParameter(cmdInsert, "@SerialNo", DbType.Int32, enumValue.SerialNo); db.AddInParameter(cmdInsert, "@GOODSCODE", DbType.String, enumValue.GoodsCode); db.AddInParameter(cmdInsert, "@GOODSNAME", DbType.String, enumValue.GoodsName); db.AddInParameter(cmdInsert, "@PKGS", DbType.Decimal, enumValue.Pkgs); db.AddInParameter(cmdInsert, "@PRICE", DbType.Decimal, enumValue.Price); db.AddInParameter(cmdInsert, "@TOTAL", DbType.Decimal, enumValue.Total); db.AddInParameter(cmdInsert, "@CURRENCY", DbType.String, enumValue.Currency); db.AddInParameter(cmdInsert, "@Remark", DbType.String, enumValue.Remark); db.AddInParameter(cmdInsert, "@WMSIN_GID", DbType.String, enumValue.WMSIN_GID); db.AddInParameter(cmdInsert, "@WMSNO", DbType.String, enumValue.WMSNO); db.AddInParameter(cmdInsert, "@GOODSMODEL", DbType.String, enumValue.GOODSMODEL); db.AddInParameter(cmdInsert, "@GOODSSTANDARD", DbType.String, enumValue.GOODSSTANDARD); db.AddInParameter(cmdInsert, "@GOODSNUM", DbType.Decimal, enumValue.GOODSNUM); db.AddInParameter(cmdInsert, "@PICINO", DbType.String, enumValue.PICINO); db.AddInParameter(cmdInsert, "@PONO", DbType.String, enumValue.PONO); if (enumValue.KGS=="") db.AddInParameter(cmdInsert, "@KGS", DbType.String, "0"); else db.AddInParameter(cmdInsert, "@KGS", DbType.String, enumValue.KGS); db.AddInParameter(cmdInsert, "@KINDPKGS", DbType.String, enumValue.KINDPKGS); db.ExecuteNonQuery(cmdInsert, tran); } else { cmdUpdate.Parameters.Clear(); db.AddInParameter(cmdUpdate, "@BSNO", DbType.String, headData.BSNO); db.AddInParameter(cmdUpdate, "@SerialNo", DbType.Int32, enumValue.SerialNo); db.AddInParameter(cmdUpdate, "@GOODSCODE", DbType.String, enumValue.GoodsCode); db.AddInParameter(cmdUpdate, "@GOODSNAME", DbType.String, enumValue.GoodsName); db.AddInParameter(cmdUpdate, "@PKGS", DbType.Decimal, enumValue.Pkgs); db.AddInParameter(cmdUpdate, "@PRICE", DbType.Decimal, enumValue.Price); db.AddInParameter(cmdUpdate, "@TOTAL", DbType.Decimal, enumValue.Total); db.AddInParameter(cmdUpdate, "@CURRENCY", DbType.String, enumValue.Currency); db.AddInParameter(cmdUpdate, "@Remark", DbType.String, enumValue.Remark); db.AddInParameter(cmdUpdate, "@WMSNO", DbType.String, enumValue.WMSNO); db.AddInParameter(cmdUpdate, "@WMSIN_GID", DbType.String, enumValue.WMSIN_GID); db.AddInParameter(cmdUpdate, "@GOODSMODEL", DbType.String, enumValue.GOODSMODEL); db.AddInParameter(cmdUpdate, "@GOODSSTANDARD", DbType.String, enumValue.GOODSSTANDARD); db.AddInParameter(cmdUpdate, "@GOODSNUM", DbType.Decimal, enumValue.GOODSNUM); db.AddInParameter(cmdUpdate, "@PICINO", DbType.String, enumValue.PICINO); db.AddInParameter(cmdUpdate, "@PONO", DbType.String, enumValue.PONO); if (enumValue.KGS == "") db.AddInParameter(cmdUpdate, "@KGS", DbType.String, "0"); else db.AddInParameter(cmdUpdate, "@KGS", DbType.String, enumValue.KGS); db.AddInParameter(cmdUpdate, "@KINDPKGS", DbType.String, enumValue.KINDPKGS); db.ExecuteNonQuery(cmdUpdate, tran); } } } StrSerialNo = StrSerialNo + ")"; var cmdDelete = db.GetSqlStringCommand("delete from op_apply_detail where BSNO='" + headData.BSNO + "' and SerialNo not in " + StrSerialNo); db.ExecuteNonQuery(cmdDelete, tran); tran.Commit(); } catch (Exception) { tran.Rollback(); result.Success = false; result.Message = "保存出现错误,请重试或联系系统管理员"; return result; } } result.Success = true; result.Message = "保存成功" + result.Message; return result; } public static bool GetPONOCount(string BSNO,string PONO) { var isfee = false; var strSql = new StringBuilder(); strSql.Append("Select count(*) as count "); strSql.Append(" from op_apply_detail "); strSql.Append(" where BSNO<>'" + BSNO + "' AND PONO='"+ PONO + "'"); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { var evData = Convert.ToInt32(reader["count"]); if (evData > 0) { isfee = true; }; } reader.Close(); } return isfee; } #region 删除 public static DBResult DeleteDetail(MsOpSeai headData) { var result = new DBResult(); Database db = DatabaseFactory.CreateDatabase(); using (var conn = db.CreateConnection()) { conn.Open(); var tran = conn.BeginTransaction(); try { var cmdDelete = db.GetSqlStringCommand("delete from op_Seai_detail where BSNO='" + headData.BSNO + "'"); db.ExecuteNonQuery(cmdDelete, tran); cmdDelete = db.GetSqlStringCommand("delete from op_Seai_service where BSNO='" + headData.BSNO + "'"); db.ExecuteNonQuery(cmdDelete, tran); cmdDelete = db.GetSqlStringCommand("delete from op_Seai_service_detail where BSNO='" + headData.BSNO + "'"); db.ExecuteNonQuery(cmdDelete, tran); cmdDelete = db.GetSqlStringCommand("delete from OP_SEAETOSEAI where SEAIBSNO='" + headData.BSNO + "'"); db.ExecuteNonQuery(cmdDelete, tran); tran.Commit(); } catch (Exception) { tran.Rollback(); result.Success = false; result.Message = "删除出现错误,请重试或联系系统管理员"; return result; } } result.Success = true; result.Message = "操作成功"; return result; } public static DBResult DeleteDetail2(MsOpSeaiDetail headData) { var result = new DBResult(); Database db = DatabaseFactory.CreateDatabase(); using (var conn = db.CreateConnection()) { conn.Open(); var tran = conn.BeginTransaction(); try { var cmdDelete = db.GetSqlStringCommand("delete from op_ctn where CTN_ID='" + headData.CTN_ID + "'"); db.ExecuteNonQuery(cmdDelete, tran); tran.Commit(); } catch (Exception) { tran.Rollback(); result.Success = false; result.Message = "删除出现错误,请重试或联系系统管理员"; return result; } } // getCNTRTOTAL(headData.BSNO, "op_seai"); // result.Success = true; result.Message = "操作成功"; return result; } #endregion #region EDI引入 public static string GetPosString(string str, int pos, bool isnum = false) { var result = ""; if (isnum) result = "0"; var j = 0; if (str.IndexOf(":") == -1) return result; str=str.Replace("??", "?").Replace("?:", "^").Replace("?'", "'").Replace("?+", "+"); for (int i = 1; i < pos; i++) { if (str.IndexOf(":") == -1) return result; if (str.IndexOf(":") != -1) { j = str.IndexOf(":"); str = str.Substring(j + 1, str.Length - j - 1); } } j = str.IndexOf(":"); if (j != -1) { str = str.Substring(0, j); } else { if (str.Length != 0) str = str.Substring(0, str.Length - 1); } result = str.Replace("^", ":"); if (isnum) { if (result == "") result = "0"; } return result; } public static string GetDateString(string str) { var result = ""; if (str.Length != 8) return result; return str.Substring(0, 4) + "-" + str.Substring(4, 2) + "-" + str.Substring(6, 2); } public static List ImportEdiList(string filename, string userid, string usercode, string companyid) { var result = new DBResult(); var headList = new List(); try { FileStream fs = new FileStream(filename, FileMode.Open); StreamReader sr = new StreamReader(fs, System.Text.Encoding.GetEncoding("gb2312")); string line; var head = ""; var Corps = ""; var VslID = ""; var Vessel = ""; var VoyNo = ""; var etd = ""; var eta = ""; var Carrier = ""; var headData = new MsOpSeai(); var strtmp = ""; var BSNO = ""; var addbill = false; Database db = DatabaseFactory.CreateDatabase(); using (var conn = db.CreateConnection()) { while ((line = sr.ReadLine()) != null&&line!="") { head = line.Substring(0, 2); if (head == "00") { Corps = GetPosString(line, 5); } if (head == "10") { VslID = GetPosString(line, 2); Vessel = GetPosString(line, 3); VoyNo = GetPosString(line, 5); etd = GetPosString(line, 8); eta = GetPosString(line, 9); } if (head == "11") { Carrier = GetPosString(line, 2); } if (head == "12") { headData = new MsOpSeai(); BSNO = "topseai" + Guid.NewGuid().ToString(); T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); string rq = T_ALL_DA.GetStrSQL("rq", "select getdate() as rq"); string sYear = DateTime.Parse(rq).Year.ToString(); string sMonth = DateTime.Parse(rq).ToString("MM"); headData.ACCDATE = sYear + "-" + sMonth; headData.BSDATE = rq; headData.BSNO = BSNO; headData.MASTERNO = BSNO; var isuse = MsBaseInfoDAL.MsBaseInfoDAL.GetRuleUse("委托编号", "2"); if (isuse) { headData.CUSTNO =getCodeRule("委托编号", "CUSTNO", headData.BSDATE.ToString().Trim(), headData.ACCDATE.ToString().Trim(), userid, companyid); } headData.CORPID = companyid; headData.INPUTBY = usercode; headData.OP = usercode; headData.BSDATE = DateTime.Now.ToString(); headData.CREATETIME = DateTime.Now.ToString(); headData.BSSTATUS = false; headData.FEESTATUS = false; headData.DbOperationType = DbOperationType.DbotIns; headData.CUSTOMERNAME = Corps; headData.VESSEL = Vessel; headData.VOYNO = VoyNo; headData.MBLNO = GetPosString(line, 2); if (eta != "") headData.ETD = GetDateString(eta); if (etd != "") headData.ETA = GetDateString(etd); headData.PORTLOADID = GetPosString(line, 8); headData.PORTLOAD = GetPosString(line, 9); headData.SERVICE = GetPosString(line, 10); strtmp = GetPosString(line, 11); if (strtmp == "P") headData.BLFRT = "FREIGHT PREPAID"; else headData.BLFRT = "FREIGHT COLLECT"; var ct = MsOpSeaiDAL.GetRdCount("BSNO<>'" + headData.BSNO + "' AND MBLNO='" + headData.MBLNO + "' and CORPID='" + companyid + "'"); if (ct == 0) { addbill = true; } } if (head == "13") { headData.PORTDISCHARGEID = GetPosString(line, 4); headData.PORTDISCHARGE = GetPosString(line, 5); headData.DESTINATIONID = GetPosString(line, 6); headData.DESTINATION = GetPosString(line, 7); } if (head == "16") { strtmp = GetPosString(line, 3); if (strtmp != "") if (headData.SHIPPER == "") headData.SHIPPER = strtmp; else headData.SHIPPER = headData.SHIPPER + Environment.NewLine + strtmp; strtmp = GetPosString(line, 4); if (strtmp != "") if (headData.SHIPPER == "") headData.SHIPPER = strtmp; else headData.SHIPPER = headData.SHIPPER + Environment.NewLine + strtmp; strtmp = GetPosString(line, 5); if (strtmp != "") if (headData.SHIPPER == "") headData.SHIPPER = strtmp; else headData.SHIPPER = headData.SHIPPER + Environment.NewLine + strtmp; strtmp = GetPosString(line, 6); if (strtmp != "") if (headData.SHIPPER == "") headData.SHIPPER = strtmp; else headData.SHIPPER = headData.SHIPPER + Environment.NewLine + strtmp; strtmp = GetPosString(line, 7); if (strtmp != "") if (headData.SHIPPER == "") headData.SHIPPER = strtmp; else headData.SHIPPER = headData.SHIPPER + Environment.NewLine + strtmp; strtmp = GetPosString(line, 8); if (strtmp != "") if (headData.SHIPPER == "") headData.SHIPPER = strtmp; else headData.SHIPPER = headData.SHIPPER + Environment.NewLine + strtmp; } if (head == "17") { strtmp = GetPosString(line, 3); if (strtmp != "") if (headData.CONSIGNEE == "") headData.CONSIGNEE = strtmp; else headData.CONSIGNEE = headData.CONSIGNEE + Environment.NewLine + strtmp; strtmp = GetPosString(line, 4); if (strtmp != "") if (headData.CONSIGNEE == "") headData.CONSIGNEE = strtmp; else headData.CONSIGNEE = headData.CONSIGNEE + Environment.NewLine + strtmp; strtmp = GetPosString(line, 5); if (strtmp != "") if (headData.CONSIGNEE == "") headData.CONSIGNEE = strtmp; else headData.CONSIGNEE = headData.CONSIGNEE + Environment.NewLine + strtmp; strtmp = GetPosString(line, 6); if (strtmp != "") if (headData.CONSIGNEE == "") headData.CONSIGNEE = strtmp; else headData.CONSIGNEE = headData.CONSIGNEE + Environment.NewLine + strtmp; strtmp = GetPosString(line, 7); if (strtmp != "") if (headData.CONSIGNEE == "") headData.CONSIGNEE = strtmp; else headData.CONSIGNEE = headData.CONSIGNEE + Environment.NewLine + strtmp; strtmp = GetPosString(line, 8); if (strtmp != "") if (headData.CONSIGNEE == "") headData.CONSIGNEE = strtmp; else headData.CONSIGNEE = headData.CONSIGNEE + Environment.NewLine + strtmp; } if (head == "18") { strtmp = GetPosString(line, 3); if (strtmp != "") if (headData.NOTIFYPARTY == "") headData.NOTIFYPARTY = strtmp; else headData.NOTIFYPARTY = headData.NOTIFYPARTY + Environment.NewLine + strtmp; strtmp = GetPosString(line, 4); if (strtmp != "") if (headData.NOTIFYPARTY == "") headData.NOTIFYPARTY = strtmp; else headData.NOTIFYPARTY = headData.NOTIFYPARTY + Environment.NewLine + strtmp; strtmp = GetPosString(line, 5); if (strtmp != "") if (headData.NOTIFYPARTY == "") headData.NOTIFYPARTY = strtmp; else headData.NOTIFYPARTY = headData.NOTIFYPARTY + Environment.NewLine + strtmp; strtmp = GetPosString(line, 6); if (strtmp != "") if (headData.NOTIFYPARTY == "") headData.NOTIFYPARTY = strtmp; else headData.NOTIFYPARTY = headData.NOTIFYPARTY + Environment.NewLine + strtmp; strtmp = GetPosString(line, 7); if (strtmp != "") if (headData.NOTIFYPARTY == "") headData.NOTIFYPARTY = strtmp; else headData.NOTIFYPARTY = headData.NOTIFYPARTY + Environment.NewLine + strtmp; strtmp = GetPosString(line, 8); if (strtmp != "") if (headData.NOTIFYPARTY == "") headData.NOTIFYPARTY = strtmp; else headData.NOTIFYPARTY = headData.NOTIFYPARTY + Environment.NewLine + strtmp; } if (head == "19") { strtmp = GetPosString(line, 3); if (strtmp != "") if (headData.AGENT == "") headData.AGENT = strtmp; else headData.AGENT = headData.AGENT + Environment.NewLine + strtmp; strtmp = GetPosString(line, 4); if (strtmp != "") if (headData.AGENT == "") headData.AGENT = strtmp; else headData.AGENT = headData.AGENT + Environment.NewLine + strtmp; strtmp = GetPosString(line, 5); if (strtmp != "") if (headData.AGENT == "") headData.AGENT = strtmp; else headData.AGENT = headData.AGENT + Environment.NewLine + strtmp; strtmp = GetPosString(line, 6); if (strtmp != "") if (headData.AGENT == "") headData.AGENT = strtmp; else headData.AGENT = headData.AGENT + Environment.NewLine + strtmp; strtmp = GetPosString(line, 7); if (strtmp != "") if (headData.AGENT == "") headData.AGENT = strtmp; else headData.AGENT = headData.AGENT + Environment.NewLine + strtmp; strtmp = GetPosString(line, 8); if (strtmp != "") if (headData.AGENT == "") headData.AGENT = strtmp; else headData.AGENT = headData.AGENT + Environment.NewLine + strtmp; } if (head == "41") { headData.PKGS = Convert.ToInt32(GetPosString(line, 4, true)); headData.KINDPKGS = GetPosString(line, 6); headData.KGS = Convert.ToDecimal(GetPosString(line, 7, true)); headData.CBM = Convert.ToDecimal(GetPosString(line, 9, true)); headData.NOPKGS = Convert.ToInt32(GetPosString(line, 4, true)).ToString() + GetPosString(line, 6); headData.GROSSWEIGHT = Convert.ToDecimal(GetPosString(line, 7, true)).ToString() + "KGS"; headData.MEASUREMENT = Convert.ToDecimal(GetPosString(line, 9, true)).ToString() + "CBM"; } if (head == "44") { strtmp = GetPosString(line, 2); if (strtmp != "") if (headData.MARKS == "") headData.MARKS = strtmp; else headData.MARKS = headData.MARKS + Environment.NewLine + strtmp; strtmp = GetPosString(line, 3); if (strtmp != "") if (headData.MARKS == "") headData.MARKS = strtmp; else headData.MARKS = headData.MARKS + Environment.NewLine + strtmp; strtmp = GetPosString(line, 4); if (strtmp != "") if (headData.MARKS == "") headData.MARKS = strtmp; else headData.MARKS = headData.MARKS + Environment.NewLine + strtmp; strtmp = GetPosString(line, 5); if (strtmp != "") if (headData.MARKS == "") headData.MARKS = strtmp; else headData.MARKS = headData.MARKS + Environment.NewLine + strtmp; strtmp = GetPosString(line, 6); if (strtmp != "") if (headData.MARKS == "") headData.MARKS = strtmp; else headData.MARKS = headData.MARKS + Environment.NewLine + strtmp; strtmp = GetPosString(line, 7); if (strtmp != "") if (headData.MARKS == "") headData.MARKS = strtmp; else headData.MARKS = headData.MARKS + Environment.NewLine + strtmp; strtmp = GetPosString(line, 8); if (strtmp != "") if (headData.MARKS == "") headData.MARKS = strtmp; else headData.MARKS = headData.MARKS + Environment.NewLine + strtmp; strtmp = GetPosString(line, 9); if (strtmp != "") if (headData.MARKS == "") headData.MARKS = strtmp; else headData.MARKS = headData.MARKS + Environment.NewLine + strtmp; strtmp = GetPosString(line, 10); if (strtmp != "") if (headData.MARKS == "") headData.MARKS = strtmp; else headData.MARKS = headData.MARKS + Environment.NewLine + strtmp; } if (head == "47") { strtmp = GetPosString(line, 2); if (strtmp != "") if (headData.DESCRIPTION == "") headData.DESCRIPTION = strtmp; else headData.DESCRIPTION = headData.DESCRIPTION + Environment.NewLine + strtmp; strtmp = GetPosString(line, 3); if (strtmp != "") if (headData.DESCRIPTION == "") headData.DESCRIPTION = strtmp; else headData.DESCRIPTION = headData.DESCRIPTION + Environment.NewLine + strtmp; strtmp = GetPosString(line, 4); if (strtmp != "") if (headData.DESCRIPTION == "") headData.DESCRIPTION = strtmp; else headData.DESCRIPTION = headData.DESCRIPTION + Environment.NewLine + strtmp; strtmp = GetPosString(line, 5); if (strtmp != "") if (headData.DESCRIPTION == "") headData.DESCRIPTION = strtmp; else headData.DESCRIPTION = headData.DESCRIPTION + Environment.NewLine + strtmp; strtmp = GetPosString(line, 6); if (strtmp != "") if (headData.DESCRIPTION == "") headData.DESCRIPTION = strtmp; else headData.DESCRIPTION = headData.DESCRIPTION + Environment.NewLine + strtmp; strtmp = GetPosString(line, 7); if (strtmp != "") if (headData.DESCRIPTION == "") headData.DESCRIPTION = strtmp; else headData.DESCRIPTION = headData.DESCRIPTION + Environment.NewLine + strtmp; strtmp = GetPosString(line, 8); if (strtmp != "") if (headData.DESCRIPTION == "") headData.DESCRIPTION = strtmp; else headData.DESCRIPTION = headData.DESCRIPTION + Environment.NewLine + strtmp; } if (head == "51") { if (addbill) { var modb = new ModelObjectDB(); modb.Save(headData); headList.Add(headData); addbill = false; } var ctncode = BasicDataRefDAL.GetCodeCtnList("EDICODE='" + GetPosString(line, 5) + "'",false); if (ctncode.Count== 0) ctncode = BasicDataRefDAL.GetCodeCtnList("CTN='" + GetPosString(line, 5) + "'",false); if (ctncode.Count != 0) { var teu = 0; if (ctncode[0].CTN.IndexOf("2") != -1) teu = 1; else teu = 2; var cmdInsert = db.GetSqlStringCommand(@"insert into op_ctn (CTN_ID,BSNO,CTNCODE,[SIZE],CTN,CTNNUM,TEU,CTNALL,CNTRNO,SEALNO,PKGS,KGS,CBM,CTNSTATUS) values (newid(),'" + BSNO + "','" + ctncode[0].CTNID + "','" + ctncode[0].CTNSIZE + "','" + ctncode[0].CTNTYPE + "'," + 1 + "," + teu.ToString() + ",'" + ctncode[0].CTN + "','" + GetPosString(line, 3) + "','" + GetPosString(line, 4) + "'," + GetPosString(line, 7, true) + "," + GetPosString(line, 8, true) + "," + GetPosString(line, 10, true) + ",'" + GetPosString(line, 6) + "')"); db.ExecuteNonQuery(cmdInsert); getCNTRTOTAL(BSNO, "op_seai"); } else { var ctncode2 = MsCodeCtnEdiDAL.GetData("EDICODE='" + GetPosString(line, 5) + "'"); ctncode = BasicDataRefDAL.GetCodeCtnList("CTN='" + ctncode2.CTN+ "'",false); if (ctncode.Count != 0) { var teu = 0; if (ctncode[0].CTN.IndexOf("2") != -1) teu = 1; else teu = 2; var cmdInsert = db.GetSqlStringCommand(@"insert into op_ctn (CTN_ID,BSNO,CTNCODE,[SIZE],CTN,CTNNUM,TEU,CTNALL,CNTRNO,SEALNO,PKGS,KGS,CBM,CTNSTATUS) values (newid(),'" + BSNO + "','" + ctncode[0].CTNID + "','" + ctncode[0].CTNSIZE + "','" + ctncode[0].CTNTYPE + "'," + 1 + "," + teu.ToString() + ",'" + ctncode[0].CTN + "','" + GetPosString(line, 3) + "','" + GetPosString(line, 4) + "'," + GetPosString(line, 7, true) + "," + GetPosString(line, 8, true) + "," + GetPosString(line, 10, true) + ",'" + GetPosString(line, 6) + "')"); db.ExecuteNonQuery(cmdInsert); getCNTRTOTAL(BSNO, "op_seai"); } } } } } //result.Data = headList; //result.Success = true; //result.Message = "导入成功"; } catch (Exception) { //result.Success = false; //result.Message = "导入错误,请重试或联系系统管理员"; //return result; } return headList; } #endregion #region EDI导出 #region 基础函数 public static DBResult FtpFile(string filename, CodeFtpSet ftpset) { var result = new DBResult(); try { FTPDA FTPDA = new FTPDA(); FTPDA.ErrorMsg = ""; FTPDA.Uri = new Uri("ftp://" + ftpset.SERVERIP + "/"); FTPDA.DirectoryPath = ftpset.FOLDERNAME.Replace("/", "//"); FTPDA.UserName = ftpset.USERNAME; FTPDA.Password = ftpset.PASSWORD; FTPDA.UploadFile(filename); result.Success = true; result.Message = "上传成功" + result.Message; return result; } catch (Exception) { result.Success = false; result.Message = "上传出现错误,请重试或联系系统管理员"; return result; } } public static DBResult SFtpFile(string filename, CodeFtpSet ftpset) { var result = new DBResult(); try { SFTPHelper sftp = new SFTPHelper(ftpset.SERVERIP, ftpset.CARRIERID, ftpset.USERNAME, ftpset.PASSWORD); sftp.Connect(); sftp.Put(filename, ftpset.FOLDERNAME); sftp.Disconnect(); result.Success = true; result.Message = "上传成功" + result.Message; return result; } catch (Exception) { result.Success = false; result.Message = "上传出现错误,请重试或联系系统管理员"; return result; } } static public string GetPackageEDICode(string Package) { string EDICODE = ""; var strSql = new StringBuilder(); strSql.Append("select EDICODE from CODE_PACKAGE where PKGS='" + Package + "'"); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { EDICODE = Convert.ToString(reader["EDICODE"]); } reader.Close(); } return EDICODE; } static public string GetCtnEDICode(string Ctn) { string EDICODE = ""; Ctn = Ctn.Replace("'", "''"); var strSql = new StringBuilder(); strSql.Append("select EDICODE from code_ctn where CTN='" + Ctn + "'"); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { EDICODE = Convert.ToString(reader["EDICODE"]); } reader.Close(); } return EDICODE; } static public decimal GetCtnWeight(string Ctn) { decimal CTNWEIGHT = 0; Ctn = Ctn.Replace("'", "''"); var strSql = new StringBuilder(); strSql.Append("select CTNWEIGHT from code_ctn where CTN='" + Ctn + "'"); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { CTNWEIGHT = Convert.ToDecimal(reader["CTNWEIGHT"]); } reader.Close(); } return CTNWEIGHT; } static public string GetFrtEDICode(string FRT) { string EDICODE = "P"; var strSql = new StringBuilder(); strSql.Append("select EDICODE from code_frt where FRT='" + FRT + "'"); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { EDICODE = Convert.ToString(reader["EDICODE"]); } reader.Close(); } return EDICODE; } static public string GetLaneEDICode(string lane) { string EDICODE = ""; var strSql = new StringBuilder(); strSql.Append("select EDICODE from code_lanes where lane='" + lane + "'"); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { EDICODE = Convert.ToString(reader["EDICODE"]); } reader.Close(); } return EDICODE; } public static CompanyDef GetCompanyDef(string companyid) { var strSql = new StringBuilder(); strSql.Append("SELECT GID,[CORPID],[PORTLOADID],[PORTLOAD],[BLFRT],[SERVICE],[KGS],[ISADVANCE],[ISCGOL],[AFRCARRIERID],[AFRAGENTID],[AFRETDTIME] from subcomp_seae_def"); strSql.Append(" Where CORPID='" + companyid + "'"); Database db = DatabaseFactory.CreateDatabase(); var evList = new List(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { var evData = new CompanyDef(); evData.GID = Convert.ToString(reader["GID"]); evData.CORPID = Convert.ToString(reader["CORPID"]); evData.PORTLOADID = Convert.ToString(reader["PORTLOADID"]); evData.PORTLOAD = Convert.ToString(reader["PORTLOAD"]); evData.BLFRT = Convert.ToString(reader["BLFRT"]); evData.AFRCARRIERID = Convert.ToString(reader["AFRCARRIERID"]); evData.AFRAGENTID = Convert.ToString(reader["AFRAGENTID"]); evData.AFRETDTIME = Convert.ToString(reader["AFRETDTIME"]); evList.Add(evData); } reader.Close(); } if (evList.Count > 0) return evList[0]; return new CompanyDef(); } public static string formatEdiStr(string str) { return str.Replace("?", "??").Replace(":", "?:").Replace("+", "?+").Replace(";", "?;"); } public static List formatlengthStr(string str, int length) { str = str.Replace("\r\n", "\\"); str = str.Replace("\n", "\\"); str = str.Replace("\r", " "); string[] StrList = str.Split('\\'); var strtemp = ""; var strnewline = ""; var strtempnewline = ""; char[] spstring = { ' ', ';', ',', '.', ':', '/', '(', ')', '?', '+', '-' }; List DestList = new List(); for (var i = 0; i <= StrList.Length - 1; i++) { if (StrList[i].Length <= length) DestList.Add(StrList[i]); else { strtemp = StrList[i] + " "; strtempnewline = ""; strnewline = ""; for (var j = 0; j < strtemp.Length; j++) { strtempnewline = strtempnewline + strtemp[j]; if (strtemp[j] == ' ' || strtemp[j] == ':' || strtemp[j] == ',' || strtemp[j] == '.' || strtemp[j] == ':' || strtemp[j] == '/' || strtemp[j] == '?' || strtemp[j] == ')' || strtemp[j] == '}' || strtemp[j] == '+' || strtemp[j] == '-') { if ((strnewline.Length + strtempnewline.Length) <= length) strnewline = strnewline + strtempnewline; else { DestList.Add(strnewline); strnewline = strtempnewline; } strtempnewline = ""; } } if (strnewline.Trim() != "") DestList.Add(strnewline); } } return DestList; } public static string formatListStr(List DestList, int lineCount) { var result = ""; for (var i = 0; i < lineCount; i++) { if (DestList.Count > i) { result = result + DestList[i]; } if (i != (lineCount - 1)) result = result + ":"; } return result; } public static bool IsChinese(char c) { return (int)c > 0x80; } public static bool StringIsChinese(string str) { var result = false; for (int i = 1; i < str.Length; i++) { if (IsChinese(str[i])) { result = true; return result; } } return result; } public static string GetDateStr(string datestr, string dateformat) { var result = ""; if (datestr == null || datestr == "") { result = ""; } else { result = Convert.ToDateTime(datestr).ToString(dateformat); } return result; } static public string GetCustEdi(string Cust) { string EDICODE = ""; var strSql = new StringBuilder(); strSql.Append("select EDICODE from info_client WHERE SHORTNAME='" + Cust + "'"); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { EDICODE = Convert.ToString(reader["EDICODE"]); } reader.Close(); } if (EDICODE == null) EDICODE = ""; return EDICODE; } static public string GetVESSELID(string VESSEL) { string VESSELID = ""; var strSql = new StringBuilder(); strSql.Append("select top 1 EDICODE from code_vessel WHERE VESSEL='" + VESSEL + "'"); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { VESSELID = Convert.ToString(reader["EDICODE"]); } reader.Close(); } if (VESSELID == null) VESSELID = ""; return VESSELID; } /// /// /// /// 要处理的数据 /// 每行长度 /// 主提单号 /// 数据类型(例如:发货人内容、货描等) /// 限制录入的行数(“0”代表不限制) /// 限录后多出的放到货描中的数据的连接符(例如:“*”发货人内容、“**”收件人等) /// public static System.String formatlengthError(string str, int length, string sMBLNO, string sType, int rowNum, string sSymbol, bool isHuoMiao) { string error = ""; string Shipping = formatEdiStr(str); string[] argAGENT = Shipping.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); if (argAGENT.Length > 0) { if (argAGENT.Length == 1) { argAGENT = Shipping.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries); if (argAGENT.Length > 0) { if (argAGENT.Length > rowNum && rowNum != 0) { if (isHuoMiao) { error = error + "
提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据!"; } else { error = error + "
提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据,多余信息请已“" + sSymbol + "”号开头放到货物描述中!(例如:“货描内容" + sSymbol + "超出部分”)"; } } for (int j = 0; j < argAGENT.Length; j++) { //List AgentList = formatlengthStr(argAGENT[j].ToString(), 35); if (argAGENT[j].ToString().Length > length) { error = error + "
提单号:" + sMBLNO + " " + sType + " 第" + (j + 1) + "行超过" + length + "个字符"; } } } } else { if (argAGENT.Length > rowNum && rowNum != 0) { if (isHuoMiao) { error = error + "
提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据!"; } else { error = error + "
提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据,多余信息请已“" + sSymbol + "”号开头放到货物描述中!(例如:“货描内容" + sSymbol + "超出部分”)"; } } for (int j = 0; j < argAGENT.Length; j++) { //List AgentList = formatlengthStr(argAGENT[j].ToString(), 35); if (argAGENT[j].ToString().Length > length) { error = error + "
提单号:" + sMBLNO + " " + sType + " 第" + (j + 1) + "行超过" + length + "个字符"; } } } } return error; } #endregion #region 接口函数 public static string IsCreateEdi(List headData, string type, string filetype, string filerole, string carrier) { var error = ""; if (type == "WDSEAIEDI") { error = IsCreateEdiWD(headData, type, filetype, filerole); } if(type == "IFTMBF") { if (carrier.Trim() == "NBCDI")//宁波船代(NBCD) { error = IsCreateEdiNBCDI(headData, type, filerole); } else if (carrier.Trim() == "SHCDI")//上海船代(SHCD) { error = IsCreateEdiSHCDI(headData, type, filerole); } } return error; } public static string IsCreateEdiDHL(List headData, string filerole) { var error = ""; foreach (var bill in headData) { if (bill.HBLNO == null || bill.HBLNO == "") { error += "
提单号:" + bill.MBLNO + ",分提单号不能为空"; } if (filerole == "DOS") { if (bill.CHANGEDOCDATE == null || bill.CHANGEDOCDATE == "") { error += "
提单号:" + bill.MBLNO + "换单日期不能为空"; } } if (filerole == "CLS") { if (bill.CUSTOMDATE == null || bill.CUSTOMDATE == "") { error += "
提单号:" + bill.MBLNO + " 通关日期不能为空"; } } if (filerole == "GOU") { if (bill.TIHUOTIME == null || bill.TIHUOTIME == "") { error += "
提单号:" + bill.MBLNO + " 提货时间不能为空"; } } } return error; } public static string IsCreateEdiWD(List headData, string type, string filetype, string filerole) { var error = ""; foreach (var bill in headData) { if (bill.MBLNO == null || bill.MBLNO == "") { error += "
主提单号不能为空"; } if (bill.VESSEL == null || bill.VESSEL == "") { error += "
提单号:" + bill.MBLNO + "船名不能为空"; } else { if (GetVESSELID(bill.VESSEL) == "") { error += "
提单号:" + bill.MBLNO + "的船名" + bill.VESSEL + "的船舶呼号不能为空"; } } if (bill.VOYNO == null || bill.VOYNO == "") { error += "
提单号:" + bill.MBLNO + "航次不能为空"; } if (bill.CARRIER == null || bill.CARRIER == "") { error += "
提单号:" + bill.MBLNO + "船公司不能为空"; } if (GetCustEdi(bill.CARRIER) == "") { error += "
提单号:" + bill.MBLNO + "的船公司" + bill.CARRIER + "的EDI代码不能为空"; } if (bill.ETA == null || bill.ETA == "") { error += "
提单号:" + bill.MBLNO + "开船日期不能为空"; } if (bill.ETD == null || bill.ETD == "") { error += "
提单号:" + bill.MBLNO + "到港日期不能为空"; } if (bill.PORTLOADID == null || bill.PORTLOADID == "") { error += "
提单号:" + bill.MBLNO + "卸货港代码不能为空"; } if (bill.PORTLOAD == null || bill.PORTLOAD == "") { error += "
提单号:" + bill.MBLNO + "卸货港不能为空"; } if (bill.PORTDISCHARGEID == null || bill.PORTDISCHARGEID == "") { error += "
提单号:" + bill.MBLNO + "装货港代码不能为空"; } if (bill.PORTDISCHARGE == null || bill.PORTDISCHARGE == "") { error += "
提单号:" + bill.MBLNO + "装货港不能为空"; } if (bill.PLACEDELIVERYID == null || bill.PLACEDELIVERYID == "") { error += "
提单号:" + bill.MBLNO + "交货地代码不能为空"; } if (bill.PLACEDELIVERY == null || bill.PLACEDELIVERY == "") { error += "
提单号:" + bill.MBLNO + "交货地不能为空"; } if (bill.DESTINATION == null || bill.DESTINATION == "") { error += "
提单号:" + bill.MBLNO + "目的港代码不能为空"; } if (bill.KINDPKGS == "") { error += "
提单号:" + bill.MBLNO + "包装不能为空"; } if (GetPackageEDICode(bill.KINDPKGS).Trim() == "") { error += "
提单号:" + bill.MBLNO + "包装EDI代码不能为空"; } if (bill.DESCRIPTION == null || bill.DESCRIPTION == "") { error += "
提单号:" + bill.MBLNO + "货物描述不能为空"; } if (bill.MARKS == null || bill.MARKS == "") { error += "
提单号:" + bill.MBLNO + "货物唛头不能为空"; } if (bill.PKGS == 0) { error += "
提单号:" + bill.MBLNO + "货物件数不能为空"; } if (bill.SERVICE == null || bill.SERVICE == "") { error += "
提单号:" + bill.MBLNO + "运输条款不能为空"; } if (bill.BLFRT == null || bill.BLFRT == "") { error += "
提单号:" + bill.MBLNO + "付费方式不能为空"; } if (bill.CARGOID == null || bill.CARGOID == "") { error += "
提单号:" + bill.MBLNO + "货物标示不能为空"; } else { if (bill.CARGOID == "D") { if (bill.DCLASS == null || bill.DCLASS == "") { error += "
提单号:" + bill.MBLNO + "危险品分类不能为空"; } if (bill.DPAGE == null || bill.DPAGE == "") { error += "
提单号:" + bill.MBLNO + "危险品页号不能为空"; } if (bill.DUNNO == null || bill.DUNNO == "") { error += "
提单号:" + bill.MBLNO + "危险品编号不能为空"; } if (bill.DLABEL == null || bill.DLABEL == "") { error += "
提单号:" + bill.MBLNO + "危险品标签不能为空"; } } if (bill.CARGOID == "R") { if (bill.TEMPSET == null || bill.TEMPSET == "") { error += "
提单号:" + bill.MBLNO + "设置温度不能为空"; } if (bill.TEMPID == null || bill.TEMPID == "") { error += "
提单号:" + bill.MBLNO + "温度计量单位不能为空"; } } } var ctnlist = GetBodyList("BSNO='" + bill.BSNO + "'"); if (ctnlist.Count == 0) { error += "
提单号:" + bill.MBLNO + "集装箱信息不能为空"; } else { foreach (var ctn in ctnlist) { if (ctn.CNTRNO == null || ctn.CNTRNO == "") { error += "
提单号:" + bill.MBLNO + "箱号不能为空"; } } } if (StringIsChinese(bill.MARKS)) { error += "
提单号:" + bill.MBLNO + "唛头含有中文或双字节字符"; } if (StringIsChinese(bill.DESCRIPTION)) { error += "
提单号:" + bill.MBLNO + "货物描述含有中文或双字节字符"; } #region 发货人 if (bill.SHIPPER == "") { error = error + "
提单号:" + bill.MBLNO + " 发货人不能为空"; } else { if (StringIsChinese(bill.SHIPPER)) { error = error + "
提单号:" + bill.MBLNO + " 发货人含有中文或双字节字符"; } else { error += formatlengthError(bill.SHIPPER, 35, bill.MBLNO, "发货人", 5, "*", false); } } #endregion #region 收货人 if (bill.CONSIGNEE == "") { error = error + "
提单号:" + bill.MBLNO + " 收货人不能为空"; } else { if (StringIsChinese(bill.CONSIGNEE)) { error = error + "
提单号:" + bill.MBLNO + " 收货人含有中文或双字节字符"; } else { error += formatlengthError(bill.CONSIGNEE, 35, bill.MBLNO, "收货人", 5, "**", false); } } #endregion #region 通知人 if (bill.NOTIFYPARTY == "") { error = error + "
提单号:" + bill.MBLNO + " 通知人不能为空"; } else { if (StringIsChinese(bill.NOTIFYPARTY)) { error = error + "
提单号:" + bill.MBLNO + " 通知人含有中文或双字节字符"; } else { error += formatlengthError(bill.NOTIFYPARTY, 35, bill.MBLNO, "通知人", 5, "***", false); } } #endregion #region 唛头 if (bill.MARKS == "") { error = error + "
提单号:" + bill.MBLNO + " 唛头不能为空"; } else { if (StringIsChinese(bill.MARKS)) { error = error + "
提单号:" + bill.MBLNO + " 唛头含有中文或双字节字符"; } else { error += formatlengthError(bill.MARKS, 35, bill.MBLNO, "唛头", 10, "", false); } } #endregion #region 货物描述 if (bill.DESCRIPTION == "") { error = error + "
提单号:" + bill.MBLNO + " 货物描述不能为空"; } else { if (StringIsChinese(bill.DESCRIPTION)) { error = error + "
提单号:" + bill.MBLNO + " 货物描述含有中文或双字节字符"; } else { error += formatlengthError(bill.DESCRIPTION, 35, bill.MBLNO, "货物描述", 10, "", true); } } #endregion } return error; } public static string CreateEdi(List headData, string usercode, string path, string mblno, string filerole, CodeFtpSet ftpset, string type, int isbill, int isnotctn, string carrier, string filetype) { var result = ""; if (type == "WDSEAIEDI") { result = CreateEdiWD(headData, usercode, path, mblno, filerole, ftpset, type, isbill, isnotctn); } if (type == "IFTMBF") { if (carrier.Trim() == "NBCDI")//宁波船代(NBCDI) { result = CreateEdiIFTMBF2(headData, usercode, path, mblno, filerole, ftpset, type); } else if (carrier.Trim() == "SHCDI")//上海船代(SHCDI) { result = CreateEdiIFTMBF(headData, usercode, path, mblno, filerole, ftpset, type); } } return result; } #endregion #region 外代EDI public static string CreateEdiWD(List headData, string usercode, string path, string mblno, string filerole, CodeFtpSet ftpset, string type, int isbill, int isnotctn) { string filename = path + "\\" + mblno + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".txt"; if (System.IO.File.Exists(filename)) { System.IO.File.Delete(filename); } FileStream f = new FileStream(filename, FileMode.Create); StreamWriter r = new StreamWriter(f); var icount = 0; filerole = "9C"; r.WriteLine("00:IFCSUM:MANIFEST:" + filerole + ":" + ftpset.SENDCODE + ":" + ftpset.RECEIVECODE + ":" + DateTime.Now.ToString("yyMMddHHmm")); foreach (var bill in headData) { r.WriteLine("10::" + bill.VESSEL + "::" + bill.VOYNO + "::" + bill.LANE + ":" + GetDateStr(bill.ETA, "yyyyMMdd") + ":" + GetDateStr(bill.ETD, "yyyyMMdd") + ":::::" + bill.TEU.ToString() + ":"); r.WriteLine("11:" + ftpset.SENDCODE + ":" + bill.CARRIER); var xtype = "P"; if (bill.BLFRT.IndexOf("FREIGHT COLLECT") >= 0) xtype = "C"; r.WriteLine("12:" + bill.MBLNO.Trim() + "::::::" + bill.PORTLOADID + ":" + bill.PORTLOAD + ":" + bill.SERVICE + ":" + xtype + "::::::"); r.WriteLine("13:" + bill.PORTDISCHARGEID + ":" + bill.PORTDISCHARGE + ":" + bill.DESTINATIONID + ":" + bill.DESTINATION + "::::" + bill.ISSUEPLACE + "::"); var Shipping = ""; Shipping = formatEdiStr(bill.SHIPPER); List ShippingList = formatlengthStr(Shipping, 35); if (ShippingList.Count != 0) { r.WriteLine("16::" + formatListStr(ShippingList, 6)); } Shipping = formatEdiStr(bill.CONSIGNEE); ShippingList = formatlengthStr(Shipping, 35); if (ShippingList.Count != 0) { r.WriteLine("17::" + formatListStr(ShippingList, 6)); } Shipping = formatEdiStr(bill.NOTIFYPARTY); ShippingList = formatlengthStr(Shipping, 35); if (ShippingList.Count != 0) { r.WriteLine("18::" + formatListStr(ShippingList, 6)); } Shipping = formatEdiStr(bill.AGENT); ShippingList = formatlengthStr(Shipping, 35); if (ShippingList.Count != 0) { r.WriteLine("19::" + formatListStr(ShippingList, 6)); } var cargoid = bill.CARGOID; if (cargoid == "") cargoid = "S"; r.WriteLine("41:1:0:" + bill.PKGS.ToString() + "::" + bill.KINDPKGS + ":" + bill.KGS.ToString() + "::" + bill.CBM.ToString()); icount = icount + 10; r.WriteLine("43::" + bill.DCLASS + ":none:" + bill.DUNNO + ":none:::::::::"); icount = icount + 1; Shipping = formatEdiStr(bill.MARKS); ShippingList = formatlengthStr(Shipping, 300); if (ShippingList.Count != 0) { r.WriteLine("44:" + formatListStr(ShippingList, 5)); icount = icount + 1; } Shipping = formatEdiStr(bill.DESCRIPTION); ShippingList = formatlengthStr(Shipping, 300); var m = 1; var strtemp = ""; if (ShippingList.Count != 0) { for (var i = 0; i < ShippingList.Count; i++) { if (m <= 5) { if (m == 1) strtemp = "47:" + ShippingList[i] + ":"; else { if (m == 5) strtemp = strtemp + ShippingList[i]; else strtemp = strtemp + ShippingList[i] + ":"; } } else { m = 1; r.WriteLine(strtemp); strtemp = "47:" + ShippingList[i] + ":"; icount = icount + 1; } } } if (strtemp != "") { r.WriteLine(strtemp); icount = icount + 1; }; if (isnotctn == 1) { r.WriteLine("51:001:::::::::::::::"); icount = icount + 1; } else { var ctnlist = GetBodyList("BSNO='" + bill.BSNO + "'"); foreach (var ctn in ctnlist) { r.WriteLine("51:001:" + ctn.CNTRNO + ":" + ctn.SEALNO + ":" + ctn.SIZE.ToString() + ctn.CTN + ":F:" + ctn.PKGS.ToString() + ":" + ctn.KGS.ToString() + ":"); icount = icount + 1; } } } icount = icount + 1; r.WriteLine("99:" + icount.ToString()); r.Close(); f.Close(); return filename; } #endregion #region 外代EDI public static string CreateEdiDHL(MsOpSeai headData, string usercode, string path, string mblno, string filerole, CodeFtpSet ftpset) { string filename = path + "\\" + mblno + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".XML"; if (System.IO.File.Exists(filename)) { System.IO.File.Delete(filename); } FileStream f = new FileStream(filename, FileMode.Create); StreamWriter r = new StreamWriter(f); r.WriteLine(""); r.WriteLine(""); r.WriteLine(""); r.WriteLine(""); r.WriteLine(""); r.WriteLine("" + filerole + ""); r.WriteLine(""); r.WriteLine(""); r.WriteLine(""); r.WriteLine(""); r.WriteLine(""+ftpset.SENDCODE+""); r.WriteLine(""); r.WriteLine(""); r.WriteLine(""); r.WriteLine(""); r.WriteLine("ESP"); r.WriteLine(""); r.WriteLine(""); r.WriteLine(""); r.WriteLine("" + Guid.NewGuid().ToString() + ""); r.WriteLine("" + DateTime.Now.ToString("yyyy-MM-dd") + "T" + DateTime.Now.ToString("HH:mm:ss") + "+08:00"); r.WriteLine(""); r.WriteLine(""); r.WriteLine("Simple"); r.WriteLine(""); r.WriteLine(""); r.WriteLine(""); r.WriteLine(""); r.WriteLine(""); r.WriteLine("" + filerole + ""); r.WriteLine(""); r.WriteLine(""); r.WriteLine("" + headData.HBLNO + ""); r.WriteLine(""); if (filerole == "DOS") { r.WriteLine("" + Convert.ToDateTime(headData.CHANGEDOCDATE).ToString("yyyy-MM-dd") + "T" + Convert.ToDateTime(headData.CHANGEDOCDATE).ToString("HH:mm:ss") + "+08:00"); } else if (filerole == "CLC") { r.WriteLine("" + Convert.ToDateTime(headData.CUSTOMDATE).ToString("yyyy-MM-dd") + "T" + Convert.ToDateTime(headData.CUSTOMDATE).ToString("HH:mm:ss") + "+08:00"); } else if (filerole == "GOU") { r.WriteLine("" + Convert.ToDateTime(headData.TIHUOTIME).ToString("yyyy-MM-dd") + "T" + Convert.ToDateTime(headData.TIHUOTIME).ToString("HH:mm:ss") + "+08:00"); } r.WriteLine(""); if (filerole == "DOS") { r.WriteLine("" + ftpset.SENDNAME + ""); } r.WriteLine(""); r.WriteLine(""); r.WriteLine(""); r.Close(); f.Close(); return filename; } #endregion #region IFTMBF V2.0 上海船代(SHCDI) public static string IsCreateEdiSHCDI(List headData, string type, string filerole) { var error = ""; foreach (var bill in headData) { if (bill.MBLNO == null || bill.MBLNO == "") { error += "
主提单号不能为空"; } if (bill.VESSEL == null || bill.VESSEL == "") { error += "
提单号:" + bill.MBLNO + "船名不能为空"; } else { if (GetVESSELID(bill.VESSEL) == "") { error += "
提单号:" + bill.MBLNO + "的船名" + bill.VESSEL + "的船舶呼号不能为空"; } } if (bill.VOYNO == null || bill.VOYNO == "") { error += "
提单号:" + bill.MBLNO + "航次不能为空"; } if (bill.CARRIER == null || bill.CARRIER == "") { error += "
提单号:" + bill.MBLNO + "船公司不能为空"; } if (GetCustEdi(bill.CARRIER) == "") { error += "
提单号:" + bill.MBLNO + "的船公司" + bill.CARRIER + "的EDI代码不能为空"; } if (bill.ETA == null || bill.ETA == "") { error += "
提单号:" + bill.MBLNO + "开船日期不能为空"; } if (bill.ETD == null || bill.ETD == "") { error += "
提单号:" + bill.MBLNO + "到港日期不能为空"; } if (bill.PORTLOADID == null || bill.PORTLOADID == "") { error += "
提单号:" + bill.MBLNO + "卸货港代码不能为空"; } if (bill.PORTLOAD == null || bill.PORTLOAD == "") { error += "
提单号:" + bill.MBLNO + "卸货港不能为空"; } if (bill.PORTDISCHARGEID == null || bill.PORTDISCHARGEID == "") { error += "
提单号:" + bill.MBLNO + "装货港代码不能为空"; } if (bill.PORTDISCHARGE == null || bill.PORTDISCHARGE == "") { error += "
提单号:" + bill.MBLNO + "装货港不能为空"; } if (bill.PLACEDELIVERYID == null || bill.PLACEDELIVERYID == "") { error += "
提单号:" + bill.MBLNO + "交货地代码不能为空"; } if (bill.PLACEDELIVERY == null || bill.PLACEDELIVERY == "") { error += "
提单号:" + bill.MBLNO + "交货地不能为空"; } if (bill.DESTINATION == null || bill.DESTINATION == "") { error += "
提单号:" + bill.MBLNO + "目的港代码不能为空"; } if (bill.KINDPKGS == "") { error += "
提单号:" + bill.MBLNO + "包装不能为空"; } if (GetPackageEDICode(bill.KINDPKGS).Trim() == "") { error += "
提单号:" + bill.MBLNO + "包装EDI代码不能为空"; } if (bill.DESCRIPTION == null || bill.DESCRIPTION == "") { error += "
提单号:" + bill.MBLNO + "货物描述不能为空"; } if (bill.MARKS == null || bill.MARKS == "") { error += "
提单号:" + bill.MBLNO + "货物唛头不能为空"; } if (bill.PKGS == 0) { error += "
提单号:" + bill.MBLNO + "货物件数不能为空"; } if (bill.SERVICE == null || bill.SERVICE == "") { error += "
提单号:" + bill.MBLNO + "运输条款不能为空"; } if (bill.BLFRT == null || bill.BLFRT == "") { error += "
提单号:" + bill.MBLNO + "付费方式不能为空"; } if (bill.CARGOID == null || bill.CARGOID == "") { error += "
提单号:" + bill.MBLNO + "货物标示不能为空"; } else { if (bill.CARGOID == "D") { if (bill.DCLASS == null || bill.DCLASS == "") { error += "
提单号:" + bill.MBLNO + "危险品分类不能为空"; } if (bill.DPAGE == null || bill.DPAGE == "") { error += "
提单号:" + bill.MBLNO + "危险品页号不能为空"; } if (bill.DUNNO == null || bill.DUNNO == "") { error += "
提单号:" + bill.MBLNO + "危险品编号不能为空"; } if (bill.DLABEL == null || bill.DLABEL == "") { error += "
提单号:" + bill.MBLNO + "危险品标签不能为空"; } } if (bill.CARGOID == "R") { if (bill.TEMPSET == null || bill.TEMPSET == "") { error += "
提单号:" + bill.MBLNO + "设置温度不能为空"; } if (bill.TEMPID == null || bill.TEMPID == "") { error += "
提单号:" + bill.MBLNO + "温度计量单位不能为空"; } } } var ctnlist = GetBodyList("BSNO='" + bill.BSNO + "'"); if (ctnlist.Count == 0) { error += "
提单号:" + bill.MBLNO + "集装箱信息不能为空"; } else { foreach (var ctn in ctnlist) { if (ctn.CNTRNO == null || ctn.CNTRNO == "") { error += "
提单号:" + bill.MBLNO + "箱号不能为空"; } } } #region 发货人 if (bill.SHIPPER == "") { error = error + "
提单号:" + bill.MBLNO + " 发货人不能为空"; } else { if (StringIsChinese(bill.SHIPPER)) { error = error + "
提单号:" + bill.MBLNO + " 发货人含有中文或双字节字符"; } else { // error += formatlengthError(bill.SHIPPER, 35, bill.MBLNO, "发货人", 2, "*", false); } } #endregion #region 收货人 if (bill.CONSIGNEE == "") { error = error + "
提单号:" + bill.MBLNO + " 收货人不能为空"; } else { if (StringIsChinese(bill.CONSIGNEE)) { error = error + "
提单号:" + bill.MBLNO + " 收货人含有中文或双字节字符"; } else { // error += formatlengthError(bill.CONSIGNEE, 35, bill.MBLNO, "收货人", 2, "**", false); } } #endregion #region 通知人 if (bill.NOTIFYPARTY == "") { error = error + "
提单号:" + bill.MBLNO + " 通知人不能为空"; } else { if (StringIsChinese(bill.NOTIFYPARTY)) { error = error + "
提单号:" + bill.MBLNO + " 通知人含有中文或双字节字符"; } else { // error += formatlengthError(bill.NOTIFYPARTY, 35, bill.MBLNO, "通知人", 2, "***", false); } } #endregion #region 唛头 if (bill.MARKS == "") { error = error + "
提单号:" + bill.MBLNO + " 唛头不能为空"; } else { if (StringIsChinese(bill.MARKS)) { error = error + "
提单号:" + bill.MBLNO + " 唛头含有中文或双字节字符"; } else { // error += formatlengthError(bill.MARKS, 35, bill.MBLNO, "唛头", 90, "", false); } } #endregion #region 货物描述 if (bill.DESCRIPTION == "") { error = error + "
提单号:" + bill.MBLNO + " 货物描述不能为空"; } else { if (StringIsChinese(bill.DESCRIPTION)) { error = error + "
提单号:" + bill.MBLNO + " 货物描述含有中文或双字节字符"; } else { // error += formatlengthError(bill.DESCRIPTION, 70, bill.MBLNO, "货物描述", 45, "", true); } } #endregion } return error; } public static string CreateEdiIFTMBF(List headData, string usercode, string path, string mblno, string filerole, CodeFtpSet ftpset, string type) { string filename = path + "\\" + mblno + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".txt"; if (System.IO.File.Exists(filename)) { System.IO.File.Delete(filename); } FileStream f = new FileStream(filename, FileMode.Create); StreamWriter r = new StreamWriter(f, Encoding.Default); var icount = 0; r.WriteLine("00:IFCTST:MANIFEST:" + filerole + ":" + ftpset.SENDCODE + ":" + ftpset.RECEIVECODE + ":" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ":1.0'"); icount++; foreach (var bill in headData) { #region 10/11 船舶有关的基本信息 r.WriteLine("10:" + GetVESSELID(bill.VESSEL) //2 + ":" + bill.VESSEL//3 + ":"//4 舶国籍代码 + ":" + bill.VOYNO//5 + ":"//6航线代码 + ":"//7航线 + ":" + GetDateStr(bill.ETD, "yyyyMMdd")//8 ETD ARRIVED DATE 预计到达日期CCYYMMDD + ":" + GetDateStr(bill.ETA, "yyyyMMddHHmm") + "086"//9 SAILING DATE (Vessel departure date &time) 离港日期(船舶启运日期和时间) 9(15) YYYYMMDDhhmmZZZ,固定长度,ZZZ为时区086,填写运输工具境外预计启运时间 + ":" + bill.PORTLOADID//10 DEPART PORT CODE(Vessel off-border custom code) 离港地点代码(船舶离境地海关代码) X(11) 进口:填写货物境外离境地港口代码,参照代码表UN009(5位UN目的地代码); + ":" + bill.PORTLOAD//11 DEPART PORT 离港地点 X(35) + ":"//12 NEXT CALLING PORT 下一挂港代码 X(5) + ":"//13 NEXT CALLING PORT 下一挂港 X(35) + ":" + bill.TEU.ToString()//14 CONTAINER COUNT 集装箱箱数 9(10) + ":1"//15 Mode/type of means of transport crossing the border, coded 运输方式代码 X(4) "1=海上运输 //2=铁路运输 //3=公路运输 //4=航空运输 //5=邮政运输 //6=多式联运 //7=管道运输 //8=内河运输 //9=未知的运输方式" + "'"); icount++; r.WriteLine("11" + ":" + GetCustEdi(bill.CARRIER)//2 SHIPPING LINE CODE 船公司(承运人)代码 X(17) 填写在直属海关备案的承运人编码;承运人可以使用本公司的国际通用代码(比如英文缩写等),但不得出现除“-”、“/”,“_”、“ ”之外的符号,且这四种符号合计只能出现一次 + ":"+ bill.CARRIER//3 SHIPPING LINE 船公司(承运人) X(35) + "'"); icount++; #endregion #region 12 提单的第一个记录 var xtype = "PP"; if (bill.BLFRT.IndexOf("COLLECT") >= 0) xtype = "CC"; r.WriteLine("12" + ":" + bill.MBLNO// 2 B/L NO. 总提运单号 X(35) (Master B/L) M + ":"// 3 PRE. VESSEL CODE 前程运输船名代码 X(9) C + ":"// 4 PRE. VESSEL 前程运输船名 X(35) C + ":"// 5 PRE. VOYAGE 前程运输航次 X(6) C + ":" + bill.PORTLOADID// 6 PLACE CODE OF RECEIPT 收货地代码(货物托运地或者国家代码) X(11) "填写货物托运地点或国家、地区代码,货物托运的地点是指货物交付给承运人的地点;进口:参照代码表:UN009(5位UN目的地代码);" O + ":" + bill.PORTLOAD// 7 PLACE OF RECEIPT 收货地名称 X(70) 收货地点代码和收货地点名称可任填其一 O + ":" + bill.PORTLOADID// 8 LOAD PORT CODE 装货港代码 X(25) "进口:指进境货物进入中国关境前最后一个装载进境运输工具的地点,参照代码表:UN009(5位UN目的地代码);该数据项仅允许3、5、8、9、10、11、16位数据" M + ":" + bill.PORTLOAD// 9 LOAD PORT 装货港 X(35) C + ":" + bill.SERVICE// 10 B/L CY-CFS ITEM 运输条款 X(5) M + ":" + xtype// 11 PREPAID OR COLLECT 付款方式(运费支付方法代码) X(3) "CC:Collect到付,PP:Prepaid only预付" M + ":" + GetDateStr(bill.ETA, "yyyyMMddHHmm") + "086"// 12 Consignment loading date 货物装船时间 9(15) "YYYYMMDDhhmmZZZ,固定长度,ZZZ为时区086,北京时间,进口:填写境外计划装载时间" M //+ ":" 13 QUARANTINE CODING 检疫代码 X(1) C //+ ":" 14 DATE OF ISSUE 签发日期 9(8) CCYYMMDD C //+ ":" 15 CURRENCY 币种(金额类型代码) X(3) 填写“托运货物价值”数据项填写的金额数值对应的货币代码,参照代码表:CN025 C //+ ":" 16 EXCHANGE RATE 汇率 9(5). 9999 C //+ ":" 17 Associated transport document number 分提运单号 X(35) 由无船承运人承运的货物或集运分拨货物(Consolidation Cargo)必须填写分提单号(House B/L),分提运单在一个船次中不能重复。填写内容必须由大写字母与数字组成,不得出现除“_”、“*”、“/”之外的其他特殊字符,特殊字符在分提运单号中最多出现一次,并不得作为分提运单号开头和结尾。 O //+ ":" 18 Total number of packages 托运货物总件数 9(8) "填写全部托运货物的包装件数(和提运单一致);无法填报件数的裸装散货填“1”" M //+ ":" 19 Type of packages identification 包装种类代码 X(2) 填写提运单的托运货物件数所对应的包装种类代码,参照代码表:CN005 O //+ ":" 20 Total gross weight 货物总毛重 9(14,4) 单位:千克;填写提运单货物毛重,包括货物包装但不包括承运人设备重量,最大长度:10位整数,精确到小数点后4位。 M //+ ":" 21 Cube 货物体积 9(6).999 单位:立方米,填写货物实际体积,不包括包装和运输设备 O + "'"); icount++; #endregion #region 13 提单的地点信息 r.WriteLine("13" + ":" + bill.PORTDISCHARGEID// 2 DISCHARGE PORT CODE 卸货地代码 X(25) 进口:是指进境货物从进境运输工具卸载的地点,填写5位国内港口代码(代码表:CN003)(必填)和4位海关关区代码(代码表:CC011)(选填)(中间以“/”分隔)。如果舱单申报人填报关区代码,就将舱单分配给相应的海关;如果不填报关区代码,用港口代码对应关区代码转换。如果一个港口对应多个关区,待确定具体的关区代码后,才允许报关; M + ":" + bill.PORTDISCHARGE// 3 DISCHARGE PORT 卸货港 X(35) C + ":" + bill.PLACEDELIVERYID// 4 PLACE CODE OF DELIVERY 交货地代码 X(11) "对应海关的收货地点字段,是指承运人与收货人交接货物的地点代码;不允许出现斜杠,进口:参照代码表:UN001;" C + ":" + bill.PLACEDELIVERY// 5 PLACE OF DELIVERY 交货地 X(70) 交货地点代码和交货地点名称可任填其一 C + ":"// 6 TRANSFER PORT CODE 中转港代码 X(5) C + ":"// 7 TRANSFER PORT 中转港 X(35) C + ":"// 8 PLACE CODE OF B/L ISSUE 提单签发地代码 X(5) 使用5位UN目的地代码 C + ":"// 9 PLACE OF B/L ISSUE 提单签发地 X(35) C + ":"// 10 TRANSFER FLAG 中转标志 X(2) "10=国内中转统码 //11=国内水路中转 //12=国内公路中转 //13=国内铁路中转 //21=国际水水中转 //30=内贸本地 //31=内贸中转" C + "'"); icount++; #endregion var strtemp = ""; var Shipping = ""; #region 16 发货人 Shipping = formatEdiStr(bill.SHIPPER); //Shipping = Shipping.Replace("\n", "\\"); //Shipping = Shipping.Replace("\r", ""); //string[] ShippingList = Shipping.Split('\\'); //strtemp = "16" //+ ":" // //+ ":" + ShippingList[0]; //if (ShippingList.Length >= 2) strtemp = strtemp + ' ' + ShippingList[1]; //strtemp = strtemp + "'"; //r.WriteLine(strtemp); List ShippingList = formatlengthStr(Shipping, 100); if (ShippingList.Count != 0 && Shipping.Length > 0) { r.WriteLine("16:" + formatListStr(ShippingList, 12) + "'"); } icount++; #endregion #region 17 收货人 Shipping = formatEdiStr(bill.CONSIGNEE); //Shipping = Shipping.Replace("\n", "\\"); //Shipping = Shipping.Replace("\r", ""); //string[] ConsigneeList = Shipping.Split('\\'); //strtemp = "17" //+ ":" // //+ ":" + ConsigneeList[0]; //if (ConsigneeList.Length >= 2) strtemp = strtemp + ' ' + ConsigneeList[1]; //strtemp = strtemp + "'"; //r.WriteLine(strtemp); ShippingList = formatlengthStr(Shipping, 100); if (ShippingList.Count != 0 && Shipping.Length > 0) { r.WriteLine("17:" + formatListStr(ShippingList, 16) + "'"); } icount++; #endregion #region 18 通知人 Shipping = formatEdiStr(bill.NOTIFYPARTY); //Shipping = Shipping.Replace("\n", "\\"); //Shipping = Shipping.Replace("\r", ""); //string[] NotifypartyList = Shipping.Split('\\'); //strtemp = "18" //+ ":" // //+ ":" + NotifypartyList[0]; //if (NotifypartyList.Length >= 2) strtemp = strtemp +' '+ NotifypartyList[1]; //strtemp = strtemp + "'"; //r.WriteLine(strtemp); ShippingList = formatlengthStr(Shipping, 100); if (ShippingList.Count != 0 && Shipping.Length > 0) { r.WriteLine("18:" + formatListStr(ShippingList, 11) + "'"); } icount++; #endregion #region 41 货物信息 r.WriteLine("41" + ":1" //2 CARGO SEQUENCE NO. 货物序号 X(5) 填写提单中的货物顺序号,每票提运单中的不同商品从“1”开始按顺序填写,舱单变更时原序号不得变更,只能出现数字和字母 M + ":" //3 CARGO CODE 货类代码 X(8) C + ":" + bill.PKGS //4 NUMBERS OF PACKAGES 货物件数 9(8) 填写本项货物的包装数量,包装以不再拆解为准;散货时, 件数=“1” M + ":" + GetPackageEDICode(bill.KINDPKGS).Trim() //5 PACKAGES KIND CODE 包装类型代码 X(2) 参照代码表CN005,只能填写数字或字母 M + ":" + bill.KINDPKGS //6 PACKAGES KIND 包装类型 X(35) C + ":" + Math.Round(bill.KGS, 4) //7 CARGO GROSS WEIGHT 货毛重 9(14,4) 单位:千克;最大长度:10位整数,精确到小数点后4位。 M + ":" + Math.Round(bill.NETWEIGHT, 3) //8 CARGO NET WEIGHT 货净重 9(10). 999 单位:KG,千克;整数位最多10位,小数位最多3位 C + ":" + Math.Round(bill.CBM, 3) //9 CARGO MEASUREMENT 货尺码 9(5). 999 单位:M3,立方米 C + "'"); icount++; #endregion #region 43 危险品和冷藏信息 var cargoid = bill.CARGOID; if (cargoid == "" || cargoid == " ") cargoid = "S"; if (cargoid == "D") { r.WriteLine("43" + ":" + bill.DCLASS //2 CLASS 危险品分类 X(5) O + ":" + bill.DPAGE //3 PAGE 危险品页号 X(7) O + ":" + bill.DUNNO //4 UNDG NO. 联合国危险品编号 9(4) 参照代码表CN032,由4位数字和大写字母组成 O + ":" + bill.DLABEL //5 LABEL 危险品标签 X(32) O + ":" //6 FLASH POINT 危险货物闪点 X(5) 摄氏 C + ":" //7 EMS NO. 船运危险品应急措施号 X(6) C + ":" //8 MFAG NO. 医疗急救指南号 X(4) C + ":" //9 EMERGENCY CONTACT 应急联系 X(35) C + ":" //10 TEMPERATURE ID 温度计量单位 X(1) C = 摄氏 F = 华氏 O + ":" //11 TEMPERATURE SETTING 设置温度 X(5) O + ":" //12 MIN. TEMPERATURE 冷藏最低温度 X(5) C + ":" //13 MAX. TEMPERATURE 冷藏最高温度 X(5) C + ":" //注: 温度中,除正(+)负(-)号及小数点外,最多只能三位数字。 + ":" // 若是危险品箱,则字段2、3、4、5为必填;若是冷藏箱,则字段10、11为必填。 + "'"); icount++; } else if (cargoid == "R") { string sTEMPID = "C"; if(bill.TEMPID.IndexOf("F")>-1 || bill.TEMPID.IndexOf("华")>-1) { sTEMPID = "F"; } r.WriteLine("43" + ":" //2 CLASS 危险品分类 X(5) O + ":" //3 PAGE 危险品页号 X(7) O + ":" //4 UNDG NO. 联合国危险品编号 9(4) 参照代码表CN032,由4位数字和大写字母组成 O + ":" //5 LABEL 危险品标签 X(32) O + ":" //6 FLASH POINT 危险货物闪点 X(5) 摄氏 C + ":" //7 EMS NO. 船运危险品应急措施号 X(6) C + ":" //8 MFAG NO. 医疗急救指南号 X(4) C + ":" //9 EMERGENCY CONTACT 应急联系 X(35) C + ":" + sTEMPID //10 TEMPERATURE ID 温度计量单位 X(1) C = 摄氏 F = 华氏 O + ":" + bill.TEMPSET //11 TEMPERATURE SETTING 设置温度 X(5) O + ":" //12 MIN. TEMPERATURE 冷藏最低温度 X(5) C + ":" //13 MAX. TEMPERATURE 冷藏最高温度 X(5) C + ":" //注: 温度中,除正(+)负(-)号及小数点外,最多只能三位数字。 + ":" // 若是危险品箱,则字段2、3、4、5为必填;若是冷藏箱,则字段10、11为必填。 + "'"); icount++; } #endregion #region 44 唛头 //2 MARKS 唛头 X(512) 填写运输包装的标志及代码(唛头)M。每条记录44允许有10项,每项长度为35;该记录一次最多允许重复9次 var m = 1;//项,允许有10项 var iLine = 0;//行,最多允许重复9次 strtemp = ""; Shipping = formatEdiStr(bill.MARKS); List ShippingListName = formatlengthStr(Shipping, 35); if (ShippingListName.Count != 0) { for (var i = 0; i < ShippingListName.Count; i++) { if (iLine > 9) { break; } if (m <= 10) { if (m == 1) { strtemp = "44:" + ShippingListName[i] + ":"; iLine++; } else { if (m == 10) strtemp += ShippingListName[i]; else strtemp += ShippingListName[i] + ":"; } } else { m = 1; r.WriteLine(strtemp + "'"); strtemp = "44:" + ShippingListName[i] + ":"; icount++; iLine++; } m++; } if (strtemp != "") { r.WriteLine(strtemp + "'"); icount++; }; } #endregion #region 47 货物描述 //2 CARGO DESCRIPTION 货物描述 X(256) 填写足以鉴别货物的性质的简明描述 M。每条记录47允许有5项,每项长度为70;该记录一次最多允许重复9次 m = 1;//项,允许有5项 iLine = 0;//行,最多允许重复9次 strtemp = ""; Shipping = formatEdiStr(bill.DESCRIPTION); List ListName = formatlengthStr(Shipping, 70); if (ListName.Count != 0) { for (var i = 0; i < ListName.Count; i++) { if (iLine > 9) { break; } if (m <= 9) { if (m == 1) { strtemp = "47:" + ListName[i] + ":"; iLine++; } else { if (m == 9) strtemp += ListName[i]; else strtemp += ListName[i] + ":"; } } else { m = 1; r.WriteLine(strtemp + "'"); strtemp = "47:" + ListName[i] + ":"; icount++; iLine++; } m++; } if (strtemp != "") { r.WriteLine(strtemp + "'"); icount++; }; } #endregion #region 51/52 集装箱 var ctndetaillist = GetBodyList("BSNO='" + bill.BSNO + "'"); foreach (var ctn in ctndetaillist) { if (ctn.CNTRNO != "") { r.WriteLine("51" + ":"//2 CARGO SEQUENCE NO. 货物序号 9(3) 此字段无意义 M + ":" + ctn.CNTRNO//3 CTN. NO. 箱号 X(17) "由4个字母即货主编码、6位数字序列号以及1位检测数字组成。填写内容必须由大写字母与数字组成,可以出现一次中划线。非集装箱货没有箱号的情况下填写:0000" M 测试数据不能超过12位 + ":" + ctn.SEALNO//4 SEAL NO. 主铅封号 X(30) 机械封志且封志人为CA C 铅封号以52记录为准 + ":" + GetCtnEDICode(ctn.CTNALL)//5 CTN. SIZE & TYPE 集装箱尺寸类型 X(4) "使用UN95码,非集装箱货填写:0000" M + ":8"//6 ctn.CTNSTATUS 箱状态(重箱或者空箱标识代码) X(1) //1=货物多于1/4容量 //2=货物多于1/2容量 //3=货物多于3/4容量 //4=空箱 //5=重箱 //6=满箱 //7=拼箱 //8=整箱 //非集装箱货填写:5=重箱" M + ":" + ctn.PKGS//7 CTN. NUMBERS OF PACKAGES 箱内货物件数 9(6) 按实填写 M + ":" + Math.Round(ctn.KGS, 3)//8 NET WEIGHT 箱内货重 9(5). 999 按实填写 M + ":" + Math.Round(ctn.TAREWEIGHT, 3)//9 TARE WEIGHT 箱皮重 9(5). 999 非集装箱货填写:0 M + ":" + Math.Round(ctn.CBM, 3)//10 CTN. CARGO MEASUREMENT 箱内货物尺码 9(5) . 999 C //+ ":"11 Over Length Front 前超 9(4) CM,厘米 C //+ ":"12 Over Length Back 后超 9(4) CM,厘米 C //+ ":"13 Over Width Left 左超 9(4) CM,厘米 C //+ ":"14 Over Width Right 右超 9(4) CM,厘米 C //+ ":"15 Over Height 超高 9(4) CM,厘米 C //+ ":"16 STOWAGE LOCATION 贝位 9(7) C //+ ":"17 Container supplier type, coded 集装箱来源代码 9(2) //1=货主自备箱 //2=承运人提供箱 //3=拼箱人提供箱 //4=拆箱人提供箱 //5=第三方提供箱" O //注: 此记录反应的是该提单在该箱下的信息 + "'"); icount++; r.WriteLine("52" + ":" + ctn.SEALNO// 2 SEAL NO 封志号 X(30) 对于特种箱不能施封,但属于重箱的封志号码填写“0000”。如:框架箱、开顶箱、油罐箱 M 测试数据不能超过10位 + ":M"// 3 SEAL KIND,CODE 封志类型 X(1) "M=机械封志、E=电子封志,只有特种箱不能施封可不填" O + ":CA"// 4 SEALER,CODE 施加封志人 X(2) "AA=拼箱人 //AB=未知 //AC=检疫 //CA=承运人 //CU=海关 //SH=发货人 //TO=码头 //只有特种箱不能施封可不填" O // 注: 第一条出现的记录为主铅封信息 + "'"); icount++; } } #endregion } icount++; r.WriteLine("99:" + icount.ToString() + "'");//包括;头、尾记录 r.Close(); f.Close(); return filename; } #endregion #region IFTMBF V2.0 宁波船代(NBCD) public static string IsCreateEdiNBCDI(List headData, string type, string filerole) { var error = ""; foreach (var bill in headData) { if (bill.MBLNO == null || bill.MBLNO == "") { error += "
主提单号不能为空"; } if (bill.VESSEL == null || bill.VESSEL == "") { error += "
提单号:" + bill.MBLNO + "船名不能为空"; } else { if (GetVESSELID(bill.VESSEL) == "") { error += "
提单号:" + bill.MBLNO + "的船名" + bill.VESSEL + "的船舶呼号不能为空"; } } if (bill.VOYNO == null || bill.VOYNO == "") { error += "
提单号:" + bill.MBLNO + "航次不能为空"; } if (bill.CARRIER == null || bill.CARRIER == "") { error += "
提单号:" + bill.MBLNO + "船公司不能为空"; } if (GetCustEdi(bill.CARRIER) == "") { error += "
提单号:" + bill.MBLNO + "的船公司" + bill.CARRIER + "的EDI代码不能为空"; } if (bill.ETA == null || bill.ETA == "") { error += "
提单号:" + bill.MBLNO + "开船日期不能为空"; } if (bill.ETD == null || bill.ETD == "") { error += "
提单号:" + bill.MBLNO + "到港日期不能为空"; } if (bill.PORTLOADID == null || bill.PORTLOADID == "") { error += "
提单号:" + bill.MBLNO + "卸货港代码不能为空"; } if (bill.PORTLOAD == null || bill.PORTLOAD == "") { error += "
提单号:" + bill.MBLNO + "卸货港不能为空"; } if (bill.PORTDISCHARGEID == null || bill.PORTDISCHARGEID == "") { error += "
提单号:" + bill.MBLNO + "装货港代码不能为空"; } if (bill.PORTDISCHARGE == null || bill.PORTDISCHARGE == "") { error += "
提单号:" + bill.MBLNO + "装货港不能为空"; } if (bill.PLACEDELIVERYID == null || bill.PLACEDELIVERYID == "") { error += "
提单号:" + bill.MBLNO + "交货地代码不能为空"; } if (bill.PLACEDELIVERY == null || bill.PLACEDELIVERY == "") { error += "
提单号:" + bill.MBLNO + "交货地不能为空"; } if (bill.DESTINATION == null || bill.DESTINATION == "") { error += "
提单号:" + bill.MBLNO + "目的港代码不能为空"; } if (bill.KINDPKGS == "") { error += "
提单号:" + bill.MBLNO + "包装不能为空"; } if (GetPackageEDICode(bill.KINDPKGS).Trim() == "") { error += "
提单号:" + bill.MBLNO + "包装EDI代码不能为空"; } if (bill.DESCRIPTION == null || bill.DESCRIPTION == "") { error += "
提单号:" + bill.MBLNO + "货物描述不能为空"; } if (bill.MARKS == null || bill.MARKS == "") { error += "
提单号:" + bill.MBLNO + "货物唛头不能为空"; } if (bill.PKGS == 0) { error += "
提单号:" + bill.MBLNO + "货物件数不能为空"; } if (bill.SERVICE == null || bill.SERVICE == "") { error += "
提单号:" + bill.MBLNO + "运输条款不能为空"; } if (bill.BLFRT == null || bill.BLFRT == "") { error += "
提单号:" + bill.MBLNO + "付费方式不能为空"; } if (bill.CARGOID == null || bill.CARGOID == "") { error += "
提单号:" + bill.MBLNO + "货物标示不能为空"; } else { if (bill.CARGOID == "D") { if (bill.DCLASS == null || bill.DCLASS == "") { error += "
提单号:" + bill.MBLNO + "危险品分类不能为空"; } if (bill.DPAGE == null || bill.DPAGE == "") { error += "
提单号:" + bill.MBLNO + "危险品页号不能为空"; } if (bill.DUNNO == null || bill.DUNNO == "") { error += "
提单号:" + bill.MBLNO + "危险品编号不能为空"; } if (bill.DLABEL == null || bill.DLABEL == "") { error += "
提单号:" + bill.MBLNO + "危险品标签不能为空"; } } if (bill.CARGOID == "R") { if (bill.TEMPSET == null || bill.TEMPSET == "") { error += "
提单号:" + bill.MBLNO + "设置温度不能为空"; } if (bill.TEMPID == null || bill.TEMPID == "") { error += "
提单号:" + bill.MBLNO + "温度计量单位不能为空"; } } } var ctnlist = GetBodyList("BSNO='" + bill.BSNO + "'"); if (ctnlist.Count == 0) { error += "
提单号:" + bill.MBLNO + "集装箱信息不能为空"; } else { foreach (var ctn in ctnlist) { if (ctn.CNTRNO == null || ctn.CNTRNO == "") { error += "
提单号:" + bill.MBLNO + "箱号不能为空"; } } } //#region 发货人 //if (bill.SHIPPER == "") //{ // error = error + "
提单号:" + bill.MBLNO + " 发货人不能为空"; //} //else //{ // if (StringIsChinese(bill.SHIPPER)) // { // error = error + "
提单号:" + bill.MBLNO + " 发货人含有中文或双字节字符"; // } // else // { // error += formatlengthError(bill.SHIPPER, 35, bill.MBLNO, "发货人", 5, "*", false); // } //} //#endregion //#region 收货人 //if (bill.CONSIGNEE == "") //{ // error = error + "
提单号:" + bill.MBLNO + " 收货人不能为空"; //} //else //{ // if (StringIsChinese(bill.CONSIGNEE)) // { // error = error + "
提单号:" + bill.MBLNO + " 收货人含有中文或双字节字符"; // } // else // { // error += formatlengthError(bill.CONSIGNEE, 35, bill.MBLNO, "收货人", 5, "**", false); // } //} //#endregion //#region 通知人 //if (bill.NOTIFYPARTY == "") //{ // error = error + "
提单号:" + bill.MBLNO + " 通知人不能为空"; //} //else //{ // if (StringIsChinese(bill.NOTIFYPARTY)) // { // error = error + "
提单号:" + bill.MBLNO + " 通知人含有中文或双字节字符"; // } // else // { // error += formatlengthError(bill.NOTIFYPARTY, 35, bill.MBLNO, "通知人", 5, "***", false); // } //} //#endregion #region 唛头 if (bill.MARKS == "") { error = error + "
提单号:" + bill.MBLNO + " 唛头不能为空"; } else { if (StringIsChinese(bill.MARKS)) { error = error + "
提单号:" + bill.MBLNO + " 唛头含有中文或双字节字符"; } else { error += formatlengthError(bill.MARKS, 35, bill.MBLNO, "唛头", 10, "", false); } } #endregion #region 货物描述 if (bill.DESCRIPTION == "") { error = error + "
提单号:" + bill.MBLNO + " 货物描述不能为空"; } else { if (StringIsChinese(bill.DESCRIPTION)) { error = error + "
提单号:" + bill.MBLNO + " 货物描述含有中文或双字节字符"; } else { error += formatlengthError(bill.DESCRIPTION, 35, bill.MBLNO, "货物描述", 10, "", true); } } #endregion } return error; } public static string CreateEdiIFTMBF2(List headData, string usercode, string path, string mblno, string filerole, CodeFtpSet ftpset, string type) { string filename = path + "\\" + mblno + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".txt"; if (System.IO.File.Exists(filename)) { System.IO.File.Delete(filename); } FileStream f = new FileStream(filename, FileMode.Create); StreamWriter r = new StreamWriter(f, Encoding.Default); var icount = 0; // r.WriteLine("00:IFCSUM:MANIFEST:" + filerole + ":" + ftpset.SENDCODE + ":" + ftpset.RECEIVECODE + ":" + DateTime.Now.ToString("yyMMddHHmm") + ":" + headData[0].PORTLOADID + ":" + headData[0].PORTDISCHARGEID + "'"); r.WriteLine("00:IFCTST:MANIFEST:" + filerole + ":" + ftpset.SENDCODE + ":" + ftpset.RECEIVECODE + ":" + DateTime.Now.ToString("yyMMddHHmm") + ":1.0'"); icount++; foreach (var bill in headData) { #region 10/11 描述船舶有关的基本数据项目 r.WriteLine("10" + ":" + GetVESSELID(bill.VESSEL)//2 VESSEL CODE 船名代码 X(9) C/M + ":" + bill.VESSEL//3 VESSEL 船名 X(35) M/C + ":"//4 NATIONALITY CODE 舶国籍代码 X(2) C + ":" + bill.VOYNO//5 VOYAGE 航次 X(6) M + ":"//6 TRADE CODE 航线代码 X(10) C + ":"//7 TRADE 航线 X(35) C + ":" + GetDateStr(bill.ETD, "yyyyMMdd")//8 ETD ARRIVED DATE 预计到达日期 9(8) CCYYMMDD C + ":" + GetDateStr(bill.ETA, "yyyyMMdd")//9 SAILING DATE 离港日期 9(8) CCYYMMDD M + ":" + bill.PORTLOADID//10 DEPART PORT CODE 离港地点代码 X(5) M/C + ":" + bill.PORTLOAD//11 DEPART PORT 离港地点 X(35) C/M + ":"//12 NEXT CALLING PORT CODE 下一挂港代码 X(5) M/C + ":"//13 NEXT CALLING PORT 下一挂港 X(35) C/M + "'"); icount++; r.WriteLine("11" + ":" + GetCustEdi(bill.CARRIER)//2 SHIPPING LINE CODE 船公司(承运人)代码 X(13) C/M + ":" + bill.CARRIER//3 SHIPPING LINE 船公司(承运人) X(35) M/C + "'"); icount++; #endregion #region 12 提单的第一个记录 var xtype = "P"; if (bill.BLFRT.IndexOf("COLLECT") >= 0) xtype = "C"; r.WriteLine("12" + ":" + bill.MBLNO// 2 B/L NO. 提单号 X(20) M + ":"//3 PRE. VESSEL CODE 前程运输船名代码 X(7) C + ":"//4 PRE. VESSEL 前程运输船名 X(35) C + ":"//5 PRE. VOYAGE 前程运输航次 X(6) C + ":" + bill.PORTLOADID//6 PLACE CODE OF RECEIPT 收货地代码 X(5) C + ":" + bill.PORTLOAD//7 PLACE OF RECEIPT 收货地 X70) C + ":" + bill.PORTLOADID//8 LOAD PORT CODE 装货港代码 X(5) M/C + ":" + bill.PORTLOAD//9 LOAD PORT 装货港 X(35) C/M + ":" + bill.SERVICE//10 DELIVERY TERM 运输条款 X(9) C + ":" + xtype//11 PREPAID OR COLLECT 付款方式 X(1) P=预付 C=到付 F=免费 M + ":" + GetDateStr(bill.ETA, "yyyyMMdd")//12 LOAD DATE 装货日期 9(8) CCYYMMDD M //+ ":"13 QUARANTINE CODING 检疫代码 X(1) C //+ ":"14 DATE OF ISSUE 签发日期 9(8) C //+ ":"15 CURRENCY 币种 X(3) C //+ ":"16 EXCHANGE RATE 汇率 9(5) v9999 C + "'"); icount++; #endregion #region 13 提单的地点信息 r.WriteLine("13" + ":" + bill.PORTDISCHARGEID//2 DISCHARGE PORT CODE 卸货港代码 X(5) M/C + ":" + bill.PORTDISCHARGE//3 DISCHARGE PORT 卸货港 X(35) C/M + ":" + bill.PLACEDELIVERYID//4 PLACE CODE OF DELIVERY 交货地代码 X(5) C + ":" + bill.PLACEDELIVERY//5 PLACE OF DELIVERY 交货地 X(70) C + ":"//6 TRANSFER PORT CODE 中转港代码 X(5) C + ":"//7 TRANSFER PORT 中转港 X(35) C + ":"//8 PLACE CODE OF B/L ISSUE 提单签发地代码 X(5) C + ":"//9 PLACE OF B/L ISSUE 提单签发地 X(35) C + "'"); icount++; #endregion var Shipping = ""; #region 16 发货人 Shipping = formatEdiStr(bill.SHIPPER); List ShippingList = formatlengthStr(Shipping, 70); if (ShippingList.Count != 0) { for (int i = 0; i < ShippingList.Count; i++) { if (i == 0) Shipping = "16:" + ShippingList[0] + ":"; if (i == 1) Shipping = Shipping + ShippingList[i]; if (i == 2 || i == 3) Shipping = Shipping + ":" + ShippingList[i]; if (i >= 4 && ShippingList.Count > 5) { if (i == 4) { if (ShippingList[i].Length > 70) { Shipping = Shipping + ":" + ShippingList[i].Substring(0, 70); } else Shipping = Shipping + ":" + ShippingList[i]; } else Shipping = Shipping + ":" + ShippingList[i]; } else if (i == 4) Shipping = Shipping + ":" + ShippingList[i]; } } if (Shipping != "") { r.WriteLine(Shipping + "'"); icount++; }; #endregion #region 17 收货人 Shipping = formatEdiStr(bill.CONSIGNEE); List ShippingList2 = formatlengthStr(Shipping, 70); if (ShippingList2.Count != 0) { for (int i = 0; i < ShippingList2.Count; i++) { if (i == 0) Shipping = "17:" + ShippingList2[0] + ":"; if (i == 1) Shipping = Shipping + ShippingList2[i]; if (i == 2 || i == 3) Shipping = Shipping + ":" + ShippingList2[i]; if (i >= 4 && ShippingList2.Count > 5) { if (i == 4) { if (ShippingList2[i].Length > 70) { Shipping = Shipping + ":" + ShippingList2[i].Substring(0, 70); } else Shipping = Shipping + ":" + ShippingList2[i]; } else Shipping = Shipping + ":" + ShippingList2[i]; } else if (i == 4) Shipping = Shipping + ":" + ShippingList2[i]; } } if (Shipping != "") { r.WriteLine(Shipping + "'"); icount++; }; #endregion #region 18 通知人 Shipping = formatEdiStr(bill.NOTIFYPARTY); List ShippingList3 = formatlengthStr(Shipping, 70); if (ShippingList3.Count != 0) { for (int i = 0; i < ShippingList3.Count; i++) { if (i == 0) Shipping = "18:" + ShippingList3[0] + ":"; if (i == 1) Shipping = Shipping + ShippingList3[i]; if (i == 2 || i == 3) Shipping = Shipping + ":" + ShippingList3[i]; if (i >= 4 && ShippingList3.Count > 5) { if (i == 4) { if (ShippingList3[i].Length > 70) { Shipping = Shipping + ":" + ShippingList3[i].Substring(0, 70); } else Shipping = Shipping + ":" + ShippingList3[i]; } else Shipping = Shipping + ":" + ShippingList3[i]; } else if (i == 4) Shipping = Shipping + ":" + ShippingList3[i]; } } if (Shipping != "") { r.WriteLine(Shipping + "'"); icount++; }; #endregion #region 41 货物信息 r.WriteLine("41" + ":1" //2 CARGO SEQUENCE NO. 货物序号 9(3) M + ":" //3 CARGO CODE 货类代码 X(8) C + ":" + bill.PKGS //4 NUMBERS OF PACKAGES 件数 9(6) M + ":" + GetPackageEDICode(bill.KINDPKGS).Trim() //5 PACKAGES KIND CODE包装类型代码 X(2) M/C + ":" + bill.KINDPKGS //6 PACKAGES KIND 包装类型 X(35) C/M + ":" + Math.Round(bill.KGS, 1) //7 CARGO GROSS WEIGHT 货毛重 9(5)V9 千克 C + ":" + Math.Round(bill.NETWEIGHT, 1) //8 CARGO NET WEIGHT 货净重 9(5)V9 千克 C + ":" + Math.Round(bill.CBM, 3) //9 CARGO MEASUREMENT 货尺码 9(5) V999 立方米 C + "'"); icount++; #endregion #region 43 危险品和冷藏信息 var cargoid = bill.CARGOID; if (cargoid == "" || cargoid == " ") cargoid = "S"; if (cargoid == "D") { r.WriteLine("43" + ":" + bill.DCLASS //2 CLASS 危险品分类 X(5) M + ":" + bill.DPAGE//3 PAGE 危险品页号 X(7) M + ":" + bill.DUNNO//4 UNDG NO. 联合国危险品编号 X(4) C + ":" + bill.DLABEL//5 LABEL (1-3) 危险品标签 X(32) C + ":"//6 FLASH POINT 危险货物闪点 X(5) 摄氏 C + ":"//7 EMS NO. 船运危险品应急措施号 X(6) C + ":"//8 MFAG NO. 医疗急救指南号 X(4) C + ":"//9 EMERGENCY CONTACT 应急联系 X(35) C + ":"//10 TEMPERATURE ID 温度计量单位 X(1) C = 摄氏 F = 华氏 C + ":"//11 TEMPERATURE SETTING 设置温度 X(5) 见注 C + ":"//12 MIN. TEMPERATURE 冷藏最低温度 X(5) C + ":"//13 MAX. TEMPERATURE 冷藏最高温度 X(5) C //注:第一位放正(+)负(-)号,后四位放温度数。 + "'"); icount++; } else if (cargoid == "R") { string sTEMPID = "C"; if (bill.TEMPID.IndexOf("F") > -1 || bill.TEMPID.IndexOf("华") > -1) { sTEMPID = "F"; } r.WriteLine("43" + ":" //2 CLASS 危险品分类 X(5) M + ":"//3 PAGE 危险品页号 X(7) M + ":"//4 UNDG NO. 联合国危险品编号 X(4) C + ":"//5 LABEL (1-3) 危险品标签 X(32) C + ":"//6 FLASH POINT 危险货物闪点 X(5) 摄氏 C + ":"//7 EMS NO. 船运危险品应急措施号 X(6) C + ":"//8 MFAG NO. 医疗急救指南号 X(4) C + ":"//9 EMERGENCY CONTACT 应急联系 X(35) C + ":" + sTEMPID//10 TEMPERATURE ID 温度计量单位 X(1) C = 摄氏 F = 华氏 C + ":" + bill.TEMPSET//11 TEMPERATURE SETTING 设置温度 X(5) 见注 C + ":"//12 MIN. TEMPERATURE 冷藏最低温度 X(5) C + ":"//13 MAX. TEMPERATURE 冷藏最高温度 X(5) C //注:第一位放正(+)负(-)号,后四位放温度数。 + "'"); icount++; } #endregion #region 44 唛头 //2 MARKS 唛头 X(512) 填写运输包装的标志及代码(唛头)M。每条记录44允许有5项,每项长度为35;该记录一次最多允许重复2次 var m = 1;//项,允许有5项 var iLine = 0;//行,最多允许重复2次 var strtemp = ""; Shipping = formatEdiStr(bill.MARKS); List ShippingListName = formatlengthStr(Shipping, 35); if (ShippingListName.Count != 0) { for (var i = 0; i < ShippingListName.Count; i++) { if (iLine > 2) { break; } if (m <= 5) { if (m == 1) { strtemp = "44:" + ShippingListName[i] + ":"; iLine++; } else { if (m == 5) strtemp += ShippingListName[i]; else strtemp += ShippingListName[i] + ":"; } } else { m = 1; r.WriteLine(strtemp + "'"); strtemp = "44:" + ShippingListName[i] + ":"; icount++; iLine++; } m++; } if (strtemp != "") { r.WriteLine(strtemp + "'"); icount++; }; } #endregion #region 47 货物描述 //2 CARGO DESCRIPTION 货物描述 X(256) 填写足以鉴别货物的性质的简明描述 M。每条记录47允许有5项,每项长度为35;该记录一次最多允许重复2次 m = 1;//项,允许有5项 iLine = 0;//行,最多允许重复2次 strtemp = ""; Shipping = formatEdiStr(bill.DESCRIPTION); List ListName = formatlengthStr(Shipping, 35); if (ListName.Count != 0) { for (var i = 0; i < ListName.Count; i++) { if (iLine > 2) { break; } if (m <= 5) { if (m == 1) { strtemp = "47:" + ListName[i] + ":"; iLine++; } else { if (m == 5) strtemp += ListName[i]; else strtemp += ListName[i] + ":"; } } else { m = 1; r.WriteLine(strtemp + "'"); strtemp = "47:" + ListName[i] + ":"; icount++; iLine++; } m++; } if (strtemp != "") { r.WriteLine(strtemp + "'"); icount++; }; } #endregion #region 51 集装箱 var ctndetaillist = GetBodyList("BSNO='" + bill.BSNO + "'"); foreach (var ctn in ctndetaillist) { if (ctn.CNTRNO != "") { r.WriteLine("51" + ":"//2 CARGO SEQUENCE NO. 货物序号 9(3) M + ":" + ctn.CNTRNO//3 CTN. NO. 箱号 X(12) M + ":" + ctn.SEALNO//4 SEAL NO. 铅封号 X(10) M + ":" + GetCtnEDICode(ctn.CTNALL)//5 CTN. SIZE & TYPE 集装箱尺寸类型 X(4) M + ":F"//6 CTN. STATUS 箱状态 X(1) E=空 F=整 L=拼 M + ":" + ctn.PKGS//7 CTN. NUMBERS OF PACKAGES 箱内货物件数 9(6) M + ":" + Math.Round(ctn.KGS, 1)//8 NET WEIGHT 箱内货重 9(5)V9 是该类货的箱内货重 M + ":" + Math.Round(ctn.TAREWEIGHT, 1)//9 TARE WEIGHT 箱皮重 9(5)V9 M + ":" + Math.Round(ctn.CBM, 3)//10 CTN.CARGO MEASUREMENT 箱内货物尺码 9(5)V999 C //+ ":"11 OVER LENGTH FRONT 前超 X(4) 厘米 C //+ ":"12 OVER LENGTH BACK 后超 X(4) 厘米 C //+ ":"13 OVER WIDTH LEFT 左超 X(4) 厘米 C //+ ":"14 OVER WIDTH RIGHT 右超 X(4) 厘米 C //+ ":"15 OVER HEIGHT 超高 X(4) 厘米 C //+ ":"16 STOWAGE LOCATION 贝位 9(7) C + "'"); icount++; } } #endregion } icount++; r.WriteLine("99:" + icount.ToString() + "'"); r.Close(); f.Close(); return filename; } #endregion #endregion #region 舱单申报 public static DBResult CreateCustomList(List billList, string type, string userid, string usercode, string companyid) { var result = new DBResult(); var companydef = GetCompanyDef(companyid); Database db = DatabaseFactory.CreateDatabase(); using (var conn = db.CreateConnection()) { conn.Open(); var tran = conn.BeginTransaction(); try { foreach (var bill in billList) { if (bill.BLTYPE == "拼箱主票") { CreateCustomdb(bill, db, tran, type, companydef, usercode, companyid); var billfenlist = GetFenList(" MASTERNO<>BSNO AND MASTERNO='" + bill.BSNO + "'", userid, usercode, companyid); if (billfenlist.Count > 0) { foreach (var billfen in billfenlist) { CreateCustomdb(billfen, db, tran, type, companydef, usercode, companyid); } } } else CreateCustomdb(bill, db, tran, type, companydef, usercode, companyid); } result = new DBResult(); result.Success = true; result.Message = "生成成功"; tran.Commit(); } catch (Exception) { tran.Rollback(); result.Success = false; result.Message = "生成错误,请重试或联系系统管理员"; return result; } } return result; } static public DBResult CreateCustomdb(MsOpSeai bill, Database db, DbTransaction tran, string type, CompanyDef companydef, string usercode, string companyid) { var result = new DBResult(); try { var cmdInsert = db.GetSqlStringCommand( @"INSERT INTO op_seae_edi([MFNO],[BSNO],[MASTERNO],[EDITYPE],[EDISTATUS],[INPUTBY],[INPUTDATE],[CUSTNO],[MBLNO],[HBLNO],SHIPPERCODE ,[SHIPPERNAME],[SHIPPERADDR1],[SHIPPERADDR2],[SHIPPERADDR3],[SHIPPERCITY],[SHIPPERPROVINCE],[SHIPPERPOSTCODE] ,[SHIPPERCOUNTRY],[SHIPPERATTN],[SHIPPERTEL],[SHIPPEREMAIL],[CONSIGNEECODE],[CONSIGNEENAME],[CONSIGNEEADDR1],[CONSIGNEEADDR2],[CONSIGNEEADDR3] ,[CONSIGNEECITY],[CONSIGNEEPROVINCE],[CONSIGNEEPOSTCODE],[CONSIGNEECOUNTRY],[CONSIGNEEATTN],[CONSIGNEETEL],[CONSIGNEEEMAIL] ,[NOTIFYPARTYCODE],[NOTIFYPARTYNAME],[NOTIFYPARTYADDR1],[NOTIFYPARTYADDR2],[NOTIFYPARTYADDR3],[NOTIFYPARTYCITY],[NOTIFYPARTYPROVINCE] ,[NOTIFYPARTYPOSTCODE],[NOTIFYPARTYCOUNTRY],[NOTIFYPARTYATTN],[NOTIFYPARTYTEL],[NOTIFYPARTYEMAIL],[SHIPPER],[CONSIGNEE],[NOTIFYPARTY] ,[VESSEL],[VOYNO],[ETD],[PORTLOADID],[PORTLOAD],[PORTDISCHARGEID],[PORTDISCHARGE],[PLACEDELIVERYID],[PLACEDELIVERY] ,[DESTINATIONID],[DESTINATION],[SERVICE],[MARKS],[DESCRIPTION],[PKGS],[KINDPKGS],[KGS],[CBM],[CARGOID],[DCLASS] ,[DUNNO],[REEFERF],[TEMPID],[TEMPSET],[TEMPMAX],[TEMPMIN],[SHIPIMO],[CARRIERID],[ORDERNO] ,[FILEROLE],[PACKINGTYPE],[TRANSTYPE],[FILETYPE],[ISLASTHBL],[BLFRT],[ISSUEPLACE],YARD,CARRIER,ETA ,[AGENTID],[CORPID]) VALUES (@MFNO,@BSNO,@MASTERNO,@EDITYPE,@EDISTATUS,@INPUTBY,@INPUTDATE,@CUSTNO,@MBLNO,@HBLNO,@SHIPPERCODE ,@SHIPPERNAME,@SHIPPERADDR1,@SHIPPERADDR2,@SHIPPERADDR3,@SHIPPERCITY,@SHIPPERPROVINCE,@SHIPPERPOSTCODE ,@SHIPPERCOUNTRY,@SHIPPERATTN,@SHIPPERTEL,@SHIPPEREMAIL,@CONSIGNEECODE,@CONSIGNEENAME,@CONSIGNEEADDR1,@CONSIGNEEADDR2,@CONSIGNEEADDR3 ,@CONSIGNEECITY,@CONSIGNEEPROVINCE,@CONSIGNEEPOSTCODE,@CONSIGNEECOUNTRY,@CONSIGNEEATTN,@CONSIGNEETEL,@CONSIGNEEEMAIL ,@NOTIFYPARTYCODE,@NOTIFYPARTYNAME,@NOTIFYPARTYADDR1,@NOTIFYPARTYADDR2,@NOTIFYPARTYADDR3,@NOTIFYPARTYCITY,@NOTIFYPARTYPROVINCE ,@NOTIFYPARTYPOSTCODE,@NOTIFYPARTYCOUNTRY,@NOTIFYPARTYATTN,@NOTIFYPARTYTEL,@NOTIFYPARTYEMAIL,@SHIPPER,@CONSIGNEE,@NOTIFYPARTY ,@VESSEL,@VOYNO,@ETD,@PORTLOADID,@PORTLOAD,@PORTDISCHARGEID,@PORTDISCHARGE,@PLACEDELIVERYID,@PLACEDELIVERY ,@DESTINATIONID,@DESTINATION,@SERVICE,@MARKS,@DESCRIPTION,@PKGS,@KINDPKGS,@KGS,@CBM,@CARGOID,@DCLASS ,@DUNNO,@REEFERF,@TEMPID,@TEMPSET,@TEMPMAX,@TEMPMIN,@SHIPIMO,@CARRIERID,@ORDERNO ,@FILEROLE,@PACKINGTYPE,@TRANSTYPE,@FILETYPE,@ISLASTHBL,@BLFRT,@ISSUEPLACE,@YARD,@CARRIER,@ETA ,@AGENTID,@CORPID) "); var MFNO = Guid.NewGuid().ToString(); cmdInsert.Parameters.Clear(); db.AddInParameter(cmdInsert, "@MFNO", DbType.String, MFNO); db.AddInParameter(cmdInsert, "@BSNO", DbType.String, bill.BSNO); db.AddInParameter(cmdInsert, "@MASTERNO", DbType.String, bill.MASTERNO); db.AddInParameter(cmdInsert, "@EDITYPE", DbType.String, "CN"); db.AddInParameter(cmdInsert, "@FILETYPE", DbType.String, "House"); db.AddInParameter(cmdInsert, "@EDISTATUS", DbType.String, "未发送"); db.AddInParameter(cmdInsert, "@INPUTBY", DbType.String, usercode); db.AddInParameter(cmdInsert, "@INPUTDATE", DbType.DateTime, DateTime.Now); db.AddInParameter(cmdInsert, "@CUSTNO", DbType.String, bill.CUSTNO); db.AddInParameter(cmdInsert, "@MBLNO", DbType.String, bill.MBLNO); db.AddInParameter(cmdInsert, "@HBLNO", DbType.String, bill.HBLNO); db.AddInParameter(cmdInsert, "@YARD", DbType.String, bill.YARD); db.AddInParameter(cmdInsert, "@CARRIER", DbType.String, bill.CARRIER); var Shipping = bill.SHIPPER; Shipping = Shipping.Replace("\n", "\\"); Shipping = Shipping.Replace("\r", " "); string[] ShippingList = Shipping.Split('\\'); db.AddInParameter(cmdInsert, "@SHIPPERCODE", DbType.String, bill.SHIPPERCODE); if (ShippingList.Length != 0) { db.AddInParameter(cmdInsert, "@SHIPPERNAME", DbType.String, ShippingList[0]); } else { db.AddInParameter(cmdInsert, "@SHIPPERNAME", DbType.String, ""); } if (ShippingList.Length >= 2) { db.AddInParameter(cmdInsert, "@SHIPPERADDR1", DbType.String, ShippingList[1]); } else { db.AddInParameter(cmdInsert, "@SHIPPERADDR1", DbType.String,""); } if (ShippingList.Length >= 3) { db.AddInParameter(cmdInsert, "@SHIPPERADDR2", DbType.String, ShippingList[2]); } else { db.AddInParameter(cmdInsert, "@SHIPPERADDR2", DbType.String, ""); } if (ShippingList.Length >= 4) { db.AddInParameter(cmdInsert, "@SHIPPERADDR3", DbType.String, ShippingList[3]); } else { db.AddInParameter(cmdInsert, "@SHIPPERADDR3", DbType.String, ""); } var portload = bill.PORTLOAD; if (portload.Length > 30) portload = portload.Substring(0, 30); db.AddInParameter(cmdInsert, "@SHIPPERCITY", DbType.String, portload); db.AddInParameter(cmdInsert, "@SHIPPERPROVINCE", DbType.String,""); db.AddInParameter(cmdInsert, "@SHIPPERPOSTCODE", DbType.String,""); db.AddInParameter(cmdInsert, "@SHIPPERCOUNTRY", DbType.String, bill.SHIPPERCOUNTRY); db.AddInParameter(cmdInsert, "@SHIPPERATTN", DbType.String, bill.SHIPPERATTN); db.AddInParameter(cmdInsert, "@SHIPPERTEL", DbType.String, bill.SHIPPERTEL); db.AddInParameter(cmdInsert, "@SHIPPEREMAIL", DbType.String, bill.SHIPPEREMAIL); db.AddInParameter(cmdInsert, "@CONSIGNEECODE", DbType.String, bill.CONSIGNEECODE); Shipping = bill.CONSIGNEE; Shipping = Shipping.Replace("\n", "\\"); Shipping = Shipping.Replace("\r", " "); ShippingList = Shipping.Split('\\'); if (ShippingList.Length != 0) { db.AddInParameter(cmdInsert, "@CONSIGNEENAME", DbType.String, ShippingList[0]); } else { db.AddInParameter(cmdInsert, "@CONSIGNEENAME", DbType.String, ""); } if (ShippingList.Length >= 2) { db.AddInParameter(cmdInsert, "@CONSIGNEEADDR1", DbType.String, ShippingList[1]); } else { db.AddInParameter(cmdInsert, "@CONSIGNEEADDR1", DbType.String,""); } if (ShippingList.Length >= 3) { db.AddInParameter(cmdInsert, "@CONSIGNEEADDR2", DbType.String, ShippingList[2]); } else { db.AddInParameter(cmdInsert, "@CONSIGNEEADDR2", DbType.String, ""); } if (ShippingList.Length >= 4) { db.AddInParameter(cmdInsert, "@CONSIGNEEADDR3", DbType.String, ShippingList[3]); } else { db.AddInParameter(cmdInsert, "@CONSIGNEEADDR3", DbType.String, ""); } portload = bill.PORTDISCHARGE; if (portload.Length > 30) portload = portload.Substring(0, 30); db.AddInParameter(cmdInsert, "@CONSIGNEECITY", DbType.String, portload); db.AddInParameter(cmdInsert, "@CONSIGNEEPROVINCE", DbType.String,""); db.AddInParameter(cmdInsert, "@CONSIGNEEPOSTCODE", DbType.String,""); db.AddInParameter(cmdInsert, "@CONSIGNEECOUNTRY", DbType.String, bill.CONSIGNEECOUNTRY); db.AddInParameter(cmdInsert, "@CONSIGNEEATTN", DbType.String, bill.CONSIGNEEATTN); db.AddInParameter(cmdInsert, "@CONSIGNEETEL", DbType.String, bill.CONSIGNEETEL); db.AddInParameter(cmdInsert, "@CONSIGNEEEMAIL", DbType.String, bill.CONSIGNEEEMAIL); db.AddInParameter(cmdInsert, "@NOTIFYPARTYCODE", DbType.String, bill.NOTIFYPARTYCODE); Shipping = bill.NOTIFYPARTY; Shipping = Shipping.Replace("\n", "\\"); Shipping = Shipping.Replace("\r", " "); ShippingList = Shipping.Split('\\'); if (ShippingList.Length != 0) { db.AddInParameter(cmdInsert, "@NOTIFYPARTYNAME", DbType.String, ShippingList[0]); } else { db.AddInParameter(cmdInsert, "@NOTIFYPARTYNAME", DbType.String, ""); } if (ShippingList.Length >= 2) { db.AddInParameter(cmdInsert, "@NOTIFYPARTYADDR1", DbType.String, ShippingList[1]); } else { db.AddInParameter(cmdInsert, "@NOTIFYPARTYADDR1", DbType.String,""); } if (ShippingList.Length >= 3) { db.AddInParameter(cmdInsert, "@NOTIFYPARTYADDR2", DbType.String, ShippingList[2]); } else { db.AddInParameter(cmdInsert, "@NOTIFYPARTYADDR2", DbType.String, ""); } if (ShippingList.Length >= 4) { db.AddInParameter(cmdInsert, "@NOTIFYPARTYADDR3", DbType.String, ShippingList[3]); } else { db.AddInParameter(cmdInsert, "@NOTIFYPARTYADDR3", DbType.String, ""); } db.AddInParameter(cmdInsert, "@NOTIFYPARTYCITY", DbType.String,""); db.AddInParameter(cmdInsert, "@NOTIFYPARTYPROVINCE", DbType.String,""); db.AddInParameter(cmdInsert, "@NOTIFYPARTYPOSTCODE", DbType.String,""); db.AddInParameter(cmdInsert, "@NOTIFYPARTYCOUNTRY", DbType.String, bill.NOTIFYPARTYCOUNTRY); db.AddInParameter(cmdInsert, "@NOTIFYPARTYATTN", DbType.String, bill.NOTIFYPARTYATTN); db.AddInParameter(cmdInsert, "@NOTIFYPARTYTEL", DbType.String, bill.NOTIFYPARTYTEL); db.AddInParameter(cmdInsert, "@NOTIFYPARTYEMAIL", DbType.String, bill.NOTIFYPARTYEMAIL); db.AddInParameter(cmdInsert, "@SHIPPER", DbType.String, bill.SHIPPER); db.AddInParameter(cmdInsert, "@CONSIGNEE", DbType.String, bill.CONSIGNEE); db.AddInParameter(cmdInsert, "@NOTIFYPARTY", DbType.String, bill.NOTIFYPARTY); db.AddInParameter(cmdInsert, "@VESSEL", DbType.String, bill.VESSEL); db.AddInParameter(cmdInsert, "@VOYNO", DbType.String, bill.VOYNO); db.AddInParameter(cmdInsert, "@ETD", DbType.String, bill.ETD); db.AddInParameter(cmdInsert, "@ETA", DbType.String, bill.ETA); db.AddInParameter(cmdInsert, "@PORTLOADID", DbType.String, bill.PORTLOADID); db.AddInParameter(cmdInsert, "@PORTLOAD", DbType.String, bill.PORTLOAD); db.AddInParameter(cmdInsert, "@PORTDISCHARGEID", DbType.String, bill.PORTDISCHARGEID); db.AddInParameter(cmdInsert, "@PORTDISCHARGE", DbType.String, bill.PORTDISCHARGE); db.AddInParameter(cmdInsert, "@DESTINATIONID", DbType.String, bill.DESTINATIONID); db.AddInParameter(cmdInsert, "@DESTINATION", DbType.String, bill.DESTINATION); db.AddInParameter(cmdInsert, "@PLACEDELIVERYID", DbType.String, bill.PORTLOADID); db.AddInParameter(cmdInsert, "@PLACEDELIVERY", DbType.String, bill.PORTLOAD); db.AddInParameter(cmdInsert, "@SERVICE", DbType.String, bill.SERVICE); db.AddInParameter(cmdInsert, "@MARKS", DbType.String, bill.MARKS); db.AddInParameter(cmdInsert, "@DESCRIPTION", DbType.String, bill.DESCRIPTION); db.AddInParameter(cmdInsert, "@PKGS", DbType.Int16, bill.PKGS); db.AddInParameter(cmdInsert, "@KINDPKGS", DbType.String, bill.KINDPKGS); db.AddInParameter(cmdInsert, "@KGS", DbType.Decimal, bill.KGS); db.AddInParameter(cmdInsert, "@CBM", DbType.Decimal, bill.CBM); db.AddInParameter(cmdInsert, "@CARGOID", DbType.String, bill.CARGOID); db.AddInParameter(cmdInsert, "@DCLASS", DbType.String, bill.DCLASS); db.AddInParameter(cmdInsert, "@DUNNO", DbType.String, bill.DUNNO); db.AddInParameter(cmdInsert, "@REEFERF", DbType.String, bill.REEFERF); db.AddInParameter(cmdInsert, "@TEMPID", DbType.String, bill.TEMPID); db.AddInParameter(cmdInsert, "@TEMPSET", DbType.String, bill.TEMPSET); db.AddInParameter(cmdInsert, "@TEMPMAX", DbType.String, bill.TEMPMAX); db.AddInParameter(cmdInsert, "@TEMPMIN", DbType.String, bill.TEMPMIN); db.AddInParameter(cmdInsert, "@SHIPIMO", DbType.String, GetVESSELID(bill.VESSEL)); db.AddInParameter(cmdInsert, "@ORDERNO", DbType.String, bill.ORDERNO); db.AddInParameter(cmdInsert, "@FILEROLE", DbType.String, "9"); if (bill.BLTYPE == "拼箱分票" || bill.BLTYPE == "拼箱单票") { db.AddInParameter(cmdInsert, "@PACKINGTYPE", DbType.String, "拼箱"); db.AddInParameter(cmdInsert, "@ISLASTHBL", DbType.Boolean, false); } else { db.AddInParameter(cmdInsert, "@PACKINGTYPE", DbType.String, "整箱"); db.AddInParameter(cmdInsert, "@ISLASTHBL", DbType.Boolean, true); } db.AddInParameter(cmdInsert, "@TRANSTYPE", DbType.String, "PortToPort"); db.AddInParameter(cmdInsert, "@BLFRT", DbType.String, bill.BLFRT); db.AddInParameter(cmdInsert, "@ISSUEPLACE", DbType.String, bill.ISSUEPLACE); if (type == "2") { if (companydef.AFRCARRIERID == "") { db.AddInParameter(cmdInsert, "@CARRIERID", DbType.String, GetCustEdi(bill.CARRIER)); db.AddInParameter(cmdInsert, "@AGENTID", DbType.String, ""); } else { db.AddInParameter(cmdInsert, "@CARRIERID", DbType.String, companydef.AFRCARRIERID); db.AddInParameter(cmdInsert, "@AGENTID", DbType.String, companydef.AFRAGENTID); } } else { db.AddInParameter(cmdInsert, "@CARRIERID", DbType.String, GetCustEdi(bill.CARRIER)); db.AddInParameter(cmdInsert, "@AGENTID", DbType.String, ""); } db.AddInParameter(cmdInsert, "@CORPID", DbType.String, companyid); db.ExecuteNonQuery(cmdInsert, tran); var ctnlist = new List(); ctnlist = GetBodyList(" BSNO='" + bill.BSNO + "'"); if (ctnlist.Count > 0) { foreach (var ctn in ctnlist) { var ctnid = Guid.NewGuid().ToString(); var cmdInsertCtn = db.GetSqlStringCommand(@"insert into op_seae_edi_ctn (CTN_ID,MFNO,CTNCODE,[SIZE],CTN,CTNNUM,TEU,CTNALL,CNTRNO,SEALNO,PKGS,KGS,CBM,KINDPKGS,MARKS,DESCRIPTION,CTNOWNER) values ('" + ctnid + "','" + MFNO + "','" + ctn.CTNCODE + "','" + ctn.SIZE + "','" + ctn.CTN + "'," + ctn.CTNNUM + "," + ctn.TEU + ",'" + ctn.CTNALL.Replace("'", "''") + "','" + ctn.CNTRNO + "','" + ctn.SEALNO + "','" + ctn.PKGS + "'," + ctn.KGS + "," + ctn.CBM + ",'" + ctn.KINDPKGS + "','" + bill.MARKS.Replace("'", "''") + "','" + bill.DESCRIPTION.Replace("'", "''") + "','Carrier')"); db.ExecuteNonQuery(cmdInsertCtn, tran); var cmdInsertCtnDetail = db.GetSqlStringCommand(@"insert into op_seae_edi_ctndetail (GID,MFNO,CTN_ID,PKGS,KGS,CBM,KINDPKGS) values (newid(),'" + MFNO + "','" + ctnid + "'," + ctn.PKGS + "," + ctn.KGS + "," + ctn.CBM + ",'" + ctn.KINDPKGS + "')"); db.ExecuteNonQuery(cmdInsertCtnDetail, tran); } } result = new DBResult(); result.Success = true; result.Data = MFNO; result.Message = "生成成功"; //tran.Commit(); } catch (Exception) { //tran.Rollback(); result.Success = false; result.Message = "生成错误,请重试或联系系统管理员"; return result; } return result; } #endregion #region 编码生成 public static String getCodeRule(string strRULENAME, string strfield, string strETD, string strACCDATE, string strUserID, string strCompanyID) { //调用编码规则 if (strETD.Trim().IndexOf("0001") > -1) { strETD = ""; } string strRULEYEAR = ""; string strRULECONTENT = ""; string strCODENAME = ""; string strDEPTNO = ""; string strRULENOLENGTH = ""; int iRULENOLENGTH = 0; int inum = 0; string strCONTENT = ""; T_ALL_DA T_ALL_DA = new T_ALL_DA(); // DataSet ds = T_ALL_DA.GetAllSQL("select * from code_rule where RULENAME='" + strRULENAME.Trim() + "' and RULETYPE=2"); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ISSTARTUSING"].ToString().Trim().Equals("True")) { if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("业务日期")) { if (strETD.Trim() == "") { return ""; } DateTime dETD = System.Convert.ToDateTime(strETD.Trim()); if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True")) { if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4") { strRULEYEAR = dETD.ToString("yyyy") + dETD.ToString("MM"); } else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2") { strRULEYEAR = dETD.ToString("yy") + dETD.ToString("MM"); } } else { if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4") { strRULEYEAR = dETD.ToString("yyyy"); } else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2") { strRULEYEAR = dETD.ToString("yy"); } } } else if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("会计期间")) { if (strACCDATE.Trim() == "") { return ""; } DateTime dACCDATE = System.Convert.ToDateTime(strACCDATE.Trim() + "-01"); if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True")) { if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4") { strRULEYEAR = dACCDATE.ToString("yyyy") + dACCDATE.ToString("MM"); } else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2") { strRULEYEAR = dACCDATE.ToString("yy") + dACCDATE.ToString("MM"); } } else { if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4") { strRULEYEAR = dACCDATE.ToString("yyyy"); } else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2") { strRULEYEAR = dACCDATE.ToString("yy"); } } } else if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("自然月份")) { DateTime fwqdate = System.Convert.ToDateTime(T_ALL_DA.GetStrSQL("fwqdate", "select fwqdate=getdate()")); if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True")) { if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4") { strRULEYEAR = fwqdate.ToString("yyyy") + fwqdate.ToString("MM"); } else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2") { strRULEYEAR = fwqdate.ToString("yy") + fwqdate.ToString("MM"); } } else { if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4") { strRULEYEAR = fwqdate.ToString("yyyy"); } else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2") { strRULEYEAR = fwqdate.ToString("yy"); } } } // if (ds.Tables[0].Rows[0]["ISCOMPANY"].ToString().Trim().Equals("True")) { strCODENAME = T_ALL_DA.GetStrSQL("CODENAME", "select CODENAME from [company] where GID=(select top 1 COMPANYID from user_company where USERID='" + strUserID.Trim() + "')"); } if (ds.Tables[0].Rows[0]["ISDEPT"].ToString().Trim().Equals("True")) { strDEPTNO = T_ALL_DA.GetStrSQL("DEPTNO", "select DEPTNO from [sys_dept] where LINKID=(select top 1 COMPANYID from user_company where USERID='" + strUserID.Trim() + "')"); } strRULECONTENT = ds.Tables[0].Rows[0]["RULECONTENT"].ToString().Trim(); strRULECONTENT = strRULECONTENT.Replace("《COMPANY》", strCODENAME); strRULECONTENT = strRULECONTENT.Replace("《DEPT》", strDEPTNO); // iRULENOLENGTH = int.Parse(ds.Tables[0].Rows[0]["RULENOLENGTH"].ToString().Trim()); strCONTENT = strRULECONTENT + strRULEYEAR; //获取分公司的票号头字符 string tempBANKSHEAD = T_ALL_DA.GetStrSQL("BANKSHEAD", "SELECT TOP 1 BANKSHEAD FROM company WHERE GID='" + strCompanyID.Trim() + "'"); strCONTENT = tempBANKSHEAD + strCONTENT; // strRULENOLENGTH = T_ALL_DA.GetStrSQL(strfield, "select top 1 " + strfield + " from [op_Seai] where " + strfield + " like '" + strCONTENT.Trim() + "%' order by " + strfield + " DESC"); if (strRULENOLENGTH == "") { strRULENOLENGTH = "1"; } else { strRULENOLENGTH = strRULENOLENGTH.Replace(strCONTENT.Trim(), ""); inum = int.Parse(strRULENOLENGTH.Trim()); inum = inum + 1; strRULENOLENGTH = inum.ToString(); } int j = iRULENOLENGTH - strRULENOLENGTH.Length; for (int i = 1; i <= j; i++) { strRULENOLENGTH = "0" + strRULENOLENGTH; } // strCONTENT = strCONTENT + strRULENOLENGTH; return strCONTENT; } } } return ""; } #endregion #region 判断是否有费用 public static bool GetFeeCount(string BSNO) { var isfee = false; var strSql = new StringBuilder(); strSql.Append("Select count(*) as count "); strSql.Append(" from ch_fee "); strSql.Append(" where BSNO='" + BSNO+"'"); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { var evData = Convert.ToInt32(reader["count"]); if (evData > 0) { isfee = true; }; } reader.Close(); } return isfee; } #endregion #region 委托业务费用加锁 /// /// 委托业务费用加锁 /// /// 委托业务编号 /// 值等于1表示加锁成功 值不等于1表示加锁失败 public static int LockFeeStatus(string tempBSNO) { int iResult = 0; using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction)) { try { SqlParameter[] parms = new SqlParameter[] { new SqlParameter("@BSNO",SqlDbType.VarChar,100) }; parms[0].Value = tempBSNO; SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, "UPDATE op_Seai SET FEESTATUS = 1 WHERE BSNO = @BSNO", parms); sqlTran.Commit(); iResult = 1;//状态为1表示更新成功 } catch (Exception execError) { iResult = -1;//有异常,更新失败 sqlTran.Rollback(); iResult = -2;//更新异常,事务已回滚成功 throw execError; } finally { SqlHelper.CloseConnection(); } } return iResult; } #endregion #region 委托业务费用解锁 /// /// 委托业务费用解锁 /// /// 委托业务编号 /// 值等于1表示解锁成功 值不等于1表示解锁失败 public static int UnLockFeeStatus(string tempBSNO) { int iResult = 0; using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction)) { try { SqlParameter[] parms = new SqlParameter[] { new SqlParameter("@BSNO",SqlDbType.VarChar,100) }; parms[0].Value = tempBSNO; SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, "UPDATE op_Seai SET FEESTATUS =0 WHERE BSNO = @BSNO", parms); sqlTran.Commit(); iResult = 1;//状态为1表示更新成功 } catch (Exception execError) { iResult = -1;//有异常,更新失败 sqlTran.Rollback(); iResult = -2;//更新异常,事务已回滚成功 throw execError; } finally { SqlHelper.CloseConnection(); } } return iResult; } #endregion #region 海运进口生成需引入业务 static public List GetImpDataList(int start, int limit, string strCondition, string userid, string usercode, string companyid, string sort = null) { var strSql = new StringBuilder(); strSql.Append(@"SELECT * from (SELECT row_number() over ("); var sortstring = DatasetSort.Getsortstring(sort); if (!string.IsNullOrEmpty(sortstring)) { strSql.Append(" order by " + sortstring); } else { strSql.Append(" order by INPUTTIME desc,ETD desc"); } strSql.Append(@") as num , "); strSql.Append(" T.GID,T.BSNO,T.SEAIOP,T.SEAIBSNO,T.SUBCOMPANYID,dbo.GetISIMP(T.BSNO,T.GID) ISIMP,T.IMPTIME,T.INPUTBY,T.INPUTTIME"); strSql.Append(",S.MBLNO,S.HBLNO,S.CUSTNO,S.CUSTOMERNAME,S.BLTYPE,"); strSql.Append("S.SHIPPER,S.CONSIGNEE,S.NOTIFYPARTY,S.VESSEL,S.VOYNO,S.ETD,S.CLOSINGDATE,S.ETA,S.ATD,"); strSql.Append("S.PlACERECEIPT,S.PORTLOADID,S.PORTLOAD,S.PORTDISCHARGEID,S.PORTDISCHARGE,S.PLACEDELIVERYID,S.PLACEDELIVERY,S.DESTINATIONID,S.DESTINATION,S.COPYNOBILL,"); strSql.Append("S.NOBILL,S.ISSUETYPE,S.ISSUEDATE,S.ISSUEPLACE,S.BLFRT,S.PREPARDAT,S.PAYABLEAT,S.[SERVICE],S.MARKS,S.NOPKGS,S.[DESCRIPTION],S.GOODSNAME,"); strSql.Append("S.GROSSWEIGHT,S.MEASUREMENT,S.PKGS,S.KINDPKGS,S.KGS,S.CBM,"); strSql.Append("S.CARGOID,S.DCLASS,S.DUNNO,S.DPAGE,S.DLABEL,S.LINKMAN,"); strSql.Append("S.REEFERF,S.TEMPID,S.TEMPSET,S.TEMPMAX,S.TEMPMIN,S.HUMIDITY,S.HSCODE"); strSql.Append(",(select ShowName from [user] where GID=T.INPUTBY) as INPUTBYREF,(SELECT TOP 1 CUSTNO FROM OP_SEAI WHERE BSNO=T.SEAIBSNO) SEAICUSTNO "); strSql.Append(",(select ENNAME from [company] where GID=S.CORPID) as CORP,S.CORPID "); strSql.Append(" from OP_SEAETOSEAI T LEFT JOIN OP_SEAE S ON (S.BSNO=T.BSNO) "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" WHERE " + strCondition + " "); } // strSql.Append(@")as t "); strSql.Append(string.Format("where t.num>={0} and t.num<={1} ", start, start + limit)); // return SetImpData(strSql); } public static int getImpTotalCount(string strCondition, string userid, string usercode, string companyid) { StringBuilder strSql = new StringBuilder(); strSql.Append("select count(*) "); strSql.Append(" from OP_SEAETOSEAI "); strSql.Append(" I LEFT JOIN OP_SEAE S ON (S.BSNO=I.BSNO) "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" WHERE " + strCondition + " "); } int cnt = 0; Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { cnt = Convert.ToInt32(reader[0]); } } return cnt; } private static List SetImpData(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { MsOpSeaeToSeai data = new MsOpSeaeToSeai(); #region Set DB data to Object data.GID = Convert.ToString(reader["GID"]);//业务编号 data.BSNO = Convert.ToString(reader["BSNO"]);//业务编号 data.SEAIOP = Convert.ToString(reader["SEAIOP"]);//委托方式 data.SEAIBSNO = Convert.ToString(reader["SEAIBSNO"]);//主编号 data.CUSTNO = Convert.ToString(reader["CUSTNO"]);//委托编号 data.SEAICUSTNO = Convert.ToString(reader["SEAICUSTNO"]);//委托编号 data.MBLNO = Convert.ToString(reader["MBLNO"]);//主提单号 data.HBLNO = Convert.ToString(reader["HBLNO"]);//分提单号 data.SUBCOMPANYID = Convert.ToString(reader["SUBCOMPANYID"]);//放箱申请单号 if (reader["ISIMP"] != DBNull.Value) data.ISIMP = Convert.ToString(reader["ISIMP"]);//是否引入 if (reader["ETD"] != DBNull.Value) data.ETD = Convert.ToDateTime(reader["ETD"]).ToString("yyyy-MM-dd");//引入时间 data.INPUTBYREF = Convert.ToString(reader["INPUTBYREF"]);// 费用状态 if (reader["INPUTTIME"] != DBNull.Value) data.INPUTTIME = Convert.ToDateTime(reader["INPUTTIME"]).ToString("yyyy-MM-dd HH:mm:ss");//录入日期 data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);//委托单位 data.INPUTBY = Convert.ToString(reader["INPUTBY"]);//录入人 data.CORPID = Convert.ToString(reader["CORPID"]);//分公司代码 data.VESSEL = Convert.ToString(reader["VESSEL"]);//船名 data.VOYNO = Convert.ToString(reader["VOYNO"]);//航次 if (reader["ETD"] != DBNull.Value) data.ETD = Convert.ToDateTime(reader["ETD"]).ToString("yyyy-MM-dd");//到港日期 if (reader["ATD"] != DBNull.Value) data.ATD = Convert.ToDateTime(reader["ATD"]).ToString("yyyy-MM-dd");//到港日期 data.PORTLOADID = Convert.ToString(reader["PORTLOADID"]);//装货港代码 data.PORTLOAD = Convert.ToString(reader["PORTLOAD"]);//装货港 data.PORTDISCHARGEID = Convert.ToString(reader["PORTDISCHARGEID"]);//卸货港代码 data.PORTDISCHARGE = Convert.ToString(reader["PORTDISCHARGE"]);//卸货港 data.GOODSNAME = Convert.ToString(reader["GOODSNAME"]);//品名 if (reader["KGS"] != DBNull.Value) data.KGS = Convert.ToDecimal(reader["KGS"]);//毛重 if (reader["PKGS"] != DBNull.Value) data.PKGS = Convert.ToInt32(reader["PKGS"]);//件数 data.KINDPKGS = Convert.ToString(reader["KINDPKGS"]);//件数包装 data.BLTYPE = Convert.ToString(reader["BLTYPE"]);//装运方式 if (reader["CBM"] != DBNull.Value) data.CBM = Convert.ToDecimal(reader["CBM"]);//立方数/尺码 data.NOPKGS = Convert.ToString(reader["NOPKGS"]);//件数包装 if (reader["GROSSWEIGHT"] != DBNull.Value) data.GROSSWEIGHT = Convert.ToString(reader["GROSSWEIGHT"]);//货物毛重 if (reader["MEASUREMENT"] != DBNull.Value) data.MEASUREMENT = Convert.ToString(reader["MEASUREMENT"]);//货物尺码 data.DESCRIPTION = Convert.ToString(reader["DESCRIPTION"]);//货物描述 data.SHIPPER = Convert.ToString(reader["SHIPPER"]).Replace(@"\\\\", "\n").Replace(@"^", "\'");//发货人内容 data.CONSIGNEE = Convert.ToString(reader["CONSIGNEE"]).Replace(@"\\\\", "\n").Replace(@"^", "\'");//收货人内容 data.NOTIFYPARTY = Convert.ToString(reader["NOTIFYPARTY"]).Replace(@"\\\\", "\n").Replace(@"^", "\'");//通知人内容 if (reader["ETA"] != DBNull.Value) data.ETA = Convert.ToDateTime(reader["ETA"]).ToString("yyyy-MM-dd");//预抵日期 data.PLACERECEIPT = Convert.ToString(reader["PlACERECEIPT"]);//收货地 data.PLACEDELIVERYID = Convert.ToString(reader["PLACEDELIVERYID"]);//交货地代码 data.PLACEDELIVERY = Convert.ToString(reader["PLACEDELIVERY"]);//交货地 data.DESTINATIONID = Convert.ToString(reader["DESTINATIONID"]);//目的地代码 data.DESTINATION = Convert.ToString(reader["DESTINATION"]);//目的地 data.NOBILL = Convert.ToString(reader["NOBILL"]);//提单份数 data.COPYNOBILL = Convert.ToString(reader["COPYNOBILL"]);//提单份数 data.ISSUETYPE = Convert.ToString(reader["ISSUETYPE"]);//签单方式 if (reader["ISSUEDATE"] != DBNull.Value) data.ISSUEDATE = Convert.ToDateTime(reader["ISSUEDATE"]).ToString("yyyy-MM-dd");//预抵日期 data.ISSUEPLACE = Convert.ToString(reader["ISSUEPLACE"]);//签单地点 data.BLFRT = Convert.ToString(reader["BLFRT"]);//付费方式 data.PREPARDAT = Convert.ToString(reader["PREPARDAT"]);//预付地点 data.PAYABLEAT = Convert.ToString(reader["PAYABLEAT"]);//到付地点 data.SERVICE = Convert.ToString(reader["SERVICE"]);//运输条款 data.MARKS = Convert.ToString(reader["MARKS"]);//唛头 data.CARGOID = Convert.ToString(reader["CARGOID"]);//货物标识 data.DCLASS = Convert.ToString(reader["DCLASS"]);//危险品分类/等级 data.DUNNO = Convert.ToString(reader["DUNNO"]);//危险品编号 data.REEFERF = Convert.ToString(reader["REEFERF"]);//冷藏通风量 data.TEMPID = Convert.ToString(reader["TEMPID"]);//温度单位 data.TEMPSET = Convert.ToString(reader["TEMPSET"]);//设置温度 data.TEMPMAX = Convert.ToString(reader["TEMPMAX"]);//最高温度 data.TEMPMIN = Convert.ToString(reader["TEMPMIN"]);//最低温度 data.HUMIDITY = Convert.ToString(reader["HUMIDITY"]);//湿度 data.DPAGE = Convert.ToString(reader["DPAGE"]);//危险品页号 data.DLABEL = Convert.ToString(reader["DLABEL"]);//危险品标签 data.LINKMAN = Convert.ToString(reader["LINKMAN"]);//危险品联系人 data.HSCODE = Convert.ToString(reader["HSCODE"]);//HS编码 #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 权限范围 public static string GetRangDAStr(string tb, string userid, string username, string companyid) { string str = ""; var strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append(" VISIBLERANGE,OPERATERANGE,AUTHORITYID,VSSQL "); strSql.Append(" from VW_User_Authority "); strSql.Append(" where [NAME]='modSeaImportList' and USERID='" + userid + "' and ISDELETE=0"); string visiblerange = "4"; string operaterange = "4"; string AUTHORITYID = ""; string VSSQL = ""; Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { visiblerange = Convert.ToString(reader["VISIBLERANGE"]); operaterange = Convert.ToString(reader["OPERATERANGE"]); AUTHORITYID = Convert.ToString(reader["AUTHORITYID"]); VSSQL = Convert.ToString(reader["VSSQL"]); break; } reader.Close(); } if (visiblerange == "4") { str = " (OP='" + username + "' OR SALE='" + username + "' OR INPUTBY='" + username + "' or CUSTSERVICE='" + username + "' OR FRCUSTSERVICE='" + username + "' OR DOC='" + username + "')"; } else if (visiblerange == "3") { str = " (OP='" + username + "' OR SALE='" + username + "' OR INPUTBY='" + username + "' or CUSTSERVICE='" + username + "' OR FRCUSTSERVICE='" + username + "' OR DOC='" + username + "')"; } else if (visiblerange == "2") { var rangeDa = new RangeDA(); var deptid = rangeDa.GetDEPTGID(userid); str = " (OP in (select showname from vw_user where deptgid='" + deptid + "') OR SALE in (select showname from vw_user where deptgid='" + deptid + "') OR CUSTSERVICE in (select showname from vw_user where deptgid='" + deptid + "') " + " OR DOC in (select showname from vw_user where deptgid='" + deptid + "') OR FRCUSTSERVICE in (select showname from vw_user where deptgid='" + deptid + "') OR INPUTBY in (select showname from vw_user where deptgid='" + deptid + "'))"; } else if (visiblerange == "1") { str = " (UPPER(B.Corpid)='" + companyid + "' or B.SALECORPID='" + companyid + "') "; } else if (visiblerange == "5") { if (tb == "index") { var userstr = new StringBuilder(); userstr.Append(" select COMPANYID from user_authority_range_company where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1"); Database userdb = DatabaseFactory.CreateDatabase(); using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString())) { str = ""; while (reader.Read()) { if (str == "") { str = " (B.Corpid='" + Convert.ToString(reader["COMPANYID"]) + "' or B.SALECORPID='" + Convert.ToString(reader["COMPANYID"]) + "' "; } else { str = str + " or B.Corpid='" + Convert.ToString(reader["COMPANYID"]) + "' or B.SALECORPID='" + Convert.ToString(reader["COMPANYID"]) + "'"; }; } str = str + ")"; reader.Close(); } } else { str = " (UPPER(B.Corpid)='" + companyid + "' or B.SALECORPID='" + companyid + "') "; } } else if (visiblerange == "6") { if (tb == "index") { var opstr = ""; var userstr = new StringBuilder(); userstr.Append(" select OPID,(select SHOWNAME from [user] where GID=user_authority_range_op.OPID) SHOWNAME from user_authority_range_op where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1"); Database userdb = DatabaseFactory.CreateDatabase(); using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString())) { while (reader.Read()) { if (opstr == "") { opstr = " ('" + Convert.ToString(reader["SHOWNAME"]) + "'"; } else { opstr = opstr + ",'" + Convert.ToString(reader["SHOWNAME"]) + "'"; }; } if (opstr != "") opstr = opstr + ")"; reader.Close(); } if (opstr == "") opstr = "('" + username + "')"; str = " (OP in " + opstr + " or SALE in " + opstr + " or CUSTSERVICE IN " + opstr + " or DOC IN " + opstr + " or FRCUSTSERVICE IN " + opstr + " or INPUTBY IN " + opstr + ")"; } else { str = " (UPPER(B.Corpid)='" + companyid + "' or B.SALECORPID='" + companyid + "') "; } } else if (visiblerange == "0") { str = " 1=1 "; } VSSQL = VSSQL.Trim(); if (!string.IsNullOrEmpty(VSSQL)) { if (!string.IsNullOrEmpty(str)) { str = str + " and (" + VSSQL + ") "; } else { str = " (" + VSSQL + ") "; } } return str; } public static string GetSaleRangDAStr(string tb, string userid, string username, string companyid) { string str = ""; var strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append(" VISIBLERANGE,OPERATERANGE,AUTHORITYID,VSSQL "); strSql.Append(" from VW_User_Authority "); strSql.Append(" where [NAME]='modSeaiSaleList' and USERID='" + userid + "' and ISDELETE=0"); string visiblerange = "4"; string operaterange = "4"; string AUTHORITYID = ""; string VSSQL = ""; Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { visiblerange = Convert.ToString(reader["VISIBLERANGE"]); operaterange = Convert.ToString(reader["OPERATERANGE"]); AUTHORITYID = Convert.ToString(reader["AUTHORITYID"]); VSSQL = Convert.ToString(reader["VSSQL"]); break; } reader.Close(); } if (visiblerange == "4") { str = " SALE='" + username + "' "; } else if (visiblerange == "3") { str = " SALE='" + username + "' "; } else if (visiblerange == "2") { if (tb == "index") { var rangeDa = new RangeDA(); var deptname = rangeDa.GetDEPTNAME(userid); var userstr = new StringBuilder(); userstr.Append(" select SHOWNAME from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')"); Database userdb = DatabaseFactory.CreateDatabase(); using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString())) { str = ""; while (reader.Read()) { if (str == "") { str = " (SALE='" + Convert.ToString(reader["SHOWNAME"]) + "'"; } else { str = str + " OR SALE='" + Convert.ToString(reader["SHOWNAME"]) + "'"; }; } str = str + ")"; reader.Close(); } } else { str = " UPPER(Corpid)='" + companyid + "'"; } } else if (visiblerange == "5") { if (tb == "index") { var userstr = new StringBuilder(); userstr.Append(" select COMPANYID from user_authority_range_company where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1"); Database userdb = DatabaseFactory.CreateDatabase(); using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString())) { str = ""; while (reader.Read()) { if (str == "") { str = " (B.Corpid='" + Convert.ToString(reader["COMPANYID"]) + "' or B.SALECORPID='" + Convert.ToString(reader["COMPANYID"]) + "' "; } else { str = str + " or B.Corpid='" + Convert.ToString(reader["COMPANYID"]) + "' or B.SALECORPID='" + Convert.ToString(reader["COMPANYID"]) + "'"; }; } str = str + ")"; reader.Close(); } } else { str = " UPPER(Corpid)='" + companyid + "'"; } } else if (visiblerange == "6") { if (tb == "index") { var opstr = ""; var userstr = new StringBuilder(); userstr.Append(" select OPID,(select SHOWNAME from [user] where GID=user_authority_range_op.OPID) SHOWNAME from user_authority_range_op where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1"); Database userdb = DatabaseFactory.CreateDatabase(); using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString())) { while (reader.Read()) { if (opstr == "") { opstr = " ('" + Convert.ToString(reader["SHOWNAME"]) + "'"; } else { opstr = opstr + ",'" + Convert.ToString(reader["SHOWNAME"]) + "'"; }; } if (opstr != "") opstr = opstr + ")"; reader.Close(); } if (opstr == "") opstr = "('" + username + "')"; str = " (SALE in " + opstr + ")"; } else { str = " UPPER(Corpid)='" + companyid + "'"; } } else if (visiblerange == "1") { str = " (UPPER(B.Corpid)='" + companyid + "' or B.SALECORPID='" + companyid + "') "; } else if (visiblerange == "0") { str = " 1=1 "; } VSSQL = VSSQL.Trim(); if (!string.IsNullOrEmpty(VSSQL)) { if (!string.IsNullOrEmpty(str)) { str = str + " and (" + VSSQL + ") "; } else { str = " (" + VSSQL + ") "; } } return str; } #endregion #region 新仓储出入库 按报关单号显示 static public List GetOP_WMS_CHANGE_BILL(string CUSTOMNO) { var cdc = new CommonDataContext(); var result = cdc.VW_OP_WMS_CHANGE_BILL.Where(x => x.CUSTOMNO == CUSTOMNO).OrderBy(o=>o.DODATE).ThenBy(o=>o.CHANGETYPE).ToList(); return result; } #endregion } }