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.
1267 lines
56 KiB
C#
1267 lines
56 KiB
C#
|
|
using System;
|
|
using System.Data;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using DSWeb.MvcShipping.Models.MsOpLetter;
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
using DSWeb.EntityDA;
|
|
using HcUtility.Comm;
|
|
using DSWeb.MvcShipping.DAL.MsOpSeaeDAL;
|
|
using System.Data.SqlClient;
|
|
using WebSqlHelper;
|
|
using DSWeb.MvcShipping.Models.MsOpSeae;
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
using DSWeb.MvcShipping.DAL.MsSysParamSet;
|
|
using Newtonsoft.Json;
|
|
using DSWeb.Areas.Dispatch.Helper;
|
|
using DSWeb.MvcShipping.DAL.MsSysThirdPartyAccount;
|
|
|
|
namespace DSWeb.Areas.MvcShipping.DAL
|
|
{
|
|
public class MsOpLetterDAL
|
|
{
|
|
#region Inquery DataList
|
|
|
|
static public List<MsOpLetter> GetDataList(string strCondition)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append("LE_ID,BSNO,HEAD_TO,HEAD_ATTN,LETTERNAME,INPUTBY,INPUTTIME,UpdateTime,");
|
|
strSql.Append("HEAD_ATTNTEL,HEAD_ATTNFAX,HEAD_FMTEL,HEAD_FMFAX,HEAD_FMEMAIL");
|
|
strSql.Append(" from op_letter ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
return SetData(strSql);
|
|
}
|
|
|
|
static public MsOpLetter GetData(string condition)
|
|
{
|
|
var list = GetDataList(condition);
|
|
if (list.Count > 0)
|
|
return list[0];
|
|
|
|
return new MsOpLetter();
|
|
}
|
|
|
|
|
|
private static List<MsOpLetter> SetData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<MsOpLetter>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
MsOpLetter data = new MsOpLetter();
|
|
#region Set DB data to Object
|
|
data.LE_ID = Convert.ToString(reader["LE_ID"]);
|
|
data.BSNO = Convert.ToString(reader["BSNO"]);
|
|
data.HEAD_TO = Convert.ToString(reader["HEAD_TO"]);
|
|
data.HEAD_ATTN = Convert.ToString(reader["HEAD_ATTN"]);
|
|
data.LETTERNAME = Convert.ToString(reader["LETTERNAME"]);
|
|
data.INPUTBY = Convert.ToString(reader["INPUTBY"]);
|
|
data.INPUTTIME = Convert.ToString(reader["INPUTTIME"]);
|
|
data.UpdateTime = Convert.ToString(reader["UpdateTime"]);
|
|
data.HEAD_ATTNTEL = Convert.ToString(reader["HEAD_ATTNTEL"]);
|
|
data.HEAD_ATTNFAX = Convert.ToString(reader["HEAD_ATTNFAX"]);
|
|
data.HEAD_FMTEL = Convert.ToString(reader["HEAD_FMTEL"]);
|
|
data.HEAD_FMFAX = Convert.ToString(reader["HEAD_FMFAX"]);
|
|
data.HEAD_FMEMAIL = Convert.ToString(reader["HEAD_FMEMAIL"]);
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 入货通知
|
|
|
|
static public List<MsOpLetterYard> GetYardList(string strCondition)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append("LE_ID,MBLNO,PORTDISCHARGE,VESSELVOYNO,ETD,DESTINATION,PKC,CNTR,[DESCRIPTION],YARD,[Address],Tel,YARD2,Address2,Tel2,TiXiangTime,RuHuoTime,");
|
|
strSql.Append("DRQ,CLOSEDOCDATE,ExportCustoms,CustomsCode,DeclarationCode,REMARK,CLOSINGDATE,DOC,CHIEF,CHIEF2,DOCTEL,DOCFAX,DOCEMAIL,CLOSEVGMDATE,TXXPURL");
|
|
strSql.Append(",(SELECT TOP 1 SHARE_LINK FROM op_seae_billtrace_share_link where BSNO IN (SELECT BSNO FROM op_letter where LE_ID=op_letter_yard.LE_ID)) TRACKSHARELINK");
|
|
strSql.Append(" from op_letter_yard ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
return SetYardData(strSql);
|
|
}
|
|
|
|
static public MsOpLetterYard GetYardData(string condition)
|
|
{
|
|
var list = GetYardList(condition);
|
|
if (list.Count > 0)
|
|
return list[0];
|
|
|
|
return new MsOpLetterYard();
|
|
}
|
|
|
|
|
|
private static List<MsOpLetterYard> SetYardData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<MsOpLetterYard>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
MsOpLetterYard data = new MsOpLetterYard();
|
|
#region Set DB data to Object
|
|
data.LE_ID = Convert.ToString(reader["LE_ID"]);
|
|
data.MBLNO = Convert.ToString(reader["MBLNO"]);
|
|
data.PORTDISCHARGE = Convert.ToString(reader["PORTDISCHARGE"]);
|
|
data.DESTINATION = Convert.ToString(reader["DESTINATION"]);
|
|
data.VESSELVOYNO = Convert.ToString(reader["VESSELVOYNO"]);
|
|
if (reader["ETD"] != DBNull.Value)
|
|
data.ETD = Convert.ToDateTime(reader["ETD"]).ToString("yyyy-MM-dd");//截港日期
|
|
// data.ETD = Convert.ToString(reader["ETD"]);
|
|
data.PKC = Convert.ToString(reader["PKC"]);
|
|
data.CNTR = Convert.ToString(reader["CNTR"]);
|
|
data.DESCRIPTION = Convert.ToString(reader["DESCRIPTION"]);
|
|
data.YARD = Convert.ToString(reader["YARD"]);
|
|
data.Address = Convert.ToString(reader["Address"]);
|
|
data.Tel = Convert.ToString(reader["Tel"]);
|
|
data.YARD2 = Convert.ToString(reader["YARD2"]);
|
|
data.Address2 = Convert.ToString(reader["Address2"]);
|
|
data.Tel2 = Convert.ToString(reader["Tel2"]);
|
|
data.DRQ = Convert.ToString(reader["DRQ"]);
|
|
data.CLOSEDOCDATE = Convert.ToString(reader["CLOSEDOCDATE"]);
|
|
if (reader["CLOSEDOCDATE"] != DBNull.Value)
|
|
data.CLOSEDOCDATE = Convert.ToDateTime(reader["CLOSEDOCDATE"]).ToString("yyyy-MM-dd HH:mm:ss");//截港日期 if (reader["CLOSINGDATE"] != DBNull.Value)
|
|
if (reader["CLOSINGDATE"] != DBNull.Value)
|
|
data.CLOSINGDATE = Convert.ToDateTime(reader["CLOSINGDATE"]).ToString("yyyy-MM-dd HH:mm:ss");//截港日期 if (reader["CLOSINGDATE"] != DBNull.Value)
|
|
data.ExportCustoms = Convert.ToString(reader["ExportCustoms"]);
|
|
data.CustomsCode = Convert.ToString(reader["CustomsCode"]);
|
|
data.DeclarationCode = Convert.ToString(reader["DeclarationCode"]);
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
data.DOC = Convert.ToString(reader["DOC"]);
|
|
data.CHIEF = Convert.ToString(reader["CHIEF"]);
|
|
data.CHIEF2 = Convert.ToString(reader["CHIEF2"]);
|
|
data.DOCTEL = Convert.ToString(reader["DOCTEL"]);
|
|
data.DOCFAX = Convert.ToString(reader["DOCFAX"]);
|
|
data.DOCEMAIL = Convert.ToString(reader["DOCEMAIL"]);
|
|
data.CLOSEVGMDATE = Convert.ToString(reader["CLOSEVGMDATE"]);
|
|
if (reader["TiXiangTime"] != DBNull.Value)
|
|
data.TiXiangTime = Convert.ToDateTime(reader["TiXiangTime"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
if (reader["RuHuoTime"] != DBNull.Value)
|
|
data.RuHuoTime = Convert.ToDateTime(reader["RuHuoTime"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
if (reader["CLOSEVGMDATE"] != DBNull.Value)
|
|
data.CLOSEVGMDATE = Convert.ToDateTime(reader["CLOSEVGMDATE"]).ToString("yyyy-MM-dd HH:mm:ss");//截VGM日期
|
|
data.TXXPURL = Convert.ToString(reader["TXXPURL"]);
|
|
data.TRACKSHARELINK = Convert.ToString(reader["TRACKSHARELINK"]);
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
|
|
public static DBResult SendToTxxp(string bsno, string companyid)
|
|
{
|
|
|
|
var result = new DBResult();
|
|
var TXXPYTUSERNAME = "";
|
|
var TXXPYTPASS ="";
|
|
var TXXPDJYUSERNAME = MsSysParamSetDAL.GetData("PARAMNAME='TXXPDJYUSERNAME'").PARAMVALUE;
|
|
var TXXPDJYPASS = MsSysParamSetDAL.GetData("PARAMNAME='TXXPDJYPASS'").PARAMVALUE;
|
|
|
|
var headData = MsOpSeaeDAL.GetData("BSNO='" + bsno + "'");
|
|
var thirdpartyaccount = MsSysThirdPartyAccountDAL.GetData(" THIRDPARTY='提箱小票网站' and (CUSTOMERNAME='" + headData.CARRIER + "' OR ISNULL(CUSTOMERNAME,'')='')");
|
|
TXXPYTUSERNAME = thirdpartyaccount.ACCOUNT;
|
|
TXXPYTPASS = thirdpartyaccount.ACCOUNTPSW;
|
|
if (string.IsNullOrEmpty(TXXPYTUSERNAME))
|
|
{
|
|
result.Message = "不能生成数据,请在系统设置中第三方账号维护中设置船公司的提箱小票网站账户信息!";
|
|
result.Success = false;
|
|
}
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(TXXPYTUSERNAME) && !string.IsNullOrEmpty(TXXPYTPASS))
|
|
{
|
|
|
|
try
|
|
{
|
|
|
|
|
|
var NEWID = Guid.NewGuid().ToString().Replace("{", "").Replace("}", "");
|
|
var orderlist = CreateTxxp(headData, NEWID, companyid, TXXPYTUSERNAME, TXXPYTPASS, TXXPDJYUSERNAME, TXXPDJYPASS);
|
|
var strJson = JsonConvert.SerializeObject(orderlist);
|
|
string rtn = WebRequestHelper.DoPost("http://txxp.myshipping.net/txxp", strJson);
|
|
var objRtn = JsonConvert.DeserializeAnonymousType(rtn, new { status = false, message = "" });
|
|
if (objRtn.status)
|
|
{
|
|
|
|
result.Data = "http://txxp.myshipping.net/web/txxp/ticket.html#/gid=" + NEWID;
|
|
result.Success = true;
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
|
|
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
static public string GetCustEDICode(string CUST, string EDINAME)
|
|
{
|
|
string EDICODE = "";
|
|
CUST = CUST.Replace("'", "''");
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("select EDICODE from code_cust_edi where CUST='" + CUST + "' AND EDINAME='" + EDINAME + "'");
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
EDICODE = Convert.ToString(reader["EDICODE"]).Trim();
|
|
}
|
|
reader.Close();
|
|
}
|
|
if (EDICODE.Trim() == "")
|
|
{
|
|
var strSql2 = new StringBuilder();
|
|
strSql2.Append("select EDICODE from info_client WHERE SHORTNAME='" + CUST + "'");
|
|
db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql2.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
EDICODE = Convert.ToString(reader["EDICODE"]).Trim();
|
|
}
|
|
reader.Close();
|
|
}
|
|
}
|
|
return EDICODE;
|
|
}
|
|
static public string GetCtnEDICode(string Ctn, string EDINAME)
|
|
{
|
|
string EDICODE = "";
|
|
Ctn = Ctn.Replace("'", "''");
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("select EDICODE from code_ctn_edi where CTN='" + Ctn + "' AND EDINAME='" + EDINAME + "'");
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
EDICODE = Convert.ToString(reader["EDICODE"]);
|
|
}
|
|
reader.Close();
|
|
}
|
|
if (EDICODE.Trim() == "")
|
|
{
|
|
EDICODE = Ctn;
|
|
}
|
|
return EDICODE;
|
|
}
|
|
|
|
|
|
public static TxxpModel CreateTxxp(MsOpSeae headData, string txxpGID, string companyid, string TXXPYTUSERNAME, string TXXPYTPASS, string TXXPDJYUSERNAME, string TXXPDJYPASS)
|
|
{
|
|
var DJYTXXPCOMPANYID = MsSysParamSetDAL.GetData("PARAMNAME='DJYTXXPCOMPANYID'").PARAMVALUE;
|
|
string strCompanyName = DJYTXXPCOMPANYID;
|
|
if (string.IsNullOrEmpty(DJYTXXPCOMPANYID))
|
|
{
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
strCompanyName = T_ALL_DA.GetStrSQL("FULLNAME", "select top 1 FULLNAME from [company] where gid='" + companyid + "'");
|
|
}
|
|
var SALE = BasicDataRefDAL.GetUserLinkRef("U.SHOWNAME='" + headData.OP + "'");
|
|
|
|
|
|
var order = new TxxpModel();
|
|
order.billOrderId = txxpGID;
|
|
order.sendOrderCode = headData.MBLNO;
|
|
order.userId = SALE.GID;
|
|
order.userName = TXXPDJYUSERNAME;
|
|
order.userPassword = TXXPDJYPASS;
|
|
order.AgentName = strCompanyName;
|
|
order.CustomerName = headData.CUSTOMERNAME;
|
|
order.operatorName = headData.OP;
|
|
order.depotName = GetCustEDICode(headData.YARD, "TXXP");
|
|
order.linkName = headData.OP;
|
|
order.linkMobile = SALE.Tel;
|
|
order.CarrierCode = GetCustEDICode(headData.CARRIER, "TXXP");
|
|
order.portdischargeCode = headData.PORTDISCHARGEID;
|
|
order.portdischarge = headData.PORTDISCHARGE;
|
|
var cntrlist = new List<OpCtnTxxpViewModel>();
|
|
var ctnsumlist = MsOpSeaeDAL.GetBodyList("BSNO='" + headData.BSNO + "'");
|
|
foreach (var ctn in ctnsumlist)
|
|
{
|
|
var cntr = new OpCtnTxxpViewModel();
|
|
cntr.boxType = GetCtnEDICode(ctn.CTNALL,"TXXP");
|
|
cntr.boxCount = ctn.CTNNUM.ToString();
|
|
cntrlist.Add(cntr);
|
|
|
|
}
|
|
order.boxInfo = cntrlist;
|
|
order.sysLoginName = TXXPYTUSERNAME;
|
|
order.sysPsssword = TXXPYTPASS;
|
|
order.SystemCode = "dongsheng7";
|
|
|
|
return order;
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region 派车通知
|
|
|
|
static public List<MsOpLetterTruck> GetTruckList(string strCondition)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append("t.LE_ID,t.BSNO,t.TRUCK,t.CTNS,t.YARD,t.YARDATTN,t.YARDTEL,t.INPUTTIME,t.FACTRYNAME,t.FACTRYTIME,t.FACTRYATTN,t.FACTRYTEL,");
|
|
strSql.Append("t.FACTRYADDR,t.RETURNYARD,t.RETURNATTN,t.RETURNTEL,t.TRUCKDATE,t.TRUCKFEE,t.OTHERFEE,t.PAYTYPE,t.REMARK,t.TRUCKDETAIL,t.RETRUNYARDTIME,");
|
|
strSql.Append("t.CLOSINGDATE,t.TEAMTYPE,t.ISTEAMSTATUS,t.INPUTBY,t.TRUCKSTATUS,t.CARGODATE,t.KGS,b.VESSEL,b.VOYNO,b.MBLNO,t.ISFEE");
|
|
strSql.Append(",(SELECT top 1 OP FROM op_task where TASKNO=t.LE_ID) DDOP ");
|
|
strSql.Append(",(SELECT top 1 showname from [user] where GID=t.INPUTBY) INPUTBYREF ");
|
|
strSql.Append(" from op_letter_truck t ");
|
|
strSql.Append(" left join op_seae b on (b.BSNO=t.BSNO) ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
strSql.Append(" ORDER BY t.INPUTTIME DESC ");
|
|
|
|
return SetTruckData(strSql);
|
|
}
|
|
|
|
static public MsOpLetterTruck GetTruckData(string condition)
|
|
{
|
|
var list = GetTruckList(condition);
|
|
if (list.Count > 0)
|
|
return list[0];
|
|
|
|
return new MsOpLetterTruck();
|
|
}
|
|
|
|
|
|
private static List<MsOpLetterTruck> SetTruckData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<MsOpLetterTruck>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
MsOpLetterTruck data = new MsOpLetterTruck();
|
|
#region Set DB data to Object
|
|
|
|
|
|
data.LE_ID = Convert.ToString(reader["LE_ID"]);
|
|
data.TRUCK = Convert.ToString(reader["TRUCK"]);
|
|
data.BSNO = Convert.ToString(reader["BSNO"]);
|
|
data.CTNS = Convert.ToString(reader["CTNS"]);
|
|
data.YARD = Convert.ToString(reader["YARD"]);
|
|
data.YARDATTN = Convert.ToString(reader["YARDATTN"]);
|
|
data.YARDTEL = Convert.ToString(reader["YARDTEL"]);
|
|
data.YARDTEL = Convert.ToString(reader["YARDTEL"]);
|
|
data.INPUTTIME = Convert.ToString(reader["INPUTTIME"]);
|
|
data.YARD = Convert.ToString(reader["YARD"]);
|
|
data.FACTRYNAME = Convert.ToString(reader["FACTRYNAME"]);
|
|
data.FACTRYTIME = Convert.ToString(reader["FACTRYTIME"]);
|
|
data.FACTRYATTN = Convert.ToString(reader["FACTRYATTN"]);
|
|
data.FACTRYTEL = Convert.ToString(reader["FACTRYTEL"]);
|
|
data.FACTRYADDR = Convert.ToString(reader["FACTRYADDR"]);
|
|
data.RETURNYARD = Convert.ToString(reader["RETURNYARD"]);
|
|
data.RETURNATTN = Convert.ToString(reader["RETURNATTN"]);
|
|
data.RETURNTEL = Convert.ToString(reader["RETURNTEL"]);
|
|
data.RETRUNYARDTIME = Convert.ToString(reader["RETRUNYARDTIME"]);
|
|
data.TRUCKDATE = Convert.ToString(reader["TRUCKDATE"]);
|
|
data.TRUCKFEE = Convert.ToString(reader["TRUCKFEE"]);
|
|
data.OTHERFEE = Convert.ToString(reader["OTHERFEE"]);
|
|
data.PAYTYPE = Convert.ToString(reader["PAYTYPE"]);
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
data.TRUCKDETAIL = Convert.ToString(reader["TRUCKDETAIL"]);
|
|
data.CLOSINGDATE = Convert.ToString(reader["CLOSINGDATE"]);
|
|
data.TEAMTYPE = Convert.ToString(reader["TEAMTYPE"]);
|
|
data.ISTEAMSTATUS = Convert.ToString(reader["ISTEAMSTATUS"]);
|
|
data.INPUTBY = Convert.ToString(reader["INPUTBY"]);
|
|
data.TRUCKSTATUS = Convert.ToString(reader["TRUCKSTATUS"]);
|
|
data.CARGODATE = Convert.ToString(reader["CARGODATE"]);
|
|
data.VESSEL = Convert.ToString(reader["VESSEL"]);
|
|
data.VOYNO = Convert.ToString(reader["VOYNO"]);
|
|
data.MBLNO = Convert.ToString(reader["MBLNO"]);
|
|
data.KGS= Convert.ToString(reader["KGS"]);
|
|
data.ISFEE = Convert.ToString(reader["ISFEE"]);
|
|
data.DDOP = Convert.ToString(reader["DDOP"]);
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
|
|
public static List<MsOpLetterTruckCtn> GetLetterCtnList(string strCondition)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT CTN_ID,LE_ID,CTNALL,CTNNUM,KGS from op_letter_yard_ctn");
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
var evList = new List<MsOpLetterTruckCtn>();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
MsOpLetterTruckCtn Data = new MsOpLetterTruckCtn();
|
|
Data.CTN_ID = Convert.ToString(reader["CTN_ID"]);
|
|
Data.LE_ID = Convert.ToString(reader["LE_ID"]);
|
|
Data.CTNALL = Convert.ToString(reader["CTNALL"]);
|
|
if (reader["CTNNUM"] != DBNull.Value)
|
|
Data.CTNNUM = Convert.ToDecimal(reader["CTNNUM"]);
|
|
if (reader["KGS"] != DBNull.Value)
|
|
Data.KGS = Convert.ToDecimal(reader["KGS"]);
|
|
|
|
|
|
evList.Add(Data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
return evList;
|
|
}
|
|
|
|
|
|
public static DBResult SaveTruckCtn(MsOpLetterTruck headData, List<MsOpLetterTruckCtn> bodyList)
|
|
{
|
|
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_letter_yard_ctn where LE_ID='" + headData.LE_ID + "'");
|
|
db.ExecuteNonQuery(cmddelete, tran);
|
|
var cntr = "";
|
|
if (bodyList != null)
|
|
{
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
|
|
//if (enumValue.LE_ID == "*"|| enumValue.LE_ID == "")
|
|
//{
|
|
var cmdInsert = db.GetSqlStringCommand(@"insert into op_letter_yard_ctn (CTN_ID,LE_ID,CTNNUM,CTNALL,KGS) values (newid(),'" + headData.LE_ID + "'," + enumValue.CTNNUM + ",'" + enumValue.CTNALL + "',"+enumValue.KGS+")");
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
//}
|
|
//else
|
|
//{
|
|
// var cmdUpdate = db.GetSqlStringCommand(@"update op_letter_yard_ctn set CTNNUM=" + enumValue.CTNNUM + ",CTNALL='" + enumValue.CTNALL + "',KGS=" + enumValue.KGS + " where LE_ID='" + enumValue.LE_ID + "' AND CTN_ID='" + enumValue.CTN_ID + "'");
|
|
// db.ExecuteNonQuery(cmdUpdate, tran);
|
|
|
|
//}
|
|
|
|
}
|
|
}
|
|
//
|
|
|
|
|
|
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
result.Success = false;
|
|
result.Message = "保存出现错误,请重试或联系系统管理员";
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "保存成功" + result.Message;
|
|
return result;
|
|
}
|
|
public static DBResult DeleteTruckCtn(MsOpLetterTruckCtn headData, string userid)
|
|
{
|
|
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_letter_yard_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 IsSaveTruckCtn(MsOpLetterTruck headData, List<MsOpLetterTruckCtn> bodyList)
|
|
{
|
|
var result = new DBResult();
|
|
result.Success = true;
|
|
var letterctnlist = GetLetterCtnList("LE_ID<>'"+headData.LE_ID+ "' AND LE_ID IN (SELECT LE_ID FROM op_letter_truck where BSNO='"+headData.BSNO+"')");
|
|
if (bodyList != null)
|
|
{
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
var isfinded = false;
|
|
letterctnlist.ForEach(i =>
|
|
{
|
|
if (i.CTNALL == enumValue.CTNALL)
|
|
{
|
|
i.CTNNUM = i.CTNNUM + enumValue.CTNNUM;
|
|
isfinded = true;
|
|
}
|
|
});
|
|
if (!isfinded) {
|
|
letterctnlist.Add(enumValue);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
var opseaectnsum = MsOpSeaeDAL.GetBodyListSum("BSNO='" + headData.BSNO + "'");
|
|
if (letterctnlist != null)
|
|
{
|
|
foreach (var enumValue in letterctnlist)
|
|
{
|
|
var isfinded = false;
|
|
opseaectnsum.ForEach(i =>
|
|
{
|
|
if (i.CTNALL == enumValue.CTNALL)
|
|
{
|
|
if (i.CTNNUM < enumValue.CTNNUM) {
|
|
result.Success = false;
|
|
result.Message = result.Message + " 箱型:" + enumValue.CTNALL + ",不能超过总箱量不能保存!";
|
|
}
|
|
isfinded = true;
|
|
}
|
|
});
|
|
if (!isfinded) {
|
|
result.Success = false;
|
|
result.Message = result.Message+" 箱型:" + enumValue.CTNALL+",不存在不能保存!";
|
|
}
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
public static DBResult UpdateTruckStauts(string bsno,string status)
|
|
{
|
|
var result = new DBResult();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
try
|
|
{
|
|
var cmdDelete = db.GetSqlStringCommand("update op_letter_truck set TRUCKSTATUS='"+status+"' where LE_ID='" + bsno + "'");
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "删除出现错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
result.Success = true;
|
|
result.Message = "操作成功";
|
|
return result;
|
|
}
|
|
|
|
public static DBResult CreateTruckTask(MsOpLetterTruck headData,string username)
|
|
{
|
|
var result = new DBResult();
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
var BLCOUNT = T_ALL_DA.GetStrSQL("BLCOUNT", "select COUNT(*) BLCOUNT from op_task where TASKNO='" + headData.LE_ID + "'");
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
if (BLCOUNT == "0")
|
|
{
|
|
var cmdUpdateBL =
|
|
db.GetSqlStringCommand(
|
|
@"INSERT INTO [op_task] (GID,[TASKNO] ,[PTASKNO],[TASKTYPE],[TASKSOURCE],[TASKSTATUS],[TASKTITLE] "
|
|
+ ",[CREATEUSER] ,[CREATETIME] ,[TASKBEGINDATE] ,[COMPLETETYPE] ,[COMPLETETIME] ,[KPI],[MBLNO],[FILENO],[MAILNO],[FILEPATH],[ISPUBLIC],[OP],[BSNO],ISCOMPLETE)"
|
|
+ " SELECT NEWID(),'" + headData.LE_ID + "' as [任务编号],null as [上级任务号], '待派车' as [任务类型], '操作' as [任务来源], '未开始' as [任务状态], '箱型箱量:" + headData.CTNS + "|重量:" + Convert.ToString(headData.KGS) + "|工厂:" + headData.FACTRYNAME + " ' as [任务说明],"
|
|
+ "'" + username + "' as [发起人],GETDATE() as [录入日期],'" + headData.FACTRYTIME + "' as[任务开始时间], '手动' as [完成方式],null as [完成时间] ,null as [KPI值] , '" + headData.MBLNO + "' as [提单号], "
|
|
+ " null as [文件编号], '' as [邮件编号], '' as [电子档案路径], 1 as 是否公共,'' as 客服员,'" + headData.BSNO + "' as 编号,0");
|
|
db.ExecuteNonQuery(cmdUpdateBL, tran);
|
|
|
|
}
|
|
else {
|
|
var cmdUpdateBL =
|
|
db.GetSqlStringCommand(
|
|
@"update [op_task] set [TASKTITLE]='箱型箱量:" + headData.CTNS + "|重量:" + Convert.ToString(headData.KGS) + "|工厂:" + headData.FACTRYNAME + " ', "
|
|
+ "TASKBEGINDATE='" + headData.FACTRYTIME + "',[TASKTYPE]='待派车(重新提交)' where TASKNO='" + headData.LE_ID + "'");
|
|
db.ExecuteNonQuery(cmdUpdateBL, tran);
|
|
|
|
}
|
|
|
|
var cmdUpdateTruck =
|
|
db.GetSqlStringCommand(
|
|
@"update op_letter_truck set TRUCKSTATUS='提交派车' where LE_ID=@LE_ID ");
|
|
cmdUpdateTruck.Parameters.Clear();
|
|
db.AddInParameter(cmdUpdateTruck, "@LE_ID", DbType.String, headData.LE_ID);
|
|
db.ExecuteNonQuery(cmdUpdateTruck, tran);
|
|
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "生成任务出现错误,请重试或联系系统管理员" + e.Message;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "生成成功";
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
|
|
public static DBResult CreateFeeBl(MsOpLetterTruck headData, string userid,string username)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
var cmdInsertFee =
|
|
db.GetSqlStringCommand(
|
|
@"INSERT INTO ch_fee(GID, BSNO, FEETYPE, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY,
|
|
EXCHANGERATE, REASON, REMARK, COMMISSIONRATE,ENTEROPERATOR, ENTERDATE,ISOPEN, ISADVANCEDPAY, SORT, FEESTATUS, FEEFRT,CARGO_GID,
|
|
TAXRATE,NOTAXAMOUNT,ACCTAXRATE,LINENUM,TAXUNITPRICE,MODIFIEDUSER,MODIFIEDTIME,WMSOUTBSNO,PREAMOUNT,ISINVOICE,INPUTMODE,LOCALCURR,MANAGER,ISACC)
|
|
VALUES(@GID,@BSNO,@FEETYPE,@FEENAME,@FEEDESCRIPTION,@CUSTOMERTYPE,@CUSTOMERNAME,@UNIT,@UNITPRICE,@QUANTITY,@AMOUNT,@CURRENCY,
|
|
@EXCHANGERATE, @REASON, @REMARK, @COMMISSIONRATE,@ENTEROPERATOR, @ENTERDATE,@ISOPEN, @ISADVANCEDPAY, @SORT, @FEESTATUS, @FEEFRT,@CARGO_GID,
|
|
@TAXRATE,@NOTAXAMOUNT,@ACCTAXRATE,@LINENUM,@TAXUNITPRICE,@MODIFIEDUSER,@MODIFIEDTIME,@WMSOUTBSNO,@PREAMOUNT,@ISINVOICE,@INPUTMODE,@LOCALCURR,@MANAGER,@ISACC)
|
|
");
|
|
|
|
if (!GetTruckFeeCount(headData.LE_ID))
|
|
{
|
|
|
|
cmdInsertFee.Parameters.Clear();
|
|
|
|
db.AddInParameter(cmdInsertFee, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
db.AddInParameter(cmdInsertFee, "@BSNO", DbType.String, headData.BSNO);
|
|
db.AddInParameter(cmdInsertFee, "@FEETYPE", DbType.Int16, 2);
|
|
db.AddInParameter(cmdInsertFee, "@FEENAME", DbType.String, "陆运费");
|
|
db.AddInParameter(cmdInsertFee, "@FEEDESCRIPTION", DbType.String, "");
|
|
db.AddInParameter(cmdInsertFee, "@CUSTOMERTYPE", DbType.String, "车队");
|
|
db.AddInParameter(cmdInsertFee, "@CUSTOMERNAME", DbType.String, headData.TRUCK);
|
|
db.AddInParameter(cmdInsertFee, "@UNIT", DbType.String,"票");
|
|
db.AddInParameter(cmdInsertFee, "@UNITPRICE", DbType.Decimal, headData.TRUCKFEE);
|
|
db.AddInParameter(cmdInsertFee, "@QUANTITY", DbType.Decimal, 1);
|
|
db.AddInParameter(cmdInsertFee, "@AMOUNT", DbType.Decimal, headData.TRUCKFEE);
|
|
db.AddInParameter(cmdInsertFee, "@CURRENCY", DbType.String, "RMB");
|
|
db.AddInParameter(cmdInsertFee, "@EXCHANGERATE", DbType.Decimal, 1);
|
|
db.AddInParameter(cmdInsertFee, "@REASON", DbType.String, "");
|
|
db.AddInParameter(cmdInsertFee, "@REMARK", DbType.String, "");
|
|
db.AddInParameter(cmdInsertFee, "@COMMISSIONRATE", DbType.Decimal, 0);
|
|
db.AddInParameter(cmdInsertFee, "@ENTEROPERATOR", DbType.String, userid);
|
|
db.AddInParameter(cmdInsertFee, "@ENTERDATE", DbType.String, DateTime.Now.ToString());
|
|
db.AddInParameter(cmdInsertFee, "@ISOPEN", DbType.Boolean, false);
|
|
db.AddInParameter(cmdInsertFee, "@ISADVANCEDPAY", DbType.Boolean, false);
|
|
db.AddInParameter(cmdInsertFee, "@SORT", DbType.Int16, 1);
|
|
db.AddInParameter(cmdInsertFee, "@FEESTATUS", DbType.Int16, 1);
|
|
db.AddInParameter(cmdInsertFee, "@FEEFRT", DbType.String, "PP");
|
|
db.AddInParameter(cmdInsertFee, "@CARGO_GID", DbType.String, headData.LE_ID);
|
|
db.AddInParameter(cmdInsertFee, "@TAXRATE", DbType.Decimal, 0);
|
|
db.AddInParameter(cmdInsertFee, "@NOTAXAMOUNT", DbType.Decimal, headData.TRUCKFEE);
|
|
db.AddInParameter(cmdInsertFee, "@ACCTAXRATE", DbType.Decimal, 0);
|
|
db.AddInParameter(cmdInsertFee, "@LINENUM", DbType.Int16, 1);
|
|
db.AddInParameter(cmdInsertFee, "@TAXUNITPRICE", DbType.Decimal, headData.TRUCKFEE);
|
|
db.AddInParameter(cmdInsertFee, "@MODIFIEDUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdInsertFee, "@MODIFIEDTIME", DbType.String, DateTime.Now.ToString());
|
|
|
|
db.AddInParameter(cmdInsertFee, "@WMSOUTBSNO", DbType.String, "");
|
|
db.AddInParameter(cmdInsertFee, "@PREAMOUNT", DbType.Decimal, 0);
|
|
db.AddInParameter(cmdInsertFee, "@ISINVOICE", DbType.Boolean, false);
|
|
db.AddInParameter(cmdInsertFee, "@INPUTMODE", DbType.String, "");
|
|
db.AddInParameter(cmdInsertFee, "@LOCALCURR", DbType.String, "RMB");
|
|
db.AddInParameter(cmdInsertFee, "@MANAGER", DbType.String, "");
|
|
db.AddInParameter(cmdInsertFee, "@ISACC", DbType.Boolean, false);
|
|
|
|
db.ExecuteNonQuery(cmdInsertFee, tran);
|
|
|
|
if (headData.OTHERFEE != "" && headData.OTHERFEE != "0" && headData.OTHERFEE !=null)
|
|
{
|
|
|
|
cmdInsertFee.Parameters.Clear();
|
|
|
|
db.AddInParameter(cmdInsertFee, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
db.AddInParameter(cmdInsertFee, "@BSNO", DbType.String, headData.BSNO);
|
|
db.AddInParameter(cmdInsertFee, "@FEETYPE", DbType.Int16, 2);
|
|
db.AddInParameter(cmdInsertFee, "@FEENAME", DbType.String, "绩效及加班");
|
|
db.AddInParameter(cmdInsertFee, "@FEEDESCRIPTION", DbType.String, "");
|
|
db.AddInParameter(cmdInsertFee, "@CUSTOMERTYPE", DbType.String, "其他");
|
|
db.AddInParameter(cmdInsertFee, "@CUSTOMERNAME", DbType.String, username);
|
|
db.AddInParameter(cmdInsertFee, "@UNIT", DbType.String, "票");
|
|
db.AddInParameter(cmdInsertFee, "@UNITPRICE", DbType.Decimal, headData.OTHERFEE);
|
|
db.AddInParameter(cmdInsertFee, "@QUANTITY", DbType.Decimal, 1);
|
|
db.AddInParameter(cmdInsertFee, "@AMOUNT", DbType.Decimal, headData.OTHERFEE);
|
|
db.AddInParameter(cmdInsertFee, "@CURRENCY", DbType.String, "RMB");
|
|
db.AddInParameter(cmdInsertFee, "@EXCHANGERATE", DbType.Decimal, 1);
|
|
db.AddInParameter(cmdInsertFee, "@REASON", DbType.String, "");
|
|
db.AddInParameter(cmdInsertFee, "@REMARK", DbType.String, "");
|
|
db.AddInParameter(cmdInsertFee, "@COMMISSIONRATE", DbType.Decimal, 0);
|
|
db.AddInParameter(cmdInsertFee, "@ENTEROPERATOR", DbType.String, userid);
|
|
db.AddInParameter(cmdInsertFee, "@ENTERDATE", DbType.String, DateTime.Now.ToString());
|
|
db.AddInParameter(cmdInsertFee, "@ISOPEN", DbType.Boolean, false);
|
|
db.AddInParameter(cmdInsertFee, "@ISADVANCEDPAY", DbType.Boolean, false);
|
|
db.AddInParameter(cmdInsertFee, "@SORT", DbType.Int16, 1);
|
|
db.AddInParameter(cmdInsertFee, "@FEESTATUS", DbType.Int16, 1);
|
|
db.AddInParameter(cmdInsertFee, "@FEEFRT", DbType.String, "PP");
|
|
db.AddInParameter(cmdInsertFee, "@CARGO_GID", DbType.String, headData.LE_ID);
|
|
db.AddInParameter(cmdInsertFee, "@TAXRATE", DbType.Decimal, 0);
|
|
db.AddInParameter(cmdInsertFee, "@NOTAXAMOUNT", DbType.Decimal, headData.OTHERFEE);
|
|
db.AddInParameter(cmdInsertFee, "@ACCTAXRATE", DbType.Decimal, 0);
|
|
db.AddInParameter(cmdInsertFee, "@LINENUM", DbType.Int16, 1);
|
|
db.AddInParameter(cmdInsertFee, "@TAXUNITPRICE", DbType.Decimal, headData.OTHERFEE);
|
|
db.AddInParameter(cmdInsertFee, "@MODIFIEDUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdInsertFee, "@MODIFIEDTIME", DbType.String, DateTime.Now.ToString());
|
|
|
|
db.AddInParameter(cmdInsertFee, "@WMSOUTBSNO", DbType.String, "");
|
|
db.AddInParameter(cmdInsertFee, "@PREAMOUNT", DbType.Decimal, 0);
|
|
db.AddInParameter(cmdInsertFee, "@ISINVOICE", DbType.Boolean, false);
|
|
db.AddInParameter(cmdInsertFee, "@INPUTMODE", DbType.String, "");
|
|
db.AddInParameter(cmdInsertFee, "@LOCALCURR", DbType.String, "RMB");
|
|
db.AddInParameter(cmdInsertFee, "@MANAGER", DbType.String, "");
|
|
db.AddInParameter(cmdInsertFee, "@ISACC", DbType.Boolean, false);
|
|
|
|
db.ExecuteNonQuery(cmdInsertFee, tran);
|
|
|
|
}
|
|
|
|
|
|
var cmdUpdateBL =
|
|
db.GetSqlStringCommand(
|
|
@"update op_letter_truck set ISFEE='1' where BSNO=@BSNO ");
|
|
cmdUpdateBL.Parameters.Clear();
|
|
db.AddInParameter(cmdUpdateBL, "@BSNO", DbType.String, headData.BSNO);
|
|
db.ExecuteNonQuery(cmdUpdateBL, tran);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "生成费用出现错误,请重试或联系系统管理员" + e.Message;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "生成成功";
|
|
|
|
return result;
|
|
}
|
|
public static DBResult DeleteFeeBl(MsOpLetterTruck headData)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
var cmdInsertFee =
|
|
db.GetSqlStringCommand(
|
|
@"delete from ch_fee where BSNO=@BSNO AND CARGO_GID=@CARGO_GID ");
|
|
|
|
if (headData.ISFEE == "1")
|
|
{
|
|
|
|
cmdInsertFee.Parameters.Clear();
|
|
|
|
db.AddInParameter(cmdInsertFee, "@BSNO", DbType.String, headData.BSNO);
|
|
db.AddInParameter(cmdInsertFee, "@CARGO_GID", DbType.String, headData.LE_ID);
|
|
|
|
db.ExecuteNonQuery(cmdInsertFee, tran);
|
|
|
|
var cmdUpdateBL =
|
|
db.GetSqlStringCommand(
|
|
@"update op_letter_truck set ISFEE='0' where BSNO=@BSNO ");
|
|
cmdUpdateBL.Parameters.Clear();
|
|
db.AddInParameter(cmdUpdateBL, "@BSNO", DbType.String, headData.BSNO);
|
|
db.ExecuteNonQuery(cmdUpdateBL, tran);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "生成费用出现错误,请重试或联系系统管理员" + e.Message;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "生成成功";
|
|
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 电放通知
|
|
|
|
static public List<MsOpLetterSur> GetSurList(string strCondition)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append("LE_ID,MBLNO,PORTLOAD,PORTDISCHARGE,VESSELVOYNO,CONSIGNEE,REMARK");
|
|
strSql.Append(" from op_letter_sur ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
return SetSurData(strSql);
|
|
}
|
|
|
|
static public MsOpLetterSur GetSurData(string condition)
|
|
{
|
|
var list = GetSurList(condition);
|
|
if (list.Count > 0)
|
|
return list[0];
|
|
|
|
return new MsOpLetterSur();
|
|
}
|
|
|
|
|
|
private static List<MsOpLetterSur> SetSurData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<MsOpLetterSur>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
MsOpLetterSur data = new MsOpLetterSur();
|
|
#region Set DB data to Object
|
|
data.LE_ID = Convert.ToString(reader["LE_ID"]);
|
|
data.MBLNO = Convert.ToString(reader["MBLNO"]);
|
|
data.PORTDISCHARGE = Convert.ToString(reader["PORTDISCHARGE"]);
|
|
data.VESSELVOYNO = Convert.ToString(reader["VESSELVOYNO"]);
|
|
data.PORTLOAD = Convert.ToString(reader["PORTLOAD"]);
|
|
data.CONSIGNEE = Convert.ToString(reader["CONSIGNEE"]);
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 更改通知
|
|
|
|
static public List<MsOpLetterChange> GetChangeList(string strCondition)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append("LE_ID,MBLNO,PORTDISCHARGE,VESSELVOYNO,ETD,PKC,CNTR,ProName,ProOld,ProNew,REMARK");
|
|
strSql.Append(" from op_letter_change ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
return SetChangeData(strSql);
|
|
}
|
|
|
|
static public MsOpLetterChange GetChangeData(string condition)
|
|
{
|
|
var list = GetChangeList(condition);
|
|
if (list.Count > 0)
|
|
return list[0];
|
|
|
|
return new MsOpLetterChange();
|
|
}
|
|
|
|
|
|
private static List<MsOpLetterChange> SetChangeData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<MsOpLetterChange>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
|
|
MsOpLetterChange data = new MsOpLetterChange();
|
|
#region Set DB data to Object
|
|
data.LE_ID = Convert.ToString(reader["LE_ID"]);
|
|
data.MBLNO = Convert.ToString(reader["MBLNO"]);
|
|
data.PORTDISCHARGE = Convert.ToString(reader["PORTDISCHARGE"]);
|
|
data.VESSELVOYNO = Convert.ToString(reader["VESSELVOYNO"]);
|
|
data.ETD = Convert.ToString(reader["ETD"]);
|
|
data.PKC = Convert.ToString(reader["PKC"]);
|
|
data.CNTR = Convert.ToString(reader["CNTR"]);
|
|
data.ProName = Convert.ToString(reader["ProName"]);
|
|
data.ProOld = Convert.ToString(reader["ProOld"]);
|
|
data.ProNew = Convert.ToString(reader["ProNew"]);
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
public static DBResult DeleteDetail(MsOpLetter 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_letter_yard where LE_ID='" + headData.LE_ID + "'");
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
cmdDelete = db.GetSqlStringCommand("delete from op_letter_truck where LE_ID='" + headData.LE_ID + "'");
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
cmdDelete = db.GetSqlStringCommand("delete from op_letter_sur where LE_ID='" + headData.LE_ID + "'");
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
cmdDelete = db.GetSqlStringCommand("delete from op_letter_change where LE_ID='" + headData.LE_ID + "'");
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
cmdDelete = db.GetSqlStringCommand("delete from op_task where TASKNO='" + headData.LE_ID + "'");
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
tran.Commit();
|
|
if (headData.LETTERNAME == "派车通知")
|
|
{
|
|
UpdateTruckStatus(headData.BSNO);
|
|
}
|
|
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "删除出现错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
result.Success = true;
|
|
result.Message = "操作成功";
|
|
return result;
|
|
}
|
|
|
|
public static DBResult DeletePc(string LE_ID)
|
|
{
|
|
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_letter where LE_ID='" + LE_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 DeleteTruckFeeLink(string bsno,string LE_ID,string data)
|
|
{
|
|
var result = new DBResult();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
try
|
|
{
|
|
var cmdDelete = db.GetSqlStringCommand("update ch_fee set CARGO_GID='' where BSNO='" + bsno+"' and GID in (" + data + ")");
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "删除出现错误,请重试或联系系统管理员"+e.Message;
|
|
|
|
return result;
|
|
}
|
|
}
|
|
result.Success = true;
|
|
result.Message = "操作成功";
|
|
return result;
|
|
}
|
|
|
|
public static DBResult UpdateTruckFeeLink(string bsno, string LE_ID, string data)
|
|
{
|
|
var result = new DBResult();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
try
|
|
{
|
|
var cmdDelete = db.GetSqlStringCommand("update ch_fee set CARGO_GID='"+LE_ID+"' where BSNO='" + bsno + "' and GID in (" + data + ")");
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "删除出现错误,请重试或联系系统管理员"+e.Message;
|
|
|
|
return result;
|
|
}
|
|
}
|
|
result.Success = true;
|
|
result.Message = "操作成功";
|
|
return result;
|
|
}
|
|
|
|
|
|
public static bool GetFeeCount(string BSNO)
|
|
{
|
|
var isfee = false;
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("Select count(*) as count ");
|
|
strSql.Append(" from ch_fee ");
|
|
strSql.Append(" where BSNO='" + BSNO + "'");
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
var evData = Convert.ToInt32(reader["count"]);
|
|
if (evData > 0) { isfee = true; };
|
|
}
|
|
reader.Close();
|
|
}
|
|
return isfee;
|
|
}
|
|
|
|
public static bool GetTruckFeeCount(string LE_ID)
|
|
{
|
|
var isfee = false;
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("Select count(*) as count ");
|
|
strSql.Append(" from ch_fee ");
|
|
strSql.Append(" where CARGO_GID='" + LE_ID + "'");
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
var evData = Convert.ToInt32(reader["count"]);
|
|
if (evData > 0) { isfee = true; };
|
|
}
|
|
reader.Close();
|
|
}
|
|
return isfee;
|
|
}
|
|
|
|
public static bool UpdateTruckStatus(string BSNO)
|
|
{
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
var BLCOUNT = T_ALL_DA.GetStrSQL("BLCOUNT", "select sum(CTNNUM) BLCOUNT from op_ctn where BSNO='" + BSNO + "'");
|
|
if (BLCOUNT == "0")
|
|
{
|
|
var blUpSQL = " update op_seae set TRUCKSTATUS='' WHERE BSNO='" + BSNO + "'";
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
|
|
}
|
|
else {
|
|
var PCCOUNT = T_ALL_DA.GetStrSQL("PCCOUNT", "select sum(CTNNUM) PCCOUNT from op_letter_yard_ctn c left join op_letter_truck l on (l.LE_ID=c.LE_ID) where l.BSNO = '"+BSNO+"' and l.TRUCKSTATUS in ('已发单', '派车中', '已派车') ");
|
|
var blUpSQL = " update op_seae set TRUCKSTATUS='"+PCCOUNT+"/"+BLCOUNT+"' WHERE BSNO='" + BSNO + "'";
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 参照部分
|
|
|
|
|
|
#endregion
|
|
|
|
#region 陆运费
|
|
|
|
public static DBResult CreateCost(CostModel cm, string userid)
|
|
{
|
|
bool rst = false;
|
|
string msg = "";
|
|
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
|
|
{
|
|
try
|
|
{
|
|
if (cm.FeeValue != 0)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append(@"insert into ch_fee (GID,BSNO,FEETYPE,FEENAME,REMARK,CUSTOMERTYPE,CUSTOMERNAME,UNIT,UNITPRICE,QUANTITY,");
|
|
sb.Append(@"AMOUNT,CURRENCY,EXCHANGERATE,FEESTATUS,NOTAXAMOUNT,TAXUNITPRICE,ENTEROPERATOR) ");
|
|
sb.Append(@" VALUES(");
|
|
sb.Append("'" + Guid.NewGuid() + "',");//GID
|
|
sb.Append("'" + cm.BSNO + "',");//BSNO
|
|
sb.Append("'" + cm.FeeType + "', ");//FEETYPE
|
|
sb.Append("'" + cm.FeeName + "',");//FEENAME
|
|
sb.Append("'" + cm.Remark + "',");//REMARK
|
|
sb.Append("'" + cm.CustomerType + "',");//CUSTOMERTYPE
|
|
sb.Append("'" + cm.CustomerName + "',");//CUSTOMERNAME
|
|
sb.Append("'" + "单票" + "',");//UNIT
|
|
sb.Append(cm.FeeValue + ",");//UNITPRICE
|
|
sb.Append("1" + ",");//QUANTITY
|
|
sb.Append(cm.FeeValue + ",");//AMOUNT
|
|
sb.Append("'" + "RMB" + "',");//CURRENCY
|
|
sb.Append("1" + ",");//EXCHANGERATE
|
|
sb.Append("1" + ",");//FEESTATUS
|
|
sb.Append(cm.FeeValue + ",");//NOTAXAMOUNT
|
|
sb.Append(cm.FeeValue + ",");//TAXUNITPRICE
|
|
|
|
sb.Append("'" + userid + "'");//ENTEROPERATOR
|
|
|
|
sb.Append(")");
|
|
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, sb.ToString(), null);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sqlTran.Commit();
|
|
msg = "生成成功!";
|
|
rst = true;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
msg = "生成失败!";
|
|
sqlTran.Rollback();
|
|
rst = false;
|
|
}
|
|
finally
|
|
{
|
|
SqlHelper.CloseConnection();
|
|
sqlTran.Dispose();
|
|
}
|
|
}
|
|
return new DBResult{Success = rst,Message = msg};
|
|
}
|
|
#endregion
|
|
}
|
|
}
|