|
|
|
|
using System;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using DSWeb.MvcShipping.Models.MsCrmPriceCarrier;
|
|
|
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
|
|
using DSWeb.EntityDA;
|
|
|
|
|
using DSWeb.Areas.CommMng.Models;
|
|
|
|
|
using HcUtility.Comm;
|
|
|
|
|
using DSWeb.MvcShipping.Models.MsSeaeOrder;
|
|
|
|
|
using DSWeb.MvcShipping.DAL.MsChFeeDAL;
|
|
|
|
|
|
|
|
|
|
//需求编号:SR2017091200003
|
|
|
|
|
namespace DSWeb.MvcShipping.DAL.MsCrmPriceCarrierListDAL
|
|
|
|
|
{
|
|
|
|
|
public class MsCrmPriceCarrierListDAL
|
|
|
|
|
{
|
|
|
|
|
#region 查询 //运价查询
|
|
|
|
|
static public List<MsCrmPriceCarrier> GetDataList(string strCondition, int start, int limit, string userid, string usercode, string companyid, string sort = null)
|
|
|
|
|
{
|
|
|
|
|
// T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
string sSql = GetDataListSQL(strCondition, start, limit, userid, usercode, companyid, sort);
|
|
|
|
|
strSql.Append(sSql);
|
|
|
|
|
//
|
|
|
|
|
return SetData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static int getTotalCount(string strCondition, string userid, string usercode, string companyid)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("select count(*) ");
|
|
|
|
|
strSql.Append(" from [crm_price_carrier_2] where 1=1");
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
|
|
}
|
|
|
|
|
int cnt = 0;
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
cnt = Convert.ToInt32(reader[0]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return cnt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static public string GetDataListStr(string strCondition, string userid, string usercode, string companyid)
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("select *");
|
|
|
|
|
strSql.Append(",(select ShowName from [user] where GID=INPUTBY) as INPUTBYREF");
|
|
|
|
|
strSql.Append(" from [crm_price_carrier_2] where 1=1");
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
|
|
}
|
|
|
|
|
strSql.Append(" order by [EFFECTIVEDATE],[VALIDDATE],PORTDISCHARGEID,CARRIER,ETD,TT");
|
|
|
|
|
return strSql.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static public string GetDataListSQL(string strCondition, int start, int limit, string userid, string usercode, string companyid, string sort = null)
|
|
|
|
|
{
|
|
|
|
|
//T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
strSql.Append(@"SELECT * from (SELECT row_number() over (");
|
|
|
|
|
|
|
|
|
|
//var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
|
|
//if (!string.IsNullOrEmpty(sortstring))
|
|
|
|
|
//{
|
|
|
|
|
// strSql.Append(" order by " + sortstring);
|
|
|
|
|
//}
|
|
|
|
|
//
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" order by [EFFECTIVEDATE],[VALIDDATE],PORTDISCHARGEID,CARRIER,ETD,TT");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
strSql.Append(@") as num , ");
|
|
|
|
|
strSql.Append("*");
|
|
|
|
|
strSql.Append(",(select ShowName from [user] where GID=INPUTBY) as INPUTBYREF");
|
|
|
|
|
|
|
|
|
|
strSql.Append(", dbo.F_ContractPriceStr_CTN0(contractno,PODLOAD,PORTDISCHARGEID,VIA,VIA2) CTN0PRICESTR");
|
|
|
|
|
strSql.Append(", dbo.F_ContractPriceStr_CTN1(contractno,PODLOAD,PORTDISCHARGEID,VIA,VIA2) CTN1PRICESTR");
|
|
|
|
|
strSql.Append(", dbo.F_ContractPriceStr_CTN2(contractno,PODLOAD,PORTDISCHARGEID,VIA,VIA2) CTN2PRICESTR");
|
|
|
|
|
strSql.Append(", dbo.F_ContractPriceStr_CTN3(contractno,PODLOAD,PORTDISCHARGEID,VIA,VIA2) CTN3PRICESTR");
|
|
|
|
|
strSql.Append(", dbo.F_ContractPriceStr_CTN4(contractno,PODLOAD,PORTDISCHARGEID,VIA,VIA2) CTN4PRICESTR");
|
|
|
|
|
|
|
|
|
|
strSql.Append(" from [crm_price_carrier_2] where 1=1");
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
|
|
}
|
|
|
|
|
strSql.Append(@")as t ");
|
|
|
|
|
strSql.Append(string.Format("where t.num>{0} and t.num<={1} order by t.num ", start, start + limit));
|
|
|
|
|
return strSql.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static List<MsCrmPriceCarrier> SetData(StringBuilder strSql)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<MsCrmPriceCarrier>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
MsCrmPriceCarrier data = new MsCrmPriceCarrier();
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));//惟一编号
|
|
|
|
|
data.LOCKFLAG = (reader["LOCKFLAG"] == null ? false : Convert.ToBoolean(reader["LOCKFLAG"]));//是否锁定
|
|
|
|
|
data.ISISSUE = (reader["ISISSUE"] == null ? false : Convert.ToBoolean(reader["ISISSUE"]));//是否发布
|
|
|
|
|
data.LANE = (reader["LANE"] == null ? "" : Convert.ToString(reader["LANE"]));//航线
|
|
|
|
|
data.PODLOAD = (reader["PODLOAD"] == null ? "" : Convert.ToString(reader["PODLOAD"]));//起运港
|
|
|
|
|
data.PORTDISCHARGEID = (reader["PORTDISCHARGEID"] == null ? "" : Convert.ToString(reader["PORTDISCHARGEID"]));//卸货港ID
|
|
|
|
|
data.PORTDISCHARGE = (reader["PORTDISCHARGE"] == null ? "" : Convert.ToString(reader["PORTDISCHARGE"]));//卸货港
|
|
|
|
|
data.CARRIER = (reader["CARRIER"] == null ? "" : Convert.ToString(reader["CARRIER"]));//船公司
|
|
|
|
|
data.VIA = (reader["VIA"] == null ? "" : Convert.ToString(reader["VIA"]));//中转港
|
|
|
|
|
data.VIA2 = (reader["VIA2"] == null ? "" : Convert.ToString(reader["VIA2"]));//中转港2
|
|
|
|
|
data.ETD = (reader["ETD"] == null ? "" : Convert.ToString(reader["ETD"]));//开航日/船期
|
|
|
|
|
data.TT = (reader["TT"] == null ? "" : Convert.ToString(reader["TT"]));//航程
|
|
|
|
|
data.CONTRACTNO = (reader["CONTRACTNO"] == null ? "" : Convert.ToString(reader["CONTRACTNO"]));//航程
|
|
|
|
|
data.CONTRACTBSNO = (reader["CONTRACTBSNO"] == null ? "" : Convert.ToString(reader["CONTRACTBSNO"]));//约号序列号
|
|
|
|
|
|
|
|
|
|
if (reader["EFFECTIVEDATE"] != null && reader["EFFECTIVEDATE"].ToString().Trim().IndexOf("0001") < 0 && reader["EFFECTIVEDATE"].ToString().Trim().IndexOf("1900") < 0 && reader["EFFECTIVEDATE"].ToString().Trim() != "")
|
|
|
|
|
{
|
|
|
|
|
data.EFFECTIVEDATE = Convert.ToDateTime(reader["EFFECTIVEDATE"]);//生效期/开始日期
|
|
|
|
|
}
|
|
|
|
|
if (reader["VALIDDATE"] != null && reader["VALIDDATE"].ToString().Trim().IndexOf("0001") < 0 && reader["VALIDDATE"].ToString().Trim().IndexOf("1900") < 0 && reader["VALIDDATE"].ToString().Trim() != "")
|
|
|
|
|
{
|
|
|
|
|
data.VALIDDATE = Convert.ToDateTime(reader["VALIDDATE"]);//有效期/结束日期
|
|
|
|
|
}
|
|
|
|
|
data.COMMODITY = (reader["COMMODITY"] == null ? "" : Convert.ToString(reader["COMMODITY"]));//品名/特殊商品
|
|
|
|
|
data.REMARK = (reader["REMARK"] == null ? "" : Convert.ToString(reader["REMARK"]));//备注
|
|
|
|
|
data.INPUTBY = (reader["INPUTBY"] == null ? "" : Convert.ToString(reader["INPUTBY"]));//录入人
|
|
|
|
|
data.INPUTBYREF = (reader["INPUTBYREF"] == null ? "" : Convert.ToString(reader["INPUTBYREF"]));//录入人
|
|
|
|
|
|
|
|
|
|
if (reader["INPUTTIME"] != null && reader["INPUTTIME"].ToString().Trim().IndexOf("0001") < 0 && reader["INPUTTIME"].ToString().Trim().IndexOf("1900") < 0 && reader["INPUTTIME"].ToString().Trim() != "")
|
|
|
|
|
{
|
|
|
|
|
data.INPUTTIME = Convert.ToDateTime(reader["INPUTTIME"]);//录入日期
|
|
|
|
|
}
|
|
|
|
|
data.MODIFIEDUSER = (reader["MODIFIEDUSER"] == null ? "" : Convert.ToString(reader["MODIFIEDUSER"]));//最后一次操作人GID
|
|
|
|
|
if (reader["MODIFYTIME"] != null && reader["MODIFYTIME"].ToString().Trim().IndexOf("0001") < 0 && reader["MODIFYTIME"].ToString().Trim().IndexOf("1900") < 0 && reader["MODIFYTIME"].ToString().Trim() != "")
|
|
|
|
|
{
|
|
|
|
|
data.MODIFYTIME = Convert.ToDateTime(reader["MODIFYTIME"]);//录入日期
|
|
|
|
|
}
|
|
|
|
|
data.FEE0 = (reader["FEE0"] == null ? "" : Convert.ToString(reader["FEE0"]));//FEE0
|
|
|
|
|
data.FEE1 = (reader["FEE1"] == null ? "" : Convert.ToString(reader["FEE1"]));//FEE1
|
|
|
|
|
data.FEE2 = (reader["FEE2"] == null ? "" : Convert.ToString(reader["FEE2"]));//FEE2
|
|
|
|
|
data.FEE3 = (reader["FEE3"] == null ? "" : Convert.ToString(reader["FEE3"]));//FEE3
|
|
|
|
|
data.FEE4 = (reader["FEE4"] == null ? "" : Convert.ToString(reader["FEE4"]));//FEE4
|
|
|
|
|
data.CTN00 = (reader["CTN00"] == null ? 0 : Convert.ToDecimal(reader["CTN00"]));//CTN00
|
|
|
|
|
data.CTN10 = (reader["CTN10"] == null ? 0 : Convert.ToDecimal(reader["CTN10"]));//CTN10
|
|
|
|
|
data.CTN20 = (reader["CTN20"] == null ? 0 : Convert.ToDecimal(reader["CTN20"]));//CTN20
|
|
|
|
|
data.CTN30 = (reader["CTN30"] == null ? 0 : Convert.ToDecimal(reader["CTN30"]));//CTN30
|
|
|
|
|
data.CTN40 = (reader["CTN40"] == null ? 0 : Convert.ToDecimal(reader["CTN40"]));//CTN40
|
|
|
|
|
data.CTN50 = (reader["CTN50"] == null ? 0 : Convert.ToDecimal(reader["CTN50"]));//CTN50
|
|
|
|
|
data.CTN60 = (reader["CTN60"] == null ? 0 : Convert.ToDecimal(reader["CTN60"]));//CTN60
|
|
|
|
|
data.CTN70 = (reader["CTN70"] == null ? 0 : Convert.ToDecimal(reader["CTN70"]));//CTN70
|
|
|
|
|
data.CTN80 = (reader["CTN80"] == null ? 0 : Convert.ToDecimal(reader["CTN80"]));//CTN80
|
|
|
|
|
data.CTN90 = (reader["CTN90"] == null ? 0 : Convert.ToDecimal(reader["CTN90"]));//CTN90
|
|
|
|
|
data.CTN01 = (reader["CTN01"] == null ? 0 : Convert.ToDecimal(reader["CTN01"]));//CTN01
|
|
|
|
|
data.CTN11 = (reader["CTN11"] == null ? 0 : Convert.ToDecimal(reader["CTN11"]));//CTN11
|
|
|
|
|
data.CTN21 = (reader["CTN21"] == null ? 0 : Convert.ToDecimal(reader["CTN21"]));//CTN21
|
|
|
|
|
data.CTN31 = (reader["CTN31"] == null ? 0 : Convert.ToDecimal(reader["CTN31"]));//CTN31
|
|
|
|
|
data.CTN41 = (reader["CTN41"] == null ? 0 : Convert.ToDecimal(reader["CTN41"]));//CTN41
|
|
|
|
|
data.CTN51 = (reader["CTN51"] == null ? 0 : Convert.ToDecimal(reader["CTN51"]));//CTN51
|
|
|
|
|
data.CTN61 = (reader["CTN61"] == null ? 0 : Convert.ToDecimal(reader["CTN61"]));//CTN61
|
|
|
|
|
data.CTN71 = (reader["CTN71"] == null ? 0 : Convert.ToDecimal(reader["CTN71"]));//CTN71
|
|
|
|
|
data.CTN81 = (reader["CTN81"] == null ? 0 : Convert.ToDecimal(reader["CTN81"]));//CTN81
|
|
|
|
|
data.CTN91 = (reader["CTN91"] == null ? 0 : Convert.ToDecimal(reader["CTN91"]));//CTN91
|
|
|
|
|
data.CTN02 = (reader["CTN02"] == null ? 0 : Convert.ToDecimal(reader["CTN02"]));//CTN02
|
|
|
|
|
data.CTN12 = (reader["CTN12"] == null ? 0 : Convert.ToDecimal(reader["CTN12"]));//CTN12
|
|
|
|
|
data.CTN22 = (reader["CTN22"] == null ? 0 : Convert.ToDecimal(reader["CTN22"]));//CTN22
|
|
|
|
|
data.CTN32 = (reader["CTN32"] == null ? 0 : Convert.ToDecimal(reader["CTN32"]));//CTN32
|
|
|
|
|
data.CTN42 = (reader["CTN42"] == null ? 0 : Convert.ToDecimal(reader["CTN42"]));//CTN42
|
|
|
|
|
data.CTN52 = (reader["CTN52"] == null ? 0 : Convert.ToDecimal(reader["CTN52"]));//CTN52
|
|
|
|
|
data.CTN62 = (reader["CTN62"] == null ? 0 : Convert.ToDecimal(reader["CTN62"]));//CTN62
|
|
|
|
|
data.CTN72 = (reader["CTN72"] == null ? 0 : Convert.ToDecimal(reader["CTN72"]));//CTN72
|
|
|
|
|
data.CTN82 = (reader["CTN82"] == null ? 0 : Convert.ToDecimal(reader["CTN82"]));//CTN82
|
|
|
|
|
data.CTN92 = (reader["CTN92"] == null ? 0 : Convert.ToDecimal(reader["CTN92"]));//CTN92
|
|
|
|
|
data.CTN03 = (reader["CTN03"] == null ? 0 : Convert.ToDecimal(reader["CTN03"]));//CTN03
|
|
|
|
|
data.CTN13 = (reader["CTN13"] == null ? 0 : Convert.ToDecimal(reader["CTN13"]));//CTN13
|
|
|
|
|
data.CTN23 = (reader["CTN23"] == null ? 0 : Convert.ToDecimal(reader["CTN23"]));//CTN23
|
|
|
|
|
data.CTN33 = (reader["CTN33"] == null ? 0 : Convert.ToDecimal(reader["CTN33"]));//CTN33
|
|
|
|
|
data.CTN43 = (reader["CTN43"] == null ? 0 : Convert.ToDecimal(reader["CTN43"]));//CTN43
|
|
|
|
|
data.CTN53 = (reader["CTN53"] == null ? 0 : Convert.ToDecimal(reader["CTN53"]));//CTN53
|
|
|
|
|
data.CTN63 = (reader["CTN63"] == null ? 0 : Convert.ToDecimal(reader["CTN63"]));//CTN63
|
|
|
|
|
data.CTN73 = (reader["CTN73"] == null ? 0 : Convert.ToDecimal(reader["CTN73"]));//CTN73
|
|
|
|
|
data.CTN83 = (reader["CTN83"] == null ? 0 : Convert.ToDecimal(reader["CTN83"]));//CTN83
|
|
|
|
|
data.CTN93 = (reader["CTN93"] == null ? 0 : Convert.ToDecimal(reader["CTN93"]));//CTN93
|
|
|
|
|
data.CTN04 = (reader["CTN04"] == null ? 0 : Convert.ToDecimal(reader["CTN04"]));//CTN04
|
|
|
|
|
data.CTN14 = (reader["CTN14"] == null ? 0 : Convert.ToDecimal(reader["CTN14"]));//CTN14
|
|
|
|
|
data.CTN24 = (reader["CTN24"] == null ? 0 : Convert.ToDecimal(reader["CTN24"]));//CTN24
|
|
|
|
|
data.CTN34 = (reader["CTN34"] == null ? 0 : Convert.ToDecimal(reader["CTN34"]));//CTN34
|
|
|
|
|
data.CTN44 = (reader["CTN44"] == null ? 0 : Convert.ToDecimal(reader["CTN44"]));//CTN44
|
|
|
|
|
data.CTN54 = (reader["CTN54"] == null ? 0 : Convert.ToDecimal(reader["CTN54"]));//CTN54
|
|
|
|
|
data.CTN64 = (reader["CTN64"] == null ? 0 : Convert.ToDecimal(reader["CTN64"]));//CTN64
|
|
|
|
|
data.CTN74 = (reader["CTN74"] == null ? 0 : Convert.ToDecimal(reader["CTN74"]));//CTN74
|
|
|
|
|
data.CTN84 = (reader["CTN84"] == null ? 0 : Convert.ToDecimal(reader["CTN84"]));//CTN84
|
|
|
|
|
data.CTN94 = (reader["CTN94"] == null ? 0 : Convert.ToDecimal(reader["CTN94"]));//CTN94
|
|
|
|
|
|
|
|
|
|
//data.CONTRACTBSNO = reader["CONTRACTBSNO"].ToString();
|
|
|
|
|
data.CTN0PRICESTR = reader["CTN0PRICESTR"].ToString();
|
|
|
|
|
data.CTN1PRICESTR = reader["CTN1PRICESTR"].ToString();
|
|
|
|
|
data.CTN2PRICESTR = reader["CTN2PRICESTR"].ToString();
|
|
|
|
|
data.CTN3PRICESTR = reader["CTN3PRICESTR"].ToString();
|
|
|
|
|
data.CTN4PRICESTR = reader["CTN4PRICESTR"].ToString();
|
|
|
|
|
|
|
|
|
|
data.CTN0DETENTION = reader["CTN0DETENTION"].ToString();
|
|
|
|
|
data.CTN1DETENTION = reader["CTN1DETENTION"].ToString();
|
|
|
|
|
data.CTN2DETENTION = reader["CTN2DETENTION"].ToString();
|
|
|
|
|
data.CTN3DETENTION = reader["CTN3DETENTION"].ToString();
|
|
|
|
|
data.CTN4DETENTION = reader["CTN4DETENTION"].ToString();
|
|
|
|
|
#endregion
|
|
|
|
|
headList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
return headList;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 插入费用
|
|
|
|
|
|
|
|
|
|
public static DBResult CreateFeeBl(MsSeaeOrder headData,List<MsSeaeOrderCtn> bodyList, MsCrmPriceCarrier price, string userid, string companyid)
|
|
|
|
|
{
|
|
|
|
|
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_order(GID, BSNO, FEETYPE, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY,
|
|
|
|
|
EXCHANGERATE, REASON, REMARK, COMMISSIONRATE,ENTEROPERATOR, ENTERDATE,ISOPEN, ISADVANCEDPAY, SORT, FEESTATUS, FEEFRT,
|
|
|
|
|
TAXRATE,NOTAXAMOUNT,ACCTAXRATE,LINENUM,TAXUNITPRICE,MODIFIEDUSER,MODIFIEDTIME,WMSOUTBSNO,PREAMOUNT,ISINVOICE)
|
|
|
|
|
VALUES(@GID,@BSNO,@FEETYPE,@FEENAME,@FEEDESCRIPTION,@CUSTOMERTYPE,@CUSTOMERNAME,@UNIT,@UNITPRICE,@QUANTITY,@AMOUNT,@CURRENCY,
|
|
|
|
|
@EXCHANGERATE, @REASON, @REMARK, @COMMISSIONRATE,@ENTEROPERATOR, @ENTERDATE,@ISOPEN, @ISADVANCEDPAY, @SORT, @FEESTATUS, @FEEFRT,
|
|
|
|
|
@TAXRATE,@NOTAXAMOUNT,@ACCTAXRATE,@LINENUM,@TAXUNITPRICE,@MODIFIEDUSER,@MODIFIEDTIME,@WMSOUTBSNO,@PREAMOUNT,@ISINVOICE)
|
|
|
|
|
");
|
|
|
|
|
if (bodyList != null)
|
|
|
|
|
{
|
|
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
|
|
var usdexrate = MsChFeeDAL.MsChFeeDAL.GetUsdExrate(headData.ETD, "USD", companyid);
|
|
|
|
|
foreach (var enumValue in bodyList)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var FIELDNAME= T_ALL_DA.GetStrSQL("EnumValueID", "SELECT top 1 EnumValueID from tSysEnumValue where EnumValueName_2='" + enumValue.CTNALL + "'");
|
|
|
|
|
if (FIELDNAME != ""){
|
|
|
|
|
var FREIGHT = T_ALL_DA.GetStrSQL("FREIGHT", "select top 1 "+FIELDNAME+"0 AS FREIGHT from [crm_price_carrier_2] where GID='" + price.GID + "'");
|
|
|
|
|
|
|
|
|
|
if (FREIGHT != "" && Convert.ToDecimal(FREIGHT) != 0)
|
|
|
|
|
{
|
|
|
|
|
decimal UNITPRICE = Convert.ToDecimal(FREIGHT);
|
|
|
|
|
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.CARRIER);
|
|
|
|
|
db.AddInParameter(cmdInsertFee, "@UNIT", DbType.String, enumValue.CTNALL);
|
|
|
|
|
db.AddInParameter(cmdInsertFee, "@UNITPRICE", DbType.Decimal, UNITPRICE);
|
|
|
|
|
db.AddInParameter(cmdInsertFee, "@QUANTITY", DbType.Decimal, enumValue.CTNNUM);
|
|
|
|
|
db.AddInParameter(cmdInsertFee, "@AMOUNT", DbType.Decimal, Math.Round(UNITPRICE*enumValue.CTNNUM, 2));
|
|
|
|
|
db.AddInParameter(cmdInsertFee, "@CURRENCY", DbType.String, "USD");
|
|
|
|
|
db.AddInParameter(cmdInsertFee, "@EXCHANGERATE", DbType.Decimal, usdexrate);
|
|
|
|
|
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, 0);
|
|
|
|
|
db.AddInParameter(cmdInsertFee, "@FEEFRT", DbType.String, "PP");
|
|
|
|
|
db.AddInParameter(cmdInsertFee, "@TAXRATE", DbType.Decimal, 0);
|
|
|
|
|
db.AddInParameter(cmdInsertFee, "@NOTAXAMOUNT", DbType.Decimal, Math.Round(UNITPRICE * enumValue.CTNNUM, 2));
|
|
|
|
|
db.AddInParameter(cmdInsertFee, "@ACCTAXRATE", DbType.Decimal, 0);
|
|
|
|
|
db.AddInParameter(cmdInsertFee, "@LINENUM", DbType.Int16, 1);
|
|
|
|
|
db.AddInParameter(cmdInsertFee, "@TAXUNITPRICE", DbType.Decimal, UNITPRICE);
|
|
|
|
|
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.ExecuteNonQuery(cmdInsertFee, 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 CreateSeaeFee(MsSeaeOrder headData, List<MsSeaeOrderCtn> bodyList, MsCrmPriceCarrier price, string userid,string companyid)
|
|
|
|
|
{
|
|
|
|
|
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 (bodyList != null)
|
|
|
|
|
{
|
|
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
|
|
var usdexrate = MsChFeeDAL.MsChFeeDAL.GetUsdExrate(headData.ETD, "USD", companyid);
|
|
|
|
|
|
|
|
|
|
foreach (var enumValue in bodyList)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var FIELDNAME = T_ALL_DA.GetStrSQL("EnumValueID", "SELECT top 1 EnumValueID from tSysEnumValue where EnumValueName_2='" + enumValue.CTNALL + "'");
|
|
|
|
|
if (FIELDNAME != "")
|
|
|
|
|
{
|
|
|
|
|
var FREIGHT = T_ALL_DA.GetStrSQL("FREIGHT", "select top 1 " + FIELDNAME + "0 AS FREIGHT from [crm_price_carrier_2] where GID='" + price.GID + "'");
|
|
|
|
|
|
|
|
|
|
if (FREIGHT != "" && Convert.ToDecimal(FREIGHT) != 0)
|
|
|
|
|
{
|
|
|
|
|
decimal UNITPRICE = Convert.ToDecimal(FREIGHT);
|
|
|
|
|
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.CARRIER);
|
|
|
|
|
db.AddInParameter(cmdInsertFee, "@UNIT", DbType.String, enumValue.CTNALL);
|
|
|
|
|
db.AddInParameter(cmdInsertFee, "@UNITPRICE", DbType.Decimal, UNITPRICE);
|
|
|
|
|
db.AddInParameter(cmdInsertFee, "@QUANTITY", DbType.Decimal, enumValue.CTNNUM);
|
|
|
|
|
db.AddInParameter(cmdInsertFee, "@AMOUNT", DbType.Decimal, Math.Round(UNITPRICE * enumValue.CTNNUM, 2));
|
|
|
|
|
db.AddInParameter(cmdInsertFee, "@CURRENCY", DbType.String, "USD");
|
|
|
|
|
db.AddInParameter(cmdInsertFee, "@EXCHANGERATE", DbType.Decimal, usdexrate);
|
|
|
|
|
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, 0);
|
|
|
|
|
db.AddInParameter(cmdInsertFee, "@FEEFRT", DbType.String, "PP");
|
|
|
|
|
db.AddInParameter(cmdInsertFee, "@CARGO_GID", DbType.String,"");
|
|
|
|
|
db.AddInParameter(cmdInsertFee, "@TAXRATE", DbType.Decimal, 0);
|
|
|
|
|
db.AddInParameter(cmdInsertFee, "@NOTAXAMOUNT", DbType.Decimal, Math.Round(UNITPRICE * enumValue.CTNNUM, 2));
|
|
|
|
|
db.AddInParameter(cmdInsertFee, "@ACCTAXRATE", DbType.Decimal, 0);
|
|
|
|
|
db.AddInParameter(cmdInsertFee, "@LINENUM", DbType.Int16, 1);
|
|
|
|
|
db.AddInParameter(cmdInsertFee, "@TAXUNITPRICE", DbType.Decimal, UNITPRICE);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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<XiaLaKuangModel> GetFeeName(string strSHOWNAME)
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("select [EnumValueID] as [VALUE],[EnumValueName] as [NAME],([EnumValueID] + ' | ' + [EnumValueName]) as CodeAndName from [tSysEnumValue] where [ENUMTYPEID]=97053 and [EnumValueName] is not null and [EnumValueName]<>'' and [EnumValueName]<>' ' order by [DispIndex]");
|
|
|
|
|
return SetXiaLaKuang(strSql, false);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 取集装箱权限_循环列
|
|
|
|
|
static public List<XiaLaKuangModel> GetCtn(string strSHOWNAME)
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("select [EnumValueID] as [VALUE],[EnumValueName] as [NAME],([EnumValueID] + ' | ' + [EnumValueName]) as CodeAndName from [tSysEnumValue] where [ENUMTYPEID]=97051 and [EnumValueName] is not null and [EnumValueName]<>'' and [EnumValueName]<>' ' order by [DispIndex]");
|
|
|
|
|
return SetXiaLaKuang(strSql, false);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 取报价权限_循环列
|
|
|
|
|
static public List<XiaLaKuangModel> GetBaoJia(string strSHOWNAME)
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("select [EnumValueID] as [VALUE],[EnumValueName] as [NAME],([EnumValueID] + ' | ' + [EnumValueName]) as CodeAndName from [tSysEnumValue] where [ENUMTYPEID]=97052 and [EnumValueName] is not null and [EnumValueName]<>'' and [EnumValueName]<>' ' and EnumValueName_2='true' order by [DispIndex]");
|
|
|
|
|
return SetXiaLaKuang(strSql, false);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 启运港,国内港口_下拉框
|
|
|
|
|
static public List<XiaLaKuangModel> GetPODLOADList()
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT DISTINCT [PODLOAD] as [VALUE],[PODLOAD] as [NAME],[PODLOAD] as CodeAndName FROM [crm_price_carrier_2] order by [PODLOAD]");
|
|
|
|
|
return SetXiaLaKuang(strSql, true);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 目的港,国外港口_下拉框
|
|
|
|
|
static public List<XiaLaKuangModel> GetPORTDISCHARGEList()
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("select DISTINCT [PORTDISCHARGEID] as [VALUE],[PORTDISCHARGE] as [NAME],([PORTDISCHARGEID] + ' | ' + [PORTDISCHARGE]) as CodeAndName from [crm_price_carrier_2] group by [PORTDISCHARGEID],[PORTDISCHARGE] order by [PORTDISCHARGEID],[PORTDISCHARGE]");
|
|
|
|
|
return SetXiaLaKuang(strSql, true);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 中转港,国外港口_下拉框
|
|
|
|
|
static public List<XiaLaKuangModel> GetVIAList()
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("select DISTINCT [VIA] as [VALUE],[VIA] as [NAME],[VIA] as CodeAndName from [crm_price_carrier_2] group by [VIA] order by [VIA]");
|
|
|
|
|
return SetXiaLaKuang(strSql, true);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 船公司_下拉框
|
|
|
|
|
static public List<XiaLaKuangModel> GetCARRIERList()
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("select distinct [CARRIER] as [VALUE],[CARRIER] as [NAME],[CARRIER] as CodeAndName from [crm_price_carrier_2] group by [CARRIER] order by [CARRIER]");
|
|
|
|
|
return SetXiaLaKuang(strSql, true);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 航线_下拉框
|
|
|
|
|
static public List<XiaLaKuangModel> GetLANEList(string codename="")
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT distinct [LANE] as [VALUE],[LANE] as [NAME],[LANE] as CodeAndName FROM [crm_price_carrier_2] ");
|
|
|
|
|
if (!string.IsNullOrEmpty(codename))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" WHERE LANE LIKE '%"+codename+"%'");
|
|
|
|
|
}
|
|
|
|
|
strSql.Append(" order by [LANE]");
|
|
|
|
|
|
|
|
|
|
return SetXiaLaKuang(strSql, true);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 下拉框实体类
|
|
|
|
|
private static List<XiaLaKuangModel> SetXiaLaKuang(StringBuilder strSql,bool isNull)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<XiaLaKuangModel>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
XiaLaKuangModel data = new XiaLaKuangModel();
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.VALUE = (reader["VALUE"] == null ? "" : Convert.ToString(reader["VALUE"]).Trim());//列名
|
|
|
|
|
data.NAME = (reader["NAME"] == null ? "" : Convert.ToString(reader["NAME"]).Trim());//标题
|
|
|
|
|
data.CodeAndName = (reader["CodeAndName"] == null ? "" : Convert.ToString(reader["CodeAndName"]).Trim());//VALUE | NAME
|
|
|
|
|
#endregion
|
|
|
|
|
headList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isNull)
|
|
|
|
|
{
|
|
|
|
|
XiaLaKuangModel data2 = new XiaLaKuangModel();
|
|
|
|
|
data2.VALUE = "";//列名
|
|
|
|
|
data2.NAME = "";//标题
|
|
|
|
|
data2.CodeAndName = "";//VALUE | NAME
|
|
|
|
|
headList.Add(data2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return headList;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|