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.
294 lines
16 KiB
C#
294 lines
16 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Data;
|
|
|
|
namespace WebSqlHelper
|
|
{
|
|
public class business
|
|
{
|
|
//excel导入
|
|
public static string importBoxBusiness(DataTable dt, string vsl, string val, string etd, string posi, string posiname, string ReachTime, string fobport,string opman)
|
|
{
|
|
string str = "";
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
DataRow dr = dt.Rows[i];
|
|
|
|
if (!string.IsNullOrEmpty(dr["CNTR NO"].ToString().Trim()))
|
|
{
|
|
var ctnno = dr["CNTR NO"].ToString().Trim();
|
|
if (ctnno.IndexOf("/") != 0) {
|
|
ctnno = ctnno.Substring(0, 11);
|
|
}
|
|
|
|
if (Common.isCntrNO(ctnno))
|
|
{
|
|
try
|
|
{
|
|
DataTable dt1 = BaseClass.db.GetSqlStrTable("select * from container_business where vessel='" + vsl + "' and Voyage='" + val + "' and Box_No='" + ctnno+ "'");
|
|
if (dt1.Rows.Count > 0)
|
|
{
|
|
BaseClass.db.SetSqlStrNonQuery("update container_business set BLNO=@BLNO,Vessel=@Vessel,Voyage=@Voyage,Box_No=@Box_No,Etd=@Etd,State=@State,Position=@Position,ReachTime=@ReachTime,fobport=@fobport,operman=@operman,opertime=@opertime,Remarks=@Remarks,OneWay=@OneWay where b_id=" + dt1.Rows[0]["b_id"].ToString() + ""
|
|
, BaseClass.db.GetParameter("BLNO", dr["B/LNO"].ToString().Trim())
|
|
, BaseClass.db.GetParameter("Vessel", vsl)
|
|
, BaseClass.db.GetParameter("Voyage", val)
|
|
, BaseClass.db.GetParameter("Box_No", ctnno)
|
|
, BaseClass.db.GetParameter("ETD", etd)
|
|
, BaseClass.db.GetParameter("Position", posi)
|
|
, BaseClass.db.GetParameter("State", setFE(dr["ISFULL"].ToString()))
|
|
, BaseClass.db.GetParameter("ReachTime", ReachTime)
|
|
, BaseClass.db.GetParameter("fobport", fobport)
|
|
, BaseClass.db.GetParameter("operman", opman)
|
|
, BaseClass.db.GetParameter("opertime", DateTime.Now.ToString())
|
|
, BaseClass.db.GetParameter("Remarks", dr["备注"].ToString())
|
|
, BaseClass.db.GetParameter("OneWay", dr["OneWay"].ToString())
|
|
);
|
|
}
|
|
else
|
|
{
|
|
BaseClass.db.SetSqlStrNonQuery("insert into container_business (BLNO,Vessel,Voyage,Box_No,Etd,State,Position,ReachTime,fobport,operman,opertime,Remarks,OneWay)values(@BLNO,@Vessel,@Voyage,@Box_No,@Etd,@State,@Position,@ReachTime,@fobport,@operman,@opertime,@Remarks,@OneWay)"
|
|
, BaseClass.db.GetParameter("BLNO", dr["B/LNO"].ToString().Trim())
|
|
, BaseClass.db.GetParameter("Vessel", vsl)
|
|
, BaseClass.db.GetParameter("Voyage", val)
|
|
, BaseClass.db.GetParameter("Box_No", ctnno)
|
|
, BaseClass.db.GetParameter("ETD", etd)
|
|
, BaseClass.db.GetParameter("Position", posi)
|
|
, BaseClass.db.GetParameter("State", setFE(dr["ISFULL"].ToString()))
|
|
, BaseClass.db.GetParameter("ReachTime", ReachTime)
|
|
, BaseClass.db.GetParameter("fobport", fobport)
|
|
, BaseClass.db.GetParameter("operman", opman)
|
|
, BaseClass.db.GetParameter("opertime", DateTime.Now.ToString())
|
|
, BaseClass.db.GetParameter("Remarks", dr["备注"].ToString())
|
|
, BaseClass.db.GetParameter("OneWay", dr["OneWay"].ToString())
|
|
);
|
|
}
|
|
// BaseClass.db.SetSqlStrNonQuery("update container_info set status=" + setFE(dr["ISFULL"].ToString()) + ",Position='" + posi + "',positionname='" + posiname + "',Vessel='" + vsl + "',Voyage='" + val + "' where CntrNo='" + dr["CNTR NO"].ToString().Trim() + "'");
|
|
BaseClass.db.SetSqlStrNonQuery(" exec p_update_ctnno '" + ctnno + "'");
|
|
|
|
}
|
|
catch { }
|
|
}
|
|
else
|
|
{
|
|
str += ctnno + ",";
|
|
}
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(str.TrimEnd(',')))
|
|
{
|
|
str = "已导入,以下箱号不合法未能导入:\\n" + str.TrimEnd(',');
|
|
}
|
|
else
|
|
str += "导入成功";
|
|
}
|
|
else
|
|
{
|
|
str = "没有数据导入";
|
|
}
|
|
return str;
|
|
}
|
|
//批量业务导入
|
|
public static string importBox(string vsl, string val, string etd, string posi, string posiname, string ReachTime, string fobport, string inputs, string operman)
|
|
{
|
|
string str = "";
|
|
|
|
string[] input = inputs.Split(',');
|
|
foreach (string record in input)
|
|
{
|
|
string[] s = record.Split('/');
|
|
|
|
if (Common.isCntrNO(s[0]))
|
|
{
|
|
try
|
|
{
|
|
|
|
DataTable dt = BaseClass.db.GetSqlStrTable("select * from container_business where vessel='" + vsl + "' and Voyage='" + val + "' and Box_No='" + s[0] + "'");
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
BaseClass.db.SetSqlStrNonQuery("update container_business set BLNO=@BLNO,Vessel=@Vessel,Voyage=@Voyage,Box_No=@Box_No,Etd=@Etd,State=@State,Position=@Position,ReachTime=@ReachTime,fobport=@fobport,operman=@operman ,opertime=@opertime where b_id=" + dt.Rows[0]["b_id"].ToString() + ""
|
|
, BaseClass.db.GetParameter("BLNO", s[1])
|
|
, BaseClass.db.GetParameter("Vessel", vsl)
|
|
, BaseClass.db.GetParameter("Voyage", val)
|
|
, BaseClass.db.GetParameter("Box_No", s[0])
|
|
, BaseClass.db.GetParameter("ETD", etd)
|
|
, BaseClass.db.GetParameter("Position", posi)
|
|
, BaseClass.db.GetParameter("State", setFE(s[2]))
|
|
, BaseClass.db.GetParameter("ReachTime", ReachTime)
|
|
, BaseClass.db.GetParameter("fobport", fobport)
|
|
, BaseClass.db.GetParameter("operman", operman)
|
|
, BaseClass.db.GetParameter("opertime", DateTime.Now.ToString())
|
|
);
|
|
}
|
|
else
|
|
{
|
|
BaseClass.db.SetSqlStrNonQuery("insert into container_business (BLNO,Vessel,Voyage,Box_No,Etd,State,Position,ReachTime,fobport,operman,opertime)values(@BLNO,@Vessel,@Voyage,@Box_No,@Etd,@State,@Position,@ReachTime,@fobport,@operman,@opertime)"
|
|
, BaseClass.db.GetParameter("BLNO", s[1])
|
|
, BaseClass.db.GetParameter("Vessel", vsl)
|
|
, BaseClass.db.GetParameter("Voyage", val)
|
|
, BaseClass.db.GetParameter("Box_No", s[0])
|
|
, BaseClass.db.GetParameter("ETD", etd)
|
|
, BaseClass.db.GetParameter("State", setFE(s[2]))
|
|
, BaseClass.db.GetParameter("Position", posi)
|
|
, BaseClass.db.GetParameter("ReachTime", ReachTime)
|
|
, BaseClass.db.GetParameter("fobport", fobport)
|
|
, BaseClass.db.GetParameter("operman", operman)
|
|
, BaseClass.db.GetParameter("opertime", DateTime.Now.ToString())
|
|
);
|
|
}
|
|
// BaseClass.db.SetSqlStrNonQuery("update container_info set status=" + setFE(dr["ISFULL"].ToString()) + ",Position='" + posi + "',positionname='" + posiname + "',Vessel='" + vsl + "',Voyage='" + val + "' where CntrNo='" + dr["CNTR NO"].ToString().Trim() + "'");
|
|
BaseClass.db.SetSqlStrNonQuery(" exec p_update_ctnno '" + s[0] + "'");
|
|
|
|
}
|
|
catch { }
|
|
}
|
|
else
|
|
{
|
|
str += s[0] + ",";
|
|
}
|
|
|
|
}
|
|
if (!string.IsNullOrEmpty(str.TrimEnd(',')))
|
|
{
|
|
str = "已导入,以下箱号不合法未能导入:\\n" + str.TrimEnd(',');
|
|
}
|
|
else
|
|
str += "批量导入成功";
|
|
return str;
|
|
}
|
|
//箱子导入
|
|
public static string ImportBoxNO(DataTable dt)
|
|
{
|
|
string str = "";
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
DataRow dr = dt.Rows[i];
|
|
if (!string.IsNullOrEmpty(dr["箱号"].ToString().Trim()))
|
|
{
|
|
//检测型号是否有效
|
|
if (Common.isCntrNO(dr["箱号"].ToString().Trim()))
|
|
{
|
|
try
|
|
{
|
|
DataTable dt1 = BaseClass.db.GetSqlStrTable("select * from container_info where cntrno='" + dr["箱号"].ToString().Trim() + "'");
|
|
if (dt1.Rows.Count > 0)
|
|
{
|
|
BaseClass.db.SetSqlStrNonQuery("update container_info set cntrno=@cntrno, cntrowner=@cntrowner, cntype=@cntype, cnsource=@cnsource, buytime=@buytime, rent_begintime=@rent_begintime, rent_endtime=@rent_endtime, status=@status, position=@position, positionName=@positionName where cntrid=" + dt1.Rows[0]["cntrid"].ToString() + ""
|
|
, BaseClass.db.GetParameter("cntrno", dr["箱号"].ToString().Trim())
|
|
, BaseClass.db.GetParameter("cntrowner", dr["箱主"].ToString().Trim())
|
|
, BaseClass.db.GetParameter("cntype", dr["箱型"].ToString().Trim())
|
|
, BaseClass.db.GetParameter("cnsource", dr["箱源"].ToString().Trim())
|
|
, BaseClass.db.GetParameter("buytime", getDate(dr["购买时间"].ToString().Trim()))
|
|
, BaseClass.db.GetParameter("rent_begintime", getDate(dr["租用开始时间"].ToString().Trim()))
|
|
, BaseClass.db.GetParameter("rent_endtime", getDate(dr["租用结束时间"].ToString().Trim()))
|
|
, BaseClass.db.GetParameter("status", getStatus(dr["状态"].ToString().Trim()))
|
|
, BaseClass.db.GetParameter("position", getPosition(dr["当前位置"].ToString().Trim()))
|
|
, BaseClass.db.GetParameter("positionName", dr["当前位置"].ToString().Trim())
|
|
);
|
|
}
|
|
else
|
|
{
|
|
//str += dr["箱号"].ToString().Trim() + "#";
|
|
BaseClass.db.SetSqlStrNonQuery("insert into container_info (cntrno, cntrowner, cntype, cnsource, buytime, rent_begintime, rent_endtime, status, position, positionName)values(@cntrno, @cntrowner, @cntype, @cnsource, @buytime, @rent_begintime, @rent_endtime, @status, @position, @positionName)"
|
|
, BaseClass.db.GetParameter("cntrno", dr["箱号"].ToString().Trim())
|
|
, BaseClass.db.GetParameter("cntrowner", dr["箱主"].ToString().Trim())
|
|
, BaseClass.db.GetParameter("cntype", dr["箱型"].ToString().Trim())
|
|
, BaseClass.db.GetParameter("cnsource", dr["箱源"].ToString().Trim())
|
|
, BaseClass.db.GetParameter("buytime", getDate(dr["购买时间"].ToString().Trim()))
|
|
, BaseClass.db.GetParameter("rent_begintime", getDate(dr["租用开始时间"].ToString().Trim()))
|
|
, BaseClass.db.GetParameter("rent_endtime", getDate(dr["租用结束时间"].ToString().Trim()))
|
|
, BaseClass.db.GetParameter("status", getStatus(dr["状态"].ToString().Trim()))
|
|
, BaseClass.db.GetParameter("position", getPosition(dr["当前位置"].ToString().Trim()))
|
|
, BaseClass.db.GetParameter("positionName", dr["当前位置"].ToString().Trim())
|
|
);
|
|
}
|
|
|
|
}
|
|
catch { }
|
|
}
|
|
else
|
|
{
|
|
str += dr["箱号"].ToString().Trim() + ",";
|
|
}
|
|
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(str.TrimEnd(',')))
|
|
{
|
|
str = "已导入,以下箱号不合法未能导入:\\n"+str.TrimEnd(',');
|
|
}
|
|
else
|
|
str += "导入成功";
|
|
}
|
|
else
|
|
{
|
|
str = "没有数据导入";
|
|
}
|
|
return str;
|
|
}
|
|
public static string getPosition(string position)
|
|
{
|
|
string str = "";
|
|
try {
|
|
str = BaseClass.db.GetSqlStrScalar("select portid from code_disport where cname='"+position+"'").ToString();
|
|
}
|
|
catch { }
|
|
return str;
|
|
}
|
|
public static string getDate(string date)
|
|
{
|
|
string str = null;
|
|
try {
|
|
str = DateTime.Parse(date).ToString("yyyy-MM-dd");
|
|
}
|
|
catch { }
|
|
return str;
|
|
}
|
|
public static string getStatus(string s)
|
|
{
|
|
string str = null;
|
|
switch (s)
|
|
{
|
|
case "可用":
|
|
str = "1";
|
|
break;
|
|
case "已用":
|
|
str = "2";
|
|
break;
|
|
case "维修":
|
|
str = "3";
|
|
break;
|
|
case "停用":
|
|
str = "4";
|
|
break;
|
|
case "退租":
|
|
str = "5";
|
|
break;
|
|
case "灭失":
|
|
str = "6";
|
|
break;
|
|
case "卖出":
|
|
str = "7";
|
|
break;
|
|
|
|
}
|
|
return str;
|
|
}
|
|
|
|
public static string setFE(string s)
|
|
{
|
|
string str = null;
|
|
if (s.ToUpper() == "F")
|
|
str = "2";
|
|
else if (s.ToUpper() == "E")
|
|
str = "1";
|
|
return str;
|
|
}
|
|
}
|
|
}
|