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

1543 lines
78 KiB
C#

This file contains ambiguous Unicode characters!

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

using System;
using System.Data;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Globalization;
using System.Xml;
using DSWeb.MvcShipping.Models.MsOpSeaeEdi;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.EntityDA;
using DSWeb.Areas.CommMng.Models;
using HcUtility.Comm;
using System.IO;
using DSWeb.MvcShipping.Models.FtpSet;
using DSWeb.MvcShipping.Models.MsOpSeaeBill;
using DSWeb.MvcShipping.Models.MsOpSeae;
using DSWeb.MvcShipping.Models.CompanyDef;
using DSWeb.MvcShipping.DAL.DsSendmail;
using HcUtility.Core;
using DSWeb.MvcShipping.DAL.MsSysParamSet;
using Microsoft.Office.Interop.Excel;
using System.Web.Configuration;
using DSWeb.Areas.MvcShipping.Comm;
using DSWeb.MvcShipping.Helper;
using System.Linq;
namespace DSWeb.MvcShipping.DAL.MsOpSeaeEdiDAL
{
public class MsOpSeaeEdiDAL
{
#region 查询
static public List<MsOpSeaeEdi> 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 [MFNO],[BSNO],[MASTERNO],[EDITYPE],[EDISTATUS],[INPUTBY],[INPUTDATE],[CUSTNO],[MBLNO],[HBLNO],SHIPPERCODE,[SHIPPERNAME]");
strSql.Append(",[SHIPPERADDR1],[SHIPPERADDR2],[SHIPPERADDR3],[SHIPPERCITY],[SHIPPERPROVINCE],[SHIPPERPOSTCODE],[SHIPPERCOUNTRY]");
strSql.Append(",[SHIPPERATTN],[SHIPPERTEL],SHIPPEREMAIL,CONSIGNEECODE,[CONSIGNEENAME],[CONSIGNEEADDR1],[CONSIGNEEADDR2],[CONSIGNEEADDR3] ,[CONSIGNEECITY]");
strSql.Append(",[CONSIGNEEPROVINCE],[CONSIGNEEPOSTCODE],[CONSIGNEECOUNTRY],[CONSIGNEEATTN],[CONSIGNEETEL],CONSIGNEEEMAIL,NOTIFYPARTYCODE,[NOTIFYPARTYNAME]");
strSql.Append(",[NOTIFYPARTYADDR1] ,[NOTIFYPARTYADDR2],[NOTIFYPARTYADDR3],[NOTIFYPARTYCITY],[NOTIFYPARTYPROVINCE],[NOTIFYPARTYPOSTCODE]");
strSql.Append(",[NOTIFYPARTYCOUNTRY],[NOTIFYPARTYATTN],[NOTIFYPARTYTEL],[NOTIFYPARTYEMAIL],[NOTIFYPARTY2NAME],[NOTIFYPARTY2ADDR1],[NOTIFYPARTY2ADDR2]");
strSql.Append(",[NOTIFYPARTY2ADDR3],[NOTIFYPARTY2CITY],[NOTIFYPARTY2PROVINCE],[NOTIFYPARTY2POSTCODE],[NOTIFYPARTY2COUNTRY]");
strSql.Append(",[NOTIFYPARTY2ATTN],[NOTIFYPARTY2TEL],[SHIPPER],[CONSIGNEE],[NOTIFYPARTY],[VESSEL],[VOYNO],[ETD],[PORTLOADID]");
strSql.Append(",[PORTLOAD],[PORTDISCHARGEID],[PORTDISCHARGE],[PLACEDELIVERYID],[PLACEDELIVERY],[DESTINATIONID],[DESTINATION],PLACERECEIPT,PLACERECEIPTID");
strSql.Append(",[SERVICE],[MARKS],[DESCRIPTION],[PKGS],[KINDPKGS],[KGS],[CBM],[CARGOID],[DCLASS],[DUNNO],[REEFERF],[TEMPID]");
strSql.Append(",[TEMPSET],[TEMPMAX],[TEMPMIN],[FREIGHTAGMNO],[HUMIDITY],[SHIPIMO],[CARRIERID],[ORDERNO],[FILEROLE],[PACKINGTYPE]");
strSql.Append(",[SHIPSERVICENO],[TRANSTYPE],[FILETYPE],[ISLASTHBL],[ETA],[BLFRT],[ISSUEPLACE],[ETDTIME],[AGENTID],[CNTRSEALNO]");
strSql.Append(",[SENDTIME],[STATUS],[YARD],[CHANGERESON],[FORWARDER],[CARRIER],[REMARKS],[CNTRNO],[CTNNUM],[CORPID],DPAGE,DLABEL,LINKMAN,ISSAMECONSIGNEE");
strSql.Append(",[DCARRIER],[ARVESSEL],[ARVOYNO],[ARSHIPIMO],[ARSHIPSERVICENO],FIRSTPORTOFCALLID,FIRSTPORTOFCALLDATE,LASTPORTOFCALLID,LASTPORTOFCALLDATE,MANIFESTSTATUS from OP_SEAE_EDI 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 INPUTDATE 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 [MFNO],[BSNO],[MASTERNO],[EDITYPE],[EDISTATUS],[INPUTBY],[INPUTDATE],[CUSTNO],[MBLNO],[HBLNO],[SHIPPERNAME]");
strSql.Append(",[SHIPPERADDR1],[SHIPPERADDR2],[SHIPPERADDR3],[SHIPPERCITY],[SHIPPERPROVINCE],[SHIPPERPOSTCODE],[SHIPPERCOUNTRY]");
strSql.Append(",[SHIPPERATTN],[SHIPPERTEL],[CONSIGNEENAME],[CONSIGNEEADDR1],[CONSIGNEEADDR2],[CONSIGNEEADDR3] ,[CONSIGNEECITY]");
strSql.Append(",[CONSIGNEEPROVINCE],[CONSIGNEEPOSTCODE],[CONSIGNEECOUNTRY],[CONSIGNEEATTN],[CONSIGNEETEL],[NOTIFYPARTYNAME]");
strSql.Append(",[NOTIFYPARTYADDR1] ,[NOTIFYPARTYADDR2],[NOTIFYPARTYADDR3],[NOTIFYPARTYCITY],[NOTIFYPARTYPROVINCE],[NOTIFYPARTYPOSTCODE]");
strSql.Append(",[NOTIFYPARTYCOUNTRY],[NOTIFYPARTYATTN],[NOTIFYPARTYTEL],[NOTIFYPARTY2NAME],[NOTIFYPARTY2ADDR1],[NOTIFYPARTY2ADDR2]");
strSql.Append(",[NOTIFYPARTY2ADDR3],[NOTIFYPARTY2CITY],[NOTIFYPARTY2PROVINCE],[NOTIFYPARTY2POSTCODE],[NOTIFYPARTY2COUNTRY]");
strSql.Append(",[NOTIFYPARTY2ATTN],[NOTIFYPARTY2TEL],[SHIPPER],[CONSIGNEE],[NOTIFYPARTY],[VESSEL],[VOYNO],[ETD],[PORTLOADID]");
strSql.Append(",[PORTLOAD],[PORTDISCHARGEID],[PORTDISCHARGE],[PLACEDELIVERYID],[PLACEDELIVERY],[DESTINATIONID],[DESTINATION],PLACERECEIPT,PLACERECEIPTID");
strSql.Append(",[SERVICE],[MARKS],[DESCRIPTION],[PKGS],[KINDPKGS],[KGS],[CBM],[CARGOID],[DCLASS],[DUNNO],[REEFERF],[TEMPID]");
strSql.Append(",[TEMPSET],[TEMPMAX],[TEMPMIN],[FREIGHTAGMNO],[HUMIDITY],[SHIPIMO],[CARRIERID],[ORDERNO],[FILEROLE],[PACKINGTYPE]");
strSql.Append(",[SHIPSERVICENO],[TRANSTYPE],[FILETYPE],[ISLASTHBL],[ETA],[BLFRT],[ISSUEPLACE],[ETDTIME],[AGENTID],[CNTRSEALNO]");
strSql.Append(",[SENDTIME],[STATUS],[YARD],[CHANGERESON],[FORWARDER],[CARRIER],[REMARKS],[CNTRNO],[CTNNUM],[CORPID],DPAGE,DLABEL,LINKMAN,ISSAMECONSIGNEE");
strSql.Append(",[DCARRIER],[ARVESSEL],[ARVOYNO],[ARSHIPIMO],[ARSHIPSERVICENO],FIRSTPORTOFCALLID,FIRSTPORTOFCALLDATE,LASTPORTOFCALLID,LASTPORTOFCALLDATE,MANIFESTSTATUS from OP_SEAE_EDI 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 INPUTDATE desc");
}
return strSql.ToString();
}
static public MsOpSeaeEdi GetData(string condition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT [MFNO],[BSNO],[MASTERNO],[EDITYPE],[EDISTATUS],[INPUTBY],[INPUTDATE],[CUSTNO],[MBLNO],[HBLNO],SHIPPERCODE,[SHIPPERNAME]");
strSql.Append(",[SHIPPERADDR1],[SHIPPERADDR2],[SHIPPERADDR3],[SHIPPERCITY],[SHIPPERPROVINCE],[SHIPPERPOSTCODE],[SHIPPERCOUNTRY]");
strSql.Append(",[SHIPPERATTN],[SHIPPERTEL],SHIPPEREMAIL,CONSIGNEECODE,[CONSIGNEENAME],[CONSIGNEEADDR1],[CONSIGNEEADDR2],[CONSIGNEEADDR3] ,[CONSIGNEECITY]");
strSql.Append(",[CONSIGNEEPROVINCE],[CONSIGNEEPOSTCODE],[CONSIGNEECOUNTRY],[CONSIGNEEATTN],[CONSIGNEETEL],CONSIGNEEEMAIL,NOTIFYPARTYCODE,[NOTIFYPARTYNAME]");
strSql.Append(",[NOTIFYPARTYADDR1] ,[NOTIFYPARTYADDR2],[NOTIFYPARTYADDR3],[NOTIFYPARTYCITY],[NOTIFYPARTYPROVINCE],[NOTIFYPARTYPOSTCODE]");
strSql.Append(",[NOTIFYPARTYCOUNTRY],[NOTIFYPARTYATTN],[NOTIFYPARTYTEL],NOTIFYPARTYEMAIL,[NOTIFYPARTY2NAME],[NOTIFYPARTY2ADDR1],[NOTIFYPARTY2ADDR2]");
strSql.Append(",[NOTIFYPARTY2ADDR3],[NOTIFYPARTY2CITY],[NOTIFYPARTY2PROVINCE],[NOTIFYPARTY2POSTCODE],[NOTIFYPARTY2COUNTRY]");
strSql.Append(",[NOTIFYPARTY2ATTN],[NOTIFYPARTY2TEL],[SHIPPER],[CONSIGNEE],[NOTIFYPARTY],[VESSEL],[VOYNO],[ETD],[PORTLOADID]");
strSql.Append(",[PORTLOAD],[PORTDISCHARGEID],[PORTDISCHARGE],[PLACEDELIVERYID],[PLACEDELIVERY],[DESTINATIONID],[DESTINATION],PLACERECEIPT,PLACERECEIPTID");
strSql.Append(",[SERVICE],[MARKS],[DESCRIPTION],[PKGS],[KINDPKGS],[KGS],[CBM],[CARGOID],[DCLASS],[DUNNO],[REEFERF],[TEMPID]");
strSql.Append(",[TEMPSET],[TEMPMAX],[TEMPMIN],[FREIGHTAGMNO],[HUMIDITY],[SHIPIMO],[CARRIERID],[ORDERNO],[FILEROLE],[PACKINGTYPE]");
strSql.Append(",[SHIPSERVICENO],[TRANSTYPE],[FILETYPE],[ISLASTHBL],[ETA],[BLFRT],[ISSUEPLACE],[ETDTIME],[AGENTID],[CNTRSEALNO]");
strSql.Append(",[SENDTIME],[STATUS],[YARD],[CHANGERESON],[FORWARDER],[CARRIER],[REMARKS],[CNTRNO],[CTNNUM],[CORPID],DPAGE,DLABEL,LINKMAN,ISSAMECONSIGNEE");
strSql.Append(",[DCARRIER],[ARVESSEL],[ARVOYNO],[ARSHIPIMO],[ARSHIPSERVICENO],FIRSTPORTOFCALLID,FIRSTPORTOFCALLDATE,LASTPORTOFCALLID,LASTPORTOFCALLDATE,MANIFESTSTATUS from OP_SEAE_EDI B");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" where " + condition);
}
var list=SetData(strSql);
if (list.Count > 0)
return list[0];
return new MsOpSeaeEdi();
}
private static List<MsOpSeaeEdi> SetData(StringBuilder strSql)
{
var headList = new List<MsOpSeaeEdi>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsOpSeaeEdi data = new MsOpSeaeEdi();
#region Set DB data to Object
data.MFNO = Convert.ToString(reader["MFNO"]);//委托方式
data.BSNO = Convert.ToString(reader["BSNO"]);//业务编号
data.MASTERNO = Convert.ToString(reader["MASTERNO"]);//主编号
data.EDITYPE = Convert.ToString(reader["EDITYPE"]);// 业务状态
data.EDISTATUS = Convert.ToString(reader["EDISTATUS"]);// 费用状态
data.INPUTBY = Convert.ToString(reader["INPUTBY"]);// 业务状态
data.INPUTDATE = Convert.ToString(reader["INPUTDATE"]);// 费用状态
data.CUSTNO = Convert.ToString(reader["CUSTNO"]);//委托编号
data.MBLNO = Convert.ToString(reader["MBLNO"]);//主提单号
data.HBLNO = Convert.ToString(reader["HBLNO"]);//分提单号
data.SHIPPERCODE = Convert.ToString(reader["SHIPPERCODE"]);//发货人
data.SHIPPERNAME = Convert.ToString(reader["SHIPPERNAME"]);//发货人
data.SHIPPERADDR1 = Convert.ToString(reader["SHIPPERADDR1"]);//发货人
data.SHIPPERADDR2 = Convert.ToString(reader["SHIPPERADDR2"]);//发货人
data.SHIPPERADDR3 = Convert.ToString(reader["SHIPPERADDR3"]);//发货人
data.SHIPPERCITY = Convert.ToString(reader["SHIPPERCITY"]);//发货人
data.SHIPPERPROVINCE = Convert.ToString(reader["SHIPPERPROVINCE"]);//发货人
data.SHIPPERPOSTCODE = Convert.ToString(reader["SHIPPERPOSTCODE"]);//发货人
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.CONSIGNEENAME = Convert.ToString(reader["CONSIGNEENAME"]);//收货人
data.CONSIGNEEADDR1 = Convert.ToString(reader["CONSIGNEEADDR1"]);//收货人
data.CONSIGNEEADDR2 = Convert.ToString(reader["CONSIGNEEADDR2"]);//收货人
data.CONSIGNEEADDR3 = Convert.ToString(reader["CONSIGNEEADDR3"]);//收货人
data.CONSIGNEECITY = Convert.ToString(reader["CONSIGNEECITY"]);//收货人
data.CONSIGNEEPROVINCE = Convert.ToString(reader["CONSIGNEEPROVINCE"]);//收货人
data.CONSIGNEEPOSTCODE = Convert.ToString(reader["CONSIGNEEPOSTCODE"]);//收货人
data.CONSIGNEECOUNTRY = Convert.ToString(reader["CONSIGNEECOUNTRY"]);//收货人
data.CONSIGNEEATTN = Convert.ToString(reader["CONSIGNEEATTN"]);//收货人
data.CONSIGNEETEL = Convert.ToString(reader["CONSIGNEETEL"]);//收货人
data.CONSIGNEEEMAIL = Convert.ToString(reader["CONSIGNEEEMAIL"]);//收货人
if (reader["ISSAMECONSIGNEE"] != DBNull.Value)
data.ISSAMECONSIGNEE = Convert.ToBoolean(reader["ISSAMECONSIGNEE"]);//同收货人
data.NOTIFYPARTYCODE = Convert.ToString(reader["NOTIFYPARTYCODE"]);//通知人
data.NOTIFYPARTYNAME = Convert.ToString(reader["NOTIFYPARTYNAME"]);//通知人
data.NOTIFYPARTYADDR1 = Convert.ToString(reader["NOTIFYPARTYADDR1"]);//通知人
data.NOTIFYPARTYADDR2 = Convert.ToString(reader["NOTIFYPARTYADDR2"]);//通知人
data.NOTIFYPARTYADDR3 = Convert.ToString(reader["NOTIFYPARTYADDR3"]);//通知人
data.NOTIFYPARTYCITY = Convert.ToString(reader["NOTIFYPARTYCITY"]);//通知人
data.NOTIFYPARTYPROVINCE = Convert.ToString(reader["NOTIFYPARTYPROVINCE"]);//通知人
data.NOTIFYPARTYPOSTCODE = Convert.ToString(reader["NOTIFYPARTYPOSTCODE"]);//通知人
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.NOTIFYPARTY2NAME = Convert.ToString(reader["NOTIFYPARTY2NAME"]);//通知人
data.NOTIFYPARTY2ADDR1 = Convert.ToString(reader["NOTIFYPARTY2ADDR1"]);//通知人
data.NOTIFYPARTY2ADDR2 = Convert.ToString(reader["NOTIFYPARTY2ADDR2"]);//通知人
data.NOTIFYPARTY2ADDR3 = Convert.ToString(reader["NOTIFYPARTY2ADDR3"]);//通知人
data.NOTIFYPARTY2CITY = Convert.ToString(reader["NOTIFYPARTY2CITY"]);//通知人
data.NOTIFYPARTY2PROVINCE = Convert.ToString(reader["NOTIFYPARTY2PROVINCE"]);//通知人
data.NOTIFYPARTY2POSTCODE = Convert.ToString(reader["NOTIFYPARTY2POSTCODE"]);//通知人
data.NOTIFYPARTY2COUNTRY = Convert.ToString(reader["NOTIFYPARTY2COUNTRY"]);//通知人
data.NOTIFYPARTY2ATTN = Convert.ToString(reader["NOTIFYPARTY2ATTN"]);//通知人
data.NOTIFYPARTY2TEL = Convert.ToString(reader["NOTIFYPARTY2TEL"]);//通知人
data.SHIPPER = Convert.ToString(reader["SHIPPER"]);//发货人内容
data.CONSIGNEE = Convert.ToString(reader["CONSIGNEE"]);//收货人内容
data.NOTIFYPARTY = Convert.ToString(reader["NOTIFYPARTY"]);//通知人内容
data.VESSEL = Convert.ToString(reader["VESSEL"]);//船名
data.VOYNO = Convert.ToString(reader["VOYNO"]);//航次
if (Convert.ToString(reader["EDITYPE"]) == "CN")
{
if (reader["ETD"] != DBNull.Value)
data.ETD = Convert.ToDateTime(reader["ETD"]).ToString("yyyy-MM-dd");//到港日期
}
else
if (reader["ETD"] != DBNull.Value)
data.ETD = Convert.ToDateTime(reader["ETD"]).ToString("yyyy-MM-dd HH:mm:ss");//到港日期
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.PLACEDELIVERYID = Convert.ToString(reader["PLACEDELIVERYID"]);//交货地代码
data.PLACEDELIVERY = Convert.ToString(reader["PLACEDELIVERY"]);//交货地
data.DESTINATIONID = Convert.ToString(reader["DESTINATIONID"]);//目的地代码
data.DESTINATION = Convert.ToString(reader["DESTINATION"]);//目的地
data.PLACERECEIPTID = Convert.ToString(reader["PLACERECEIPTID"]);//收货地代码
data.PLACERECEIPT = Convert.ToString(reader["PLACERECEIPT"]);//收货地
data.SERVICE = Convert.ToString(reader["SERVICE"]);//运输条款
data.MARKS = Convert.ToString(reader["MARKS"]);//唛头
data.DESCRIPTION = Convert.ToString(reader["DESCRIPTION"]);//货物描述
if (reader["PKGS"] != DBNull.Value)
data.PKGS = Convert.ToInt32(reader["PKGS"]);//件数
data.KINDPKGS = Convert.ToString(reader["KINDPKGS"]);//件数包装
if (reader["KGS"] != DBNull.Value)
data.KGS = Convert.ToDecimal(reader["KGS"]);//毛重
if (reader["CBM"] != DBNull.Value)
data.CBM = Convert.ToDecimal(reader["CBM"]);//立方数/尺码
data.CARGOID = Convert.ToString(reader["CARGOID"]);//货物标识
data.DCLASS = Convert.ToString(reader["DCLASS"]);//危险品分类/等级
data.DUNNO = Convert.ToString(reader["DUNNO"]);//危险品编号
data.DPAGE = Convert.ToString(reader["DPAGE"]);//危险品页号
data.DLABEL = Convert.ToString(reader["DLABEL"]);//危险品标签
data.LINKMAN = Convert.ToString(reader["LINKMAN"]);//危险品联系人
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.FREIGHTAGMNO = Convert.ToString(reader["FREIGHTAGMNO"]);//提单份数
data.HUMIDITY = Convert.ToString(reader["HUMIDITY"]);//预付地点
data.SHIPIMO = Convert.ToString(reader["SHIPIMO"]);//到付地点
data.CARRIERID = Convert.ToString(reader["CARRIERID"]);//航线
data.ORDERNO = Convert.ToString(reader["ORDERNO"]);//订舱编号
data.FILEROLE = Convert.ToString(reader["FILEROLE"]);//发票号
data.PACKINGTYPE = Convert.ToString(reader["PACKINGTYPE"]);//装运类型
data.SHIPSERVICENO = Convert.ToString(reader["SHIPSERVICENO"]);//
data.TRANSTYPE = Convert.ToString(reader["TRANSTYPE"]);//
data.FILETYPE = Convert.ToString(reader["FILETYPE"]);//
if (reader["ISLASTHBL"] != DBNull.Value)
data.ISLASTHBL = Convert.ToBoolean(reader["ISLASTHBL"]);//是否最后一票分票
if (reader["ETA"] != DBNull.Value)
data.ETA = Convert.ToDateTime(reader["ETA"]).ToString("yyyy-MM-dd");//预抵日期
data.BLFRT = Convert.ToString(reader["BLFRT"]);//付费方式
data.ISSUEPLACE = Convert.ToString(reader["ISSUEPLACE"]);//签单地点
data.ETDTIME = Convert.ToString(reader["ETDTIME"]);//开船时间
data.AGENTID = Convert.ToString(reader["AGENTID"]);//代理
data.CNTRSEALNO = Convert.ToString(reader["CNTRSEALNO"]);//箱号封号
if (reader["SENDTIME"] != DBNull.Value)
data.SENDTIME = Convert.ToDateTime(reader["SENDTIME"]).ToString("yyyy-MM-dd");//发送日期
data.STATUS = Convert.ToString(reader["STATUS"]);//
data.YARD = Convert.ToString(reader["YARD"]);//场站/靠泊码头
data.CHANGERESON = Convert.ToString(reader["CHANGERESON"]);//更改原因
data.FORWARDER = Convert.ToString(reader["FORWARDER"]);//订舱公司
data.CARRIER = Convert.ToString(reader["CARRIER"]);//船公司
data.DCARRIER = Convert.ToString(reader["DCARRIER"]);//船公司
data.CORPID = Convert.ToString(reader["CORPID"]);//分公司代码
data.CNTRNO = Convert.ToString(reader["CNTRNO"]);//集装箱全部内容
data.REMARKS = Convert.ToString(reader["REMARKS"]);//
if (reader["CTNNUM"] != DBNull.Value)
data.CTNNUM = Convert.ToInt32(reader["CTNNUM"]);//件数
data.ARVESSEL = Convert.ToString(reader["ARVESSEL"]);//船名
data.ARVOYNO = Convert.ToString(reader["ARVOYNO"]);//航次
data.ARSHIPIMO = Convert.ToString(reader["ARSHIPIMO"]);//到付地点
data.ARSHIPSERVICENO = Convert.ToString(reader["ARSHIPSERVICENO"]);//
data.FIRSTPORTOFCALLID = Convert.ToString(reader["FIRSTPORTOFCALLID"]);//
if (reader["FIRSTPORTOFCALLDATE"] != DBNull.Value)
data.FIRSTPORTOFCALLDATE = Convert.ToDateTime(reader["FIRSTPORTOFCALLDATE"]).ToString("yyyy-MM-dd");
data.LASTPORTOFCALLID = Convert.ToString(reader["LASTPORTOFCALLID"]);//
if (reader["LASTPORTOFCALLDATE"] != DBNull.Value)
data.LASTPORTOFCALLDATE = Convert.ToDateTime(reader["LASTPORTOFCALLDATE"]).ToString("yyyy-MM-dd");
data.MANIFESTSTATUS = Convert.ToString(reader["MANIFESTSTATUS"]);//
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
private static List<MsOpSeaeEdi> SetData(StringBuilder strSql, Database db)
{
var headList = new List<MsOpSeaeEdi>();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsOpSeaeEdi data = new MsOpSeaeEdi();
#region Set DB data to Object
data.MFNO = Convert.ToString(reader["MFNO"]);//委托方式
data.BSNO = Convert.ToString(reader["BSNO"]);//业务编号
data.MASTERNO = Convert.ToString(reader["MASTERNO"]);//主编号
data.EDITYPE = Convert.ToString(reader["EDITYPE"]);// 业务状态
data.EDISTATUS = Convert.ToString(reader["EDISTATUS"]);// 费用状态
data.INPUTBY = Convert.ToString(reader["INPUTBY"]);// 业务状态
data.INPUTDATE = Convert.ToString(reader["INPUTDATE"]);// 费用状态
data.CUSTNO = Convert.ToString(reader["CUSTNO"]);//委托编号
data.MBLNO = Convert.ToString(reader["MBLNO"]);//主提单号
data.HBLNO = Convert.ToString(reader["HBLNO"]);//分提单号
data.SHIPPERCODE = Convert.ToString(reader["SHIPPERCODE"]);//发货人
data.SHIPPERNAME = Convert.ToString(reader["SHIPPERNAME"]);//发货人
data.SHIPPERADDR1 = Convert.ToString(reader["SHIPPERADDR1"]);//发货人
data.SHIPPERADDR2 = Convert.ToString(reader["SHIPPERADDR2"]);//发货人
data.SHIPPERADDR3 = Convert.ToString(reader["SHIPPERADDR3"]);//发货人
data.SHIPPERCITY = Convert.ToString(reader["SHIPPERCITY"]);//发货人
data.SHIPPERPROVINCE = Convert.ToString(reader["SHIPPERPROVINCE"]);//发货人
data.SHIPPERPOSTCODE = Convert.ToString(reader["SHIPPERPOSTCODE"]);//发货人
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.CONSIGNEENAME = Convert.ToString(reader["CONSIGNEENAME"]);//收货人
data.CONSIGNEEADDR1 = Convert.ToString(reader["CONSIGNEEADDR1"]);//收货人
data.CONSIGNEEADDR2 = Convert.ToString(reader["CONSIGNEEADDR2"]);//收货人
data.CONSIGNEEADDR3 = Convert.ToString(reader["CONSIGNEEADDR3"]);//收货人
data.CONSIGNEECITY = Convert.ToString(reader["CONSIGNEECITY"]);//收货人
data.CONSIGNEEPROVINCE = Convert.ToString(reader["CONSIGNEEPROVINCE"]);//收货人
data.CONSIGNEEPOSTCODE = Convert.ToString(reader["CONSIGNEEPOSTCODE"]);//收货人
data.CONSIGNEECOUNTRY = Convert.ToString(reader["CONSIGNEECOUNTRY"]);//收货人
data.CONSIGNEEATTN = Convert.ToString(reader["CONSIGNEEATTN"]);//收货人
data.CONSIGNEETEL = Convert.ToString(reader["CONSIGNEETEL"]);//收货人
data.CONSIGNEEEMAIL = Convert.ToString(reader["CONSIGNEEEMAIL"]);//收货人
if (reader["ISSAMECONSIGNEE"] != DBNull.Value)
data.ISSAMECONSIGNEE = Convert.ToBoolean(reader["ISSAMECONSIGNEE"]);//同收货人
data.NOTIFYPARTYCODE = Convert.ToString(reader["NOTIFYPARTYCODE"]);//通知人
data.NOTIFYPARTYNAME = Convert.ToString(reader["NOTIFYPARTYNAME"]);//通知人
data.NOTIFYPARTYADDR1 = Convert.ToString(reader["NOTIFYPARTYADDR1"]);//通知人
data.NOTIFYPARTYADDR2 = Convert.ToString(reader["NOTIFYPARTYADDR2"]);//通知人
data.NOTIFYPARTYADDR3 = Convert.ToString(reader["NOTIFYPARTYADDR3"]);//通知人
data.NOTIFYPARTYCITY = Convert.ToString(reader["NOTIFYPARTYCITY"]);//通知人
data.NOTIFYPARTYPROVINCE = Convert.ToString(reader["NOTIFYPARTYPROVINCE"]);//通知人
data.NOTIFYPARTYPOSTCODE = Convert.ToString(reader["NOTIFYPARTYPOSTCODE"]);//通知人
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.NOTIFYPARTY2NAME = Convert.ToString(reader["NOTIFYPARTY2NAME"]);//通知人
data.NOTIFYPARTY2ADDR1 = Convert.ToString(reader["NOTIFYPARTY2ADDR1"]);//通知人
data.NOTIFYPARTY2ADDR2 = Convert.ToString(reader["NOTIFYPARTY2ADDR2"]);//通知人
data.NOTIFYPARTY2ADDR3 = Convert.ToString(reader["NOTIFYPARTY2ADDR3"]);//通知人
data.NOTIFYPARTY2CITY = Convert.ToString(reader["NOTIFYPARTY2CITY"]);//通知人
data.NOTIFYPARTY2PROVINCE = Convert.ToString(reader["NOTIFYPARTY2PROVINCE"]);//通知人
data.NOTIFYPARTY2POSTCODE = Convert.ToString(reader["NOTIFYPARTY2POSTCODE"]);//通知人
data.NOTIFYPARTY2COUNTRY = Convert.ToString(reader["NOTIFYPARTY2COUNTRY"]);//通知人
data.NOTIFYPARTY2ATTN = Convert.ToString(reader["NOTIFYPARTY2ATTN"]);//通知人
data.NOTIFYPARTY2TEL = Convert.ToString(reader["NOTIFYPARTY2TEL"]);//通知人
data.SHIPPER = Convert.ToString(reader["SHIPPER"]);//发货人内容
data.CONSIGNEE = Convert.ToString(reader["CONSIGNEE"]);//收货人内容
data.NOTIFYPARTY = Convert.ToString(reader["NOTIFYPARTY"]);//通知人内容
data.VESSEL = Convert.ToString(reader["VESSEL"]);//船名
data.VOYNO = Convert.ToString(reader["VOYNO"]);//航次
if (Convert.ToString(reader["EDITYPE"]) == "CN")
{
if (reader["ETD"] != DBNull.Value)
data.ETD = Convert.ToDateTime(reader["ETD"]).ToString("yyyy-MM-dd");//到港日期
}
else
if (reader["ETD"] != DBNull.Value)
data.ETD = Convert.ToDateTime(reader["ETD"]).ToString("yyyy-MM-dd HH:mm:ss");//到港日期
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.PLACEDELIVERYID = Convert.ToString(reader["PLACEDELIVERYID"]);//交货地代码
data.PLACEDELIVERY = Convert.ToString(reader["PLACEDELIVERY"]);//交货地
data.DESTINATIONID = Convert.ToString(reader["DESTINATIONID"]);//目的地代码
data.DESTINATION = Convert.ToString(reader["DESTINATION"]);//目的地
data.PLACERECEIPTID = Convert.ToString(reader["PLACERECEIPTID"]);//收货地代码
data.PLACERECEIPT = Convert.ToString(reader["PLACERECEIPT"]);//收货地
data.SERVICE = Convert.ToString(reader["SERVICE"]);//运输条款
data.MARKS = Convert.ToString(reader["MARKS"]);//唛头
data.DESCRIPTION = Convert.ToString(reader["DESCRIPTION"]);//货物描述
if (reader["PKGS"] != DBNull.Value)
data.PKGS = Convert.ToInt32(reader["PKGS"]);//件数
data.KINDPKGS = Convert.ToString(reader["KINDPKGS"]);//件数包装
if (reader["KGS"] != DBNull.Value)
data.KGS = Convert.ToDecimal(reader["KGS"]);//毛重
if (reader["CBM"] != DBNull.Value)
data.CBM = Convert.ToDecimal(reader["CBM"]);//立方数/尺码
data.CARGOID = Convert.ToString(reader["CARGOID"]);//货物标识
data.DCLASS = Convert.ToString(reader["DCLASS"]);//危险品分类/等级
data.DUNNO = Convert.ToString(reader["DUNNO"]);//危险品编号
data.DPAGE = Convert.ToString(reader["DPAGE"]);//危险品页号
data.DLABEL = Convert.ToString(reader["DLABEL"]);//危险品标签
data.LINKMAN = Convert.ToString(reader["LINKMAN"]);//危险品联系人
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.FREIGHTAGMNO = Convert.ToString(reader["FREIGHTAGMNO"]);//提单份数
data.HUMIDITY = Convert.ToString(reader["HUMIDITY"]);//预付地点
data.SHIPIMO = Convert.ToString(reader["SHIPIMO"]);//到付地点
data.CARRIERID = Convert.ToString(reader["CARRIERID"]);//航线
data.ORDERNO = Convert.ToString(reader["ORDERNO"]);//订舱编号
data.FILEROLE = Convert.ToString(reader["FILEROLE"]);//发票号
data.PACKINGTYPE = Convert.ToString(reader["PACKINGTYPE"]);//装运类型
data.SHIPSERVICENO = Convert.ToString(reader["SHIPSERVICENO"]);//
data.TRANSTYPE = Convert.ToString(reader["TRANSTYPE"]);//
data.FILETYPE = Convert.ToString(reader["FILETYPE"]);//
if (reader["ISLASTHBL"] != DBNull.Value)
data.ISLASTHBL = Convert.ToBoolean(reader["ISLASTHBL"]);//是否最后一票分票
if (reader["ETA"] != DBNull.Value)
data.ETA = Convert.ToDateTime(reader["ETA"]).ToString("yyyy-MM-dd");//预抵日期
data.BLFRT = Convert.ToString(reader["BLFRT"]);//付费方式
data.ISSUEPLACE = Convert.ToString(reader["ISSUEPLACE"]);//签单地点
data.ETDTIME = Convert.ToString(reader["ETDTIME"]);//开船时间
data.AGENTID = Convert.ToString(reader["AGENTID"]);//代理
data.CNTRSEALNO = Convert.ToString(reader["CNTRSEALNO"]);//箱号封号
if (reader["SENDTIME"] != DBNull.Value)
data.SENDTIME = Convert.ToDateTime(reader["SENDTIME"]).ToString("yyyy-MM-dd");//发送日期
data.STATUS = Convert.ToString(reader["STATUS"]);//
data.YARD = Convert.ToString(reader["YARD"]);//场站/靠泊码头
data.CHANGERESON = Convert.ToString(reader["CHANGERESON"]);//更改原因
data.FORWARDER = Convert.ToString(reader["FORWARDER"]);//订舱公司
data.CARRIER = Convert.ToString(reader["CARRIER"]);//船公司
data.DCARRIER = Convert.ToString(reader["DCARRIER"]);//船公司
data.CORPID = Convert.ToString(reader["CORPID"]);//分公司代码
data.CNTRNO = Convert.ToString(reader["CNTRNO"]);//集装箱全部内容
data.REMARKS = Convert.ToString(reader["REMARKS"]);//
if (reader["CTNNUM"] != DBNull.Value)
data.CTNNUM = Convert.ToInt32(reader["CTNNUM"]);//件数
data.ARVESSEL = Convert.ToString(reader["ARVESSEL"]);//船名
data.ARVOYNO = Convert.ToString(reader["ARVOYNO"]);//航次
data.ARSHIPIMO = Convert.ToString(reader["ARSHIPIMO"]);//到付地点
data.ARSHIPSERVICENO = Convert.ToString(reader["ARSHIPSERVICENO"]);//
data.FIRSTPORTOFCALLID = Convert.ToString(reader["FIRSTPORTOFCALLID"]);//
if (reader["FIRSTPORTOFCALLDATE"] != DBNull.Value)
data.FIRSTPORTOFCALLDATE = Convert.ToDateTime(reader["FIRSTPORTOFCALLDATE"]).ToString("yyyy-MM-dd");
data.LASTPORTOFCALLID = Convert.ToString(reader["LASTPORTOFCALLID"]);//
if (reader["FIRSTPORTOFCALLDATE"] != DBNull.Value)
data.LASTPORTOFCALLDATE = Convert.ToDateTime(reader["LASTPORTOFCALLDATE"]).ToString("yyyy-MM-dd");
data.MANIFESTSTATUS = Convert.ToString(reader["MANIFESTSTATUS"]);//
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 明细表
static public List<MsOpSeaeEdiCtn> GetBodyList(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT [CTN_ID],[MFNO],isnull(CTNCODE,1) as [CTNCODE],[SIZE],[CTN],[CTNNUM],[TEU],[CTNALL],[CNTRNO],[SEALNO],[PKGS],[KGS],");
strSql.Append("[CBM],[KINDPKGS],[DESCRIPTION],[MARKS],[PO],[SKU],[SKUDESCRIP],[DUNNO],[HTS],[CTOFORIGIN],[GOODVALUE],[CTNOWNER] from op_seae_edi_ctn");
if (strCondition.Trim() != String.Empty)
{
strSql.Append(" where " + strCondition);
}
strSql.Append(" order by MFNO,CTNCODE,CTNALL");
return SetBodyData(strSql);
}
static public List<MsOpSeaeEdiCtn> GetCtnSum(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT '' CTN_ID,'' MFNO,'' CTNCODE,'' SIZE,'' CTN,sum(CTNNUM) as CTNNUM,0 TEU,[CTNALL],'' CNTRNO,'' SEALNO,0 PKGS,0 KGS,");
strSql.Append("0 CBM,'' KINDPKGS,'' DESCRIPTION,'' MARKS,'' PO,'' SKU,'' SKUDESCRIP,'' DUNNO,'' HTS,'' CTOFORIGIN,0 GOODVALUE,'' CTNOWNER from op_seae_edi_ctn");
if (strCondition.Trim() != String.Empty)
{
strSql.Append(" where " + strCondition);
}
strSql.Append(" GROUP BY CTNALL");
return SetBodyData(strSql);
}
private static List<MsOpSeaeEdiCtn> SetBodyData(StringBuilder strSql)
{
var bodyList = new List<MsOpSeaeEdiCtn>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsOpSeaeEdiCtn data = new MsOpSeaeEdiCtn();
#region Set DB data to Object
data.CTN_ID = Convert.ToString(reader["CTN_ID"]);//编号
data.MFNO = Convert.ToString(reader["MFNO"]);//业务编号
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.KINDPKGS = Convert.ToString(reader["KINDPKGS"]);//包装类型
if (reader["GOODVALUE"] != DBNull.Value)
data.GOODVALUE = Convert.ToDecimal(reader["GOODVALUE"]);//箱皮重
data.DESCRIPTION = Convert.ToString(reader["DESCRIPTION"]);
data.MARKS = Convert.ToString(reader["MARKS"]);
data.PO = Convert.ToString(reader["PO"]);
data.SKU = Convert.ToString(reader["SKU"]);
data.SKUDESCRIP = Convert.ToString(reader["SKUDESCRIP"]);
data.DUNNO = Convert.ToString(reader["DUNNO"]);
data.HTS = Convert.ToString(reader["HTS"]);
data.CTOFORIGIN = Convert.ToString(reader["CTOFORIGIN"]);
data.CTNOWNER = Convert.ToString(reader["CTNOWNER"]);
#endregion
bodyList.Add(data);
}
reader.Close();
}
return bodyList;
}
static public List<MsOpSeaeEdiCtnDetail> GetCargoList(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT [GID],[CTN_ID],[MFNO],[PKGS],[KGS],");
strSql.Append("[CBM],[KINDPKGS],[DUNNO],[HTS],[GOODVALUE],(SELECT CNTRNO from op_seae_edi_ctn where CTN_ID=op_seae_edi_ctndetail.CTN_ID) AS CNTRNO from op_seae_edi_ctndetail ");
if (strCondition.Trim() != String.Empty)
{
strSql.Append(" where " + strCondition);
}
strSql.Append(" order by MFNO,CTN_ID");
return SetCargoData(strSql);
}
private static List<MsOpSeaeEdiCtnDetail> SetCargoData(StringBuilder strSql)
{
var bodyList = new List<MsOpSeaeEdiCtnDetail>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsOpSeaeEdiCtnDetail data = new MsOpSeaeEdiCtnDetail();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);//编号
data.CTN_ID = Convert.ToString(reader["CTN_ID"]);//编号
data.MFNO = Convert.ToString(reader["MFNO"]);//业务编号
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.KINDPKGS = Convert.ToString(reader["KINDPKGS"]);//包装类型
if (reader["GOODVALUE"] != DBNull.Value)
data.GOODVALUE = Convert.ToDecimal(reader["GOODVALUE"]);//箱皮重
data.DUNNO = Convert.ToString(reader["DUNNO"]);
data.HTS = Convert.ToString(reader["HTS"]);
data.CNTRNO = Convert.ToString(reader["CNTRNO"]);
#endregion
bodyList.Add(data);
}
reader.Close();
}
return bodyList;
}
#endregion
#region 保存明细
public static DBResult SaveDetail(MsOpSeaeEdi headData, List<MsOpSeaeEdiCtn> bodyList, List<MsOpSeaeEdiCtnDetail> cargoList)
{
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)
{
int SIZE = int.Parse(enumValue.CTNALL.ToString().Trim().Substring(0, 2));
var CTN = "";
if (enumValue.CTNALL.Length == 5)
{
CTN = enumValue.CTNALL.ToString().Trim().Substring(3);
}
else {
CTN = enumValue.CTNALL.ToString().Trim().Substring(2);
}
int TEU = enumValue.CTNNUM;
int iTEU = int.Parse(enumValue.CTNALL.ToString().Trim().Substring(0, 1));
if (iTEU == 4)
{
TEU = TEU*2;
}
//
if (enumValue.MFNO == "*")
{
var cmdInsert = 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,PO,SKU,SKUDESCRIP,DUNNO,HTS,CTOFORIGIN,CTNOWNER,GOODVALUE) values ('" + enumValue.CTN_ID+ "','"
+ headData.MFNO + "','" + enumValue.CTNCODE + "','" + SIZE + "','" + CTN + "'," + enumValue.CTNNUM + "," + TEU + ",'" + enumValue.CTNALL.Replace("'", "''") + "','" + enumValue.CNTRNO + "','" + enumValue.SEALNO + "','" + enumValue.PKGS + "'," + enumValue.KGS + ","
+ enumValue.CBM + ",'" + enumValue.KINDPKGS + "','" + enumValue.MARKS.Replace("'", "''") + "','" + enumValue.DESCRIPTION.Replace("'", "''") + "','" + enumValue.PO + "','" + enumValue.SKU + "','" + enumValue.SKUDESCRIP + "','" + enumValue.DUNNO + "','"
+ enumValue.HTS + "','" + enumValue.CTOFORIGIN + "','" + enumValue.CTNOWNER + "'," + enumValue.GOODVALUE + ")");
db.ExecuteNonQuery(cmdInsert, tran);
}
else
{
var cmdUpdate = db.GetSqlStringCommand(@"update op_seae_edi_ctn set CTNCODE='" + enumValue.CTNCODE + "',[SIZE]='" + SIZE + "',CTN='" + CTN + "',CTNNUM=" + enumValue.CTNNUM + ",TEU=" + TEU + ",CTNALL='" + enumValue.CTNALL.Replace("'", "''") + "',CNTRNO='" + enumValue.CNTRNO + "',SEALNO='" + enumValue.SEALNO + "',PKGS='"
+ enumValue.PKGS + "',KGS=" + enumValue.KGS + ",CBM=" + enumValue.CBM + ",KINDPKGS='" + enumValue.KINDPKGS + "',MARKS='" + enumValue.MARKS.Replace("'", "''") + "',DESCRIPTION='" + enumValue.DESCRIPTION.Replace("'", "''") + "',"
+"PO='"+ enumValue.PO + "',SKU='"+enumValue.SKU+"',SKUDESCRIP='"+enumValue.SKUDESCRIP+"',DUNNO='"+enumValue.DUNNO+"',HTS='"+enumValue.HTS+"',CTOFORIGIN='"+enumValue.CTOFORIGIN+"',CTNOWNER='"+enumValue.CTNOWNER+"',GOODVALUE="+enumValue.GOODVALUE+" where MFNO='" + enumValue.MFNO + "' AND CTN_ID='" + enumValue.CTN_ID + "'");
db.ExecuteNonQuery(cmdUpdate, tran);
}
}
}
if (cargoList != null)
{
foreach (var enumValue in cargoList)
{
if (enumValue.MFNO == "*")
{
var cmdInsert = db.GetSqlStringCommand(@"insert into op_seae_edi_ctndetail (GID,MFNO,CTN_ID,PKGS,KGS,CBM,KINDPKGS,DUNNO,HTS,GOODVALUE) values ('" + enumValue.CTN_ID + "','"
+ headData.MFNO + "','" + enumValue.CTN_ID+"'," + enumValue.PKGS + "," + enumValue.KGS + ","
+ enumValue.CBM + ",'" + enumValue.KINDPKGS + "','" + enumValue.DUNNO + "','"+ enumValue.HTS + "'," + enumValue.GOODVALUE + ")");
db.ExecuteNonQuery(cmdInsert, tran);
}
else
{
var cmdUpdate = db.GetSqlStringCommand(@"update op_seae_edi_ctndetail set CTN_ID='" + enumValue.CTN_ID + "',PKGS="+ enumValue.PKGS + ",KGS=" + enumValue.KGS + ",CBM=" + enumValue.CBM
+ ",KINDPKGS='" + enumValue.KINDPKGS + "',DUNNO='"+enumValue.DUNNO+"',HTS='"+enumValue.HTS+"',GOODVALUE="+enumValue.GOODVALUE+" where MFNO='" + enumValue.MFNO + "' AND GID='" + enumValue.GID + "'");
db.ExecuteNonQuery(cmdUpdate, tran);
}
}
}
//
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "保存出现错误,请重试或联系系统管理员";
return result;
}
}
//
getCNTRTOTAL(headData.BSNO, "op_seae_edi");
//
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_seae_edi_ctn where MFNO='" + strBSNO.Trim() + "'");
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
foreach (System.Data.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 (System.Data.DataTable myTable in ds.Tables)
{
foreach (DataRow myRow in myTable.Rows)//遍历表
{
strCNTRTOTAL += myRow["CTNALL"].ToString().Trim() + "*" + myRow["hj"].ToString().Trim() + " / ";
//
}
}
strCNTRTOTAL = strCNTRTOTAL.Trim().Substring(0, strCNTRTOTAL.Trim().Length - 1);
}
}
str = "update op_seae_edi set CNTRTOTAL='" + strCNTRTOTAL + "',CNTRSEALNO='" + strCNTRNO + "' 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_seae_edi");
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
#region 删除
public static DBResult DeletePiLiang(string bsnos)
{
var result = new DBResult();
var billList = bsnos.Split(',');
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var bill in billList)
{
var cmdDelete = db.GetSqlStringCommand("delete from op_seae_edi_ctn where MFNO='" + bill + "'");
db.ExecuteNonQuery(cmdDelete, tran);
cmdDelete = db.GetSqlStringCommand("delete from op_seae_edi_ctndetail where MFNO='" + bill + "'");
db.ExecuteNonQuery(cmdDelete, tran);
cmdDelete = db.GetSqlStringCommand("delete from op_seae_edi where MFNO='" + bill + "'");
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 DeleteDetail(MsOpSeaeEdi 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_seae_edi_ctn where MFNO='" + headData.MFNO + "'");
db.ExecuteNonQuery(cmdDelete, tran);
cmdDelete = db.GetSqlStringCommand("delete from op_seae_edi_ctndetail where MFNO='" + headData.MFNO + "'");
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(MsOpSeaeEdiCtn 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_seae_edi_ctn where CTN_ID='" + headData.CTN_ID + "'");
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 DeleteDetailCargo(MsOpSeaeEdiCtnDetail 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_seae_edi_ctndetail where GID='" + headData.GID + "'");
db.ExecuteNonQuery(cmdDelete, tran);
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "删除出现错误,请重试或联系系统管理员";
return result;
}
}
result.Success = true;
result.Message = "操作成功";
return result;
}
#endregion
#region AFR
public static string formatAfrStr(string str)
{
str = ToDBC(str);
return str.Replace("&", "&amp;").Replace("<", "&lt;").Replace("\"", "&quot;").Replace(">", "&gt;").Replace("''", "&apos;");
}
static public string GetPackageAFRCode(string Package)
{
string EDICODE = "";
var strSql = new StringBuilder();
strSql.Append("select AFRCODE 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["AFRCODE"]);
}
reader.Close();
}
return EDICODE;
}
public static string ToDBC(string input)
{
char[] array = input.ToCharArray();
for (int i = 0; i < array.Length; i++)
{
if (array[i] == 12288)
{
array[i] = (char)32;
continue;
}
if (array[i] > 65280 && array[i] < 65375)
{
array[i] = (char)(array[i] - 65248);
}
}
return new string(array);
}
static public string GetCtnAFRCode(string Ctn)
{
string EDICODE = "";
Ctn = Ctn.Replace("'", "''");
var strSql = new StringBuilder();
strSql.Append("select AFRCODE 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["AFRCODE"]);
}
reader.Close();
}
return EDICODE;
}
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 bool UpSendStatus(List<MsOpSeaeEdi> headData,string sendstatus)
{
var Result = true;
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
foreach (var bill in headData)
{
var cmdupdate = db.GetSqlStringCommand("update op_seae_edi set EDISTATUS='" + sendstatus + "' where MFNO=@MFNO");
cmdupdate.Parameters.Clear();
db.AddInParameter(cmdupdate, "@MFNO", DbType.String, bill.MFNO);
db.ExecuteNonQuery(cmdupdate, tran);
}
Result = true;
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
Result = false;
}
}
return Result;
}
#endregion
#region 舱单申报
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;
}
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();
}
return EDICODE;
}
static public string GetWDCustEdi(string Cust,string type)
{
string EDICODE = "";
var strSql = new StringBuilder();
if (type=="WDKR")
strSql.Append("select EDICODE3 AS EDICODE from info_client WHERE SHORTNAME='" + Cust + "'");
else if (type == "WD2101")
strSql.Append("select EDICODE2 AS EDICODE from info_client WHERE SHORTNAME='" + Cust + "'");
else 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();
}
return EDICODE;
}
public static List<System.String> 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<System.String> DestList = new List<System.String>();
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<System.String> DestList, int lineCount)
{
var result = "";
for (var i = 0; i < lineCount; i++)
{
if (DestList.Count > i)
{
result = result + DestList[i] + ":";
}
else result = result + ":";
}
return result;
}
//public static string BreakLongString(string SubjectString, int lineLength)
//{
// StringBuilder sb = new StringBuilder(SubjectString);
// int offset = 0;
// ArrayList indexList = buildInsertIndexList(SubjectString, lineLength);
// for (int i = 0; i < indexList.Count; i++)
// {
// sb.Insert((int)indexList[i] + offset, '\n');
// offset++;
// }
// return sb.ToString();
//}
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;
}
private static ArrayList buildInsertIndexList(string str, int maxLen)
{
int nowLen = 0;
ArrayList list = new ArrayList();
for (int i = 1; i < str.Length; i++)
{
if (IsChinese(str[i]))
{
nowLen += 2;
}
else
{
nowLen++;
}
if (nowLen > maxLen)
{
nowLen = 0;
list.Add(i);
}
}
return list;
}
public static string GetDateStr(string datestr, string dateformat)
{
var result = "";
if (datestr == null || datestr == "")
{
result = "";
}
else
{
result = Convert.ToDateTime(datestr).ToString(dateformat);
}
return result;
}
public static string IsCreateCustomEdi(List<MsOpSeaeEdi> headData, string type)
{
var error = "";
if (type == "WD2101" || type == "WD1101" || type == "COSCO" || type == "WDKR")
{
error = IsCreateCustomEdiWD(headData, type);
}
return error;
}
public static string IsCreateCustomEdiWD(List<MsOpSeaeEdi> headData,string type)
{
var error = "";
foreach (var bill in headData)
{
if (bill.MBLNO == null || bill.MBLNO == "")
{ error =error+ "|主提单号不能为空"; }
if (bill.CARRIERID == null || bill.CARRIERID == "")
{ error = error + "|提单号:" + bill.MBLNO + "船公司代码不能为空"; }
if (bill.BLFRT == null || bill.BLFRT == "")
{ error = error + "|提单号:" + bill.MBLNO + "付费方式不能为空"; }
if (bill.VESSEL == null || bill.VESSEL == "")
{ error = error + "|提单号:" + bill.MBLNO + "船名不能为空"; }
if (bill.VOYNO == null || bill.VOYNO == "")
{ error = error + "|提单号:" + bill.MBLNO + "航次不能为空"; }
if (bill.PORTLOADID == null || bill.PORTLOADID == "")
{ error = error + "|提单号:" + bill.MBLNO + "装货港代码不能为空"; }
if (bill.PORTLOAD == null || bill.PORTLOAD == "")
{ error = error + "|提单号:" + bill.MBLNO + "装货港不能为空"; }
if (bill.ETD == null || bill.ETD == "")
{
error = error + "|提单号:" + bill.MBLNO + "开船日期不能为空";
}
if (bill.PORTDISCHARGEID == null || bill.PORTDISCHARGEID == "")
{ error = error + "|提单号:" + bill.MBLNO + "卸货港代码不能为空"; }
if (bill.DESTINATION == null || bill.DESTINATION == "")
{ error = error + "|提单号:" + bill.MBLNO + "目的港代码不能为空"; }
if (GetPackageEDICode(bill.KINDPKGS) == "")
{ error = error + "|提单号:" + bill.MBLNO + "包装EDI代码不能为空"; }
if (bill.DESCRIPTION == null || bill.DESCRIPTION == "")
{ error = error + "|提单号:" + bill.MBLNO + "货物描述不能为空"; }
if (bill.MARKS == null || bill.MARKS == "")
{ error = error + "|提单号:" + bill.MBLNO + "货物唛头不能为空"; }
if (bill.PKGS.ToString().Trim() == "" || bill.PKGS == 0)
{ error = error + "|提单号:" + bill.MBLNO + "货物件数不能为空"; }
if (bill.CARGOID == null || bill.CARGOID == "")
{ error = error + "|提单号:" + bill.MBLNO + "货物标示不能为空"; }
if (type == "WD2101" || type == "WD1101" || type == "COSCO" || type == "WDKR")
{
//if (bill.SHIPPERCODE.Trim() == "")
//{
// error = error + "<br />提单号:" + bill.MBLNO + " 发货人企业代码不能为空";
//}
if (bill.SHIPPERCOUNTRY.Trim() == "")
{
error = error + "<br />提单号:" + bill.MBLNO + " 发货人国家代码不能为空";
}
if (bill.SHIPPERTEL.Trim() == "" && bill.SHIPPEREMAIL.Trim() == "")
{
error = error + "<br />提单号:" + bill.MBLNO + " 发货人电话和邮箱不能都为空";
}
var consigneestr = bill.CONSIGNEENAME.ToUpper().Replace(" ", "");
if ((consigneestr.Length>=7&&consigneestr.Substring(0, 7) == "TOORDER") || (consigneestr.Length>=10&&consigneestr.Substring(0, 10) == "TOTHEORDER"))
{
if (bill.NOTIFYPARTYCODE.Trim() == "")
{
error = error + "<br />提单号:" + bill.MBLNO + " 通知人企业代码不能为空";
}
if (bill.NOTIFYPARTYCOUNTRY.Trim() == "")
{
error = error + "<br />提单号:" + bill.MBLNO + " 通知人国家代码不能为空";
}
}
else
{
//if (bill.CONSIGNEECODE.Trim() == "")
//{
// error = error + "<br />提单号:" + bill.MBLNO + " 收货人企业代码不能为空";
//}
//if (bill.CONSIGNEETEL.Trim() == "" && bill.CONSIGNEEEMAIL.Trim() == "")
//{
// error = error + "<br />提单号:" + bill.MBLNO + " 收货人电话和邮箱不能都为空";
//}
//if (bill.CONSIGNEECOUNTRY.Trim() == "")
//{
// error = error + "<br />提单号:" + bill.MBLNO + " 收货人国家代码不能为空";
//}
}
}
if (bill.CARGOID == "D") {
if (bill.DCLASS == null || bill.DCLASS == "")
{ error = error + "|提单号:" + bill.MBLNO + "危险品分类不能为空"; }
if (bill.DUNNO == null || bill.DUNNO == "")
{ error = error + "|提单号:" + bill.MBLNO + "危险品编号不能为空"; }
}
if (bill.CARGOID == "R")
{
if (bill.TEMPSET == null || bill.TEMPSET == "")
{ error = error + "|提单号:" + bill.MBLNO + "设置温度不能为空"; }
}
var ctnlist = GetBodyList("MFNO='" + bill.MFNO + "'");
if (ctnlist.Count == 0) { error = error + "|提单号:" + bill.MBLNO + "集装箱信息不能为空"; };
foreach (var ctn in ctnlist)
{
if (ctn.CNTRNO == null || ctn.CNTRNO == "")
{ error = error + "|提单号:" + bill.MBLNO + "箱号不能为空"; }
}
}
return error;
}
#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 ");
strSql.Append(" from VW_User_Authority ");
strSql.Append(" where [NAME]='modOrderManagement' and USERID='" + userid + "' and ISDELETE=0");
string visiblerange = "4";
string operaterange = "4";
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"]);
break;
}
reader.Close();
}
if (visiblerange == "4")
{
str = "1=2";
}
else if (visiblerange == "3")
{
str = " (INPUTBY='" + username + "')";
}
else if (visiblerange == "2")
{
if (tb == "index")
{
}
else
{
str = " UPPER(Corpid)='" + companyid + "'";
}
}
else if (visiblerange == "1")
{
str = " UPPER(Corpid)='" + companyid + "'";
}
return str;
}
#endregion
//
#endregion
public static bool CheckCangDanIsSend ( string bsno )
{
string sql = "select count(*) from op_SeaCover where coverTitle = '发送舱单' and bsno in ( " + bsno + ") ";
Database db = DatabaseFactory.CreateDatabase();
int rst = Convert.ToInt32(db.ExecuteScalar(CommandType.Text, sql));
return rst > 0;
}
}
}