\r\n\r\n\r\n
主单货物状态及跟踪\r\n\r\n\r\n \r\n \r\n \r\n\r\n "
+ "\r\n\r\n\r\n "
+ "
\r\n\r\n \r\n\r\n\r\n
\r\n\r\n\r\n" + datahtml;
result.Data = datahtml;
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
return result;
}
#endregion
#region 引入EXCEL
static public MsOpSeaeDetail FindCtnData(string cntrno, List
ctnlist)
{
MsOpSeaeDetail head = null;
foreach (var ctndata in ctnlist)
{
if (ctndata.CNTRNO == cntrno) head = ctndata;
}
return head;
}
static public DBResult InsertCtnData(string bsno,List ctnlist,bool isexcel=false)
{
var result = new DBResult();
result.Success = true;
Database db = DatabaseFactory.CreateDatabase();
using (DbConnection connection = db.CreateConnection())
{
connection.Open();
DbTransaction idbTran = connection.BeginTransaction();
try
{
var bodyList = new List();
var cmdDelete = db.GetSqlStringCommand(@"delete from op_ctn where BSNO='"+bsno+"'");
db.ExecuteNonQuery(cmdDelete, idbTran);
foreach (var ctndata in ctnlist)
{
var nowctndata = FindCtnData(ctndata.CNTRNO, bodyList);
if (nowctndata == null)
{
var CTNID = Guid.NewGuid().ToString();
int SIZE = int.Parse(ctndata.CTNALL.ToString().Trim().Substring(0, 2));
string CTN = ctndata.CTNALL.ToString().Trim().Substring(2);
int TEU = 1;
int iTEU = int.Parse(ctndata.CTNALL.ToString().Trim().Substring(0, 1));
if (iTEU == 4)
{
TEU = TEU * 2;
}
var CTNCODE = "";
#region 托单数据生成
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,WEIGHTYPE,WEIGHKGS,WEIGHATTN,WEIGHTEL,WEIGHSIGN) values ('"
+ CTNID + "','" + bsno + "','" + CTNCODE + "','" + SIZE + "','" + CTN + "',1," + TEU + ",'" + ctndata.CTNALL.Replace("'", "''") + "','" + ctndata.CNTRNO + "','" + ctndata.SEALNO + "',"+ctndata.PKGS+","+ctndata.KGS+","+ctndata.CBM+",'" + ctndata.REMARK + "','"+ctndata.KINDPKGS+"',0,'','',0,'','','')");
db.ExecuteNonQuery(cmdInsert, idbTran);
ctndata.CTN_ID = CTNID;
bodyList.Add(ctndata);
nowctndata = ctndata;
}
else {
var cmdInsert = db.GetSqlStringCommand(@"update op_ctn set PKGS=PKGS+" + ctndata.PKGS + ",KGS=KGS+"+ctndata.KGS+",CBM=CBM+"+ctndata.CBM+" where CTN_ID='"+nowctndata.CTN_ID+"'");
db.ExecuteNonQuery(cmdInsert, idbTran);
}
if (ctndata.CTNFEE != "") {
var cmdInsertdetail = db.GetSqlStringCommand(@"insert into op_ctn_detail (GID,CTN_ID,PKGS,KGS,CBM,KINDPKGS,HSCODE,DESCRIPTION,MARKS) values ('"
+ Guid.NewGuid().ToString() + "','" + nowctndata.CTN_ID + "'," + ctndata.PKGS + "," + ctndata.KGS + "," + ctndata.CBM + ",'"+ctndata.KINDPKGS+"','" + ctndata.CTNFEE + "','" + ctndata.GOODSNAME + "','" + ctndata.WEIGHSIGN + "')");
db.ExecuteNonQuery(cmdInsertdetail, idbTran);
}
#endregion
}
idbTran.Commit();
result.Success = true;
}
catch (Exception exception)
{
idbTran.Rollback();
result.Success = false;
result.Message= exception.Message;
}
}
return result;
}
static public DBResult InsertMSCCtn(string bsno, List ctnlist)
{
var result = new DBResult();
result.Success = true;
Database db = DatabaseFactory.CreateDatabase();
using (DbConnection connection = db.CreateConnection())
{
connection.Open();
DbTransaction idbTran = connection.BeginTransaction();
try
{
var bodyList = new List();
var cmdDelete = db.GetSqlStringCommand(@"delete from op_ctn where BSNO='" + bsno + "'");
db.ExecuteNonQuery(cmdDelete, idbTran);
foreach (var ctndata in ctnlist)
{
var CTNID = Guid.NewGuid().ToString();
int SIZE = int.Parse(ctndata.CTNALL.ToString().Trim().Substring(0, 2));
string CTN = ctndata.CTNALL.ToString().Trim().Substring(2);
if (ctndata.CTNALL.IndexOf("'")>0) CTN = ctndata.CTNALL.ToString().Trim().Substring(3);
int TEU = 1;
int iTEU = int.Parse(ctndata.CTNALL.ToString().Trim().Substring(0, 1));
if (iTEU == 4)
{
TEU = TEU * 2;
}
TEU =TEU*ctndata.CTNNUM;
var CTNCODE = "";
#region 托单数据生成
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,WEIGHTYPE,WEIGHKGS,WEIGHATTN,WEIGHTEL,WEIGHSIGN) values ('"
+ CTNID + "','" + bsno + "','" + CTNCODE + "','" + SIZE + "','" + CTN + "',"+ctndata.CTNNUM+"," + TEU + ",'" + ctndata.CTNALL.Replace("'", "''") + "','" + ctndata.CNTRNO + "','" + ctndata.SEALNO + "'," + ctndata.PKGS + "," + ctndata.KGS + "," + ctndata.CBM + ",'" + ctndata.REMARK + "','',0,'','',0,'','','')");
db.ExecuteNonQuery(cmdInsert, idbTran);
ctndata.CTN_ID = CTNID;
bodyList.Add(ctndata);
#endregion
}
idbTran.Commit();
result.Success = true;
}
catch (Exception exception)
{
idbTran.Rollback();
result.Success = false;
result.Message = exception.Message;
}
}
return result;
}
public static bool ImportBsList(DataTable table,string username,string companyid,MsOpSeae opseae, out string msg)
{
var isSucess = false;
msg = "";
if (table == null) throw new ArgumentNullException("table");
var billNoList = new List();
var i = 1;
Database db = DatabaseFactory.CreateDatabase();
using (DbConnection connection = db.CreateConnection())
{
connection.Open();
DbTransaction idbTran = connection.BeginTransaction();
try
{
var billnoset = MsSysBillNoSet.MsSysBillNoSetDAL.GetData("OPLBNAME='海运出口' AND RULEBLNO='委托编号' ",companyid);
foreach (DataRow row in table.Rows)
{
var GP20 = Convert.ToString(row["20GP"]);
if (GP20.Length > 10) GP20 = "0";
var TK20 = Convert.ToString(row["20TK"]);
if (TK20.Length > 10) TK20 = "0";
var DG20 = Convert.ToString(row["20DG"]);
if (DG20.Length > 10) DG20 = "0";
var RF20 = Convert.ToString(row["20RF"]);
if (RF20.Length > 10) RF20 = "0";
var GP40 = Convert.ToString(row["40GP"]);
if (GP40.Length > 10) GP40 = "0";
var HQ40 = Convert.ToString(row["40HQ"]);
if (HQ40.Length > 10) HQ40 = "0";
var RH40 = Convert.ToString(row["40RH"]);
if (RH40.Length > 10) RH40 = "0";
var MBLNO = Convert.ToString(row["提单号"]);
var ct = GetRdCount(" MBLNO='" + MBLNO + "' and CORPID='" + companyid + "'");
if (MBLNO != "" && ct==0)
{
var head = new MsOpSeae();
head.OP =username;
var period = ChMonthCloseDAL.ChMonthCloseDAL.GetData("",companyid);
if (Convert.ToDateTime(period.FDAY) > DateTime.Now)
{
head.ACCDATE = period.PERIOD;
}
head.INPUTBY = username;
head.MASTERNO = head.BSNO;
head.ETD = opseae.ETD;
head.ETD2 = opseae.ETD2;
head.VESSEL = opseae.VESSEL;
head.VOYNO = opseae.VOYNO;
head.CUSTOMERNAME = opseae.CUSTOMERNAME;
head.CARRIER = opseae.CARRIER;
head.FORWARDER = opseae.FORWARDER;
head.LANE = opseae.LANE;
head.PORTLOAD = opseae.PORTLOAD;
head.PORTLOADID = opseae.PORTLOADID;
head.PORTDISCHARGE = opseae.PORTDISCHARGE;
head.PORTDISCHARGEID = opseae.PORTDISCHARGEID;
head.AGENTID = opseae.AGENTID;
head.CORPID = companyid;
head.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
head.BSSTATUS = false;
head.FEESTATUS = false;
head.DbOperationType = DbOperationType.DbotIns;
var BSNO = head.BSNO;
head.CUSTNO =MsSysBillNoSet.MsSysBillNoSetDAL.GetBillNo(billnoset, head.ETD.ToString().Trim(), head.ACCDATE.ToString().Trim(), "", head.OP, head.SALECORPID);
if (head.ETA == "") head.ETA = null;
if (head.ETD == "") head.ETD = null;
if (head.ETD2 == "") head.ETD2 = null;
if (head.STLDATE == "") head.STLDATE = null;
if (head.ATD == "") head.ATD = null;
if (head.DELIVERYDATE == "") head.DELIVERYDATE = null;
if (head.ISSUEDATE == "" || (Convert.ToDateTime(head.ISSUEDATE) < Convert.ToDateTime("2010-01-01"))) head.ISSUEDATE = null;
if (head.CLOSINGDATE == "") head.CLOSINGDATE = null;
if (head.CLOSEDOCDATE == "") head.CLOSEDOCDATE = null;
if (head.INSPECTIONDATE == "") head.INSPECTIONDATE = null;
if (head.CUSTOMDATE == "") head.CUSTOMDATE = null;
if (head.CLEARCUSTOMDATE == "") head.CLEARCUSTOMDATE = null;
head.MBLNO = MBLNO;
var modb = new ModelObjectDB();
DBResult result = modb.Save(head);
var cntrstr = "";
var teuall = 0;
if (result.Success&&GP20.Trim() != "" && GP20.Trim() != "0")
{
var CTNID = Guid.NewGuid().ToString();
int SIZE =20;
string CTN ="GP";
int TEU = Convert.ToInt32(GP20.Trim()); ;
int iTEU = Convert.ToInt32(GP20.Trim());
teuall = teuall + iTEU;
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,WEIGHTYPE,WEIGHKGS,WEIGHATTN,WEIGHTEL,WEIGHSIGN) values ('"
+ CTNID + "','" + BSNO + "','','" + SIZE + "','" + CTN + "',"+TEU+"," + iTEU + ",'20GP','','',0,0,0,'','',0,'','',0,'','','')");
db.ExecuteNonQuery(cmdInsert, idbTran);
cntrstr = cntrstr + " " + "20GP*" + GP20.Trim();
}
if (result.Success && TK20.Trim() != "" && TK20.Trim() != "0")
{
var CTNID = Guid.NewGuid().ToString();
int SIZE = 20;
string CTN = "TK";
int TEU = Convert.ToInt32(TK20.Trim()); ;
int iTEU = Convert.ToInt32(TK20.Trim());
teuall = teuall + iTEU;
cntrstr = cntrstr + " " + "20TK*" + TK20.Trim();
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,WEIGHTYPE,WEIGHKGS,WEIGHATTN,WEIGHTEL,WEIGHSIGN) values ('"
+ CTNID + "','" + BSNO + "','','" + SIZE + "','" + CTN + "'," + TEU + "," + iTEU + ",'20TK','','',0,0,0,'','',0,'','',0,'','','')");
db.ExecuteNonQuery(cmdInsert, idbTran);
}
if (result.Success && DG20.Trim() != "" && DG20.Trim() != "0")
{
var CTNID = Guid.NewGuid().ToString();
int SIZE = 20;
string CTN = "DG";
int TEU = Convert.ToInt32(DG20.Trim()); ;
int iTEU = Convert.ToInt32(DG20.Trim());
teuall = teuall + iTEU;
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,WEIGHTYPE,WEIGHKGS,WEIGHATTN,WEIGHTEL,WEIGHSIGN) values ('"
+ CTNID + "','" + BSNO + "','','" + SIZE + "','" + CTN + "'," + TEU + "," + iTEU + ",'20DG','','',0,0,0,'','',0,'','',0,'','','')");
db.ExecuteNonQuery(cmdInsert, idbTran);
cntrstr = cntrstr + " " + "20DG*" + DG20.Trim();
}
if (result.Success && RF20.Trim() != "" && RF20.Trim() != "0")
{
var CTNID = Guid.NewGuid().ToString();
int SIZE = 20;
string CTN = "RF";
int TEU = Convert.ToInt32(RF20.Trim()); ;
int iTEU = Convert.ToInt32(RF20.Trim());
teuall = teuall + iTEU;
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,WEIGHTYPE,WEIGHKGS,WEIGHATTN,WEIGHTEL,WEIGHSIGN) values ('"
+ CTNID + "','" + BSNO + "','','" + SIZE + "','" + CTN + "'," + TEU + "," + iTEU + ",'20RF','','',0,0,0,'','',0,'','',0,'','','')");
db.ExecuteNonQuery(cmdInsert, idbTran);
cntrstr = cntrstr + " " + "20RF*" + RF20.Trim();
}
if (result.Success && GP40.Trim() != "" && GP40.Trim() != "0")
{
var CTNID = Guid.NewGuid().ToString();
int SIZE = 40;
string CTN = "GP";
int TEU = Convert.ToInt32(GP40.Trim()); ;
int iTEU = Convert.ToInt32(GP40.Trim()) * 2;
teuall = teuall + iTEU;
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,WEIGHTYPE,WEIGHKGS,WEIGHATTN,WEIGHTEL,WEIGHSIGN) values ('"
+ CTNID + "','" + BSNO + "','','" + SIZE + "','" + CTN + "'," + TEU + "," + iTEU + ",'40GP','','',0,0,0,'','',0,'','',0,'','','')");
db.ExecuteNonQuery(cmdInsert, idbTran);
cntrstr = cntrstr + " " + "40GP*" + GP40.Trim();
}
if (result.Success && HQ40.Trim() != "" && HQ40.Trim() != "0")
{
var CTNID = Guid.NewGuid().ToString();
int SIZE = 40;
string CTN = "HQ";
int TEU = Convert.ToInt32(HQ40.Trim()); ;
int iTEU = Convert.ToInt32(HQ40.Trim()) * 2;
teuall = teuall + iTEU;
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,WEIGHTYPE,WEIGHKGS,WEIGHATTN,WEIGHTEL,WEIGHSIGN) values ('"
+ CTNID + "','" + BSNO + "','','" + SIZE + "','" + CTN + "'," + TEU + "," + iTEU + ",'40HQ','','',0,0,0,'','',0,'','',0,'','','')");
db.ExecuteNonQuery(cmdInsert, idbTran);
cntrstr = cntrstr + " " + "40HQ*" + HQ40.Trim();
}
if (result.Success && RH40.Trim() != "" && RH40.Trim() != "0")
{
var CTNID = Guid.NewGuid().ToString();
int SIZE = 40;
string CTN = "RH";
int TEU = Convert.ToInt32(RH40.Trim()); ;
int iTEU = Convert.ToInt32(RH40.Trim()) * 2;
teuall = teuall + iTEU;
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,WEIGHTYPE,WEIGHKGS,WEIGHATTN,WEIGHTEL,WEIGHSIGN) values ('"
+ CTNID + "','" + BSNO + "','','" + SIZE + "','" + CTN + "'," + TEU + "," + iTEU + ",'40RH','','',0,0,0,'','',0,'','',0,'','','')");
db.ExecuteNonQuery(cmdInsert, idbTran);
cntrstr = cntrstr + " " + "40RH*" + RH40.Trim();
}
var cmdUpdate = db.GetSqlStringCommand(@"update op_seae set CNTRTOTAL='" + cntrstr + "',TEU="+teuall+" WHERE BSNO='" + BSNO + "' ");
db.ExecuteNonQuery(cmdUpdate, idbTran);
}
i++;
}
idbTran.Commit();
isSucess = true;
}
catch (Exception exception)
{
idbTran.Rollback();
isSucess = false;
msg = exception.Message;
}
}
return isSucess;
}
public static bool ImportCtnData ( string bsno, HttpRequestBase request, DataTable table, out string msg, out List headList )
{
var isSucess = false;
msg = "";
headList = new List();
if (table == null) throw new ArgumentNullException("table");
var billNoList = new List();
var i = 1;
Database db = DatabaseFactory.CreateDatabase();
using (DbConnection connection = db.CreateConnection())
{
connection.Open();
DbTransaction idbTran = connection.BeginTransaction();
try
{
foreach (DataRow row in table.Rows)
{
var CNTRNO = Convert.ToString(row["箱号"]);
var SEALNO = Convert.ToString(row["铅封号"]);
var CTNALL = Convert.ToString(row["尺寸类型"]);
var PKGS = Convert.ToString(row["件数"]);
var KGS = Convert.ToString(row["重量"]);
var KINGPKGS = Convert.ToString(row["包装单位"]);
var CBM = Convert.ToString(row["尺码"]);
var TAREWEIGHT = "0";
try
{
TAREWEIGHT = Convert.ToString(row["皮重"]);
}
catch {
}
//if (i.ToString().Length == 1) CTNCODE = "0" + i.ToString();
//else CTNCODE = i.ToString();
if (CTNALL != "")
{
int SIZE = int.Parse(CTNALL.ToString().Trim().Substring(0, 2));
string CTN = CTNALL.ToString().Trim().Substring(2);
int TEU = 1;
int iTEU = int.Parse(CTNALL.ToString().Trim().Substring(0, 1));
if (iTEU == 4)
{
TEU = TEU * 2;
}
var CTNCODE = "";
#region 托单数据生成
CTNCODE = i.ToString();
if (CTNCODE.Length == 1) CTNCODE = "0" + CTNCODE;
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,WEIGHTYPE,WEIGHKGS,WEIGHATTN,WEIGHTEL,WEIGHSIGN) values ('"
+ Guid.NewGuid().ToString() + "','" + bsno + "','" + CTNCODE + "','" + SIZE + "','" + CTN + "',1," + TEU + ",'" + CTNALL.Replace("'", "''") + "','" + CNTRNO + "','" + SEALNO + "','" + PKGS + "'," + KGS + "," + CBM + ",'','" + KINGPKGS + "',"+ TAREWEIGHT + ",'','',0,'','','')");
db.ExecuteNonQuery(cmdInsert, idbTran);
#endregion
}
i++;
}
idbTran.Commit();
isSucess = true;
}
catch (Exception exception)
{
idbTran.Rollback();
isSucess = false;
msg = exception.Message;
}
}
return isSucess;
}
public static bool ImportCtnDetail ( string CTN_ID, HttpRequestBase request, DataTable table, out string msg, out List headList )
{
var isSucess = false;
msg = "";
headList = new List();
if (table == null) throw new ArgumentNullException("table");
var billNoList = new List();
var i = 1;
Database db = DatabaseFactory.CreateDatabase();
using (DbConnection connection = db.CreateConnection())
{
connection.Open();
DbTransaction idbTran = connection.BeginTransaction();
try
{
foreach (DataRow row in table.Rows)
{
var PKGS = Convert.ToString(row["件数"]);
var KGS = Convert.ToString(row["重量"]);
var KINGPKGS = Convert.ToString(row["包装"]);
var CBM = Convert.ToString(row["尺码"]);
var HSCODE = Convert.ToString(row["HS编码"]);
var GOODNAME = Convert.ToString(row["货物描述"]);
if (PKGS != "")
{
#region 托单数据生成
var cmdInsert = db.GetSqlStringCommand(@"insert into op_ctn_detail (GID,CTN_ID,PKGS,KGS,CBM,KINDPKGS,HSCODE,DESCRIPTION) values ('"
+ Guid.NewGuid().ToString() + "','" + CTN_ID + "'," + PKGS + "," + KGS + "," + CBM + ",'" + KINGPKGS + "','" + HSCODE + "','" + GOODNAME + "')");
db.ExecuteNonQuery(cmdInsert, idbTran);
#endregion
}
i++;
}
idbTran.Commit();
isSucess = true;
}
catch (Exception exception)
{
idbTran.Rollback();
isSucess = false;
msg = exception.Message;
}
}
return isSucess;
}
public static bool ImportCtnAndDetailData(string bsno, HttpRequestBase request, DataTable table, out string msg, out List headList)
{
var isSucess = false;
msg = "";
headList = new List();
if (table == null) throw new ArgumentNullException("table");
var billNoList = new List();
var i = 1;
Database db = DatabaseFactory.CreateDatabase();
using (DbConnection connection = db.CreateConnection())
{
connection.Open();
DbTransaction idbTran = connection.BeginTransaction();
try
{
foreach (DataRow row in table.Rows)
{
var CNTRNO = Convert.ToString(row["箱号"]);
if (CNTRNO != "")
{
MsOpSeaeDetail data = new MsOpSeaeDetail();
data.CNTRNO = Convert.ToString(row["箱号"]);
data.SEALNO = Convert.ToString(row["封号"]);
data.CTNALL = Convert.ToString(row["箱型"]);
data.PKGS = Convert.ToInt32(row["件数"]);
data.KGS = Convert.ToDecimal(row["重量"]);
data.GOODSNAME = Convert.ToString(row["品名"]).Replace("'", "''");
data.CBM = Convert.ToDecimal(row["尺码"]);
data.CTNFEE = Convert.ToString(row["商品编码"]);
headList.Add(data);
}
}
idbTran.Commit();
if (headList.Count>0)
InsertCtnData(bsno, headList);
isSucess = true;
}
catch (Exception exception)
{
idbTran.Rollback();
isSucess = false;
msg = exception.Message;
}
}
return isSucess;
}
public static bool ImportCtnAndDetailData2(string bsno, HttpRequestBase request, DataTable table, out string msg, out List headList)
{
var isSucess = false;
msg = "";
headList = new List();
if (table == null) throw new ArgumentNullException("table");
var billNoList = new List();
var i = 1;
Database db = DatabaseFactory.CreateDatabase();
using (DbConnection connection = db.CreateConnection())
{
connection.Open();
DbTransaction idbTran = connection.BeginTransaction();
try
{
var cntrno = "";
var sealno = "";
var cntrtype = "";
var ctnall = "";
var KINDPKGS = "";
var MARKS = "";
var first = true;
foreach (DataRow row in table.Rows)
{
if (first)
{
MARKS = Convert.ToString(row[1]);
KINDPKGS = Convert.ToString(row[2]);
first = false;
}
var HSCODE = Convert.ToString(row[6]);
if (HSCODE.Length == 6)
{
MsOpSeaeDetail data = new MsOpSeaeDetail();
data.CNTRNO = Convert.ToString(row[9]);
data.SEALNO = Convert.ToString(row[10]);
if (data.CNTRNO != ""&&data.CNTRNO.Length<20)
{
cntrno = data.CNTRNO;
sealno = data.SEALNO;
cntrtype = Convert.ToString(row[11]);
data.CTNALL = cntrtype.Substring(cntrtype.IndexOf("*") + 1, 4);
ctnall = data.CTNALL;
}
else {
data.CNTRNO = cntrno;
data.SEALNO = sealno;
data.CTNALL = ctnall;
}
data.PKGS = Convert.ToInt32(row[3]);
data.KGS = Convert.ToDecimal(row[4]);
data.KINDPKGS = KINDPKGS;
data.GOODSNAME = Convert.ToString(row[7]).Replace("'", "''");
data.CBM = Convert.ToDecimal(row[5]);
data.CTNFEE = Convert.ToString(row[6]);
data.WEIGHSIGN = MARKS;
headList.Add(data);
}
}
idbTran.Commit();
if (headList.Count > 0)
InsertCtnData(bsno, headList);
isSucess = true;
}
catch (Exception exception)
{
idbTran.Rollback();
isSucess = false;
msg = exception.Message;
}
}
return isSucess;
}
public static bool ImportMNData ( string bsno, HttpRequestBase request, DataTable table, out string msg, out List headList )
{
var isSucess = false;
msg = "";
headList = new List();
if (table == null) throw new ArgumentNullException("table");
var head = GetData("BSNO='" + bsno + "'");
var billNoList = new List();
Database db = DatabaseFactory.CreateDatabase();
using (DbConnection connection = db.CreateConnection())
{
connection.Open();
DbTransaction idbTran = connection.BeginTransaction();
try
{
foreach (DataRow row in table.Rows)
{
var MBLNO = Convert.ToString(row["分单号"]);
var CNTRNO = Convert.ToString(row["箱号"]);
var SEALNO = Convert.ToString(row["铅封号"]);
var PKGS = Convert.ToString(row["件"]);
var KGS = Convert.ToString(row["重"]);
var KINGPKGS = Convert.ToString(row["包装"]);
var CBM = Convert.ToString(row["尺"]);
var DESCRIPTION = Convert.ToString(row["品名"]);
if (DESCRIPTION == "")
DESCRIPTION = head.DESCRIPTION.Replace("'", "''");
if (MBLNO != "")
{
#region 托单数据生成
var cmdInsert = db.GetSqlStringCommand(@"insert into op_manifest (GID,BSNO,MBLNO,CNTRNO,SEALNO,PKGS,KGS,CBM,KINDPKGS,REMARK,DESCRIPTION) values ('"
+ Guid.NewGuid().ToString() + "','" + bsno + "','" + MBLNO + "','" + CNTRNO + "','" + SEALNO + "','" + PKGS + "'," + KGS + "," + CBM + ",'" + KINGPKGS + "','','" + DESCRIPTION + "')");
db.ExecuteNonQuery(cmdInsert, idbTran);
#endregion
}
}
idbTran.Commit();
isSucess = true;
}
catch (Exception exception)
{
idbTran.Rollback();
isSucess = false;
msg = exception.Message;
}
}
return isSucess;
}
#endregion
//
///
///
///
///
/// 0:未提交 1:整票提交 2:CZF确认
///
public static bool PiLiangZhengPiaoTiJiao ( string bsno,int statusvalue,string userid,string username,string comid,out string msg)
{
var BLAUDITISSEFT = MsSysParamSetDAL.GetData("PARAMNAME='BLAUDITISSEFT'");
var FEEMANGERMUSTBE = MsSysParamSetDAL.GetData("PARAMNAME='FEEMANGERMUSTBE'");
string message = "";
string blmessage = "";
string custmessage = "";
Database db = DatabaseFactory.CreateDatabase();
int rst = 0;
string[] bsnos = bsno.Split(',');
foreach (var item in bsnos)
{
string mblno = "";
var SUBMITBILLFEEISNOTZERO = MsSysParamSetDAL.GetData("PARAMNAME='SUBMITBILLFEEISNOTZERO'");
if (SUBMITBILLFEEISNOTZERO.PARAMVALUE == "1")
{
bool check0 = CheckHasZeroFeeWithBsno(item, FEEMANGERMUSTBE.PARAMVALUE, out mblno);
if (check0)
{
message += mblno + ",";
continue;
}
}
bool check1 = CheckHasNoCustWithBsno(item, out mblno);
if (check1)
{
custmessage += mblno + ",";
continue;
}
if (BLAUDITISSEFT.PARAMVALUE == "1")
{
bool checkRst = CheckHasNoAuditFeeWithBsno(item, out mblno);
if (checkRst)
{
blmessage += mblno + ",";
continue;
}
}
if (BLAUDITISSEFT.PARAMVALUE != "1")
{
string sqlLb = "select oplb from v_op_bs where bsno = " + item + "";
string oplb = db.ExecuteScalar(CommandType.Text, sqlLb).ToString();
if (oplb == "" || oplb == null)
{
continue;
}
if (oplb != "op_seae" && oplb != "op_seai" && oplb != "op_airi" && oplb != "op_aire" && oplb != "op_other" && oplb != "op_apply")
{
continue;
}
//费用提交
string condition = "BsNo=" + item;
string oplb2 = oplb;
switch (oplb)
{
case "op_seae":
oplb2 = "op_Seae";
break;
case "op_seai":
oplb2 = "op_Seai";
break;
case "op_airi":
oplb2 = "op_Airi";
break;
case "op_aire":
oplb2 = "op_Aire";
break;
case "op_appy":
oplb2 = "op_Apply";
break;
default:
break;
}
DBResult result = new DBResult();
if (statusvalue != 0)
{
// var dataList = DSWeb.MvcShipping.DAL.MsChFeeDAL.MsChFeeDAL.GetDataList(condition, 1, oplb2, userid, username, comid);
var dataList = DSWeb.MvcShipping.DAL.MsChFeeDAL.MsChFeeDAL.GetAllDataList(condition);
dataList = dataList.FindAll(t => t.FeeStatus == 1 || t.FeeStatus == 6 || t.FeeStatus == 7);
result = DSWeb.MvcShipping.DAL.Chfee_AuditDAL.Chfee_AuditDAL.SubmitAuditNew(oplb2, userid, dataList, true, "", "", comid);
}
else
{
var dataList = DSWeb.MvcShipping.DAL.MsChFeeDAL.MsChFeeDAL.GetAllDataList(condition);
dataList = dataList.FindAll(t => t.FeeStatus == 2);
var GidStr = "";
foreach (var bill in dataList)
{
if (GidStr == "") GidStr = bill.GId;
else GidStr = GidStr + "," + bill.GId;
}
result = DSWeb.MvcShipping.DAL.Chfee_AuditDAL.Chfee_AuditDAL.CancelAudit(oplb2, userid, GidStr, "");
}
if (result.Success)
{
//海运出口
StringBuilder sb = new StringBuilder();
sb.Append("update " + oplb);
sb.Append(" set BillFeeStatus = " + statusvalue);
sb.Append(" where bsno = " + item + "");
rst += db.ExecuteNonQuery(CommandType.Text, sb.ToString());
//根据参数判断是否执行【锁定】操作
if (statusvalue != 0)
{
var SUBMITFEEBLFEELOCK = MsSysParamSetDAL.GetData("PARAMNAME='SUBMITFEEBLFEELOCK'");
var SUBMITFEEBLBSLOCK = MsSysParamSetDAL.GetData("PARAMNAME='SUBMITFEEBLBSLOCK'");
if (SUBMITFEEBLFEELOCK.PARAMVALUE == "1" || SUBMITFEEBLBSLOCK.PARAMVALUE == "1")
{
if (SUBMITFEEBLFEELOCK.PARAMVALUE == "1" && SUBMITFEEBLBSLOCK.PARAMVALUE == "1")
{
string blUpSQL = "UPDATE " + oplb + " SET FEESTATUS=1,BSSTATUS=1 WHERE BSNO=" + item + "";
db.ExecuteNonQuery(CommandType.Text, blUpSQL);
}
else if (SUBMITFEEBLBSLOCK.PARAMVALUE == "1")
{
string blUpSQL = "UPDATE " + oplb + " SET BSSTATUS=1 WHERE BSNO=" + item + "";
db.ExecuteNonQuery(CommandType.Text, blUpSQL);
}
if (SUBMITFEEBLFEELOCK.PARAMVALUE == "1")
{
string blUpSQL = "UPDATE " + oplb + " SET FEESTATUS=1 WHERE BSNO=" + item + "";
db.ExecuteNonQuery(CommandType.Text, blUpSQL);
}
}
else
{
}
}
}
}
else {
var billlist = DSWeb.MvcShipping.DAL.Chfee_AuditDAL.Chfee_AuditDAL.GetBillDataList("MASTERNO=" + item + "",userid,username, comid, null, true);
if (statusvalue != 0)
{
DBResult resultbl = DSWeb.MvcShipping.DAL.Chfee_AuditDAL.Chfee_AuditDAL.SubmitAuditBL(userid, username,billlist, true, "", "", comid);
if (resultbl.Success)
{
rst = rst + 1;
foreach (var bill in billlist) {
var SUBMITFEEBLFEELOCK = MsSysParamSetDAL.GetData("PARAMNAME='SUBMITFEEBLFEELOCK'");
var SUBMITFEEBLBSLOCK = MsSysParamSetDAL.GetData("PARAMNAME='SUBMITFEEBLBSLOCK'");
if (SUBMITFEEBLFEELOCK.PARAMVALUE == "1" || SUBMITFEEBLBSLOCK.PARAMVALUE == "1")
{
if (SUBMITFEEBLFEELOCK.PARAMVALUE == "1" && SUBMITFEEBLBSLOCK.PARAMVALUE == "1")
{
string blUpSQL = "UPDATE " + bill.OPLB + " SET FEESTATUS=1,BSSTATUS=1 WHERE BSNO='" + bill.BSNO + "'";
db.ExecuteNonQuery(CommandType.Text, blUpSQL);
}
else if (SUBMITFEEBLBSLOCK.PARAMVALUE == "1")
{
string blUpSQL = "UPDATE " + bill.OPLB + " SET BSSTATUS=1 WHERE BSNO='" + bill.BSNO + "'";
db.ExecuteNonQuery(CommandType.Text, blUpSQL);
}
if (SUBMITFEEBLFEELOCK.PARAMVALUE == "1")
{
string blUpSQL = "UPDATE " + bill.OPLB + " SET FEESTATUS=1 WHERE BSNO='" + bill.BSNO + "'";
db.ExecuteNonQuery(CommandType.Text, blUpSQL);
}
}
else
{
}
}
};
}
else {
DBResult resultbl = DSWeb.MvcShipping.DAL.Chfee_AuditDAL.Chfee_AuditDAL.CancelAuditBL(userid, billlist);
if (resultbl.Success) rst = rst + 1;
}
}
}
if (message.Length>0)
{
message= message.Substring(0,message.Length-1);
if (FEEMANGERMUSTBE.PARAMVALUE=="1")
message += "存在金额为0的费用或责任人为空的费用,未进行提交操作。";
else
message += "存在金额为0或申请修改、申请删除的费用,未进行提交操作。";
}
if (blmessage.Length > 0)
{
blmessage = blmessage.Substring(0, blmessage.Length - 1);
blmessage += "存在客户名称为空或【已提交单票未审核】费用";
}
if (custmessage.Length > 0)
{
custmessage = custmessage.Substring(0, custmessage.Length - 1);
custmessage += "存在客户名称为空费用";
}
msg = message+ blmessage+ custmessage;
return rst > 0;
}
public static bool CheckMBLNONeedConfirmIsExist (string mblno,string bsno) {
string sql = "select count(*) from op_seae where mblno = '"+mblno+"' and bsno<>'"+bsno+"'";
Database db = DatabaseFactory.CreateDatabase();
bool rtn = false;
int rst = Convert.ToInt32(db.ExecuteScalar(CommandType.Text, sql));
var SeaeMblrepeat = MsSysParamSetDAL.GetData("PARAMNAME='SeaeMblrepeat'");
//海运出口主提单号允许重复=1 并且 主题单号已存在,则为true
if (SeaeMblrepeat.PARAMVALUE == "1" && rst>0)
{
rtn = true;
}
return rtn;
}
public static bool CheckHasZeroFeeWithBsno(string bsno,string mustmanage,out string mblno) {
Database db = DatabaseFactory.CreateDatabase();
int rst = 0;
string sql = "select count(*) from ch_fee where bsno = " + bsno + " and (amount = 0 OR FEESTATUS=3 OR FEESTATUS=4) ";
if (mustmanage=="1") sql = "select count(*) from ch_fee where bsno = " + bsno + " and (amount = 0 OR FEESTATUS=3 OR FEESTATUS=4 or isnull(MANAGER,'')='')";
rst = Convert.ToInt32( db.ExecuteScalar(CommandType.Text,sql));
string sql2 = "select mblno from v_op_bs where bsno = "+bsno+"";
var blno = db.ExecuteScalar(CommandType.Text, sql2);
if (blno==DBNull.Value||blno==null)
{
mblno = "";
return rst > 0;
}
else
{
mblno = blno.ToString();
return rst > 0;
}
}
public static bool CheckHasNoCustWithBsno(string bsno, out string mblno)
{
Database db = DatabaseFactory.CreateDatabase();
int rst = 0;
string sql = "select count(*) from ch_fee where bsno = " + bsno + " and CUSTOMERNAME='' ";
rst = Convert.ToInt32(db.ExecuteScalar(CommandType.Text, sql));
string sql2 = "select mblno from v_op_bs where bsno = " + bsno + "";
var blno = db.ExecuteScalar(CommandType.Text, sql2);
if (blno == DBNull.Value || blno == null)
{
mblno = "";
return rst > 0;
}
else
{
mblno = blno.ToString();
return rst > 0;
}
}
public static bool CheckHasNoAuditFeeWithBsno(string bsno, out string mblno)
{
Database db = DatabaseFactory.CreateDatabase();
int rst = 0;
string sql = "select count(*) from ch_fee where bsno = " + bsno + " and (CUSTOMERNAME='' OR FEESTATUS=2 or FEESTATUS=3 or FEESTATUS=4)";
rst = Convert.ToInt32(db.ExecuteScalar(CommandType.Text, sql));
string sql2 = "select mblno from v_op_bs where bsno = " + bsno + "";
var blno = db.ExecuteScalar(CommandType.Text, sql2);
if (blno == DBNull.Value || blno == null)
{
mblno = "";
return rst > 0;
}
else
{
mblno = blno.ToString();
return rst > 0;
}
}
}
}