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.
DS7/DSWeb/Areas/MvcShipping/DAL/MsOpApply/MsOpApplyDAL.cs

4001 lines
262 KiB
C#

2 years ago

using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using DSWeb.MvcShipping.Models.MsOpApply;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.EntityDA;
using DSWeb.Areas.CommMng.Models;
using HcUtility.Comm;
using System.Data.SqlClient;
using DSWeb.DataAccess;
using DSWeb.MvcShipping.Models.MsOpSeaeBill;
using DotNet4.Utilities;
using DSWeb.MvcShipping.Models.MsCodeServiceFeeTemplate;
using DSWeb.MvcShipping.DAL.MsSysBillNoSet;
using DSWeb.MvcShipping.DAL.MsSysParamSet;
using HcUtility.Core;
using DSWeb.SoftMng.Model;
namespace DSWeb.MvcShipping.DAL.MsOpApplyDAL
{
public class MsOpApplyDAL
{
#region Inquery DataList
static public List<MsOpApply> GetDataList(string strCondition, string userid, string usercode, string companyid,string sort = null)
{
var rangstr = GetRangDAStr("index", userid, usercode, companyid);
if (!string.IsNullOrEmpty(rangstr))
{
if (!string.IsNullOrEmpty(strCondition))
{
strCondition = strCondition + " and " + rangstr;
}
else
{
strCondition = rangstr;
}
}
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("OP_APPLY.BsNo,BsStatus,FeeStatus,BsDate,AccDate,OpDate,Mblno,Hblno,CustNo");
strSql.Append(",CustomerName,BsType,Vessel,VoyNo,ETD,ETA,PORTLOAD,PORTDISCHARGE");
strSql.Append(",INPUTBY,OP,SALE,CUSTOMSER,BSSOURCE,BSSOURCEDETAIL,MASTERNO");
strSql.Append(",CORPID,SALEDEPT,PKGS,KGS,NETWEIGHT,CBM,MANIFESTSTATUS");
strSql.Append(",CUSTOMNO,CUSTOMDATE,INSPECTIONNO,INSPECTIONDATE,INVNO,CONTRACTNO,ARCOUNTRY,GOODSOURCE");
strSql.Append(",DOCNO,TRADETYPE,REMARK,BOOKNO,BYCUSTOM,ENTERPID,ENTERP,CLEARCUSTOMDATE,ISMOREGOOD,INSPECTSERVICE,CUSTOMSNUM,TRADETERM");
strSql.Append(",IsService1,IsService2,IsService3,IsService4,IsService5,IsService6,IsService7,IsService8");
strSql.Append(",IsService9,IsService10,IsService11,IsService12,IsService13,IsService14,IsService15,IsService16");
strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=96004 and EnumValueID=OP_APPLY.BsType) as BsTypeREF");
strSql.Append(",(CASE BsStatus WHEN 1 THEN '锁定' else '未锁定' end) as bsstatusref ");
strSql.Append(",(CASE FeeStatus WHEN 1 THEN '锁定' else '未锁定' end) as feestatusref ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE1') as SERVICE1 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE2') as SERVICE2 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE3') as SERVICE3 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE4') as SERVICE4 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE5') as SERVICE5 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE6') as SERVICE6 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE7') as SERVICE7 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE8') as SERVICE8 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE9') as SERVICE9 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE10') as SERVICE10 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE11') as SERVICE11 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE12') as SERVICE12 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE13') as SERVICE13 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE14') as SERVICE14 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE15') as SERVICE15 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE16') as SERVICE16 ");
strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=97018 and EnumValueID=OP_APPLY.MANIFESTSTATUS) as MANIFESTSTATUSREF");
strSql.Append(",(select TOP 1 CUSTNO from v_op_bs where OPLB<>'op_apply' and BSNO=OP_APPLY.MASTERNO) as BSCUSTNO ");
strSql.Append(", BSCUSTOMNO,ISPRINTPR,CUSTOMTYPE,ISCLEAR,ISCUSTOMEND,CUSTOMSLNO,WMSNO ");
strSql.Append(",dbo.F_GetBillDrFeeStatus(OP_APPLY.BSNO) DRFEESTATUS");
strSql.Append(",dbo.F_GetBillCrFeeStatus(OP_APPLY.BSNO) CRFEESTATUS");
strSql.Append(",I.TTLDR,I.TTLINVDR,I.TTLDUIDR,CURRENCY,CARGOVALUE,INQUNO,ISDY");
strSql.Append(",[ediYwlx],[recordSn],[payMent],[carriageType],[carriagePrice],[carriageCurrency],[premiumType],[premiumPrice],[premiumCurrency]");
strSql.Append(",SALECORPID,(select [NAME] from [company] where GID=OP_APPLY.SALECORPID) as SALECORP,BillFeeStatus ");
strSql.Append(",[DOCSTATUS],[CUSCIQNO],[TRANCUSTOMNO],[CUSTOMLOCKNO],[EXPCUSTOMTYPE],[DESPPORT],CONSIGNEE ");
strSql.Append(",(SELECT TOP 1 STATUS FROM OP_STATUS WITH (NOLOCK) WHERE BSNO=OP_APPLY.BSNO ORDER BY COMPTIME DESC,INPUTTIME DESC) as OPSTATUS");
strSql.Append(",ETPS_CATEGORY,CDNTYPE,CUSTSERVICE,OPERATORCODE");
strSql.Append(" from OP_APPLY ");
strSql.Append(" LEFT JOIN v_op_gain_dr_INV I ON (I.BSNO=OP_APPLY.BSNO) ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
sortstring = sortstring.Replace("OPSTATUS", "(SELECT TOP 1 STATUS FROM OP_STATUS WITH (NOLOCK) WHERE BSNO=OP_APPLY.BSNO ORDER BY COMPTIME DESC,INPUTTIME DESC)");
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" order by BsDate Desc ");
}
return SetData(strSql);
}
static public string GetDataListStr(string strCondition, string userid, string usercode, string companyid, string sort = null)
{
var rangstr = GetRangDAStr("index", userid, usercode, companyid);
if (!string.IsNullOrEmpty(rangstr))
{
if (!string.IsNullOrEmpty(strCondition))
{
strCondition = strCondition + " and " + rangstr;
}
else
{
strCondition = rangstr;
}
}
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("BsNo,BsStatus,FeeStatus,BsDate,AccDate,OpDate,Mblno,Hblno,CustNo");
strSql.Append(",CustomerName,BsType,Vessel,VoyNo,ETD,ETA,PORTLOAD,PORTDISCHARGE");
strSql.Append(",INPUTBY,OP,SALE,CUSTOMSER,BSSOURCE,BSSOURCEDETAIL");
strSql.Append(",CORPID,SALEDEPT,PKGS,KGS,NETWEIGHT,CBM,MANIFESTSTATUS");
strSql.Append(",CUSTOMNO,CUSTOMDATE,INSPECTIONNO,INSPECTIONDATE,INVNO,CONTRACTNO,ARCOUNTRY,GOODSOURCE");
strSql.Append(",DOCNO,TRADETYPE,REMARK,BOOKNO,BYCUSTOM,ENTERPID,ENTERP,CLEARCUSTOMDATE,ISMOREGOOD,INSPECTSERVICE,CUSTOMSNUM,TRADETERM");
strSql.Append(",IsService1,IsService2,IsService3,IsService4,IsService5,IsService6,IsService7,IsService8");
strSql.Append(",IsService9,IsService10,IsService11,IsService12,IsService13,IsService14,IsService15,IsService16");
strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=96004 and EnumValueID=OP_APPLY.BsType) as BsTypeREF");
strSql.Append(",(CASE BsStatus WHEN 1 THEN '锁定' else '未锁定' end) as bsstatusref ");
strSql.Append(",(CASE FeeStatus WHEN 1 THEN '锁定' else '未锁定' end) as feestatusref ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE1') as SERVICE1 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE2') as SERVICE2 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE3') as SERVICE3 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE4') as SERVICE4 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE5') as SERVICE5 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE6') as SERVICE6 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE7') as SERVICE7 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE8') as SERVICE8 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE9') as SERVICE9 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE10') as SERVICE10 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE11') as SERVICE11 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE12') as SERVICE12 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE13') as SERVICE13 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE14') as SERVICE14 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE15') as SERVICE15 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE16') as SERVICE16 ");
strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=97018 and EnumValueID=OP_APPLY.MANIFESTSTATUS) as MANIFESTSTATUSREF");
strSql.Append(",(select TOP 1 CUSTNO from v_op_bs where OPLB<>'op_apply' and BSNO=OP_APPLY.MASTERNO) as BSCUSTNO ");
strSql.Append(", BSCUSTOMNO,ISPRINTPR,CUSTOMTYPE,ISCLEAR,ISCUSTOMEND,CUSTOMSLNO,WMSNO,CURRENCY,CARGOVALUE,INQUNO,ISDY ");
strSql.Append(",dbo.F_GetBillDrFeeStatus(OP_APPLY.BSNO) DRFEESTATUS");
strSql.Append(",dbo.F_GetBillCrFeeStatus(OP_APPLY.BSNO) CRFEESTATUS");
strSql.Append(",[ediYwlx],[recordSn],[payMent],[carriageType],[carriagePrice],[carriageCurrency],[premiumType],[premiumPrice],[premiumCurrency]");
strSql.Append(",SALECORPID,(select [NAME] from [company] where GID=OP_APPLY.SALECORPID) as SALECORP,BillFeeStatus ");
strSql.Append(",[DOCSTATUS],[CUSCIQNO],[TRANCUSTOMNO],[CUSTOMLOCKNO],[EXPCUSTOMTYPE],[DESPPORT],CONSIGNEE ");
strSql.Append(",(SELECT TOP 1 STATUS FROM OP_STATUS WITH (NOLOCK) WHERE BSNO=OP_APPLY.BSNO ORDER BY COMPTIME DESC,INPUTTIME DESC) as OPSTATUS");
strSql.Append(",ETPS_CATEGORY,CDNTYPE,CUSTSERVICE,OPERATORCODE");
strSql.Append(" from OP_APPLY ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" order by BsDate Desc ");
}
return strSql.ToString();
}
static public MsOpApply GetData(string condition,string dbname = "")
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("BsNo,BsStatus,FeeStatus,BsDate,AccDate,OpDate,Mblno,Hblno,CustNo,BSCUSTOMNO,'' DRFEESTATUS,'' CRFEESTATUS,ISPRINTPR ");
strSql.Append(",CustomerName,BsType,Vessel,VoyNo,ETD,ETA,PORTLOAD,PORTDISCHARGE,MASTERNO");
strSql.Append(",INPUTBY,OP,SALE,CUSTOMSER,BSSOURCE,BSSOURCEDETAIL");
strSql.Append(",CORPID,SALEDEPT,PKGS,KGS,NETWEIGHT,CBM,MANIFESTSTATUS");
strSql.Append(",CUSTOMNO,CUSTOMDATE,INSPECTIONNO,INSPECTIONDATE,INVNO,CONTRACTNO,ARCOUNTRY,GOODSOURCE");
strSql.Append(",DOCNO,TRADETYPE,REMARK,BOOKNO,BYCUSTOM,ENTERPID,ENTERP,CLEARCUSTOMDATE,ISMOREGOOD,INSPECTSERVICE,CUSTOMSNUM,TRADETERM");
strSql.Append(",IsService1,IsService2,IsService3,IsService4,IsService5,IsService6,IsService7,IsService8");
strSql.Append(",IsService9,IsService10,IsService11,IsService12,IsService13,IsService14,IsService15,IsService16");
strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=96004 and EnumValueID=OP_APPLY.BsType) as BsTypeREF");
strSql.Append(",(CASE BsStatus WHEN 1 THEN '锁定' else '未锁定' end) as bsstatusref ");
strSql.Append(",(CASE FeeStatus WHEN 1 THEN '锁定' else '未锁定' end) as feestatusref ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE1') as SERVICE1 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE2') as SERVICE2 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE3') as SERVICE3 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE4') as SERVICE4 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE5') as SERVICE5 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE6') as SERVICE6 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE7') as SERVICE7 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE7') as SERVICE8 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE9') as SERVICE9 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE10') as SERVICE10 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE11') as SERVICE11 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE12') as SERVICE12 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE13') as SERVICE13 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE14') as SERVICE14 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE15') as SERVICE15 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=OP_APPLY.BSNO AND OPField='SERVICE16') as SERVICE16 ");
strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=97018 and EnumValueID=OP_APPLY.MANIFESTSTATUS) as MANIFESTSTATUSREF");
strSql.Append(",(select TOP 1 CUSTNO from v_op_bs where OPLB<>'op_apply' and BSNO=OP_APPLY.MASTERNO) as BSCUSTNO ");
strSql.Append(",0 TTLDR,0 TTLINVDR,0 TTLDUIDR,CUSTOMTYPE,ISCLEAR,ISCUSTOMEND,CUSTOMSLNO,WMSNO,CURRENCY,CARGOVALUE,INQUNO,ISDY");
strSql.Append(",[ediYwlx],[recordSn],[payMent],[carriageType],[carriagePrice],[carriageCurrency],[premiumType],[premiumPrice],[premiumCurrency]");
strSql.Append(",SALECORPID,(select [NAME] from [company] where GID=OP_APPLY.SALECORPID) as SALECORP,BillFeeStatus ");
strSql.Append(",[DOCSTATUS],[CUSCIQNO],[TRANCUSTOMNO],[CUSTOMLOCKNO],[EXPCUSTOMTYPE],[DESPPORT],CONSIGNEE ");
strSql.Append(",(SELECT TOP 1 STATUS FROM OP_STATUS WITH (NOLOCK) WHERE BSNO=OP_APPLY.BSNO ORDER BY COMPTIME DESC,INPUTTIME DESC) as OPSTATUS");
strSql.Append(",ETPS_CATEGORY,CDNTYPE,CUSTSERVICE,OPERATORCODE");
strSql.Append(" from OP_APPLY ");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" where " + condition);
}
var list=SetData(strSql, dbname);
if (list.Count > 0)
return list[0];
return new MsOpApply();
}
private static List<MsOpApply> SetData(StringBuilder strSql,string dbname = "")
{
var headList = new List<MsOpApply>();
Database db = string.IsNullOrWhiteSpace(dbname) ? DatabaseFactory.CreateDatabase(): DatabaseFactory.CreateDatabase(dbname);
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsOpApply data = new MsOpApply();
#region Set DB data to Object
data.BSNO = Convert.ToString(reader["BSNO"]);
data.MASTERNO = Convert.ToString(reader["MASTERNO"]);
data.BSSTATUS = Convert.ToBoolean(reader["BSSTATUS"]);
data.FEESTATUS = Convert.ToBoolean(reader["FEESTATUS"]);
data.BSSTATUSREF = Convert.ToString(reader["BSSTATUSREF"]);
data.FEESTATUSREF = Convert.ToString(reader["FEESTATUSREF"]);
data.DRFEESTATUS = getfeestatus(Convert.ToString(reader["DRFEESTATUS"]));
data.CRFEESTATUS = getfeestatus(Convert.ToString(reader["CRFEESTATUS"]));
if (reader["BSDATE"] != DBNull.Value)
data.BSDATE = Convert.ToDateTime(reader["BSDATE"]);
data.ETD = Convert.ToString(reader["ETD"]);
data.ETA = Convert.ToString(reader["ETA"]);
data.ACCDATE = Convert.ToString(reader["ACCDATE"]);
if (reader["OpDate"] != DBNull.Value)
data.OPDATE = Convert.ToString(reader["OpDate"]);
else if (Convert.ToString(reader["CUSTNO"])!="")
data.OPDATE ="";
data.MBLNO = Convert.ToString(reader["MBLNO"]);
data.HBLNO = Convert.ToString(reader["HBLNO"]);
data.MANIFESTSTATUS = Convert.ToString(reader["MANIFESTSTATUSREF"]);
data.CUSTNO = Convert.ToString(reader["CUSTNO"]);
data.BSCUSTNO = Convert.ToString(reader["BSCUSTNO"]);
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
data.BSTYPE = Convert.ToString(reader["BSTYPE"]);
data.BSTYPEREF = Convert.ToString(reader["BsTypeREF"]);
data.VESSEL = Convert.ToString(reader["VESSEL"]);
data.VOYNO = Convert.ToString(reader["VOYNO"]);
data.PORTLOAD = Convert.ToString(reader["PORTLOAD"]);
data.PORTDISCHARGE = Convert.ToString(reader["PORTDISCHARGE"]);
data.INPUTBY = Convert.ToString(reader["INPUTBY"]);
data.OP = Convert.ToString(reader["OP"]);
data.SALE = Convert.ToString(reader["SALE"]);
data.CUSTSERVICE = Convert.ToString(reader["CUSTSERVICE"]);
data.CUSTOMSER = Convert.ToString(reader["CUSTOMSER"]);
data.BSSOURCE = Convert.ToString(reader["BSSOURCE"]);
data.BSSOURCEDETAIL = Convert.ToString(reader["BSSOURCEDETAIL"]);
data.CORPID = Convert.ToString(reader["CORPID"]);
data.SALEDEPT = Convert.ToString(reader["SALEDEPT"]);
data.SALECORPID = Convert.ToString(reader["SALECORPID"]);//分公司代码
data.SALECORP = Convert.ToString(reader["SALECORP"]);//分公司代码
data.PKGS = Convert.ToInt32(reader["PKGS"]);
data.KGS = Convert.ToDecimal(reader["KGS"]);
data.NETWEIGHT = Convert.ToDecimal(reader["NETWEIGHT"]);
data.CBM = Convert.ToDecimal(reader["CBM"]);
data.CUSTOMNO = Convert.ToString(reader["CUSTOMNO"]);
data.BSCUSTOMNO = Convert.ToString(reader["BSCUSTOMNO"]);
data.CUSTOMDATE = Convert.ToString(reader["CUSTOMDATE"]);
data.INSPECTIONNO = Convert.ToString(reader["INSPECTIONNO"]);
data.INSPECTIONDATE = Convert.ToString(reader["INSPECTIONDATE"]);
data.INVNO = Convert.ToString(reader["INVNO"]);
data.CONTRACTNO = Convert.ToString(reader["CONTRACTNO"]);
data.ARCOUNTRY = Convert.ToString(reader["ARCOUNTRY"]);
data.GOODSOURCE = Convert.ToString(reader["GOODSOURCE"]);
data.DOCNO = Convert.ToString(reader["DOCNO"]);
data.TRADETYPE = Convert.ToString(reader["TRADETYPE"]);
data.TRADETERM = Convert.ToString(reader["TRADETERM"]);//贸易条款
data.REMARK = Convert.ToString(reader["REMARK"]);
data.BOOKNO = Convert.ToString(reader["BOOKNO"]);
data.BYCUSTOM = Convert.ToString(reader["BYCUSTOM"]);
data.ENTERPID = Convert.ToString(reader["ENTERPID"]);
data.ENTERP = Convert.ToString(reader["ENTERP"]);
data.CURRENCY = Convert.ToString(reader["CURRENCY"]);
data.CARGOVALUE = Convert.ToString(reader["CARGOVALUE"]);
if (reader["CLEARCUSTOMDATE"] != DBNull.Value)
data.CLEARCUSTOMDATE = Convert.ToDateTime(reader["CLEARCUSTOMDATE"]).ToString("yyyy-MM-dd");//
data.INSPECTSERVICE = Convert.ToString(reader["INSPECTSERVICE"]);//
if (reader["ISMOREGOOD"] != DBNull.Value)
data.ISMOREGOOD = Convert.ToBoolean(reader["ISMOREGOOD"]);//多品名
if (reader["CUSTOMSNUM"] != DBNull.Value)
data.CUSTOMSNUM = Convert.ToInt16(reader["CUSTOMSNUM"]);
data.IsSERVICE1 = Convert.ToString(reader["IsService1"]);
data.IsSERVICE2 = Convert.ToString(reader["IsService2"]);
data.IsSERVICE3 = Convert.ToString(reader["IsService3"]);
data.IsSERVICE4 = Convert.ToString(reader["IsService4"]);
data.IsSERVICE5 = Convert.ToString(reader["IsService5"]);
data.IsSERVICE6 = Convert.ToString(reader["IsService6"]);
data.IsSERVICE7 = Convert.ToString(reader["IsService7"]);
data.IsSERVICE8 = Convert.ToString(reader["IsService8"]);
data.IsSERVICE9 = Convert.ToString(reader["IsService9"]);
data.IsSERVICE10 = Convert.ToString(reader["IsService10"]);
data.IsSERVICE11 = Convert.ToString(reader["IsService11"]);
data.IsSERVICE12 = Convert.ToString(reader["IsService12"]);
data.IsSERVICE13 = Convert.ToString(reader["IsService13"]);
data.IsSERVICE14= Convert.ToString(reader["IsService14"]);
data.IsSERVICE15 = Convert.ToString(reader["IsService15"]);
data.IsSERVICE16 = Convert.ToString(reader["IsService16"]);
if (reader["Service1"] != DBNull.Value)
data.SERVICE1 = Convert.ToString(reader["Service1"]);
if (reader["Service2"] != DBNull.Value)
data.SERVICE2 = Convert.ToString(reader["Service2"]);
if (reader["Service3"] != DBNull.Value)
data.SERVICE3 = Convert.ToString(reader["Service3"]);
if (reader["Service4"] != DBNull.Value)
data.SERVICE4 = Convert.ToString(reader["Service4"]);
if (reader["Service5"] != DBNull.Value)
data.SERVICE5 = Convert.ToString(reader["Service5"]);
if (reader["Service6"] != DBNull.Value)
data.SERVICE6 = Convert.ToString(reader["Service6"]);
if (reader["Service7"] != DBNull.Value)
data.SERVICE7 = Convert.ToString(reader["Service7"]);
if (reader["Service8"] != DBNull.Value)
data.SERVICE8 = Convert.ToString(reader["Service8"]);
if (reader["Service9"] != DBNull.Value)
data.SERVICE9 = Convert.ToString(reader["Service9"]);
if (reader["Service10"] != DBNull.Value)
data.SERVICE10 = Convert.ToString(reader["Service10"]);
if (reader["Service11"] != DBNull.Value)
data.SERVICE11 = Convert.ToString(reader["Service11"]);
if (reader["Service12"] != DBNull.Value)
data.SERVICE12= Convert.ToString(reader["Service12"]);
if (reader["Service13"] != DBNull.Value)
data.SERVICE13 = Convert.ToString(reader["Service13"]);
if (reader["Service14"] != DBNull.Value)
data.SERVICE14 = Convert.ToString(reader["Service14"]);
if (reader["Service15"] != DBNull.Value)
data.SERVICE15 = Convert.ToString(reader["Service15"]);
if (reader["Service16"] != DBNull.Value)
data.SERVICE16 = Convert.ToString(reader["Service16"]);
data.ISPRINTPR = Convert.ToString(reader["ISPRINTPR"]);
decimal ttldr = 0;
if (reader["TTLDR"] != DBNull.Value)
ttldr = Convert.ToDecimal(reader["TTLDR"]);
decimal ttlinvdr = 0;
if (reader["TTLDR"] != DBNull.Value)
ttlinvdr = Convert.ToDecimal(reader["TTLINVDR"]);
if (ttlinvdr == 0) data.DRINVSTATUS = "未开票";
else if (ttlinvdr == ttldr) data.DRINVSTATUS = "已开票";
else if (ttlinvdr != ttldr) data.DRINVSTATUS = "部分开票";
decimal ttlduidr = 0;
if (reader["TTLDUIDR"] != DBNull.Value)
ttlduidr = Convert.ToDecimal(reader["TTLDUIDR"]);
if (ttlduidr == 0) data.DRDUISTATUS = "未对账";
else if (ttlduidr == ttldr) data.DRDUISTATUS = "已对账";
else if (ttlduidr != ttldr) data.DRDUISTATUS = "部分对账";
data.CUSTOMTYPE = Convert.ToString(reader["CUSTOMTYPE"]);
data.ISCLEAR = Convert.ToString(reader["ISCLEAR"]);
if (data.ISCLEAR == "") data.ISCLEAR = "0";
data.ISCUSTOMEND = Convert.ToString(reader["ISCUSTOMEND"]);
if (data.ISCUSTOMEND == "") data.ISCUSTOMEND = "0";
data.CUSTOMSLNO = Convert.ToString(reader["CUSTOMSLNO"]);
data.WMSNO = Convert.ToString(reader["WMSNO"]);
if (reader["EDIYWLX"] != DBNull.Value)
data.EDIYWLX = Convert.ToInt32(reader["EDIYWLX"]);//易航线_0代表一般出口业务;1代表一般进口业务;2代表出口备案手册业务;3代表进口备案手册业务;4出境清单业务;5进境清单业务;
data.RECORDSN = (reader["RECORDSN"] == null ? "" : Convert.ToString(reader["RECORDSN"]));//易航线_备案号EDIYWLX =0||1时该字段不填写其他必须填写
data.PAYMENT = (reader["PAYMENT"] == null ? "" : Convert.ToString(reader["PAYMENT"]));//易航线_征税比例电汇出口方式需要必填进口方式不填
data.CARRIAGETYPE = (reader["CARRIAGETYPE"] == null ? "" : Convert.ToString(reader["CARRIAGETYPE"]));//易航线_运费类型率,单价,总价
if (reader["CARRIAGEPRICE"] != DBNull.Value)
data.CARRIAGEPRICE = Convert.ToDecimal(reader["CARRIAGEPRICE"]);//易航线_运费金额
data.CARRIAGECURRENCY = (reader["CARRIAGECURRENCY"] == null ? "" : Convert.ToString(reader["CARRIAGECURRENCY"]));//易航线_运费币制当CARRIAGETYPE是[率]时,不能填运费币制
data.PREMIUMTYPE = (reader["PREMIUMTYPE"] == null ? "" : Convert.ToString(reader["PREMIUMTYPE"]));//易航线_保费类型率,单价,总价
if (reader["PREMIUMPRICE"] != DBNull.Value)
data.PREMIUMPRICE = Convert.ToDecimal(reader["PREMIUMPRICE"]);//易航线_保费金额
data.PREMIUMCURRENCY = (reader["PREMIUMCURRENCY"] == null ? "" : Convert.ToString(reader["PREMIUMCURRENCY"]));//易航线_保费币制当PREMIUMTYPE是[率]时,不能填保费币制
data.BillFeeStatus = Convert.ToString(reader["BillFeeStatus"]);
data.INQUNO = Convert.ToString(reader["INQUNO"]);//检验检验号
data.ISDY = Convert.ToString(reader["ISDY"]);//
data.DOCSTATUS = Convert.ToString(reader["DOCSTATUS"]);//
data.CUSCIQNO = Convert.ToString(reader["CUSCIQNO"]);//
data.TRANCUSTOMNO = Convert.ToString(reader["TRANCUSTOMNO"]);//
data.CUSTOMLOCKNO = Convert.ToString(reader["CUSTOMLOCKNO"]);//
data.EXPCUSTOMTYPE = Convert.ToString(reader["EXPCUSTOMTYPE"]);//
data.DESPPORT = Convert.ToString(reader["DESPPORT"]);//
data.CONSIGNEE = Convert.ToString(reader["CONSIGNEE"]);//
data.OPSTATUS= Convert.ToString(reader["OPSTATUS"]);//
data.ETPS_CATEGORY = Convert.ToString(reader["ETPS_CATEGORY"]);//
if(reader["CDNTYPE"] != DBNull.Value)
data.CDNTYPE = Convert.ToInt32(reader["CDNTYPE"]);//
data.OPERATORCODE = Convert.ToString(reader["OPERATORCODE"]);//
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
static public List<MsOpApplySum> GetDataListSum(string strCondition, string userid, string usercode, string companyid, string sort = null)
{
var rangstr = GetRangDAStr("index", userid, usercode, companyid);
if (!string.IsNullOrEmpty(rangstr))
{
if (!string.IsNullOrEmpty(strCondition))
{
strCondition = strCondition + " and " + rangstr;
}
else
{
strCondition = rangstr;
}
}
//
var strSql = new StringBuilder();
strSql.Append("SELECT Count(BSNO) as NOBILL,SUM(CUSTOMSNUM) CUSTOMSNUM");
strSql.Append(",sum(CASE IsService1 WHEN '1' THEN 1 ELSE 0 END) as SERVICE1,sum(CASE IsService2 WHEN '1' THEN 1 ELSE 0 END) as SERVICE2");
strSql.Append(",sum(CASE IsService3 WHEN '1' THEN 1 ELSE 0 END) as SERVICE3,sum(CASE IsService4 WHEN '1' THEN 1 ELSE 0 END) as SERVICE4");
strSql.Append(",sum(CASE IsService5 WHEN '1' THEN 1 ELSE 0 END) as SERVICE5,sum(CASE IsService6 WHEN '1' THEN 1 ELSE 0 END) as SERVICE6");
strSql.Append(",sum(CASE IsService7 WHEN '1' THEN 1 ELSE 0 END) as SERVICE7,sum(CASE IsService8 WHEN '1' THEN 1 ELSE 0 END) as SERVICE8");
strSql.Append(",sum(CASE IsService9 WHEN '1' THEN 1 ELSE 0 END) as SERVICE9,sum(CASE IsService10 WHEN '1' THEN 1 ELSE 0 END) as SERVICE10");
strSql.Append(",sum(CASE IsService11 WHEN '1' THEN 1 ELSE 0 END) as SERVICE11,sum(CASE IsService12 WHEN '1' THEN 1 ELSE 0 END) as SERVICE12");
strSql.Append(",sum(CASE IsService13 WHEN '1' THEN 1 ELSE 0 END) as SERVICE13,sum(CASE IsService14 WHEN '1' THEN 1 ELSE 0 END) as SERVICE14");
strSql.Append(",sum(CASE IsService15 WHEN '1' THEN 1 ELSE 0 END) as SERVICE15,sum(CASE IsService16 WHEN '1' THEN 1 ELSE 0 END) as SERVICE16");
strSql.Append(" from OP_APPLY ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
return SetDataSum(strSql);
}
private static List<MsOpApplySum> SetDataSum(StringBuilder strSql)
{
var headList = new List<MsOpApplySum>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsOpApplySum data = new MsOpApplySum();
#region Set DB data to Object
data.NOBILL = Convert.ToInt32(reader["NOBILL"]);//票数
if (reader["CUSTOMSNUM"] != DBNull.Value)
data.CUSTOMSNUM = Convert.ToInt32(reader["CUSTOMSNUM"]);//箱型1
if (reader["SERVICE1"] != DBNull.Value)
data.SERVICE1 = Convert.ToInt32(reader["SERVICE1"]);//箱型1
if (reader["SERVICE2"] != DBNull.Value)
data.SERVICE2 = Convert.ToInt32(reader["SERVICE2"]);//箱型2
if (reader["SERVICE3"] != DBNull.Value)
data.SERVICE3 = Convert.ToInt32(reader["SERVICE3"]);//箱型3
if (reader["SERVICE4"] != DBNull.Value)
data.SERVICE4 = Convert.ToInt32(reader["SERVICE4"]);//箱型4
if (reader["SERVICE5"] != DBNull.Value)
data.SERVICE5 = Convert.ToInt32(reader["SERVICE5"]);//箱型5
if (reader["SERVICE6"] != DBNull.Value)
data.SERVICE6 = Convert.ToInt32(reader["SERVICE6"]);//箱型6
if (reader["SERVICE7"] != DBNull.Value)
data.SERVICE7 = Convert.ToInt32(reader["SERVICE7"]);//箱型7
if (reader["SERVICE8"] != DBNull.Value)
data.SERVICE8 = Convert.ToInt32(reader["SERVICE8"]);//箱型8
if (reader["SERVICE9"] != DBNull.Value)
data.SERVICE9 = Convert.ToInt32(reader["SERVICE9"]);//箱型9
if (reader["SERVICE10"] != DBNull.Value)
data.SERVICE10 = Convert.ToInt32(reader["SERVICE10"]);//箱型10
if (reader["SERVICE11"] != DBNull.Value)
data.SERVICE11 = Convert.ToInt32(reader["SERVICE11"]);//箱型1
if (reader["SERVICE12"] != DBNull.Value)
data.SERVICE12 = Convert.ToInt32(reader["SERVICE12"]);//箱型2
if (reader["SERVICE13"] != DBNull.Value)
data.SERVICE13 = Convert.ToInt32(reader["SERVICE13"]);//箱型3
if (reader["SERVICE14"] != DBNull.Value)
data.SERVICE14 = Convert.ToInt32(reader["SERVICE14"]);//箱型4
if (reader["SERVICE15"] != DBNull.Value)
data.SERVICE15 = Convert.ToInt32(reader["SERVICE15"]);//箱型5
if (reader["SERVICE16"] != DBNull.Value)
data.SERVICE16 = Convert.ToInt32(reader["SERVICE16"]);//箱型6
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
public static string getfeestatus(string feestatusint)
{
var result = "";
if (feestatusint == "0:") {
return "审核通过";
} else if (feestatusint == "1:") {
return "录入状态";
} else if (feestatusint == "2:") {
return "提交审核";
} else if (feestatusint == "8:") {
return "部分结算";
} else if (feestatusint == "9:") {
return "结算完毕";
} else if (feestatusint == "") {
return "未录入";
}
else if (feestatusint == "3:")
{
return "申请修改";
}
else if (feestatusint == "4:")
{
return "申请删除";
}
else if (feestatusint == "6:")
{
return "驳回提交";
}
else if (feestatusint == "7:")
{
return "驳回申请";
}
else if (feestatusint.IndexOf("9:") > -1)
{
return "部分结算";
}
else if (feestatusint.IndexOf("8:") > -1)
{
return "部分结算";
}
else if (feestatusint.IndexOf("0:") > -1)
{
return "部分审核";
}
else if (feestatusint.IndexOf("2:") > -1)
{
return "部分提交";
}
else if (feestatusint.IndexOf("6:") > -1)
{
return "驳回提交";
}
else if (feestatusint.IndexOf("7:") > -1)
{
return "驳回申请";
}
return result;
}
#endregion
#region 明细表
static public List<MsOpApply> GetDataCtnList(string strCondition, string userid, string usercode, string companyid, string sort = null)
{
var rangstr = GetRangDAStr("index", userid, usercode, companyid);
if (!string.IsNullOrEmpty(rangstr))
{
if (!string.IsNullOrEmpty(strCondition))
{
strCondition = strCondition + " and " + rangstr;
}
else
{
strCondition = rangstr;
}
}
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("B.BsNo,B.BsStatus,B.FeeStatus,BsDate,AccDate,OpDate,Mblno,Hblno,CustNo");
strSql.Append(",CustomerName,BsType,Vessel,VoyNo,ETD,ETA,PORTLOAD,PORTDISCHARGE");
strSql.Append(",INPUTBY,OP,SALE,CUSTOMSER,BSSOURCE,BSSOURCEDETAIL,B.MASTERNO");
strSql.Append(",CORPID,SALEDEPT,B.PKGS,B.KGS,B.NETWEIGHT,B.CBM,B.MANIFESTSTATUS");
strSql.Append(",B.CUSTOMNO,B.CUSTOMDATE,B.INSPECTIONNO,INSPECTIONDATE,B.INVNO,CONTRACTNO,ARCOUNTRY,GOODSOURCE");
strSql.Append(",DOCNO,TRADETYPE,B.REMARK,BOOKNO,BYCUSTOM,ENTERPID,ENTERP,CLEARCUSTOMDATE,ISMOREGOOD,INSPECTSERVICE,CUSTOMSNUM,TRADETERM");
strSql.Append(",IsService1,IsService2,IsService3,IsService4,IsService5,IsService6,IsService7,IsService8");
strSql.Append(",IsService9,IsService10,IsService11,IsService12,IsService13,IsService14,IsService15,IsService16");
strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=96004 and EnumValueID=B.BsType) as BsTypeREF");
strSql.Append(",(CASE BsStatus WHEN 1 THEN '锁定' else '未锁定' end) as bsstatusref ");
strSql.Append(",(CASE FeeStatus WHEN 1 THEN '锁定' else '未锁定' end) as feestatusref ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=B.BSNO AND OPField='SERVICE1') as SERVICE1 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=B.BSNO AND OPField='SERVICE2') as SERVICE2 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=B.BSNO AND OPField='SERVICE3') as SERVICE3 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=B.BSNO AND OPField='SERVICE4') as SERVICE4 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=B.BSNO AND OPField='SERVICE5') as SERVICE5 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=B.BSNO AND OPField='SERVICE6') as SERVICE6 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=B.BSNO AND OPField='SERVICE7') as SERVICE7 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=B.BSNO AND OPField='SERVICE8') as SERVICE8 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=B.BSNO AND OPField='SERVICE9') as SERVICE9 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=B.BSNO AND OPField='SERVICE10') as SERVICE10 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=B.BSNO AND OPField='SERVICE11') as SERVICE11 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=B.BSNO AND OPField='SERVICE12') as SERVICE12 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=B.BSNO AND OPField='SERVICE13') as SERVICE13 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=B.BSNO AND OPField='SERVICE14') as SERVICE14 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=B.BSNO AND OPField='SERVICE15') as SERVICE15 ");
strSql.Append(",(Select STATUS from op_apply_service where BSNO=B.BSNO AND OPField='SERVICE16') as SERVICE16 ");
strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=97018 and EnumValueID=B.MANIFESTSTATUS) as MANIFESTSTATUSREF");
strSql.Append(",(select TOP 1 CUSTNO from v_op_bs where OPLB<>'op_apply' and BSNO=B.MASTERNO) as BSCUSTNO ");
strSql.Append(", B.BSCUSTOMNO,B.ISPRINTPR,B.CUSTOMTYPE,B.ISCLEAR,B.ISCUSTOMEND,B.CUSTOMSLNO,B.WMSNO ");
strSql.Append(",dbo.F_GetBillDrFeeStatus(B.BSNO) DRFEESTATUS");
strSql.Append(",dbo.F_GetBillCrFeeStatus(B.BSNO) CRFEESTATUS");
strSql.Append(",I.TTLDR,I.TTLINVDR,CURRENCY,CARGOVALUE,INQUNO,ISDY");
strSql.Append(",[ediYwlx],[recordSn],[payMent],[carriageType],[carriagePrice],[carriageCurrency],[premiumType],[premiumPrice],[premiumCurrency]");
strSql.Append(",B.SALECORPID,(select [NAME] from [company] where GID=B.SALECORPID) as SALECORP,B.BillFeeStatus ");
strSql.Append(",[DOCSTATUS],[CUSCIQNO],[TRANCUSTOMNO],[CUSTOMLOCKNO],[EXPCUSTOMTYPE],[DESPPORT],B.CONSIGNEE,C.CTN_ID,C.CNTRNO ");
strSql.Append(" from OP_CTN C");
strSql.Append(" LEFT JOIN OP_APPLY B ON (B.BSNO=C.BSNO) ");
strSql.Append(" LEFT JOIN v_op_gain_dr_INV I ON (I.BSNO=B.BSNO) ");
strSql.Append(" where B.BSNO IS NOT NULL ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" AND " + strCondition);
}
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" order by B.VESSEL Desc ");
}
return SetCtnData(strSql);
}
private static List<MsOpApply> SetCtnData(StringBuilder strSql)
{
var headList = new List<MsOpApply>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsOpApply data = new MsOpApply();
#region Set DB data to Object
data.BSNO = Convert.ToString(reader["BSNO"]);
data.MASTERNO = Convert.ToString(reader["MASTERNO"]);
data.BSSTATUS = Convert.ToBoolean(reader["BSSTATUS"]);
data.FEESTATUS = Convert.ToBoolean(reader["FEESTATUS"]);
data.BSSTATUSREF = Convert.ToString(reader["BSSTATUSREF"]);
data.FEESTATUSREF = Convert.ToString(reader["FEESTATUSREF"]);
data.DRFEESTATUS = getfeestatus(Convert.ToString(reader["DRFEESTATUS"]));
data.CRFEESTATUS = getfeestatus(Convert.ToString(reader["CRFEESTATUS"]));
if (reader["BSDATE"] != DBNull.Value)
data.BSDATE = Convert.ToDateTime(reader["BSDATE"]);
data.ETD = Convert.ToString(reader["ETD"]);
data.ETA = Convert.ToString(reader["ETA"]);
data.ACCDATE = Convert.ToString(reader["ACCDATE"]);
if (reader["OpDate"] != DBNull.Value)
data.OPDATE = Convert.ToString(reader["OpDate"]);
else if (Convert.ToString(reader["CUSTNO"]) != "")
data.OPDATE = "";
data.MBLNO = Convert.ToString(reader["MBLNO"]);
data.HBLNO = Convert.ToString(reader["HBLNO"]);
data.MANIFESTSTATUS = Convert.ToString(reader["MANIFESTSTATUSREF"]);
data.CUSTNO = Convert.ToString(reader["CUSTNO"]);
data.BSCUSTNO = Convert.ToString(reader["BSCUSTNO"]);
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
data.BSTYPE = Convert.ToString(reader["BSTYPE"]);
data.BSTYPEREF = Convert.ToString(reader["BsTypeREF"]);
data.VESSEL = Convert.ToString(reader["VESSEL"]);
data.VOYNO = Convert.ToString(reader["VOYNO"]);
data.PORTLOAD = Convert.ToString(reader["PORTLOAD"]);
data.PORTDISCHARGE = Convert.ToString(reader["PORTDISCHARGE"]);
data.INPUTBY = Convert.ToString(reader["INPUTBY"]);
data.OP = Convert.ToString(reader["OP"]);
data.SALE = Convert.ToString(reader["SALE"]);
data.CUSTOMSER = Convert.ToString(reader["CUSTOMSER"]);
data.BSSOURCE = Convert.ToString(reader["BSSOURCE"]);
data.BSSOURCEDETAIL = Convert.ToString(reader["BSSOURCEDETAIL"]);
data.CORPID = Convert.ToString(reader["CORPID"]);
data.SALEDEPT = Convert.ToString(reader["SALEDEPT"]);
data.SALECORPID = Convert.ToString(reader["SALECORPID"]);//分公司代码
data.SALECORP = Convert.ToString(reader["SALECORP"]);//分公司代码
data.PKGS = Convert.ToInt32(reader["PKGS"]);
data.KGS = Convert.ToDecimal(reader["KGS"]);
data.NETWEIGHT = Convert.ToDecimal(reader["NETWEIGHT"]);
data.CBM = Convert.ToDecimal(reader["CBM"]);
data.CUSTOMNO = Convert.ToString(reader["CUSTOMNO"]);
data.BSCUSTOMNO = Convert.ToString(reader["BSCUSTOMNO"]);
data.CUSTOMDATE = Convert.ToString(reader["CUSTOMDATE"]);
data.INSPECTIONNO = Convert.ToString(reader["INSPECTIONNO"]);
data.INSPECTIONDATE = Convert.ToString(reader["INSPECTIONDATE"]);
data.INVNO = Convert.ToString(reader["INVNO"]);
data.CONTRACTNO = Convert.ToString(reader["CONTRACTNO"]);
data.ARCOUNTRY = Convert.ToString(reader["ARCOUNTRY"]);
data.GOODSOURCE = Convert.ToString(reader["GOODSOURCE"]);
data.DOCNO = Convert.ToString(reader["DOCNO"]);
data.TRADETYPE = Convert.ToString(reader["TRADETYPE"]);
data.TRADETERM = Convert.ToString(reader["TRADETERM"]);//贸易条款
data.REMARK = Convert.ToString(reader["REMARK"]);
data.BOOKNO = Convert.ToString(reader["BOOKNO"]);
data.BYCUSTOM = Convert.ToString(reader["BYCUSTOM"]);
data.ENTERPID = Convert.ToString(reader["ENTERPID"]);
data.ENTERP = Convert.ToString(reader["ENTERP"]);
data.CURRENCY = Convert.ToString(reader["CURRENCY"]);
data.CARGOVALUE = Convert.ToString(reader["CARGOVALUE"]);
if (reader["CLEARCUSTOMDATE"] != DBNull.Value)
data.CLEARCUSTOMDATE = Convert.ToDateTime(reader["CLEARCUSTOMDATE"]).ToString("yyyy-MM-dd");//
data.INSPECTSERVICE = Convert.ToString(reader["INSPECTSERVICE"]);//
if (reader["ISMOREGOOD"] != DBNull.Value)
data.ISMOREGOOD = Convert.ToBoolean(reader["ISMOREGOOD"]);//多品名
if (reader["CUSTOMSNUM"] != DBNull.Value)
data.CUSTOMSNUM = Convert.ToInt16(reader["CUSTOMSNUM"]);
data.IsSERVICE1 = Convert.ToString(reader["IsService1"]);
data.IsSERVICE2 = Convert.ToString(reader["IsService2"]);
data.IsSERVICE3 = Convert.ToString(reader["IsService3"]);
data.IsSERVICE4 = Convert.ToString(reader["IsService4"]);
data.IsSERVICE5 = Convert.ToString(reader["IsService5"]);
data.IsSERVICE6 = Convert.ToString(reader["IsService6"]);
data.IsSERVICE7 = Convert.ToString(reader["IsService7"]);
data.IsSERVICE8 = Convert.ToString(reader["IsService8"]);
data.IsSERVICE9 = Convert.ToString(reader["IsService9"]);
data.IsSERVICE10 = Convert.ToString(reader["IsService10"]);
data.IsSERVICE11 = Convert.ToString(reader["IsService11"]);
data.IsSERVICE12 = Convert.ToString(reader["IsService12"]);
data.IsSERVICE13 = Convert.ToString(reader["IsService13"]);
data.IsSERVICE14 = Convert.ToString(reader["IsService14"]);
data.IsSERVICE15 = Convert.ToString(reader["IsService15"]);
data.IsSERVICE16 = Convert.ToString(reader["IsService16"]);
if (reader["Service1"] != DBNull.Value)
data.SERVICE1 = Convert.ToString(reader["Service1"]);
if (reader["Service2"] != DBNull.Value)
data.SERVICE2 = Convert.ToString(reader["Service2"]);
if (reader["Service3"] != DBNull.Value)
data.SERVICE3 = Convert.ToString(reader["Service3"]);
if (reader["Service4"] != DBNull.Value)
data.SERVICE4 = Convert.ToString(reader["Service4"]);
if (reader["Service5"] != DBNull.Value)
data.SERVICE5 = Convert.ToString(reader["Service5"]);
if (reader["Service6"] != DBNull.Value)
data.SERVICE6 = Convert.ToString(reader["Service6"]);
if (reader["Service7"] != DBNull.Value)
data.SERVICE7 = Convert.ToString(reader["Service7"]);
if (reader["Service8"] != DBNull.Value)
data.SERVICE8 = Convert.ToString(reader["Service8"]);
if (reader["Service9"] != DBNull.Value)
data.SERVICE9 = Convert.ToString(reader["Service9"]);
if (reader["Service10"] != DBNull.Value)
data.SERVICE10 = Convert.ToString(reader["Service10"]);
if (reader["Service11"] != DBNull.Value)
data.SERVICE11 = Convert.ToString(reader["Service11"]);
if (reader["Service12"] != DBNull.Value)
data.SERVICE12 = Convert.ToString(reader["Service12"]);
if (reader["Service13"] != DBNull.Value)
data.SERVICE13 = Convert.ToString(reader["Service13"]);
if (reader["Service14"] != DBNull.Value)
data.SERVICE14 = Convert.ToString(reader["Service14"]);
if (reader["Service15"] != DBNull.Value)
data.SERVICE15 = Convert.ToString(reader["Service15"]);
if (reader["Service16"] != DBNull.Value)
data.SERVICE16 = Convert.ToString(reader["Service16"]);
data.ISPRINTPR = Convert.ToString(reader["ISPRINTPR"]);
decimal ttldr = 0;
if (reader["TTLDR"] != DBNull.Value)
ttldr = Convert.ToDecimal(reader["TTLDR"]);
decimal ttlinvdr = 0;
if (reader["TTLDR"] != DBNull.Value)
ttlinvdr = Convert.ToDecimal(reader["TTLINVDR"]);
if (ttlinvdr == 0) data.DRINVSTATUS = "未开票";
else if (ttlinvdr == ttldr) data.DRINVSTATUS = "已开票";
else if (ttlinvdr != ttldr) data.DRINVSTATUS = "部分开票";
data.CUSTOMTYPE = Convert.ToString(reader["CUSTOMTYPE"]);
data.ISCLEAR = Convert.ToString(reader["ISCLEAR"]);
if (data.ISCLEAR == "") data.ISCLEAR = "0";
data.ISCUSTOMEND = Convert.ToString(reader["ISCUSTOMEND"]);
if (data.ISCUSTOMEND == "") data.ISCUSTOMEND = "0";
data.CUSTOMSLNO = Convert.ToString(reader["CUSTOMSLNO"]);
data.WMSNO = Convert.ToString(reader["WMSNO"]);
if (reader["EDIYWLX"] != DBNull.Value)
data.EDIYWLX = Convert.ToInt32(reader["EDIYWLX"]);//易航线_0代表一般出口业务;1代表一般进口业务;2代表出口备案手册业务;3代表进口备案手册业务;4出境清单业务;5进境清单业务;
data.RECORDSN = (reader["RECORDSN"] == null ? "" : Convert.ToString(reader["RECORDSN"]));//易航线_备案号EDIYWLX =0||1时该字段不填写其他必须填写
data.PAYMENT = (reader["PAYMENT"] == null ? "" : Convert.ToString(reader["PAYMENT"]));//易航线_征税比例电汇出口方式需要必填进口方式不填
data.CARRIAGETYPE = (reader["CARRIAGETYPE"] == null ? "" : Convert.ToString(reader["CARRIAGETYPE"]));//易航线_运费类型率,单价,总价
if (reader["CARRIAGEPRICE"] != DBNull.Value)
data.CARRIAGEPRICE = Convert.ToDecimal(reader["CARRIAGEPRICE"]);//易航线_运费金额
data.CARRIAGECURRENCY = (reader["CARRIAGECURRENCY"] == null ? "" : Convert.ToString(reader["CARRIAGECURRENCY"]));//易航线_运费币制当CARRIAGETYPE是[率]时,不能填运费币制
data.PREMIUMTYPE = (reader["PREMIUMTYPE"] == null ? "" : Convert.ToString(reader["PREMIUMTYPE"]));//易航线_保费类型率,单价,总价
if (reader["PREMIUMPRICE"] != DBNull.Value)
data.PREMIUMPRICE = Convert.ToDecimal(reader["PREMIUMPRICE"]);//易航线_保费金额
data.PREMIUMCURRENCY = (reader["PREMIUMCURRENCY"] == null ? "" : Convert.ToString(reader["PREMIUMCURRENCY"]));//易航线_保费币制当PREMIUMTYPE是[率]时,不能填保费币制
data.BillFeeStatus = Convert.ToString(reader["BillFeeStatus"]);
data.INQUNO = Convert.ToString(reader["INQUNO"]);//检验检验号
data.ISDY = Convert.ToString(reader["ISDY"]);//
data.DOCSTATUS = Convert.ToString(reader["DOCSTATUS"]);//
data.CUSCIQNO = Convert.ToString(reader["CUSCIQNO"]);//
data.TRANCUSTOMNO = Convert.ToString(reader["TRANCUSTOMNO"]);//
data.CUSTOMLOCKNO = Convert.ToString(reader["CUSTOMLOCKNO"]);//
data.EXPCUSTOMTYPE = Convert.ToString(reader["EXPCUSTOMTYPE"]);//
data.DESPPORT = Convert.ToString(reader["DESPPORT"]);//
data.CONSIGNEE = Convert.ToString(reader["CONSIGNEE"]);//
data.CTN_ID = Convert.ToString(reader["CTN_ID"]);//
data.CNTRNO = Convert.ToString(reader["CNTRNO"]);//
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
static public List<MsOpApplySum> GetDataCtnSumList(string strCondition, string userid, string usercode, string companyid, string sort = null)
{
var rangstr = GetRangDAStr("index", userid, usercode, companyid);
if (!string.IsNullOrEmpty(rangstr))
{
if (!string.IsNullOrEmpty(strCondition))
{
strCondition = strCondition + " and " + rangstr;
}
else
{
strCondition = rangstr;
}
}
var strSql = new StringBuilder();
strSql.Append("SELECT COUNT(distinct B.CUSTOMNO) CUSTOMSNUM,COUNT(distinct C.CNTRNO) as NOBILL");
strSql.Append(" from OP_CTN C");
strSql.Append(" LEFT JOIN OP_APPLY B ON (B.BSNO=C.BSNO) ");
strSql.Append(" LEFT JOIN v_op_gain_dr_INV I ON (I.BSNO=B.BSNO) ");
strSql.Append(" where B.BSNO IS NOT NULL ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" AND " + strCondition);
}
return SetDataCtnSum(strSql);
}
private static List<MsOpApplySum> SetDataCtnSum(StringBuilder strSql)
{
var headList = new List<MsOpApplySum>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsOpApplySum data = new MsOpApplySum();
#region Set DB data to Object
if (reader["NOBILL"] != DBNull.Value)
data.NOBILL = Convert.ToInt32(reader["NOBILL"]);//票数
if (reader["CUSTOMSNUM"] != DBNull.Value)
data.CUSTOMSNUM = Convert.ToInt32(reader["CUSTOMSNUM"]);//箱型1
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
static public List<MsOpApplyDetail> GetBodyList(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("BsNo,SerialNo,GoodsCode,GoodsName,Pkgs,");
strSql.Append("Price,Total,WMSNO,WMSIN_GID,PICINO,PONO,KINDPKGS,KGS,GOODSMODEL,GOODSSTANDARD,GOODSNUM,ISNULL((SELECT GOODSRKSL FROM wms_in WHERE gid=WMSIN_GID),0) GOODSRKSL,");
strSql.Append("ISNULL((SELECT SUM(GOODSNUM) FROM op_apply_detail WHERE WMSIN_GID=WMSIN_GID),0) APPLYNUM,");
strSql.Append("Currency,Remark");
strSql.Append(" from op_apply_detail ");
if (strCondition.Trim() != String.Empty)
{
strSql.Append(" where " + strCondition);
}
return SetBodyData(strSql);
}
private static List<MsOpApplyDetail> SetBodyData(StringBuilder strSql)
{
var bodyList = new List<MsOpApplyDetail>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsOpApplyDetail data = new MsOpApplyDetail();
#region Set DB data to Object
data.BsNo = Convert.ToString(reader["BsNo"]);
data.SerialNo = Convert.ToDecimal(reader["SerialNo"]);
data.GoodsCode = Convert.ToString(reader["GoodsCode"]);
data.GoodsName = Convert.ToString(reader["GoodsName"]);
if (reader["Pkgs"] != DBNull.Value)
data.Pkgs = Convert.ToDecimal(reader["Pkgs"]);
if (reader["Price"] != DBNull.Value)
data.Price = Convert.ToDecimal(reader["Price"]);
if (reader["Total"] != DBNull.Value)
data.Total = Convert.ToDecimal(reader["Total"]);
data.Currency = Convert.ToString(reader["Currency"]);
data.Remark = Convert.ToString(reader["Remark"]);
data.WMSNO = Convert.ToString(reader["WMSNO"]);
data.PICINO = Convert.ToString(reader["PICINO"]);
data.PONO = Convert.ToString(reader["PONO"]);
data.KINDPKGS = Convert.ToString(reader["KINDPKGS"]);
if (reader["KGS"] != DBNull.Value)
data.KGS = Convert.ToString(reader["KGS"]);//件数
data.WMSIN_GID = Convert.ToString(reader["WMSIN_GID"]);
data.GOODSMODEL = Convert.ToString(reader["GOODSMODEL"]);
data.GOODSSTANDARD = Convert.ToString(reader["GOODSSTANDARD"]);
if (reader["GOODSNUM"] != DBNull.Value)
data.GOODSNUM = Convert.ToDecimal(reader["GOODSNUM"]);
data.NOAPPLYNUM = Convert.ToDecimal(reader["GOODSRKSL"]) - Convert.ToDecimal(reader["APPLYNUM"])+ data.GOODSNUM;
#endregion
bodyList.Add(data);
}
reader.Close();
}
return bodyList;
}
static public List<MsOpCtn> GetCtnBodyList(string strCondition, string sort = null)
{
var strSql = new StringBuilder();
strSql.Append("SELECT [CTN_ID],[BSNO],isnull(CTNCODE,1) as [CTNCODE],[SIZE],[CTN],[CTNNUM],[TEU],[CTNALL],op_ctn.CNTRNO,[SEALNO],[PKGS],[KGS],[CBM],[REMARK],[KINDPKGS],[TAREWEIGHT],[VGMCONNCOM],[GOODSNAME],CTNSTATUS,op_ctn.MASTERNO,WEIGHTYPE,WEIGHKGS,WEIGHATTN,WEIGHTEL,WEIGHSIGN,WEIGHDATE ");
strSql.Append(" ,TRUCKER,TRUCKNO,TRUCKFEE,FREESTORAGEDAY,STORAGEDAY,STORAGEPRICE,STORAGEFEE,FREECTNDAY,CTNDAY,CTNPRICE,CTNFEE,");
strSql.Append(" f.FENPKGS,f.FENKGS,f.FENCBM from op_ctn left join V_FEN_CTN_SUM f on (f.MASTERNO=op_ctn.BSNO and f.CNTRNO=op_ctn.CNTRNO) ");
if (strCondition.Trim() != String.Empty)
{
strSql.Append(" where " + strCondition);
}
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" order by BSNO,CTNCODE,CTNALL");
}
return SetCtnBodyData(strSql);
}
public static List<MsOpCtn> SetCtnBodyData(StringBuilder strSql)
{
var bodyList = new List<MsOpCtn>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsOpCtn data = new MsOpCtn();
#region Set DB data to Object
data.VGMCONNCOM = Convert.ToString(reader["VGMCONNCOM"]);//vgm联系公司
data.CTN_ID = Convert.ToString(reader["CTN_ID"]);//编号
data.BSNO = Convert.ToString(reader["BSNO"]);//业务编号
data.CTNCODE = Convert.ToString(reader["CTNCODE"]);//箱型代码
data.SIZE = Convert.ToString(reader["SIZE"]);//尺寸
data.CTN = Convert.ToString(reader["CTN"]);//箱型
data.CTNNUM = Convert.ToInt32(reader["CTNNUM"]);//箱量
data.TEU = Convert.ToInt32(reader["TEU"]);//TEU
data.CTNALL = Convert.ToString(reader["CTNALL"]);//表现形式
data.CNTRNO = Convert.ToString(reader["CNTRNO"]);//箱号
data.SEALNO = Convert.ToString(reader["SEALNO"]);//封号
if (reader["PKGS"] != DBNull.Value)
data.PKGS = Convert.ToInt32(reader["PKGS"]);//件数
if (reader["KGS"] != DBNull.Value)
data.KGS = Convert.ToDecimal(reader["KGS"]);//重量(货重)
if (reader["CBM"] != DBNull.Value)
data.CBM = Convert.ToDecimal(reader["CBM"]);//尺码
data.REMARK = Convert.ToString(reader["REMARK"]);//备注
data.KINDPKGS = Convert.ToString(reader["KINDPKGS"]);//包装类型
if (reader["TAREWEIGHT"] != DBNull.Value)
data.TAREWEIGHT = Convert.ToDecimal(reader["TAREWEIGHT"]);//箱皮重
data.GOODSNAME = Convert.ToString(reader["GOODSNAME"]);//品名
data.WEIGHTYPE = Convert.ToString(reader["WEIGHTYPE"]);
data.WEIGHKGS = Convert.ToDecimal(reader["WEIGHKGS"]);//
data.WEIGHATTN = Convert.ToString(reader["WEIGHATTN"]);
data.WEIGHTEL = Convert.ToString(reader["WEIGHTEL"]);
data.WEIGHSIGN = Convert.ToString(reader["WEIGHSIGN"]);
data.WEIGHDATE = Convert.ToString(reader["WEIGHDATE"]);
data.CTNSTATUS = Convert.ToString(reader["CTNSTATUS"]);
data.MASTERNO = Convert.ToString(reader["MASTERNO"]);
if (reader["FENPKGS"] != DBNull.Value)
data.FENPKGS = Convert.ToInt32(reader["FENPKGS"]);//件数
if (reader["FENKGS"] != DBNull.Value)
data.FENKGS = Convert.ToDecimal(reader["FENKGS"]);//重量(货重)
if (reader["FENCBM"] != DBNull.Value)
data.FENCBM = Convert.ToDecimal(reader["FENCBM"]);//尺码
data.TRUCKNO = Convert.ToString(reader["TRUCKNO"]);
data.TRUCKER = Convert.ToString(reader["TRUCKER"]);
if (reader["FREESTORAGEDAY"] != DBNull.Value)
data.FREESTORAGEDAY = Convert.ToString(reader["FREESTORAGEDAY"]);
if (reader["STORAGEDAY"] != DBNull.Value)
data.STORAGEDAY = Convert.ToString(reader["STORAGEDAY"]);
if (reader["FREECTNDAY"] != DBNull.Value)
data.FREECTNDAY = Convert.ToString(reader["FREECTNDAY"]);
if (reader["CTNDAY"] != DBNull.Value)
data.CTNDAY = Convert.ToString(reader["CTNDAY"]);
if (reader["TRUCKFEE"] != DBNull.Value)
data.TRUCKFEE = Convert.ToString(reader["TRUCKFEE"]);
if (reader["STORAGEPRICE"] != DBNull.Value)
data.STORAGEPRICE = Convert.ToString(reader["STORAGEPRICE"]);
if (reader["STORAGEFEE"] != DBNull.Value)
data.STORAGEFEE = Convert.ToString(reader["STORAGEFEE"]);
if (reader["CTNPRICE"] != DBNull.Value)
data.CTNPRICE = Convert.ToString(reader["CTNPRICE"]);
if (reader["CTNFEE"] != DBNull.Value)
data.CTNFEE = Convert.ToString(reader["CTNFEE"]);
#endregion
bodyList.Add(data);
}
reader.Close();
}
return bodyList;
}
public static DBResult SaveCtnDetail(string bsno, List<MsOpCtn> bodyList, string userid, bool updatetotal, string dbname = "")
{
var result = new DBResult();
Database db = string.IsNullOrWhiteSpace(dbname)? DatabaseFactory.CreateDatabase() : DatabaseFactory.CreateDatabase(dbname);
//if (dbname != "") db = DatabaseFactory.CreateDatabase(dbname);
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
//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) values (newid(),@BSNO,@CTNCODE,@SIZE,@CTN,@CTNNUM,@TEU,@CTNALL,@CNTRNO,@SEALNO,@PKGS,@KGS,@CBM,@REMARK,@KINDPKGS,@TAREWEIGHT,@GOODSNAME) ");
//var cmdUpdate = db.GetSqlStringCommand(@"update op_ctn set CTNCODE=@CTNCODE,SIZE=@SIZE,CTN=@CTN,CTNNUM=@CTNNUM,TEU=@TEU,CTNALL=@CTNALL,CNTRNO=@CNTRNO,SEALNO=@SEALNO,PKGS=@PKGS,KGS=@KGS,CBM=@CBM,REMARK=@REMARK,KINDPKGS=@KINDPKGS,TAREWEIGHT=@TAREWEIGHT where BSNO=@BSNO AND CTN_ID=@CTN_ID ");
if (bodyList != null)
{
//var StrSerialNo = "('1000'";
foreach (var enumValue in bodyList)
{
//StrSerialNo = StrSerialNo + ",'" + Convert.ToString(enumValue.CTN_ID) + "'";
var SIZE = enumValue.CTNALL.ToString().Trim().Substring(0, 2);
string CTN = enumValue.CTNALL.ToString().Trim().Substring(2);
int TEU = enumValue.CTNNUM;
var iTEU = enumValue.CTNALL.ToString().Trim().Substring(0, 1);
if (iTEU == "4")
{
TEU = TEU * 2;
}
else if (iTEU == "L")
{
TEU = 0;
}
if (enumValue.TRUCKFEE == "") enumValue.TRUCKFEE = "0";
if (enumValue.FREESTORAGEDAY == "") enumValue.FREESTORAGEDAY = "0";
if (enumValue.STORAGEDAY == "") enumValue.STORAGEDAY = "0";
if (enumValue.STORAGEPRICE == "") enumValue.STORAGEPRICE = "0";
if (enumValue.STORAGEFEE == "") enumValue.STORAGEFEE = "0";
if (enumValue.FREECTNDAY == "") enumValue.FREECTNDAY = "0";
if (enumValue.CTNDAY == "") enumValue.CTNDAY = "0";
if (enumValue.CTNPRICE == "") enumValue.CTNPRICE = "0";
if (enumValue.CTNFEE == "") enumValue.CTNFEE = "0";
//
if (enumValue.BSNO == "*")
{
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,CTNSTATUS,MASTERNO,WEIGHTYPE,WEIGHKGS,WEIGHATTN,WEIGHTEL,WEIGHSIGN,WEIGHDATE,TRUCKER,TRUCKFEE,FREESTORAGEDAY,STORAGEDAY,STORAGEPRICE,STORAGEFEE,FREECTNDAY,CTNDAY,CTNPRICE,CTNFEE,TRUCKNO,VGMCONNCOM) values ('" + enumValue.CTN_ID
+ "','" + bsno + "','" + enumValue.CTNCODE + "','" + SIZE + "','" + CTN + "'," + enumValue.CTNNUM + "," + TEU + ",'" + enumValue.CTNALL + "','" + enumValue.CNTRNO + "','" + enumValue.SEALNO + "','" + enumValue.PKGS + "'," + enumValue.KGS + "," + enumValue.CBM + ",'" + enumValue.REMARK + "','" + enumValue.KINDPKGS + "'," + enumValue.TAREWEIGHT + ",'','"
+ enumValue.CTNSTATUS + "','" + enumValue.MASTERNO + "','" + enumValue.WEIGHTYPE + "'," + enumValue.WEIGHKGS + ",'" + enumValue.WEIGHATTN + "','" + enumValue.WEIGHTEL + "','" + enumValue.WEIGHSIGN + "','" + enumValue.WEIGHDATE + "','" + enumValue.TRUCKER + "'," + enumValue.TRUCKFEE
+ "," + enumValue.FREESTORAGEDAY + "," + enumValue.STORAGEDAY + "," + enumValue.STORAGEPRICE + "," + enumValue.STORAGEFEE + "," + enumValue.FREECTNDAY + "," + enumValue.CTNDAY + "," + enumValue.CTNPRICE + "," + enumValue.CTNFEE + ",'" + enumValue.TRUCKNO + "','" + enumValue.VGMCONNCOM + "')");
db.ExecuteNonQuery(cmdInsert, tran);
}
else
{
var cmdUpdate = db.GetSqlStringCommand(@"update op_ctn set CTNCODE='" + enumValue.CTNCODE + "',[SIZE]='" + SIZE + "',CTN='" + CTN + "',CTNNUM=" + enumValue.CTNNUM + ",TEU=" + TEU + ",CTNALL='" + enumValue.CTNALL + "',CNTRNO='" + enumValue.CNTRNO + "',SEALNO='" + enumValue.SEALNO + "',PKGS='" + enumValue.PKGS + "',KGS=" + enumValue.KGS
+ ",CBM=" + enumValue.CBM + ",REMARK='" + enumValue.REMARK + "',KINDPKGS='" + enumValue.KINDPKGS + "',TAREWEIGHT=" + enumValue.TAREWEIGHT + ",CTNSTATUS='" + enumValue.CTNSTATUS + "',MASTERNO='" + enumValue.MASTERNO + "',WEIGHTYPE='" + enumValue.WEIGHTYPE + "',WEIGHKGS=" + enumValue.WEIGHKGS + ",WEIGHATTN='"
+ enumValue.WEIGHATTN + "',WEIGHTEL='" + enumValue.WEIGHTEL + "',WEIGHSIGN='" + enumValue.WEIGHSIGN + "',WEIGHDATE='" + enumValue.WEIGHDATE + "',TRUCKER='" + enumValue.TRUCKER + "',TRUCKFEE=" + enumValue.TRUCKFEE + ",FREESTORAGEDAY=" + enumValue.FREESTORAGEDAY + ",STORAGEDAY=" + enumValue.STORAGEDAY
+ ",STORAGEPRICE=" + enumValue.STORAGEPRICE + ",STORAGEFEE=" + enumValue.STORAGEFEE + ",FREECTNDAY=" + enumValue.FREECTNDAY + ",CTNDAY=" + enumValue.CTNDAY + ",CTNPRICE=" + enumValue.CTNPRICE + ",CTNFEE=" + enumValue.CTNFEE + ",TRUCKNO='" + enumValue.TRUCKNO + "',VGMCONNCOM='" + enumValue.VGMCONNCOM + "'"
+ " where BSNO='" + bsno + "' AND CTN_ID='" + enumValue.CTN_ID + "'");
db.ExecuteNonQuery(cmdUpdate, tran);
}
}
//StrSerialNo = StrSerialNo + ")";
//var cmdDelete = db.GetSqlStringCommand("delete from op_ctn where BSNO='" + bsno + "' and CTN_ID not in " + StrSerialNo);
//db.ExecuteNonQuery(cmdDelete, tran);
}
//
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "保存出现错误,请重试或联系系统管理员";
return result;
}
}
//
getCNTRTOTAL(bsno, "op_apply");
//
result.Success = true;
result.Message = "保存成功" + result.Message;
return result;
}
public static void getCNTRTOTAL(string strBSNO, string bstype)
{
int iTEU = 0;
string strCNTRTOTAL = "";
string strCNTRNO = "";
string str = "";
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
DataSet dsDisp = T_ALL_DA.GetAllSQL("select * from code_ctn_disp");// where CORPID = '" + strCORPID + "'";
DataSet ds = T_ALL_DA.GetAllSQL("select * from op_ctn where BSNO='" + strBSNO + "'");
//
str = "update " + bstype + " set CNTR1=0,CNTR2=0,CNTR3=0,CNTR4=0,CNTR5=0,CNTR6=0,CNTR7=0,CNTR8=0,CNTR9=0,CNTR10=0,OTCNTR=0 where BSNO='" + strBSNO + "'";
bool bl3 = T_ALL_DA.GetExecuteSqlCommand(str);
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
foreach (DataTable myTable in ds.Tables)
{
foreach (DataRow myRow in myTable.Rows)//遍历表
{
strCNTRNO += myRow["CNTRNO"].ToString().Trim() + "/" + myRow["SEALNO"].ToString().Trim() + "/" + myRow["CTNALL"].ToString().Trim() + "\r\n";
iTEU += int.Parse(myRow["TEU"].ToString().Trim());
}
}
//
str = "select CTNALL,sum(CTNNUM) as hj from op_ctn where BSNO='" + strBSNO + "' group by CTNALL order by CTNALL";
ds = T_ALL_DA.GetAllSQL(str);
foreach (DataTable myTable in ds.Tables)
{
foreach (DataRow myRow in myTable.Rows)//遍历表
{
strCNTRTOTAL += myRow["CTNALL"].ToString().Trim() + "*" + myRow["hj"].ToString().Trim() + " / ";
//
if (dsDisp == null)
{
string sHJ = T_ALL_DA.GetStrSQL("hj", "select sum(CTNNUM) as hj from op_ctn where BSNO='" + strBSNO + "'");
str = "update " + bstype + " set OTCNTR=OTCNTR+" + myRow["hj"].ToString().Trim() + " where BSNO='" + strBSNO + "'";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(str);
}
else
{
int j = 0;
for (int i = 1; i < 11; i++)
{
if (dsDisp.Tables[0].Rows[0][i].ToString().Trim().Equals(myRow["CTNALL"].ToString().Trim()))
{
str = "update " + bstype + " set CNTR" + i + "=CNTR" + i + "+" + myRow["hj"].ToString().Trim() + " where BSNO='" + strBSNO + "'";
j = j + 1;
break;
}
}
if (j == 0)
{
str = "update " + bstype + " set OTCNTR=OTCNTR+" + myRow["hj"].ToString().Trim() + " where BSNO='" + strBSNO + "'";
}
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(str);
}
}
}
strCNTRTOTAL = strCNTRTOTAL.Trim().Substring(0, strCNTRTOTAL.Trim().Length - 1);
}
}
str = "update op_apply set TEU=" + iTEU + " where BSNO='" + strBSNO + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(str);
}
public static DBResult DeleteCtnDetail(MsOpCtn 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_ctn where CTN_ID='" + headData.CTN_ID + "'");
db.ExecuteNonQuery(cmdDelete, tran);
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "删除出现错误,请重试或联系系统管理员";
return result;
}
}
//
getCNTRTOTAL(headData.BSNO, "op_apply");
//
result.Success = true;
result.Message = "操作成功";
return result;
}
static public MsOpApplyFeeService GetFeeService(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("IsServiceFee1,IsServiceFee2,IsServiceFee3,IsServiceFee4,IsServiceFee5,IsServiceFee6,IsServiceFee7,IsServiceFee8");
strSql.Append(",IsServiceFee9,IsServiceFee10,IsServiceFee11,IsServiceFee12,IsServiceFee13,IsServiceFee14,IsServiceFee15,IsServiceFee16");
strSql.Append(",IsSERVICE1,IsSERVICE2,IsSERVICE3,IsSERVICE4,IsSERVICE5,IsSERVICE6,IsSERVICE7,IsSERVICE8");
strSql.Append(",IsSERVICE9,IsSERVICE10,IsSERVICE11,IsSERVICE12,IsSERVICE13,IsSERVICE14,IsSERVICE15,IsSERVICE16");
strSql.Append(" from OP_APPLY ");
if (strCondition.Trim() != String.Empty)
{
strSql.Append(" where " + strCondition);
}
var bodyList = new List<MsOpApplyFeeService>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsOpApplyFeeService data = new MsOpApplyFeeService();
#region Set DB data to Object
if (reader["IsSERVICEFEE1"] != DBNull.Value) data.IsSERVICEFEE1 = Convert.ToString(reader["IsServiceFee1"]);
if (reader["IsSERVICEFEE2"] != DBNull.Value) data.IsSERVICEFEE2 = Convert.ToString(reader["IsServiceFee2"]);
if (reader["IsSERVICEFEE3"] != DBNull.Value) data.IsSERVICEFEE3 = Convert.ToString(reader["IsServiceFee3"]);
if (reader["IsSERVICEFEE4"] != DBNull.Value) data.IsSERVICEFEE4 = Convert.ToString(reader["IsServiceFee4"]);
if (reader["IsSERVICEFEE5"] != DBNull.Value) data.IsSERVICEFEE5 = Convert.ToString(reader["IsServiceFee5"]);
if (reader["IsSERVICEFEE6"] != DBNull.Value) data.IsSERVICEFEE6 = Convert.ToString(reader["IsServiceFee6"]);
if (reader["IsSERVICEFEE7"] != DBNull.Value) data.IsSERVICEFEE7 = Convert.ToString(reader["IsServiceFee7"]);
if (reader["IsSERVICEFEE8"] != DBNull.Value) data.IsSERVICEFEE8 = Convert.ToString(reader["IsServiceFee8"]);
if (reader["IsSERVICEFEE9"] != DBNull.Value) data.IsSERVICEFEE9 = Convert.ToString(reader["IsServiceFee9"]);
if (reader["IsSERVICEFEE10"] != DBNull.Value) data.IsSERVICEFEE10 = Convert.ToString(reader["IsServiceFee10"]);
if (reader["IsSERVICEFEE11"] != DBNull.Value) data.IsSERVICEFEE11 = Convert.ToString(reader["IsServiceFee11"]);
if (reader["IsSERVICEFEE12"] != DBNull.Value) data.IsSERVICEFEE12 = Convert.ToString(reader["IsServiceFee12"]);
if (reader["IsSERVICEFEE13"] != DBNull.Value) data.IsSERVICEFEE13 = Convert.ToString(reader["IsServiceFee13"]);
if (reader["IsSERVICEFEE14"] != DBNull.Value) data.IsSERVICEFEE14 = Convert.ToString(reader["IsServiceFee14"]);
if (reader["IsSERVICEFEE15"] != DBNull.Value) data.IsSERVICEFEE15 = Convert.ToString(reader["IsServiceFee15"]);
if (reader["IsSERVICEFEE16"] != DBNull.Value) data.IsSERVICEFEE16 = Convert.ToString(reader["IsServiceFee16"]);
if (reader["IsSERVICE1"] != DBNull.Value) data.IsSERVICE1 = Convert.ToString(reader["IsSERVICE1"]);
if (reader["IsSERVICE2"] != DBNull.Value) data.IsSERVICE2 = Convert.ToString(reader["IsSERVICE2"]);
if (reader["IsSERVICE3"] != DBNull.Value) data.IsSERVICE3 = Convert.ToString(reader["IsSERVICE3"]);
if (reader["IsSERVICE4"] != DBNull.Value) data.IsSERVICE4 = Convert.ToString(reader["IsSERVICE4"]);
if (reader["IsSERVICE5"] != DBNull.Value) data.IsSERVICE5 = Convert.ToString(reader["IsSERVICE5"]);
if (reader["IsSERVICE6"] != DBNull.Value) data.IsSERVICE6 = Convert.ToString(reader["IsSERVICE6"]);
if (reader["IsSERVICE7"] != DBNull.Value) data.IsSERVICE7 = Convert.ToString(reader["IsSERVICE7"]);
if (reader["IsSERVICE8"] != DBNull.Value) data.IsSERVICE8 = Convert.ToString(reader["IsSERVICE8"]);
if (reader["IsSERVICE9"] != DBNull.Value) data.IsSERVICE9 = Convert.ToString(reader["IsSERVICE9"]);
if (reader["IsSERVICE10"] != DBNull.Value) data.IsSERVICE10 = Convert.ToString(reader["IsSERVICE10"]);
if (reader["IsSERVICE11"] != DBNull.Value) data.IsSERVICE11 = Convert.ToString(reader["IsSERVICE11"]);
if (reader["IsSERVICE12"] != DBNull.Value) data.IsSERVICE12 = Convert.ToString(reader["IsSERVICE12"]);
if (reader["IsSERVICE13"] != DBNull.Value) data.IsSERVICE13 = Convert.ToString(reader["IsSERVICE13"]);
if (reader["IsSERVICE14"] != DBNull.Value) data.IsSERVICE14 = Convert.ToString(reader["IsSERVICE14"]);
if (reader["IsSERVICE15"] != DBNull.Value) data.IsSERVICE15 = Convert.ToString(reader["IsSERVICE15"]);
if (reader["IsSERVICE16"] != DBNull.Value) data.IsSERVICE16 = Convert.ToString(reader["IsSERVICE16"]);
#endregion
bodyList.Add(data);
}
reader.Close();
}
if (bodyList.Count > 0)
return bodyList[0];
return new MsOpApplyFeeService();
}
public static List<ENTERP> GetENTERPLIST()
{
var strSql = new StringBuilder();
strSql.Append("SELECT distinct ENTERP,ENTERPID from op_apply WHERE ENTERP<>'' ORDER BY ENTERP");
Database db = DatabaseFactory.CreateDatabase();
var evList = new List<ENTERP>();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
ENTERP Data = new ENTERP();
Data.ENTERPID = Convert.ToString(reader["ENTERPID"]);
Data.CUSTOMER = Convert.ToString(reader["ENTERP"]);
evList.Add(Data);
}
reader.Close();
}
return evList;
}
public static DBResult getCUSTNO(MsOpApply headData, string USERID,string SHOWNAME, string COMPANYID,string dbname="") {
var isuse = false;
var result = new DBResult();
//20200121 此处为防止从编码规则当中的 单一窗口编码规则 中获得业务编号
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='报关业务' and RULEBLNO='委托编号'", COMPANYID, dbname);
if (billnoset.BILLTYPE != "")
{
}
else
{
result.SetErrorInfo("请检查命名规则 增加【报关业务 委托编号】!");
return result;
}
//if (isuse)
//{
// if (billnoset.BILLTYPE != "")
// {
result.Data = MsSysBillNoSetDAL.GetBillNo(billnoset, headData.CUSTOMDATE, headData.ACCDATE.ToString().Trim(), dbname, SHOWNAME,COMPANYID);
result.Success = true;
return result;
}
static public int GetRdCount(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append(" Count(BSNO) AS CT ");
strSql.Append(" from OP_APPLY ");
if (strCondition.Trim() != String.Empty)
{
strSql.Append(" where " + strCondition);
}
var ct=0;
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
ct = Convert.ToInt16(reader["CT"]);
}
reader.Close();
}
return ct;
}
#endregion
public static DBResult SaveDetail(MsOpApply headData, List<MsOpApplyDetail> bodyList,string userid)
{
var result = new DBResult();
var up = false;
var upstr = "";
var ServiceFee = GetFeeService(" BsNo='" + headData.BSNO + "'");
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdInsert =
db.GetSqlStringCommand(
@"insert into op_apply_detail (BSNO, SerialNo,GOODSCODE,GOODSNAME,PKGS,PRICE,TOTAL,CURRENCY,Remark,WMSNO,WMSIN_GID,GOODSMODEL,GOODSSTANDARD,GOODSNUM)
values (@BSNO, @SerialNo, @GOODSCODE, @GOODSNAME,@PKGS, @PRICE, @TOTAL, @CURRENCY,@Remark,@WMSNO,@WMSIN_GID,@GOODSMODEL,@GOODSSTANDARD,@GOODSNUM) ");
var cmdUpdate =
db.GetSqlStringCommand(
@"update op_apply_detail set GOODSCODE=@GOODSCODE,GOODSNAME=@GOODSNAME,PKGS=@PKGS,PRICE=@PRICE,TOTAL=@TOTAL,CURRENCY=@CURRENCY,Remark=@Remark
,WMSNO=@WMSNO,WMSIN_GID=@WMSIN_GID,GOODSMODEL=@GOODSMODEL,GOODSSTANDARD=@GOODSSTANDARD,GOODSNUM=@GOODSNUM where BSNO=@BSNO AND SerialNo=@SerialNo ");
var StrSerialNo = "(1000";
if (bodyList != null)
{
foreach (var enumValue in bodyList)
{
StrSerialNo = StrSerialNo + "," + Convert.ToString(enumValue.SerialNo);
if (enumValue.BsNo == "*")
{
cmdInsert.Parameters.Clear();
db.AddInParameter(cmdInsert, "@BSNO", DbType.String, headData.BSNO);
db.AddInParameter(cmdInsert, "@SerialNo", DbType.Int32, enumValue.SerialNo);
db.AddInParameter(cmdInsert, "@GOODSCODE", DbType.String, enumValue.GoodsCode);
db.AddInParameter(cmdInsert, "@GOODSNAME", DbType.String, enumValue.GoodsName);
db.AddInParameter(cmdInsert, "@PKGS", DbType.Decimal, enumValue.Pkgs);
db.AddInParameter(cmdInsert, "@PRICE", DbType.Decimal, enumValue.Price);
db.AddInParameter(cmdInsert, "@TOTAL", DbType.Decimal, enumValue.Total);
db.AddInParameter(cmdInsert, "@CURRENCY", DbType.String, enumValue.Currency);
db.AddInParameter(cmdInsert, "@Remark", DbType.String, enumValue.Remark);
db.AddInParameter(cmdInsert, "@WMSIN_GID", DbType.String, enumValue.WMSIN_GID);
db.AddInParameter(cmdInsert, "@WMSNO", DbType.String, enumValue.WMSNO);
db.AddInParameter(cmdInsert, "@GOODSMODEL", DbType.String, enumValue.GOODSMODEL);
db.AddInParameter(cmdInsert, "@GOODSSTANDARD", DbType.String, enumValue.GOODSSTANDARD);
db.AddInParameter(cmdInsert, "@GOODSNUM", DbType.Decimal, enumValue.GOODSNUM);
db.ExecuteNonQuery(cmdInsert, tran);
} else {
cmdUpdate.Parameters.Clear();
db.AddInParameter(cmdUpdate, "@BSNO", DbType.String, headData.BSNO);
db.AddInParameter(cmdUpdate, "@SerialNo", DbType.Int32, enumValue.SerialNo);
db.AddInParameter(cmdUpdate, "@GOODSCODE", DbType.String, enumValue.GoodsCode);
db.AddInParameter(cmdUpdate, "@GOODSNAME", DbType.String, enumValue.GoodsName);
db.AddInParameter(cmdUpdate, "@PKGS", DbType.Decimal, enumValue.Pkgs);
db.AddInParameter(cmdUpdate, "@PRICE", DbType.Decimal, enumValue.Price);
db.AddInParameter(cmdUpdate, "@TOTAL", DbType.Decimal, enumValue.Total);
db.AddInParameter(cmdUpdate, "@CURRENCY", DbType.String, enumValue.Currency);
db.AddInParameter(cmdUpdate, "@Remark", DbType.String, enumValue.Remark);
db.AddInParameter(cmdUpdate, "@WMSNO", DbType.String, enumValue.WMSNO);
db.AddInParameter(cmdUpdate, "@WMSIN_GID", DbType.String, enumValue.WMSIN_GID);
db.AddInParameter(cmdUpdate, "@GOODSMODEL", DbType.String, enumValue.GOODSMODEL);
db.AddInParameter(cmdUpdate, "@GOODSSTANDARD", DbType.String, enumValue.GOODSSTANDARD);
db.AddInParameter(cmdUpdate, "@GOODSNUM", DbType.Decimal, enumValue.GOODSNUM);
db.ExecuteNonQuery(cmdUpdate, tran);
}
}
}
StrSerialNo = StrSerialNo + ")";
var cmdDelete = db.GetSqlStringCommand("delete from op_apply_detail where BSNO='" + headData.BSNO + "' and SerialNo not in " + StrSerialNo);
db.ExecuteNonQuery(cmdDelete, tran);
if (headData.IsSERVICE1 != "1") {
var cmdDeleteService1 = db.GetSqlStringCommand("delete from op_apply_service where OPField='SERVICE1' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteService1, tran);
var cmdDeleteServicedt1 = db.GetSqlStringCommand("delete from op_apply_service_detail where OPField='SERVICE1' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteServicedt1, tran);
}
if (headData.IsSERVICE2 != "1")
{
var cmdDeleteService2 = db.GetSqlStringCommand("delete from op_apply_service where OPField='SERVICE2' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteService2, tran);
var cmdDeleteServicedt2 = db.GetSqlStringCommand("delete from op_apply_service_detail where OPField='SERVICE2' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteServicedt2, tran);
}
if (headData.IsSERVICE3 != "1")
{
var cmdDeleteService3 = db.GetSqlStringCommand("delete from op_apply_service where OPField='SERVICE3' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteService3, tran);
var cmdDeleteServicedt3 = db.GetSqlStringCommand("delete from op_apply_service_detail where OPField='SERVICE3' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteServicedt3, tran);
}
if (headData.IsSERVICE4 != "1")
{
var cmdDeleteService4 = db.GetSqlStringCommand("delete from op_apply_service where OPField='SERVICE4' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteService4, tran);
var cmdDeleteServicedt4 = db.GetSqlStringCommand("delete from op_apply_service_detail where OPField='SERVICE4' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteServicedt4, tran);
}
if (headData.IsSERVICE5 != "1")
{
var cmdDeleteService5 = db.GetSqlStringCommand("delete from op_apply_service where OPField='SERVICE5' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteService5, tran);
var cmdDeleteServicedt5 = db.GetSqlStringCommand("delete from op_apply_service_detail where OPField='SERVICE5' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteServicedt5, tran);
}
if (headData.IsSERVICE6 != "1")
{
var cmdDeleteService6 = db.GetSqlStringCommand("delete from op_apply_service where OPField='SERVICE6' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteService6, tran);
var cmdDeleteServicedt6 = db.GetSqlStringCommand("delete from op_apply_service_detail where OPField='SERVICE6' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteServicedt6, tran);
}
if (headData.IsSERVICE7!= "1")
{
var cmdDeleteService7 = db.GetSqlStringCommand("delete from op_apply_service where OPField='SERVICE7' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteService7, tran);
var cmdDeleteServicedt7 = db.GetSqlStringCommand("delete from op_apply_service_detail where OPField='SERVICE7' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteServicedt7, tran);
}
if (headData.IsSERVICE8 != "1")
{
var cmdDeleteService8 = db.GetSqlStringCommand("delete from op_apply_service where OPField='SERVICE8' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteService8, tran);
var cmdDeleteServicedt8 = db.GetSqlStringCommand("delete from op_apply_service_detail where OPField='SERVICE8' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteServicedt8, tran);
}
if (headData.IsSERVICE9 != "1")
{
var cmdDeleteService1 = db.GetSqlStringCommand("delete from op_apply_service where OPField='SERVICE9' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteService1, tran);
var cmdDeleteServicedt1 = db.GetSqlStringCommand("delete from op_apply_service_detail where OPField='SERVICE9' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteServicedt1, tran);
}
if (headData.IsSERVICE10 != "1")
{
var cmdDeleteService2 = db.GetSqlStringCommand("delete from op_apply_service where OPField='SERVICE10' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteService2, tran);
var cmdDeleteServicedt2 = db.GetSqlStringCommand("delete from op_apply_service_detail where OPField='SERVICE10' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteServicedt2, tran);
}
if (headData.IsSERVICE11 != "1")
{
var cmdDeleteService3 = db.GetSqlStringCommand("delete from op_apply_service where OPField='SERVICE11' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteService3, tran);
var cmdDeleteServicedt3 = db.GetSqlStringCommand("delete from op_apply_service_detail where OPField='SERVICE11' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteServicedt3, tran);
}
if (headData.IsSERVICE12 != "1")
{
var cmdDeleteService4 = db.GetSqlStringCommand("delete from op_apply_service where OPField='SERVICE12' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteService4, tran);
var cmdDeleteServicedt4 = db.GetSqlStringCommand("delete from op_apply_service_detail where OPField='SERVICE12' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteServicedt4, tran);
}
if (headData.IsSERVICE13!= "1")
{
var cmdDeleteService5 = db.GetSqlStringCommand("delete from op_apply_service where OPField='SERVICE13' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteService5, tran);
var cmdDeleteServicedt5 = db.GetSqlStringCommand("delete from op_apply_service_detail where OPField='SERVICE13' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteServicedt5, tran);
}
if (headData.IsSERVICE14 != "1")
{
var cmdDeleteService6 = db.GetSqlStringCommand("delete from op_apply_service where OPField='SERVICE14' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteService6, tran);
var cmdDeleteServicedt6 = db.GetSqlStringCommand("delete from op_apply_service_detail where OPField='SERVICE14' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteServicedt6, tran);
}
if (headData.IsSERVICE15 != "1")
{
var cmdDeleteService7 = db.GetSqlStringCommand("delete from op_apply_service where OPField='SERVICE15' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteService7, tran);
var cmdDeleteServicedt7 = db.GetSqlStringCommand("delete from op_apply_service_detail where OPField='SERVICE15' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteServicedt7, tran);
}
if (headData.IsSERVICE16!= "1")
{
var cmdDeleteService8 = db.GetSqlStringCommand("delete from op_apply_service where OPField='SERVICE16' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteService8, tran);
var cmdDeleteServicedt8 = db.GetSqlStringCommand("delete from op_apply_service_detail where OPField='SERVICE16' and BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDeleteServicedt8, tran);
}
//if (headData.FEESTATUS != true)
//{
// if (headData.IsSERVICE1 != ServiceFee.IsSERVICEFEE1)
// {
// up = true;
// if (headData.IsSERVICE1 == "1")
// {
// upstr = upstr + ",IsServiceFee1='1'";
// var cmd = db.GetSqlStringCommand(" INSERT INTO ch_fee(GID, BSNO, FEETYPE, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY, "
// + " EXCHANGERATE,ENTEROPERATOR, ENTERDATE,ISOPEN, ISADVANCEDPAY, SORT, FEESTATUS, FEEFRT, "
// + " TAXRATE,NOTAXAMOUNT) "
// + " Select NEWID(),@BSNO,FEETYPE,FEENAME,'','',CUSTOMERNAME,UNIT,UNITPRICE,1,UNITPRICE,CURRENCY, "
// + " EXCHANGERATE,@ENTEROPERATOR,@ENTERDATE,0,0,0,1,'PP',0,UNITPRICE from code_service_fee_templatedetail where OPField='SERVICE1' and TEMPLATEID "
// + " IN (SELECT GID from code_servcie_fee_template where optype='5' and CUSTOMERNAME=@CUSTOMERNAME)");
// db.AddInParameter(cmd, "@BSNO", DbType.String, headData.BSNO);
// db.AddInParameter(cmd, "@ENTEROPERATOR", DbType.String, userid);
// db.AddInParameter(cmd, "@ENTERDATE", DbType.Date, DateTime.Now.Date);
// db.AddInParameter(cmd, "@CUSTOMERNAME", DbType.String, headData.CUSTOMERNAME);
// db.ExecuteNonQuery(cmd, tran);
// }
// else {
// }
// };
// if (headData.IsSERVICE2 != ServiceFee.IsSERVICEFEE2)
// {
// up = true;
// if (headData.IsSERVICE2 == "1")
// {
// upstr = upstr + ",IsServiceFee2='1'";
// var cmd = db.GetSqlStringCommand(" INSERT INTO ch_fee(GID, BSNO, FEETYPE, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY, "
// + " EXCHANGERATE,ENTEROPERATOR, ENTERDATE,ISOPEN, ISADVANCEDPAY, SORT, FEESTATUS, FEEFRT, "
// + " TAXRATE,NOTAXAMOUNT) "
// + " Select NEWID(),@BSNO,FEETYPE,FEENAME,'','',CUSTOMERNAME,UNIT,UNITPRICE,1,UNITPRICE,CURRENCY, "
// + " EXCHANGERATE,@ENTEROPERATOR,@ENTERDATE,0,0,0,1,'PP',0,UNITPRICE from code_service_fee_templatedetail where OPField='SERVICE2' and TEMPLATEID "
// + " IN (SELECT GID from code_servcie_fee_template where optype='5' and CUSTOMERNAME=@CUSTOMERNAME)");
// db.AddInParameter(cmd, "@BSNO", DbType.String, headData.BSNO);
// db.AddInParameter(cmd, "@ENTEROPERATOR", DbType.String, userid);
// db.AddInParameter(cmd, "@ENTERDATE", DbType.Date, DateTime.Now.Date);
// db.AddInParameter(cmd, "@CUSTOMERNAME", DbType.String, headData.CUSTOMERNAME);
// db.ExecuteNonQuery(cmd, tran);
// }
// else
// {
// }
// };
// if (headData.IsSERVICE3 != ServiceFee.IsSERVICEFEE3)
// {
// up = true;
// if (headData.IsSERVICE3 == "1")
// {
// upstr = upstr + ",IsServiceFee3='1'";
// var cmd = db.GetSqlStringCommand(" INSERT INTO ch_fee(GID, BSNO, FEETYPE, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY, "
// + " EXCHANGERATE,ENTEROPERATOR, ENTERDATE,ISOPEN, ISADVANCEDPAY, SORT, FEESTATUS, FEEFRT, "
// + " TAXRATE,NOTAXAMOUNT) "
// + " Select NEWID(),@BSNO,FEETYPE,FEENAME,'','',CUSTOMERNAME,UNIT,UNITPRICE,1,UNITPRICE,CURRENCY, "
// + " EXCHANGERATE,@ENTEROPERATOR,@ENTERDATE,0,0,0,1,'PP',0,UNITPRICE from code_service_fee_templatedetail where OPField='SERVICE3' and TEMPLATEID "
// + " IN (SELECT GID from code_servcie_fee_template where optype='5' and CUSTOMERNAME=@CUSTOMERNAME)");
// db.AddInParameter(cmd, "@BSNO", DbType.String, headData.BSNO);
// db.AddInParameter(cmd, "@ENTEROPERATOR", DbType.String, userid);
// db.AddInParameter(cmd, "@ENTERDATE", DbType.Date, DateTime.Now.Date);
// db.AddInParameter(cmd, "@CUSTOMERNAME", DbType.String, headData.CUSTOMERNAME);
// db.ExecuteNonQuery(cmd, tran);
// }
// else
// {
// }
// };
// if (headData.IsSERVICE4 != ServiceFee.IsSERVICEFEE4)
// {
// up = true;
// if (headData.IsSERVICE4 == "1")
// {
// upstr = upstr + ",IsServiceFee4='1'";
// var cmd = db.GetSqlStringCommand(" INSERT INTO ch_fee(GID, BSNO, FEETYPE, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY, "
// + " EXCHANGERATE,ENTEROPERATOR, ENTERDATE,ISOPEN, ISADVANCEDPAY, SORT, FEESTATUS, FEEFRT, "
// + " TAXRATE,NOTAXAMOUNT) "
// + " Select NEWID(),@BSNO,FEETYPE,FEENAME,'','',CUSTOMERNAME,UNIT,UNITPRICE,1,UNITPRICE,CURRENCY, "
// + " EXCHANGERATE,@ENTEROPERATOR,@ENTERDATE,0,0,0,1,'PP',0,UNITPRICE from code_service_fee_templatedetail where OPField='SERVICE4' and TEMPLATEID "
// + " IN (SELECT GID from code_servcie_fee_template where optype='5' and CUSTOMERNAME=@CUSTOMERNAME)");
// db.AddInParameter(cmd, "@BSNO", DbType.String, headData.BSNO);
// db.AddInParameter(cmd, "@ENTEROPERATOR", DbType.String, userid);
// db.AddInParameter(cmd, "@ENTERDATE", DbType.Date, DateTime.Now.Date);
// db.AddInParameter(cmd, "@CUSTOMERNAME", DbType.String, headData.CUSTOMERNAME);
// db.ExecuteNonQuery(cmd, tran);
// }
// else
// {
// }
// };
// if (headData.IsSERVICE5 != ServiceFee.IsSERVICEFEE5)
// {
// up = true;
// if (headData.IsSERVICE5 == "1")
// {
// upstr = upstr + ",IsServiceFee5='1'";
// var cmd = db.GetSqlStringCommand(" INSERT INTO ch_fee(GID, BSNO, FEETYPE, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY, "
// + " EXCHANGERATE,ENTEROPERATOR, ENTERDATE,ISOPEN, ISADVANCEDPAY, SORT, FEESTATUS, FEEFRT, "
// + " TAXRATE,NOTAXAMOUNT) "
// + " Select NEWID(),@BSNO,FEETYPE,FEENAME,'','',CUSTOMERNAME,UNIT,UNITPRICE,1,UNITPRICE,CURRENCY, "
// + " EXCHANGERATE,@ENTEROPERATOR,@ENTERDATE,0,0,0,1,'PP',0,UNITPRICE from code_service_fee_templatedetail where OPField='SERVICE5' and TEMPLATEID "
// + " IN (SELECT GID from code_servcie_fee_template where optype='5' and CUSTOMERNAME=@CUSTOMERNAME)");
// db.AddInParameter(cmd, "@BSNO", DbType.String, headData.BSNO);
// db.AddInParameter(cmd, "@ENTEROPERATOR", DbType.String, userid);
// db.AddInParameter(cmd, "@ENTERDATE", DbType.Date, DateTime.Now.Date);
// db.AddInParameter(cmd, "@CUSTOMERNAME", DbType.String, headData.CUSTOMERNAME);
// db.ExecuteNonQuery(cmd, tran);
// }
// else
// {
// }
// };
// if (headData.IsSERVICE6 != ServiceFee.IsSERVICEFEE6)
// {
// up = true;
// if (headData.IsSERVICE6 == "1")
// {
// upstr = upstr + ",IsServiceFee6='1'";
// var cmd = db.GetSqlStringCommand(" INSERT INTO ch_fee(GID, BSNO, FEETYPE, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY, "
// + " EXCHANGERATE,ENTEROPERATOR, ENTERDATE,ISOPEN, ISADVANCEDPAY, SORT, FEESTATUS, FEEFRT, "
// + " TAXRATE,NOTAXAMOUNT) "
// + " Select NEWID(),@BSNO,FEETYPE,FEENAME,'','',CUSTOMERNAME,UNIT,UNITPRICE,1,UNITPRICE,CURRENCY, "
// + " EXCHANGERATE,@ENTEROPERATOR,@ENTERDATE,0,0,0,1,'PP',0,UNITPRICE from code_service_fee_templatedetail where OPField='SERVICE6' and TEMPLATEID "
// + " IN (SELECT GID from code_servcie_fee_template where optype='5' and CUSTOMERNAME=@CUSTOMERNAME)");
// db.AddInParameter(cmd, "@BSNO", DbType.String, headData.BSNO);
// db.AddInParameter(cmd, "@ENTEROPERATOR", DbType.String, userid);
// db.AddInParameter(cmd, "@ENTERDATE", DbType.Date, DateTime.Now.Date);
// db.AddInParameter(cmd, "@CUSTOMERNAME", DbType.String, headData.CUSTOMERNAME);
// db.ExecuteNonQuery(cmd, tran);
// }
// else
// {
// }
// };
// if (headData.IsSERVICE7 != ServiceFee.IsSERVICEFEE7)
// {
// up = true;
// if (headData.IsSERVICE7 == "1")
// {
// upstr = upstr + ",IsServiceFee7='1'";
// var cmd = db.GetSqlStringCommand(" INSERT INTO ch_fee(GID, BSNO, FEETYPE, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY, "
// + " EXCHANGERATE,ENTEROPERATOR, ENTERDATE,ISOPEN, ISADVANCEDPAY, SORT, FEESTATUS, FEEFRT, "
// + " TAXRATE,NOTAXAMOUNT) "
// + " Select NEWID(),@BSNO,FEETYPE,FEENAME,'','',CUSTOMERNAME,UNIT,UNITPRICE,1,UNITPRICE,CURRENCY, "
// + " EXCHANGERATE,@ENTEROPERATOR,@ENTERDATE,0,0,0,1,'PP',0,UNITPRICE from code_service_fee_templatedetail where OPField='SERVICE7' and TEMPLATEID "
// + " IN (SELECT GID from code_servcie_fee_template where optype='5' and CUSTOMERNAME=@CUSTOMERNAME)");
// db.AddInParameter(cmd, "@BSNO", DbType.String, headData.BSNO);
// db.AddInParameter(cmd, "@ENTEROPERATOR", DbType.String, userid);
// db.AddInParameter(cmd, "@ENTERDATE", DbType.Date, DateTime.Now.Date);
// db.AddInParameter(cmd, "@CUSTOMERNAME", DbType.String, headData.CUSTOMERNAME);
// db.ExecuteNonQuery(cmd, tran);
// }
// else
// {
// }
// };
// if (headData.IsSERVICE8 != ServiceFee.IsSERVICEFEE8)
// {
// up = true;
// if (headData.IsSERVICE8 == "1")
// {
// upstr = upstr + ",IsServiceFee8='1'";
// var cmd = db.GetSqlStringCommand(" INSERT INTO ch_fee(GID, BSNO, FEETYPE, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY, "
// + " EXCHANGERATE,ENTEROPERATOR, ENTERDATE,ISOPEN, ISADVANCEDPAY, SORT, FEESTATUS, FEEFRT, "
// + " TAXRATE,NOTAXAMOUNT) "
// + " Select NEWID(),@BSNO,FEETYPE,FEENAME,'','',CUSTOMERNAME,UNIT,UNITPRICE,1,UNITPRICE,CURRENCY, "
// + " EXCHANGERATE,@ENTEROPERATOR,@ENTERDATE,0,0,0,1,'PP',0,UNITPRICE from code_service_fee_templatedetail where OPField='SERVICE8' and TEMPLATEID "
// + " IN (SELECT GID from code_servcie_fee_template where optype='5' and CUSTOMERNAME=@CUSTOMERNAME)");
// db.AddInParameter(cmd, "@BSNO", DbType.String, headData.BSNO);
// db.AddInParameter(cmd, "@ENTEROPERATOR", DbType.String, userid);
// db.AddInParameter(cmd, "@ENTERDATE", DbType.Date, DateTime.Now.Date);
// db.AddInParameter(cmd, "@CUSTOMERNAME", DbType.String, headData.CUSTOMERNAME);
// db.ExecuteNonQuery(cmd, tran);
// }
// else
// {
// }
// };
//}
//else {
// if (((headData.IsSERVICE1 != ServiceFee.IsSERVICEFEE1) && (headData.IsSERVICE1 == "1")) || ((headData.IsSERVICE2 != ServiceFee.IsSERVICEFEE2) && (headData.IsSERVICE2== "1"))
// || ((headData.IsSERVICE3 != ServiceFee.IsSERVICEFEE3) && (headData.IsSERVICE3 == "1"))
// || ((headData.IsSERVICE4 != ServiceFee.IsSERVICEFEE4) && (headData.IsSERVICE4 == "1")) || ((headData.IsSERVICE5 != ServiceFee.IsSERVICEFEE5) && (headData.IsSERVICE5 == "1"))
// || ((headData.IsSERVICE6 != ServiceFee.IsSERVICEFEE6) && (headData.IsSERVICE6 == "1")) || ((headData.IsSERVICE7 != ServiceFee.IsSERVICEFEE7) && (headData.IsSERVICE7 == "1"))
// || ((headData.IsSERVICE8 != ServiceFee.IsSERVICEFEE8) && (headData.IsSERVICE8 == "1")))
// {
// result.Message = " 已费用封帐,无法自动生成服务项目相关费用";
// };
//}
//if (up) {
// var cmdup = db.GetSqlStringCommand("update op_apply set isService1=isService1"+upstr+" where BSNO='" + headData.BSNO + "'");
// db.ExecuteNonQuery(cmdup, 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 DeleteDetail(MsOpApply 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_apply_detail where BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDelete, tran);
cmdDelete = db.GetSqlStringCommand("delete from op_apply_service where BSNO='" + headData.BSNO + "'");
db.ExecuteNonQuery(cmdDelete, tran);
cmdDelete = db.GetSqlStringCommand("delete from op_apply_service_detail where BSNO='" + headData.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;
}
#region 服务费用生成
public static DBResult PiliangServiceFee(List<MsOpApply> billList, List<MsCodeServiceFeeTemplateDetail> feeList, string userid)
{
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdInsert =
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,
TAXRATE,NOTAXAMOUNT,ACCTAXRATE,LINENUM,TAXUNITPRICE,MODIFIEDUSER,MODIFIEDTIME,WMSOUTBSNO) VALUES
(@gid,@bsno,@fee_type,@fee_name,@fee_description,@customer_type,@customer_name,@unit,@unit_price,@quantity,@amount,@currency,
@exchange_rate,@reason,@remark,@comm_rate,@enter_operator,@enter_date,@is_open,@is_advance_pay,@sort,@fee_status,@fee_frt,
@taxrate,@notaxamount,@acctaxrate,@LINENUM,@taxunit_price,@MODIFIEDUSER,@MODIFIEDTIME,@WMSOUTBSNO) ");
var cmdInsertFeeDo =
db.GetSqlStringCommand(
@"insert into ch_fee_do_service (GID, TEMPLATEID,TEMPLATEFEEID,BSNO,FEEID)
values (@GID,@TEMPLATEID,@TEMPLATEFEEID,@BSNO,@FEEID) ");
var TEMPLATEID = "";
if (feeList != null)
{
foreach (var enumFee in feeList)
{ TEMPLATEID = enumFee.TemplateID; }
}
if (billList != null)
{
foreach (var enumValue in billList)
{
var applyfee = GetFeeService("BSNO='" + enumValue.BSNO + "'");
var feedostr = "";
if (applyfee.IsSERVICE1 == "1") if (feedostr == "") feedostr = " OPField='SERVICE1' "; else feedostr = feedostr + " or OPField='SERVICE1' ";
if (applyfee.IsSERVICE2 == "1") if (feedostr == "") feedostr = " OPField='SERVICE2' "; else feedostr = feedostr + " or OPField='SERVICE2' ";
if (applyfee.IsSERVICE3 == "1") if (feedostr == "") feedostr = " OPField='SERVICE3' "; else feedostr = feedostr + " or OPField='SERVICE3' ";
if (applyfee.IsSERVICE4 == "1") if (feedostr == "") feedostr = " OPField='SERVICE4' "; else feedostr = feedostr + " or OPField='SERVICE4' ";
if (applyfee.IsSERVICE5 == "1") if (feedostr == "") feedostr = " OPField='SERVICE5' "; else feedostr = feedostr + " or OPField='SERVICE5' ";
if (applyfee.IsSERVICE6 == "1") if (feedostr == "") feedostr = " OPField='SERVICE6' "; else feedostr = feedostr + " or OPField='SERVICE6' ";
if (applyfee.IsSERVICE7 == "1") if (feedostr == "") feedostr = " OPField='SERVICE7' "; else feedostr = feedostr + " or OPField='SERVICE7' ";
if (applyfee.IsSERVICE8 == "1") if (feedostr == "") feedostr = " OPField='SERVICE8' "; else feedostr = feedostr + " or OPField='SERVICE8' ";
if (applyfee.IsSERVICE9 == "1") if (feedostr == "") feedostr = " OPField='SERVICE9' "; else feedostr = feedostr + " or OPField='SERVICE9' ";
if (applyfee.IsSERVICE10 == "1") if (feedostr == "") feedostr = " OPField='SERVICE10' "; else feedostr = feedostr + " or OPField='SERVICE10' ";
if (applyfee.IsSERVICE11 == "1") if (feedostr == "") feedostr = " OPField='SERVICE11' "; else feedostr = feedostr + " or OPField='SERVICE11' ";
if (applyfee.IsSERVICE12 == "1") if (feedostr == "") feedostr = " OPField='SERVICE12' "; else feedostr = feedostr + " or OPField='SERVICE12' ";
if (applyfee.IsSERVICE13 == "1") if (feedostr == "") feedostr = " OPField='SERVICE13' "; else feedostr = feedostr + " or OPField='SERVICE13' ";
if (applyfee.IsSERVICE14 == "1") if (feedostr == "") feedostr = " OPField='SERVICE14' "; else feedostr = feedostr + " or OPField='SERVICE14' ";
if (applyfee.IsSERVICE15 == "1") if (feedostr == "") feedostr = " OPField='SERVICE15' "; else feedostr = feedostr + " or OPField='SERVICE15' ";
if (applyfee.IsSERVICE16 == "1") if (feedostr == "") feedostr = " OPField='SERVICE16' "; else feedostr = feedostr + " or OPField='SERVICE16' ";
if (feedostr != "") feedostr = "(" + feedostr + ")";
if (feedostr != "")
{
feedostr = feedostr + " and TEMPLATEID='" + TEMPLATEID + "' and GID not in (select TEMPLATEFEEID from ch_fee_do_service where BSNO='" + enumValue.BSNO + "')";
var feelist2 = MsCodeServiceFeeTemplateDAL.MsCodeServiceFeeTemplateDAL.GetBodyListtran(feedostr, db, tran);
if (feelist2 != null)
{
foreach (var enumFee in feelist2)
{
var taxamount = Math.Round(enumFee.UnitPrice * (1 + (enumFee.TAXRATE / 100)), 2);
var FEEID = Guid.NewGuid().ToString();
cmdInsert.Parameters.Clear();
db.AddInParameter(cmdInsert, "@gid", DbType.String, FEEID);
db.AddInParameter(cmdInsert, "@bsno", DbType.String, enumValue.BSNO);
db.AddInParameter(cmdInsert, "@fee_type", DbType.String, enumFee.FeeType);
db.AddInParameter(cmdInsert, "@fee_name", DbType.String, enumFee.FeeName);
db.AddInParameter(cmdInsert, "@fee_description", DbType.String, "");
db.AddInParameter(cmdInsert, "@customer_type", DbType.String, enumFee.CustomerType);
if (enumFee.CustomerName != "")
db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumFee.CustomerName);
else if (enumFee.CustomerType == "委托单位")
{
db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMERNAME);
}
else db.AddInParameter(cmdInsert, "@customer_name", DbType.String, "");
db.AddInParameter(cmdInsert, "@unit", DbType.String, enumFee.Unit);
db.AddInParameter(cmdInsert, "@unit_price", DbType.Decimal, enumFee.UnitPrice);
db.AddInParameter(cmdInsert, "@quantity", DbType.Decimal, 1);
db.AddInParameter(cmdInsert, "@amount", DbType.Decimal, taxamount);
db.AddInParameter(cmdInsert, "@currency", DbType.String, enumFee.Currency);
db.AddInParameter(cmdInsert, "@exchange_rate", DbType.Decimal, enumFee.ExchangeRate);
db.AddInParameter(cmdInsert, "@reason", DbType.String, "");
db.AddInParameter(cmdInsert, "@remark", DbType.String, enumFee.Remark);
db.AddInParameter(cmdInsert, "@comm_rate", DbType.Decimal, 0);
db.AddInParameter(cmdInsert, "@enter_operator", DbType.String, userid);
db.AddInParameter(cmdInsert, "@enter_date", DbType.DateTime, DateTime.Now);
db.AddInParameter(cmdInsert, "@is_open", DbType.String, "0");
db.AddInParameter(cmdInsert, "@is_advance_pay", DbType.String, "0");
db.AddInParameter(cmdInsert, "@sort", DbType.Int16, 2);
db.AddInParameter(cmdInsert, "@fee_status", DbType.Int16, 1);
db.AddInParameter(cmdInsert, "@fee_frt", DbType.String, "");
db.AddInParameter(cmdInsert, "@taxrate", DbType.Decimal, enumFee.TAXRATE);
db.AddInParameter(cmdInsert, "@notaxamount", DbType.Decimal, enumFee.UnitPrice);
db.AddInParameter(cmdInsert, "@acctaxrate", DbType.Decimal, 0);
db.AddInParameter(cmdInsert, "@LINENUM", DbType.Int16, 2);
db.AddInParameter(cmdInsert, "@taxunit_price", DbType.Decimal, taxamount);
db.AddInParameter(cmdInsert, "@MODIFIEDUSER", DbType.String, "");
db.AddInParameter(cmdInsert, "@MODIFIEDTIME", DbType.DateTime, null);
db.AddInParameter(cmdInsert, "@WMSOUTBSNO", DbType.String, "");
db.ExecuteNonQuery(cmdInsert, tran);
cmdInsertFeeDo.Parameters.Clear();
db.AddInParameter(cmdInsertFeeDo, "@GID", DbType.String, Guid.NewGuid().ToString());
db.AddInParameter(cmdInsertFeeDo, "@TEMPLATEID", DbType.String, TEMPLATEID);
db.AddInParameter(cmdInsertFeeDo, "@TEMPLATEFEEID", DbType.String, enumFee.GID);
db.AddInParameter(cmdInsertFeeDo, "@BSNO", DbType.String, enumValue.BSNO);
db.AddInParameter(cmdInsertFeeDo, "@FEEID", DbType.String, FEEID);
db.ExecuteNonQuery(cmdInsertFeeDo, tran);
}
}
}
}
}
tran.Commit();
result.Success = true;
result.Message = "生成成功" + result.Message;
return result;
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "生成出现错误,请重试或联系系统管理员";
return result;
}
}
result.Success = true;
result.Message = "生成成功" + result.Message;
return result;
}
#endregion
// #region 服务费用生成
// public static DBResult PiliangServiceFee(List<MsOpApply> billList, List<MsCodeServiceFeeTemplateDetail> feeList, string userid)
// {
// var result = new DBResult();
// Database db = DatabaseFactory.CreateDatabase();
// using (var conn = db.CreateConnection())
// {
// conn.Open();
// var tran = conn.BeginTransaction();
// try
// {
// var cmdInsert =
// 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,
// TAXRATE,NOTAXAMOUNT,ACCTAXRATE,LINENUM,TAXUNITPRICE,MODIFIEDUSER,MODIFIEDTIME,WMSOUTBSNO) VALUES
// (@gid,@bsno,@fee_type,@fee_name,@fee_description,@customer_type,@customer_name,@unit,@unit_price,@quantity,@amount,@currency,
// @exchange_rate,@reason,@remark,@comm_rate,@enter_operator,@enter_date,@is_open,@is_advance_pay,@sort,@fee_status,@fee_frt,
// @taxrate,@notaxamount,@acctaxrate,@LINENUM,@taxunit_price,@MODIFIEDUSER,@MODIFIEDTIME,@WMSOUTBSNO) ");
// if (billList != null)
// {
// foreach (var enumValue in billList)
// {
// var applyfee = GetFeeService("BSNO='"+enumValue.BSNO+"'");
// if (feeList != null)
// {
// foreach (var enumFee in feeList)
// {
// var taxamount = Math.Round(enumFee.UnitPrice * (1 + (enumFee.TAXRATE / 100)), 2);
// if (enumFee.OPField=="SERVICE1"&&applyfee.IsSERVICE1=="1"&&applyfee.IsSERVICEFEE1!="1"){
// cmdInsert.Parameters.Clear();
// db.AddInParameter(cmdInsert, "@gid", DbType.String, Guid.NewGuid().ToString());
// db.AddInParameter(cmdInsert, "@bsno", DbType.String, enumValue.BSNO);
// db.AddInParameter(cmdInsert, "@fee_type", DbType.String, enumFee.FeeType);
// db.AddInParameter(cmdInsert, "@fee_name", DbType.String, enumFee.FeeName);
// db.AddInParameter(cmdInsert, "@fee_description", DbType.String, "");
// db.AddInParameter(cmdInsert, "@customer_type", DbType.String, enumFee.CustomerType);
// if (enumFee.CustomerName != "")
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumFee.CustomerName);
// else if (enumFee.CustomerType=="委托单位")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMERNAME);
// }
// else if (enumFee.CustomerType == "报关行")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMSER);
// }
// else db.AddInParameter(cmdInsert, "@customer_name", DbType.String, "");
// db.AddInParameter(cmdInsert, "@unit", DbType.String, enumFee.Unit);
// db.AddInParameter(cmdInsert, "@unit_price", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@quantity", DbType.Decimal, 1);
// db.AddInParameter(cmdInsert, "@amount", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@currency", DbType.String, enumFee.Currency);
// db.AddInParameter(cmdInsert, "@exchange_rate", DbType.Decimal, enumFee.ExchangeRate);
// db.AddInParameter(cmdInsert, "@reason", DbType.String,"");
// db.AddInParameter(cmdInsert, "@remark", DbType.String, "");
// db.AddInParameter(cmdInsert, "@comm_rate", DbType.Decimal,0);
// db.AddInParameter(cmdInsert, "@enter_operator", DbType.String, userid);
// db.AddInParameter(cmdInsert, "@enter_date", DbType.DateTime, DateTime.Now);
// db.AddInParameter(cmdInsert, "@is_open", DbType.String,"0");
// db.AddInParameter(cmdInsert, "@is_advance_pay", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@sort", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@fee_status", DbType.Int16, 1);
// db.AddInParameter(cmdInsert, "@fee_frt", DbType.String, "");
// db.AddInParameter(cmdInsert, "@taxrate", DbType.Decimal, enumFee.TAXRATE);
// db.AddInParameter(cmdInsert, "@notaxamount", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@acctaxrate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@LINENUM", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@taxunit_price", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@MODIFIEDUSER", DbType.String, "");
// db.AddInParameter(cmdInsert, "@MODIFIEDTIME", DbType.DateTime, null);
// db.AddInParameter(cmdInsert, "@WMSOUTBSNO", DbType.String, "");
// db.ExecuteNonQuery(cmdInsert, tran);
// var cmdUpdate =
// db.GetSqlStringCommand(@"UPDATE OP_APPLY SET ISSERVICEFEE1=1 WHERE BSNO='"+enumValue.BSNO+"' ");
// db.ExecuteNonQuery(cmdUpdate, tran);
// }
// if (enumFee.OPField == "SERVICE2" && applyfee.IsSERVICE2 == "1" && applyfee.IsSERVICEFEE2 != "1")
// {
// cmdInsert.Parameters.Clear();
// db.AddInParameter(cmdInsert, "@gid", DbType.String, Guid.NewGuid().ToString());
// db.AddInParameter(cmdInsert, "@bsno", DbType.String, enumValue.BSNO);
// db.AddInParameter(cmdInsert, "@fee_type", DbType.String, enumFee.FeeType);
// db.AddInParameter(cmdInsert, "@fee_name", DbType.String, enumFee.FeeName);
// db.AddInParameter(cmdInsert, "@fee_description", DbType.String, "");
// db.AddInParameter(cmdInsert, "@customer_type", DbType.String, enumFee.CustomerType);
// if (enumFee.CustomerName != "")
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumFee.CustomerName);
// else if (enumFee.CustomerType == "委托单位")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMERNAME);
// }
// else if (enumFee.CustomerType == "报关行")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMSER);
// }
// else db.AddInParameter(cmdInsert, "@customer_name", DbType.String, "");
// db.AddInParameter(cmdInsert, "@unit", DbType.String, enumFee.Unit);
// db.AddInParameter(cmdInsert, "@unit_price", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@quantity", DbType.Decimal, 1);
// db.AddInParameter(cmdInsert, "@amount", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@currency", DbType.String, enumFee.Currency);
// db.AddInParameter(cmdInsert, "@exchange_rate", DbType.Decimal, enumFee.ExchangeRate);
// db.AddInParameter(cmdInsert, "@reason", DbType.String, "");
// db.AddInParameter(cmdInsert, "@remark", DbType.String, "");
// db.AddInParameter(cmdInsert, "@comm_rate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@enter_operator", DbType.String, userid);
// db.AddInParameter(cmdInsert, "@enter_date", DbType.DateTime, DateTime.Now);
// db.AddInParameter(cmdInsert, "@is_open", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@is_advance_pay", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@sort", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@fee_status", DbType.Int16, 1);
// db.AddInParameter(cmdInsert, "@fee_frt", DbType.String, "");
// db.AddInParameter(cmdInsert, "@taxrate", DbType.Decimal, enumFee.TAXRATE);
// db.AddInParameter(cmdInsert, "@notaxamount", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@acctaxrate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@LINENUM", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@taxunit_price", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@MODIFIEDUSER", DbType.String, "");
// db.AddInParameter(cmdInsert, "@MODIFIEDTIME", DbType.DateTime, null);
// db.AddInParameter(cmdInsert, "@WMSOUTBSNO", DbType.String, "");
// db.ExecuteNonQuery(cmdInsert, tran);
// var cmdUpdate =
// db.GetSqlStringCommand(@"UPDATE OP_APPLY SET ISSERVICEFEE2=1 WHERE BSNO='" + enumValue.BSNO + "' ");
// db.ExecuteNonQuery(cmdUpdate, tran);
// } if (enumFee.OPField == "SERVICE3" && applyfee.IsSERVICE3 == "1" && applyfee.IsSERVICEFEE3 != "1")
// {
// cmdInsert.Parameters.Clear();
// db.AddInParameter(cmdInsert, "@gid", DbType.String, Guid.NewGuid().ToString());
// db.AddInParameter(cmdInsert, "@bsno", DbType.String, enumValue.BSNO);
// db.AddInParameter(cmdInsert, "@fee_type", DbType.String, enumFee.FeeType);
// db.AddInParameter(cmdInsert, "@fee_name", DbType.String, enumFee.FeeName);
// db.AddInParameter(cmdInsert, "@fee_description", DbType.String, "");
// db.AddInParameter(cmdInsert, "@customer_type", DbType.String, enumFee.CustomerType);
// if (enumFee.CustomerName != "")
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumFee.CustomerName);
// else if (enumFee.CustomerType == "委托单位")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMERNAME);
// }
// else if (enumFee.CustomerType == "报关行")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMSER);
// }
// else db.AddInParameter(cmdInsert, "@customer_name", DbType.String, "");
// db.AddInParameter(cmdInsert, "@unit", DbType.String, enumFee.Unit);
// db.AddInParameter(cmdInsert, "@unit_price", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@quantity", DbType.Decimal, 1);
// db.AddInParameter(cmdInsert, "@amount", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@currency", DbType.String, enumFee.Currency);
// db.AddInParameter(cmdInsert, "@exchange_rate", DbType.Decimal, enumFee.ExchangeRate);
// db.AddInParameter(cmdInsert, "@reason", DbType.String, "");
// db.AddInParameter(cmdInsert, "@remark", DbType.String, "");
// db.AddInParameter(cmdInsert, "@comm_rate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@enter_operator", DbType.String, userid);
// db.AddInParameter(cmdInsert, "@enter_date", DbType.DateTime, DateTime.Now);
// db.AddInParameter(cmdInsert, "@is_open", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@is_advance_pay", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@sort", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@fee_status", DbType.Int16, 1);
// db.AddInParameter(cmdInsert, "@fee_frt", DbType.String, "");
// db.AddInParameter(cmdInsert, "@taxrate", DbType.Decimal, enumFee.TAXRATE);
// db.AddInParameter(cmdInsert, "@notaxamount", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@acctaxrate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@LINENUM", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@taxunit_price", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@MODIFIEDUSER", DbType.String, "");
// db.AddInParameter(cmdInsert, "@MODIFIEDTIME", DbType.DateTime, null);
// db.AddInParameter(cmdInsert, "@WMSOUTBSNO", DbType.String, "");
// db.ExecuteNonQuery(cmdInsert, tran);
// var cmdUpdate =
// db.GetSqlStringCommand(@"UPDATE OP_APPLY SET ISSERVICEFEE3=1 WHERE BSNO='" + enumValue.BSNO + "' ");
// db.ExecuteNonQuery(cmdUpdate, tran);
// } if (enumFee.OPField == "SERVICE4" && applyfee.IsSERVICE4 == "1" && applyfee.IsSERVICEFEE4 != "1")
// {
// cmdInsert.Parameters.Clear();
// db.AddInParameter(cmdInsert, "@gid", DbType.String, Guid.NewGuid().ToString());
// db.AddInParameter(cmdInsert, "@bsno", DbType.String, enumValue.BSNO);
// db.AddInParameter(cmdInsert, "@fee_type", DbType.String, enumFee.FeeType);
// db.AddInParameter(cmdInsert, "@fee_name", DbType.String, enumFee.FeeName);
// db.AddInParameter(cmdInsert, "@fee_description", DbType.String, "");
// db.AddInParameter(cmdInsert, "@customer_type", DbType.String, enumFee.CustomerType);
// if (enumFee.CustomerName != "")
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumFee.CustomerName);
// else if (enumFee.CustomerType == "委托单位")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMERNAME);
// }
// else if (enumFee.CustomerType == "报关行")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMSER);
// }
// else db.AddInParameter(cmdInsert, "@customer_name", DbType.String, "");
// db.AddInParameter(cmdInsert, "@unit", DbType.String, enumFee.Unit);
// db.AddInParameter(cmdInsert, "@unit_price", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@quantity", DbType.Decimal, 1);
// db.AddInParameter(cmdInsert, "@amount", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@currency", DbType.String, enumFee.Currency);
// db.AddInParameter(cmdInsert, "@exchange_rate", DbType.Decimal, enumFee.ExchangeRate);
// db.AddInParameter(cmdInsert, "@reason", DbType.String, "");
// db.AddInParameter(cmdInsert, "@remark", DbType.String, "");
// db.AddInParameter(cmdInsert, "@comm_rate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@enter_operator", DbType.String, userid);
// db.AddInParameter(cmdInsert, "@enter_date", DbType.DateTime, DateTime.Now);
// db.AddInParameter(cmdInsert, "@is_open", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@is_advance_pay", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@sort", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@fee_status", DbType.Int16, 1);
// db.AddInParameter(cmdInsert, "@fee_frt", DbType.String, "");
// db.AddInParameter(cmdInsert, "@taxrate", DbType.Decimal, enumFee.TAXRATE);
// db.AddInParameter(cmdInsert, "@notaxamount", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@acctaxrate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@LINENUM", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@taxunit_price", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@MODIFIEDUSER", DbType.String, "");
// db.AddInParameter(cmdInsert, "@MODIFIEDTIME", DbType.DateTime, null);
// db.AddInParameter(cmdInsert, "@WMSOUTBSNO", DbType.String, "");
// db.ExecuteNonQuery(cmdInsert, tran);
// var cmdUpdate =
// db.GetSqlStringCommand(@"UPDATE OP_APPLY SET ISSERVICEFEE4=1 WHERE BSNO='" + enumValue.BSNO + "' ");
// db.ExecuteNonQuery(cmdUpdate, tran);
// } if (enumFee.OPField == "SERVICE5" && applyfee.IsSERVICE5 == "1" && applyfee.IsSERVICEFEE5 != "1")
// {
// cmdInsert.Parameters.Clear();
// db.AddInParameter(cmdInsert, "@gid", DbType.String, Guid.NewGuid().ToString());
// db.AddInParameter(cmdInsert, "@bsno", DbType.String, enumValue.BSNO);
// db.AddInParameter(cmdInsert, "@fee_type", DbType.String, enumFee.FeeType);
// db.AddInParameter(cmdInsert, "@fee_name", DbType.String, enumFee.FeeName);
// db.AddInParameter(cmdInsert, "@fee_description", DbType.String, "");
// db.AddInParameter(cmdInsert, "@customer_type", DbType.String, enumFee.CustomerType);
// if (enumFee.CustomerName != "")
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumFee.CustomerName);
// else if (enumFee.CustomerType == "委托单位")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMERNAME);
// }
// else if (enumFee.CustomerType == "报关行")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMSER);
// }
// else db.AddInParameter(cmdInsert, "@customer_name", DbType.String, "");
// db.AddInParameter(cmdInsert, "@unit", DbType.String, enumFee.Unit);
// db.AddInParameter(cmdInsert, "@unit_price", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@quantity", DbType.Decimal, 1);
// db.AddInParameter(cmdInsert, "@amount", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@currency", DbType.String, enumFee.Currency);
// db.AddInParameter(cmdInsert, "@exchange_rate", DbType.Decimal, enumFee.ExchangeRate);
// db.AddInParameter(cmdInsert, "@reason", DbType.String, "");
// db.AddInParameter(cmdInsert, "@remark", DbType.String, "");
// db.AddInParameter(cmdInsert, "@comm_rate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@enter_operator", DbType.String, userid);
// db.AddInParameter(cmdInsert, "@enter_date", DbType.DateTime, DateTime.Now);
// db.AddInParameter(cmdInsert, "@is_open", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@is_advance_pay", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@sort", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@fee_status", DbType.Int16, 1);
// db.AddInParameter(cmdInsert, "@fee_frt", DbType.String, "");
// db.AddInParameter(cmdInsert, "@taxrate", DbType.Decimal, enumFee.TAXRATE);
// db.AddInParameter(cmdInsert, "@notaxamount", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@acctaxrate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@LINENUM", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@taxunit_price", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@MODIFIEDUSER", DbType.String, "");
// db.AddInParameter(cmdInsert, "@MODIFIEDTIME", DbType.DateTime, null);
// db.AddInParameter(cmdInsert, "@WMSOUTBSNO", DbType.String, "");
// db.ExecuteNonQuery(cmdInsert, tran);
// var cmdUpdate =
// db.GetSqlStringCommand(@"UPDATE OP_APPLY SET ISSERVICEFEE5=1 WHERE BSNO='" + enumValue.BSNO + "' ");
// db.ExecuteNonQuery(cmdUpdate, tran);
// } if (enumFee.OPField == "SERVICE6" && applyfee.IsSERVICE6 == "1" && applyfee.IsSERVICEFEE6 != "1")
// {
// cmdInsert.Parameters.Clear();
// db.AddInParameter(cmdInsert, "@gid", DbType.String, Guid.NewGuid().ToString());
// db.AddInParameter(cmdInsert, "@bsno", DbType.String, enumValue.BSNO);
// db.AddInParameter(cmdInsert, "@fee_type", DbType.String, enumFee.FeeType);
// db.AddInParameter(cmdInsert, "@fee_name", DbType.String, enumFee.FeeName);
// db.AddInParameter(cmdInsert, "@fee_description", DbType.String, "");
// db.AddInParameter(cmdInsert, "@customer_type", DbType.String, enumFee.CustomerType);
// if (enumFee.CustomerName != "")
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumFee.CustomerName);
// else if (enumFee.CustomerType == "委托单位")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMERNAME);
// }
// else if (enumFee.CustomerType == "报关行")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMSER);
// }
// else db.AddInParameter(cmdInsert, "@customer_name", DbType.String, "");
// db.AddInParameter(cmdInsert, "@unit", DbType.String, enumFee.Unit);
// db.AddInParameter(cmdInsert, "@unit_price", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@quantity", DbType.Decimal, 1);
// db.AddInParameter(cmdInsert, "@amount", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@currency", DbType.String, enumFee.Currency);
// db.AddInParameter(cmdInsert, "@exchange_rate", DbType.Decimal, enumFee.ExchangeRate);
// db.AddInParameter(cmdInsert, "@reason", DbType.String, "");
// db.AddInParameter(cmdInsert, "@remark", DbType.String, "");
// db.AddInParameter(cmdInsert, "@comm_rate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@enter_operator", DbType.String, userid);
// db.AddInParameter(cmdInsert, "@enter_date", DbType.DateTime, DateTime.Now);
// db.AddInParameter(cmdInsert, "@is_open", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@is_advance_pay", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@sort", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@fee_status", DbType.Int16, 1);
// db.AddInParameter(cmdInsert, "@fee_frt", DbType.String, "");
// db.AddInParameter(cmdInsert, "@taxrate", DbType.Decimal, enumFee.TAXRATE);
// db.AddInParameter(cmdInsert, "@notaxamount", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@acctaxrate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@LINENUM", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@taxunit_price", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@MODIFIEDUSER", DbType.String, "");
// db.AddInParameter(cmdInsert, "@MODIFIEDTIME", DbType.DateTime, null);
// db.AddInParameter(cmdInsert, "@WMSOUTBSNO", DbType.String, "");
// db.ExecuteNonQuery(cmdInsert, tran);
// var cmdUpdate =
// db.GetSqlStringCommand(@"UPDATE OP_APPLY SET ISSERVICEFEE6=1 WHERE BSNO='" + enumValue.BSNO + "' ");
// db.ExecuteNonQuery(cmdUpdate, tran);
// } if (enumFee.OPField == "SERVICE7" && applyfee.IsSERVICE7 == "1" && applyfee.IsSERVICEFEE7 != "1")
// {
// cmdInsert.Parameters.Clear();
// db.AddInParameter(cmdInsert, "@gid", DbType.String, Guid.NewGuid().ToString());
// db.AddInParameter(cmdInsert, "@bsno", DbType.String, enumValue.BSNO);
// db.AddInParameter(cmdInsert, "@fee_type", DbType.String, enumFee.FeeType);
// db.AddInParameter(cmdInsert, "@fee_name", DbType.String, enumFee.FeeName);
// db.AddInParameter(cmdInsert, "@fee_description", DbType.String, "");
// db.AddInParameter(cmdInsert, "@customer_type", DbType.String, enumFee.CustomerType);
// if (enumFee.CustomerName != "")
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumFee.CustomerName);
// else if (enumFee.CustomerType == "委托单位")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMERNAME);
// }
// else if (enumFee.CustomerType == "报关行")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMSER);
// }
// else db.AddInParameter(cmdInsert, "@customer_name", DbType.String, "");
// db.AddInParameter(cmdInsert, "@unit", DbType.String, enumFee.Unit);
// db.AddInParameter(cmdInsert, "@unit_price", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@quantity", DbType.Decimal, 1);
// db.AddInParameter(cmdInsert, "@amount", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@currency", DbType.String, enumFee.Currency);
// db.AddInParameter(cmdInsert, "@exchange_rate", DbType.Decimal, enumFee.ExchangeRate);
// db.AddInParameter(cmdInsert, "@reason", DbType.String, "");
// db.AddInParameter(cmdInsert, "@remark", DbType.String, "");
// db.AddInParameter(cmdInsert, "@comm_rate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@enter_operator", DbType.String, userid);
// db.AddInParameter(cmdInsert, "@enter_date", DbType.DateTime, DateTime.Now);
// db.AddInParameter(cmdInsert, "@is_open", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@is_advance_pay", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@sort", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@fee_status", DbType.Int16, 1);
// db.AddInParameter(cmdInsert, "@fee_frt", DbType.String, "");
// db.AddInParameter(cmdInsert, "@taxrate", DbType.Decimal, enumFee.TAXRATE);
// db.AddInParameter(cmdInsert, "@notaxamount", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@acctaxrate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@LINENUM", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@taxunit_price", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@MODIFIEDUSER", DbType.String, "");
// db.AddInParameter(cmdInsert, "@MODIFIEDTIME", DbType.DateTime, null);
// db.AddInParameter(cmdInsert, "@WMSOUTBSNO", DbType.String, "");
// db.ExecuteNonQuery(cmdInsert, tran);
// var cmdUpdate =
// db.GetSqlStringCommand(@"UPDATE OP_APPLY SET ISSERVICEFEE7=1 WHERE BSNO='" + enumValue.BSNO + "' ");
// db.ExecuteNonQuery(cmdUpdate, tran);
// } if (enumFee.OPField == "SERVICE8" && applyfee.IsSERVICE8 == "1" && applyfee.IsSERVICEFEE8 != "1")
// {
// cmdInsert.Parameters.Clear();
// db.AddInParameter(cmdInsert, "@gid", DbType.String, Guid.NewGuid().ToString());
// db.AddInParameter(cmdInsert, "@bsno", DbType.String, enumValue.BSNO);
// db.AddInParameter(cmdInsert, "@fee_type", DbType.String, enumFee.FeeType);
// db.AddInParameter(cmdInsert, "@fee_name", DbType.String, enumFee.FeeName);
// db.AddInParameter(cmdInsert, "@fee_description", DbType.String, "");
// db.AddInParameter(cmdInsert, "@customer_type", DbType.String, enumFee.CustomerType);
// if (enumFee.CustomerName != "")
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumFee.CustomerName);
// else if (enumFee.CustomerType == "委托单位")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMERNAME);
// }
// else if (enumFee.CustomerType == "报关行")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMSER);
// }
// else db.AddInParameter(cmdInsert, "@customer_name", DbType.String, "");
// db.AddInParameter(cmdInsert, "@unit", DbType.String, enumFee.Unit);
// db.AddInParameter(cmdInsert, "@unit_price", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@quantity", DbType.Decimal, 1);
// db.AddInParameter(cmdInsert, "@amount", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@currency", DbType.String, enumFee.Currency);
// db.AddInParameter(cmdInsert, "@exchange_rate", DbType.Decimal, enumFee.ExchangeRate);
// db.AddInParameter(cmdInsert, "@reason", DbType.String, "");
// db.AddInParameter(cmdInsert, "@remark", DbType.String, "");
// db.AddInParameter(cmdInsert, "@comm_rate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@enter_operator", DbType.String, userid);
// db.AddInParameter(cmdInsert, "@enter_date", DbType.DateTime, DateTime.Now);
// db.AddInParameter(cmdInsert, "@is_open", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@is_advance_pay", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@sort", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@fee_status", DbType.Int16, 1);
// db.AddInParameter(cmdInsert, "@fee_frt", DbType.String, "");
// db.AddInParameter(cmdInsert, "@taxrate", DbType.Decimal, enumFee.TAXRATE);
// db.AddInParameter(cmdInsert, "@notaxamount", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@acctaxrate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@LINENUM", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@taxunit_price", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@MODIFIEDUSER", DbType.String, "");
// db.AddInParameter(cmdInsert, "@MODIFIEDTIME", DbType.DateTime, null);
// db.AddInParameter(cmdInsert, "@WMSOUTBSNO", DbType.String, "");
// db.ExecuteNonQuery(cmdInsert, tran);
// var cmdUpdate =
// db.GetSqlStringCommand(@"UPDATE OP_APPLY SET ISSERVICEFEE8=1 WHERE BSNO='" + enumValue.BSNO + "' ");
// db.ExecuteNonQuery(cmdUpdate, tran);
// } if (enumFee.OPField == "SERVICE9" && applyfee.IsSERVICE9 == "1" && applyfee.IsSERVICEFEE9 != "1")
// {
// cmdInsert.Parameters.Clear();
// db.AddInParameter(cmdInsert, "@gid", DbType.String, Guid.NewGuid().ToString());
// db.AddInParameter(cmdInsert, "@bsno", DbType.String, enumValue.BSNO);
// db.AddInParameter(cmdInsert, "@fee_type", DbType.String, enumFee.FeeType);
// db.AddInParameter(cmdInsert, "@fee_name", DbType.String, enumFee.FeeName);
// db.AddInParameter(cmdInsert, "@fee_description", DbType.String, "");
// db.AddInParameter(cmdInsert, "@customer_type", DbType.String, enumFee.CustomerType);
// if (enumFee.CustomerName != "")
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumFee.CustomerName);
// else if (enumFee.CustomerType == "委托单位")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMERNAME);
// }
// else if (enumFee.CustomerType == "报关行")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMSER);
// }
// else db.AddInParameter(cmdInsert, "@customer_name", DbType.String, "");
// db.AddInParameter(cmdInsert, "@unit", DbType.String, enumFee.Unit);
// db.AddInParameter(cmdInsert, "@unit_price", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@quantity", DbType.Decimal, 1);
// db.AddInParameter(cmdInsert, "@amount", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@currency", DbType.String, enumFee.Currency);
// db.AddInParameter(cmdInsert, "@exchange_rate", DbType.Decimal, enumFee.ExchangeRate);
// db.AddInParameter(cmdInsert, "@reason", DbType.String, "");
// db.AddInParameter(cmdInsert, "@remark", DbType.String, "");
// db.AddInParameter(cmdInsert, "@comm_rate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@enter_operator", DbType.String, userid);
// db.AddInParameter(cmdInsert, "@enter_date", DbType.DateTime, DateTime.Now);
// db.AddInParameter(cmdInsert, "@is_open", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@is_advance_pay", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@sort", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@fee_status", DbType.Int16, 1);
// db.AddInParameter(cmdInsert, "@fee_frt", DbType.String, "");
// db.AddInParameter(cmdInsert, "@taxrate", DbType.Decimal, enumFee.TAXRATE);
// db.AddInParameter(cmdInsert, "@notaxamount", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@acctaxrate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@LINENUM", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@taxunit_price", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@MODIFIEDUSER", DbType.String, "");
// db.AddInParameter(cmdInsert, "@MODIFIEDTIME", DbType.DateTime, null);
// db.AddInParameter(cmdInsert, "@WMSOUTBSNO", DbType.String, "");
// db.ExecuteNonQuery(cmdInsert, tran);
// var cmdUpdate =
// db.GetSqlStringCommand(@"UPDATE OP_APPLY SET ISSERVICEFEE9=1 WHERE BSNO='" + enumValue.BSNO + "' ");
// db.ExecuteNonQuery(cmdUpdate, tran);
// } if (enumFee.OPField == "SERVICE10" && applyfee.IsSERVICE10 == "1" && applyfee.IsSERVICEFEE10 != "1")
// {
// cmdInsert.Parameters.Clear();
// db.AddInParameter(cmdInsert, "@gid", DbType.String, Guid.NewGuid().ToString());
// db.AddInParameter(cmdInsert, "@bsno", DbType.String, enumValue.BSNO);
// db.AddInParameter(cmdInsert, "@fee_type", DbType.String, enumFee.FeeType);
// db.AddInParameter(cmdInsert, "@fee_name", DbType.String, enumFee.FeeName);
// db.AddInParameter(cmdInsert, "@fee_description", DbType.String, "");
// db.AddInParameter(cmdInsert, "@customer_type", DbType.String, enumFee.CustomerType);
// if (enumFee.CustomerName != "")
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumFee.CustomerName);
// else if (enumFee.CustomerType == "委托单位")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMERNAME);
// }
// else if (enumFee.CustomerType == "报关行")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMSER);
// }
// else db.AddInParameter(cmdInsert, "@customer_name", DbType.String, "");
// db.AddInParameter(cmdInsert, "@unit", DbType.String, enumFee.Unit);
// db.AddInParameter(cmdInsert, "@unit_price", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@quantity", DbType.Decimal, 1);
// db.AddInParameter(cmdInsert, "@amount", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@currency", DbType.String, enumFee.Currency);
// db.AddInParameter(cmdInsert, "@exchange_rate", DbType.Decimal, enumFee.ExchangeRate);
// db.AddInParameter(cmdInsert, "@reason", DbType.String, "");
// db.AddInParameter(cmdInsert, "@remark", DbType.String, "");
// db.AddInParameter(cmdInsert, "@comm_rate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@enter_operator", DbType.String, userid);
// db.AddInParameter(cmdInsert, "@enter_date", DbType.DateTime, DateTime.Now);
// db.AddInParameter(cmdInsert, "@is_open", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@is_advance_pay", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@sort", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@fee_status", DbType.Int16, 1);
// db.AddInParameter(cmdInsert, "@fee_frt", DbType.String, "");
// db.AddInParameter(cmdInsert, "@taxrate", DbType.Decimal, enumFee.TAXRATE);
// db.AddInParameter(cmdInsert, "@notaxamount", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@acctaxrate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@LINENUM", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@taxunit_price", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@MODIFIEDUSER", DbType.String, "");
// db.AddInParameter(cmdInsert, "@MODIFIEDTIME", DbType.DateTime, null);
// db.AddInParameter(cmdInsert, "@WMSOUTBSNO", DbType.String, "");
// db.ExecuteNonQuery(cmdInsert, tran);
// var cmdUpdate =
// db.GetSqlStringCommand(@"UPDATE OP_APPLY SET ISSERVICEFEE10=1 WHERE BSNO='" + enumValue.BSNO + "' ");
// db.ExecuteNonQuery(cmdUpdate, tran);
// } if (enumFee.OPField == "SERVICE11" && applyfee.IsSERVICE11 == "1" && applyfee.IsSERVICEFEE11 != "1")
// {
// cmdInsert.Parameters.Clear();
// db.AddInParameter(cmdInsert, "@gid", DbType.String, Guid.NewGuid().ToString());
// db.AddInParameter(cmdInsert, "@bsno", DbType.String, enumValue.BSNO);
// db.AddInParameter(cmdInsert, "@fee_type", DbType.String, enumFee.FeeType);
// db.AddInParameter(cmdInsert, "@fee_name", DbType.String, enumFee.FeeName);
// db.AddInParameter(cmdInsert, "@fee_description", DbType.String, "");
// db.AddInParameter(cmdInsert, "@customer_type", DbType.String, enumFee.CustomerType);
// if (enumFee.CustomerName != "")
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumFee.CustomerName);
// else if (enumFee.CustomerType == "委托单位")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMERNAME);
// }
// else if (enumFee.CustomerType == "报关行")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMSER);
// }
// else db.AddInParameter(cmdInsert, "@customer_name", DbType.String, "");
// db.AddInParameter(cmdInsert, "@unit", DbType.String, enumFee.Unit);
// db.AddInParameter(cmdInsert, "@unit_price", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@quantity", DbType.Decimal, 1);
// db.AddInParameter(cmdInsert, "@amount", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@currency", DbType.String, enumFee.Currency);
// db.AddInParameter(cmdInsert, "@exchange_rate", DbType.Decimal, enumFee.ExchangeRate);
// db.AddInParameter(cmdInsert, "@reason", DbType.String, "");
// db.AddInParameter(cmdInsert, "@remark", DbType.String, "");
// db.AddInParameter(cmdInsert, "@comm_rate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@enter_operator", DbType.String, userid);
// db.AddInParameter(cmdInsert, "@enter_date", DbType.DateTime, DateTime.Now);
// db.AddInParameter(cmdInsert, "@is_open", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@is_advance_pay", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@sort", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@fee_status", DbType.Int16, 1);
// db.AddInParameter(cmdInsert, "@fee_frt", DbType.String, "");
// db.AddInParameter(cmdInsert, "@taxrate", DbType.Decimal, enumFee.TAXRATE);
// db.AddInParameter(cmdInsert, "@notaxamount", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@acctaxrate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@LINENUM", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@taxunit_price", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@MODIFIEDUSER", DbType.String, "");
// db.AddInParameter(cmdInsert, "@MODIFIEDTIME", DbType.DateTime, null);
// db.AddInParameter(cmdInsert, "@WMSOUTBSNO", DbType.String, "");
// db.ExecuteNonQuery(cmdInsert, tran);
// var cmdUpdate =
// db.GetSqlStringCommand(@"UPDATE OP_APPLY SET ISSERVICEFEE11=1 WHERE BSNO='" + enumValue.BSNO + "' ");
// db.ExecuteNonQuery(cmdUpdate, tran);
// } if (enumFee.OPField == "SERVICE12" && applyfee.IsSERVICE12 == "1" && applyfee.IsSERVICEFEE12 != "1")
// {
// cmdInsert.Parameters.Clear();
// db.AddInParameter(cmdInsert, "@gid", DbType.String, Guid.NewGuid().ToString());
// db.AddInParameter(cmdInsert, "@bsno", DbType.String, enumValue.BSNO);
// db.AddInParameter(cmdInsert, "@fee_type", DbType.String, enumFee.FeeType);
// db.AddInParameter(cmdInsert, "@fee_name", DbType.String, enumFee.FeeName);
// db.AddInParameter(cmdInsert, "@fee_description", DbType.String, "");
// db.AddInParameter(cmdInsert, "@customer_type", DbType.String, enumFee.CustomerType);
// if (enumFee.CustomerName != "")
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumFee.CustomerName);
// else if (enumFee.CustomerType == "委托单位")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMERNAME);
// }
// else if (enumFee.CustomerType == "报关行")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMSER);
// }
// else db.AddInParameter(cmdInsert, "@customer_name", DbType.String, "");
// db.AddInParameter(cmdInsert, "@unit", DbType.String, enumFee.Unit);
// db.AddInParameter(cmdInsert, "@unit_price", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@quantity", DbType.Decimal, 1);
// db.AddInParameter(cmdInsert, "@amount", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@currency", DbType.String, enumFee.Currency);
// db.AddInParameter(cmdInsert, "@exchange_rate", DbType.Decimal, enumFee.ExchangeRate);
// db.AddInParameter(cmdInsert, "@reason", DbType.String, "");
// db.AddInParameter(cmdInsert, "@remark", DbType.String, "");
// db.AddInParameter(cmdInsert, "@comm_rate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@enter_operator", DbType.String, userid);
// db.AddInParameter(cmdInsert, "@enter_date", DbType.DateTime, DateTime.Now);
// db.AddInParameter(cmdInsert, "@is_open", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@is_advance_pay", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@sort", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@fee_status", DbType.Int16, 1);
// db.AddInParameter(cmdInsert, "@fee_frt", DbType.String, "");
// db.AddInParameter(cmdInsert, "@taxrate", DbType.Decimal, enumFee.TAXRATE);
// db.AddInParameter(cmdInsert, "@notaxamount", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@acctaxrate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@LINENUM", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@taxunit_price", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@MODIFIEDUSER", DbType.String, "");
// db.AddInParameter(cmdInsert, "@MODIFIEDTIME", DbType.DateTime, null);
// db.AddInParameter(cmdInsert, "@WMSOUTBSNO", DbType.String, "");
// db.ExecuteNonQuery(cmdInsert, tran);
// var cmdUpdate =
// db.GetSqlStringCommand(@"UPDATE OP_APPLY SET ISSERVICEFEE12=1 WHERE BSNO='" + enumValue.BSNO + "' ");
// db.ExecuteNonQuery(cmdUpdate, tran);
// } if (enumFee.OPField == "SERVICE13" && applyfee.IsSERVICE13 == "1" && applyfee.IsSERVICEFEE13 != "1")
// {
// cmdInsert.Parameters.Clear();
// db.AddInParameter(cmdInsert, "@gid", DbType.String, Guid.NewGuid().ToString());
// db.AddInParameter(cmdInsert, "@bsno", DbType.String, enumValue.BSNO);
// db.AddInParameter(cmdInsert, "@fee_type", DbType.String, enumFee.FeeType);
// db.AddInParameter(cmdInsert, "@fee_name", DbType.String, enumFee.FeeName);
// db.AddInParameter(cmdInsert, "@fee_description", DbType.String, "");
// db.AddInParameter(cmdInsert, "@customer_type", DbType.String, enumFee.CustomerType);
// if (enumFee.CustomerName != "")
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumFee.CustomerName);
// else if (enumFee.CustomerType == "委托单位")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMERNAME);
// }
// else if (enumFee.CustomerType == "报关行")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMSER);
// }
// else db.AddInParameter(cmdInsert, "@customer_name", DbType.String, "");
// db.AddInParameter(cmdInsert, "@unit", DbType.String, enumFee.Unit);
// db.AddInParameter(cmdInsert, "@unit_price", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@quantity", DbType.Decimal, 1);
// db.AddInParameter(cmdInsert, "@amount", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@currency", DbType.String, enumFee.Currency);
// db.AddInParameter(cmdInsert, "@exchange_rate", DbType.Decimal, enumFee.ExchangeRate);
// db.AddInParameter(cmdInsert, "@reason", DbType.String, "");
// db.AddInParameter(cmdInsert, "@remark", DbType.String, "");
// db.AddInParameter(cmdInsert, "@comm_rate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@enter_operator", DbType.String, userid);
// db.AddInParameter(cmdInsert, "@enter_date", DbType.DateTime, DateTime.Now);
// db.AddInParameter(cmdInsert, "@is_open", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@is_advance_pay", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@sort", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@fee_status", DbType.Int16, 1);
// db.AddInParameter(cmdInsert, "@fee_frt", DbType.String, "");
// db.AddInParameter(cmdInsert, "@taxrate", DbType.Decimal, enumFee.TAXRATE);
// db.AddInParameter(cmdInsert, "@notaxamount", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@acctaxrate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@LINENUM", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@taxunit_price", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@MODIFIEDUSER", DbType.String, "");
// db.AddInParameter(cmdInsert, "@MODIFIEDTIME", DbType.DateTime, null);
// db.AddInParameter(cmdInsert, "@WMSOUTBSNO", DbType.String, "");
// db.ExecuteNonQuery(cmdInsert, tran);
// var cmdUpdate =
// db.GetSqlStringCommand(@"UPDATE OP_APPLY SET ISSERVICEFEE13=1 WHERE BSNO='" + enumValue.BSNO + "' ");
// db.ExecuteNonQuery(cmdUpdate, tran);
// } if (enumFee.OPField == "SERVICE14" && applyfee.IsSERVICE14 == "1" && applyfee.IsSERVICEFEE14 != "1")
// {
// cmdInsert.Parameters.Clear();
// db.AddInParameter(cmdInsert, "@gid", DbType.String, Guid.NewGuid().ToString());
// db.AddInParameter(cmdInsert, "@bsno", DbType.String, enumValue.BSNO);
// db.AddInParameter(cmdInsert, "@fee_type", DbType.String, enumFee.FeeType);
// db.AddInParameter(cmdInsert, "@fee_name", DbType.String, enumFee.FeeName);
// db.AddInParameter(cmdInsert, "@fee_description", DbType.String, "");
// db.AddInParameter(cmdInsert, "@customer_type", DbType.String, enumFee.CustomerType);
// if (enumFee.CustomerName != "")
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumFee.CustomerName);
// else if (enumFee.CustomerType == "委托单位")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMERNAME);
// }
// else if (enumFee.CustomerType == "报关行")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMSER);
// }
// else db.AddInParameter(cmdInsert, "@customer_name", DbType.String, "");
// db.AddInParameter(cmdInsert, "@unit", DbType.String, enumFee.Unit);
// db.AddInParameter(cmdInsert, "@unit_price", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@quantity", DbType.Decimal, 1);
// db.AddInParameter(cmdInsert, "@amount", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@currency", DbType.String, enumFee.Currency);
// db.AddInParameter(cmdInsert, "@exchange_rate", DbType.Decimal, enumFee.ExchangeRate);
// db.AddInParameter(cmdInsert, "@reason", DbType.String, "");
// db.AddInParameter(cmdInsert, "@remark", DbType.String, "");
// db.AddInParameter(cmdInsert, "@comm_rate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@enter_operator", DbType.String, userid);
// db.AddInParameter(cmdInsert, "@enter_date", DbType.DateTime, DateTime.Now);
// db.AddInParameter(cmdInsert, "@is_open", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@is_advance_pay", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@sort", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@fee_status", DbType.Int16, 1);
// db.AddInParameter(cmdInsert, "@fee_frt", DbType.String, "");
// db.AddInParameter(cmdInsert, "@taxrate", DbType.Decimal, enumFee.TAXRATE);
// db.AddInParameter(cmdInsert, "@notaxamount", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@acctaxrate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@LINENUM", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@taxunit_price", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@MODIFIEDUSER", DbType.String, "");
// db.AddInParameter(cmdInsert, "@MODIFIEDTIME", DbType.DateTime, null);
// db.AddInParameter(cmdInsert, "@WMSOUTBSNO", DbType.String, "");
// db.ExecuteNonQuery(cmdInsert, tran);
// var cmdUpdate =
// db.GetSqlStringCommand(@"UPDATE OP_APPLY SET ISSERVICEFEE14=1 WHERE BSNO='" + enumValue.BSNO + "' ");
// db.ExecuteNonQuery(cmdUpdate, tran);
// } if (enumFee.OPField == "SERVICE15" && applyfee.IsSERVICE15 == "1" && applyfee.IsSERVICEFEE15 != "1")
// {
// cmdInsert.Parameters.Clear();
// db.AddInParameter(cmdInsert, "@gid", DbType.String, Guid.NewGuid().ToString());
// db.AddInParameter(cmdInsert, "@bsno", DbType.String, enumValue.BSNO);
// db.AddInParameter(cmdInsert, "@fee_type", DbType.String, enumFee.FeeType);
// db.AddInParameter(cmdInsert, "@fee_name", DbType.String, enumFee.FeeName);
// db.AddInParameter(cmdInsert, "@fee_description", DbType.String, "");
// db.AddInParameter(cmdInsert, "@customer_type", DbType.String, enumFee.CustomerType);
// if (enumFee.CustomerName != "")
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumFee.CustomerName);
// else if (enumFee.CustomerType == "委托单位")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMERNAME);
// }
// else if (enumFee.CustomerType == "报关行")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMSER);
// }
// else db.AddInParameter(cmdInsert, "@customer_name", DbType.String, "");
// db.AddInParameter(cmdInsert, "@unit", DbType.String, enumFee.Unit);
// db.AddInParameter(cmdInsert, "@unit_price", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@quantity", DbType.Decimal, 1);
// db.AddInParameter(cmdInsert, "@amount", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@currency", DbType.String, enumFee.Currency);
// db.AddInParameter(cmdInsert, "@exchange_rate", DbType.Decimal, enumFee.ExchangeRate);
// db.AddInParameter(cmdInsert, "@reason", DbType.String, "");
// db.AddInParameter(cmdInsert, "@remark", DbType.String, "");
// db.AddInParameter(cmdInsert, "@comm_rate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@enter_operator", DbType.String, userid);
// db.AddInParameter(cmdInsert, "@enter_date", DbType.DateTime, DateTime.Now);
// db.AddInParameter(cmdInsert, "@is_open", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@is_advance_pay", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@sort", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@fee_status", DbType.Int16, 1);
// db.AddInParameter(cmdInsert, "@fee_frt", DbType.String, "");
// db.AddInParameter(cmdInsert, "@taxrate", DbType.Decimal, enumFee.TAXRATE);
// db.AddInParameter(cmdInsert, "@notaxamount", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@acctaxrate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@LINENUM", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@taxunit_price", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@MODIFIEDUSER", DbType.String, "");
// db.AddInParameter(cmdInsert, "@MODIFIEDTIME", DbType.DateTime, null);
// db.AddInParameter(cmdInsert, "@WMSOUTBSNO", DbType.String, "");
// db.ExecuteNonQuery(cmdInsert, tran);
// var cmdUpdate =
// db.GetSqlStringCommand(@"UPDATE OP_APPLY SET ISSERVICEFEE15=1 WHERE BSNO='" + enumValue.BSNO + "' ");
// db.ExecuteNonQuery(cmdUpdate, tran);
// } if (enumFee.OPField == "SERVICE16" && applyfee.IsSERVICE16 == "1" && applyfee.IsSERVICEFEE16 != "1")
// {
// cmdInsert.Parameters.Clear();
// db.AddInParameter(cmdInsert, "@gid", DbType.String, Guid.NewGuid().ToString());
// db.AddInParameter(cmdInsert, "@bsno", DbType.String, enumValue.BSNO);
// db.AddInParameter(cmdInsert, "@fee_type", DbType.String, enumFee.FeeType);
// db.AddInParameter(cmdInsert, "@fee_name", DbType.String, enumFee.FeeName);
// db.AddInParameter(cmdInsert, "@fee_description", DbType.String, "");
// db.AddInParameter(cmdInsert, "@customer_type", DbType.String, enumFee.CustomerType);
// if (enumFee.CustomerName != "")
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumFee.CustomerName);
// else if (enumFee.CustomerType == "委托单位")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMERNAME);
// }
// else if (enumFee.CustomerType == "报关行")
// {
// db.AddInParameter(cmdInsert, "@customer_name", DbType.String, enumValue.CUSTOMSER);
// }
// else db.AddInParameter(cmdInsert, "@customer_name", DbType.String, "");
// db.AddInParameter(cmdInsert, "@unit", DbType.String, enumFee.Unit);
// db.AddInParameter(cmdInsert, "@unit_price", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@quantity", DbType.Decimal, 1);
// db.AddInParameter(cmdInsert, "@amount", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@currency", DbType.String, enumFee.Currency);
// db.AddInParameter(cmdInsert, "@exchange_rate", DbType.Decimal, enumFee.ExchangeRate);
// db.AddInParameter(cmdInsert, "@reason", DbType.String, "");
// db.AddInParameter(cmdInsert, "@remark", DbType.String, "");
// db.AddInParameter(cmdInsert, "@comm_rate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@enter_operator", DbType.String, userid);
// db.AddInParameter(cmdInsert, "@enter_date", DbType.DateTime, DateTime.Now);
// db.AddInParameter(cmdInsert, "@is_open", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@is_advance_pay", DbType.String, "0");
// db.AddInParameter(cmdInsert, "@sort", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@fee_status", DbType.Int16, 1);
// db.AddInParameter(cmdInsert, "@fee_frt", DbType.String, "");
// db.AddInParameter(cmdInsert, "@taxrate", DbType.Decimal, enumFee.TAXRATE);
// db.AddInParameter(cmdInsert, "@notaxamount", DbType.Decimal, enumFee.UnitPrice);
// db.AddInParameter(cmdInsert, "@acctaxrate", DbType.Decimal, 0);
// db.AddInParameter(cmdInsert, "@LINENUM", DbType.Int16, 2);
// db.AddInParameter(cmdInsert, "@taxunit_price", DbType.Decimal, taxamount);
// db.AddInParameter(cmdInsert, "@MODIFIEDUSER", DbType.String, "");
// db.AddInParameter(cmdInsert, "@MODIFIEDTIME", DbType.DateTime, null);
// db.AddInParameter(cmdInsert, "@WMSOUTBSNO", DbType.String, "");
// db.ExecuteNonQuery(cmdInsert, tran);
// var cmdUpdate =
// db.GetSqlStringCommand(@"UPDATE OP_APPLY SET ISSERVICEFEE16=1 WHERE BSNO='" + enumValue.BSNO + "' ");
// db.ExecuteNonQuery(cmdUpdate, tran);
// }
// }
// }
// }
// }
// tran.Commit();
// result.Success = true;
// result.Message = "保存成功" + result.Message;
// return result;
// }
// catch (Exception)
// {
// tran.Rollback();
// result.Success = false;
// result.Message = "保存出现错误,请重试或联系系统管理员";
// return result;
// }
// }
// result.Success = true;
// result.Message = "保存成功" + result.Message;
// return result;
// }
// #endregion
public static String getCodeRule(string strRULENAME, string strfield, string strETD, string strACCDATE, string strUserID, string strCompanyID)
{
//调用编码规则
if (strETD.Trim().IndexOf("0001") > -1)
{
strETD = "";
}
string strRULEYEAR = "";
string strRULECONTENT = "";
string strCODENAME = "";
string strDEPTNO = "";
string strRULENOLENGTH = "";
int iRULENOLENGTH = 0;
int inum = 0;
string strCONTENT = "";
T_ALL_DA T_ALL_DA = new T_ALL_DA();
//
DataSet ds = T_ALL_DA.GetAllSQL("select * from code_rule where RULENAME='" + strRULENAME.Trim() + "' and RULETYPE=4");
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0]["ISSTARTUSING"].ToString().Trim().Equals("True"))
{
if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("业务日期"))
{
if (strETD.Trim() == "")
{
return "";
}
DateTime dETD = System.Convert.ToDateTime(strETD.Trim());
if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
{
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
{
strRULEYEAR = dETD.ToString("yyyy") + dETD.ToString("MM");
}
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
{
strRULEYEAR = dETD.ToString("yy") + dETD.ToString("MM");
}
}
else
{
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
{
strRULEYEAR = dETD.ToString("yyyy");
}
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
{
strRULEYEAR = dETD.ToString("yy");
}
}
}
else if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("会计期间"))
{
if (strACCDATE.Trim() == "")
{
return "";
}
DateTime dACCDATE = System.Convert.ToDateTime(strACCDATE.Trim() + "-01");
if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
{
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
{
strRULEYEAR = dACCDATE.ToString("yyyy") + dACCDATE.ToString("MM");
}
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
{
strRULEYEAR = dACCDATE.ToString("yy") + dACCDATE.ToString("MM");
}
}
else
{
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
{
strRULEYEAR = dACCDATE.ToString("yyyy");
}
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
{
strRULEYEAR = dACCDATE.ToString("yy");
}
}
}
else if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("自然月份"))
{
DateTime fwqdate = System.Convert.ToDateTime(T_ALL_DA.GetStrSQL("fwqdate", "select fwqdate=getdate()"));
if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
{
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
{
strRULEYEAR = fwqdate.ToString("yyyy") + fwqdate.ToString("MM");
}
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
{
strRULEYEAR = fwqdate.ToString("yy") + fwqdate.ToString("MM");
}
}
else
{
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
{
strRULEYEAR = fwqdate.ToString("yyyy");
}
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
{
strRULEYEAR = fwqdate.ToString("yy");
}
}
}
//
if (ds.Tables[0].Rows[0]["ISCOMPANY"].ToString().Trim().Equals("True"))
{
strCODENAME = T_ALL_DA.GetStrSQL("CODENAME", "select CODENAME from [company] where GID=(select top 1 COMPANYID from user_company where USERID='" + strUserID.Trim() + "')");
}
if (ds.Tables[0].Rows[0]["ISDEPT"].ToString().Trim().Equals("True"))
{
strDEPTNO = T_ALL_DA.GetStrSQL("DEPTNO", "select DEPTNO from [sys_dept] where LINKID=(select top 1 COMPANYID from user_company where USERID='" + strUserID.Trim() + "')");
}
strRULECONTENT = ds.Tables[0].Rows[0]["RULECONTENT"].ToString().Trim();
strRULECONTENT = strRULECONTENT.Replace("《COMPANY》", strCODENAME);
strRULECONTENT = strRULECONTENT.Replace("《DEPT》", strDEPTNO);
//
iRULENOLENGTH = int.Parse(ds.Tables[0].Rows[0]["RULENOLENGTH"].ToString().Trim());
strCONTENT = strRULECONTENT + strRULEYEAR;
//获取分公司的票号头字符
string tempBANKSHEAD = T_ALL_DA.GetStrSQL("BANKSHEAD", "SELECT TOP 1 BANKSHEAD FROM company WHERE GID='" + strCompanyID.Trim() + "'");
strCONTENT = tempBANKSHEAD + strCONTENT;
//
strRULENOLENGTH = T_ALL_DA.GetStrSQL(strfield, "select top 1 " + strfield + " from [op_apply] where " + strfield + " like '" + strCONTENT.Trim() + "%' order by " + strfield + " DESC");
if (strRULENOLENGTH == "")
{
strRULENOLENGTH = "1";
}
else
{
strRULENOLENGTH = strRULENOLENGTH.Replace(strCONTENT.Trim(), "");
inum = int.Parse(strRULENOLENGTH.Trim());
inum = inum + 1;
strRULENOLENGTH = inum.ToString();
}
int j = iRULENOLENGTH - strRULENOLENGTH.Length;
for (int i = 1; i <= j; i++)
{
strRULENOLENGTH = "0" + strRULENOLENGTH;
}
//
strCONTENT = strCONTENT + strRULENOLENGTH;
return strCONTENT;
}
}
}
return "";
}
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;
}
#region 委托业务费用加锁
/// <summary>
/// 委托业务费用加锁
/// </summary>
/// <param name="tempBSNO">委托业务编号</param>
/// <returns>值等于1表示加锁成功 值不等于1表示加锁失败</returns>
public static int LockFeeStatus(string tempBSNO)
{
int iResult = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
SqlParameter[] parms = new SqlParameter[] {
new SqlParameter("@bsno",SqlDbType.VarChar,100)
};
parms[0].Value = tempBSNO;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, "UPDATE op_apply SET FEESTATUS = 1 WHERE BSNO = @bsno", parms);
sqlTran.Commit();
iResult = 1;//状态为1表示更新成功
}
catch (Exception execError)
{
iResult = -1;//有异常,更新失败
sqlTran.Rollback();
iResult = -2;//更新异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return iResult;
}
#endregion
#region 委托业务费用解锁
/// <summary>
/// 委托业务费用解锁
/// </summary>
/// <param name="tempBSNO">委托业务编号</param>
/// <returns>值等于1表示解锁成功 值不等于1表示解锁失败</returns>
public static int UnLockFeeStatus(string tempBSNO)
{
int iResult = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
SqlParameter[] parms = new SqlParameter[] {
new SqlParameter("@bsno",SqlDbType.VarChar,100)
};
parms[0].Value = tempBSNO;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, "UPDATE op_apply SET FEESTATUS =0 WHERE BSNO = @bsno", parms);
sqlTran.Commit();
iResult = 1;//状态为1表示更新成功
}
catch (Exception execError)
{
iResult = -1;//有异常,更新失败
sqlTran.Rollback();
iResult = -2;//更新异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return iResult;
}
#endregion
#region 物流信息网报关状态
static public string GetDataHtmlList(string html, string startstr, string endstr)
{
var subhtml = html;
var htmllength = subhtml.Length;
var startindex = subhtml.IndexOf(startstr);
if (startindex == -1) return "";
subhtml = subhtml.Substring(startindex + startstr.Length, htmllength - startindex - startstr.Length);
var endindex = subhtml.IndexOf(endstr);
if (endindex == -1) return "";
subhtml = subhtml.Substring(0, endindex);
return subhtml;
}
#region 更新舱单状态
public static DBResult RefreshManifestStatus(List<MsOpApply> bodyList)
{
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var strSql = new StringBuilder();
strSql.Append("update op_apply set MANIFESTSTATUS=@MANIFESTSTATUS ");
strSql.Append(" where BSNO=@BSNO ");
var cmdupdate =
db.GetSqlStringCommand(strSql.ToString());
if (bodyList != null)
{
foreach (var enumValue in bodyList)
{
var manifeststatus = GetManifestSTATUSList(enumValue.MBLNO, enumValue.BSNO);
if (manifeststatus.ISPREPARED == false)
{
}
else
{
var status = "0";
if (manifeststatus.ISLOADCLEAR)
{
status = "5";
}
else if (manifeststatus.ISBILLCLEAR)
{
status = "4";
}
else if (manifeststatus.ISCUSTOMCLEAR)
{
status = "3";
}
else if (manifeststatus.ISARRIVAL)
{
status = "2";
}
else if (manifeststatus.ISPREPARED)
{
status = "1";
}
cmdupdate.Parameters.Clear();
db.AddInParameter(cmdupdate, "@MANIFESTSTATUS", DbType.String, status);
db.AddInParameter(cmdupdate, "@BSNO", DbType.String, enumValue.BSNO);
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;
}
#endregion
static public DBResult Get56CDCSTATUSList(string mblno, string bsno)
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeCustomStatus>();
try
{
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://cdp.qdcdc.com/CDP/Login.aspx",//URL这里都是测试 必需项
Referer = "http://cdp.qdcdc.com/CDP/Login.aspx",
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "56.qdcdc.com",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",
Postdata = "__VIEWSTATE=%2FwEPDwULLTE2NDY3NDYxOTEPFgIeCWF1dGhMZXZlbAIBZGQFDBMiaM5jeSqYOP96II7WoW0oyc%2BSfvVv%2FGIrZ%2FP5bg%3D%3D&__EVENTVALIDATION=%2FwEWAgLO2Kj0DALLr40TnsCiM32qLiMK44G5moITtUwkOOjKlsY5RQB7pzBatDk%3D&user_name=user1&password=88888888&hdSuccess=true",
Method = "POST",//URL 可选项 默认为Get
};
HttpResult resulthtml = http.GetHtml(item);
var mycookie = resulthtml.Cookie;
http = new HttpHelper();
item = new HttpItem()
{
URL = "http://cdp.qdcdc.com/CDP/MftQuery/BillExportQuery.aspx",//URL这里都是测试 必需项
Referer = "http://cdp.qdcdc.com/CDP/MftQuery/BillExportQuery.aspx",
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "cdp.qdcdc.com",
Cookie = mycookie,
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",
Postdata = "__VIEWSTATE=%2FwEPDwUKLTExMzU1MTk4OGRktjQbcTwrtROJIB0DnKW%2FD24wHlo1MdO2yN13vwaX7GI%3D"
+ "&__EVENTVALIDATION=%2FwEWGAK%2FttbiCQKj%2B6LoDwLooeTACQLu%2F%2Fi7CwLa9PCNDgLp7r6qDgLblJqhCgLV3JG"
+ "HCALkwOjWBQLD2Y%2F%2FAwKYnc6YDwLJ7LFVAuDmrTwCvf3v3AcCluH%2BPgKs37SpCwKqgp2pDQLZ1tnQDQLol%2BuuCQL"
+ "T4ZKcAQKklPGiDwLB043aDwLAkeEVAoba9d8KBTCeVFBSa01eOoxl%2FjKz%2Fc7CpJUHsEtTic89nJEP3hM%3D&txtIMO="
+ "&txtTransportName=&txtVoyageNo=&txtBillNo=" + mblno + "&LinkButtonQuery=%E6%9F%A5%E8%AF%A2&hdSelectRow="
+ "&hdData=&hdCols=%E5%BA%8F%E5%8F%B7%2C%E5%87%BA%E5%8F%A3%E6%8F%90%E5%8D%95%E5%8F%B7%2C%E8%BF%90%E8%BE"
+ "%93%E5%B7%A5%E5%85%B7%E4%BF%A1%E6%81%AF%2C%E6%80%BB%E5%8D%95%2F%E5%88%86%E5%8D%95%2C%E9%A2%84%E9%85%"
+ "8D%E8%88%B1%E5%8D%95%2C%E5%87%BA%E5%8F%A3%E8%BF%90%E6%8A%B5%E6%8A%A5%E5%91%8A%2C%E8%90%BD%E8%B4%A7%E"
+ "6%94%B9%E9%85%8D%E7%8A%B6%E6%80%81%2C%E5%87%BA%E5%8F%A3%E8%A3%85%E8%BD%BD%2C%E5%87%BA%E5%8F%A3%E7%90"
+ "%86%E8%B4%A7%2C%E5%87%BA%E5%8F%A3%E6%8A%A5%E5%85%B3%E7%8A%B6%E6%80%81%2C%E6%8F%90%E5%8D%95%E6%94%BE%"
+ "E8%A1%8C%2C%E8%BD%AC%E5%8F%91%E7%8A%B6%E6%80%81&hdChildHide=&hdColsHide=&hdColSpan=%E6%8F%90%E5%8D%95"
+ "%E5%8F%B7&hdMutiQuery=&hdReturnResult=&hdLoadMarkText=&hdArrivalMarkText=&hdEmptyResult=&hdTalMarkText=&hdBillRelStatus=",
Method = "POST",//URL 可选项 默认为Get
};
resulthtml = http.GetHtml(item);
resulthtml.Html = resulthtml.Html.Replace("../Css/NewMftQueryStyle.css", "http://56.qdcdc.com/cnm/Css/NewMftQueryStyle.css");
result.Data = resulthtml.Html;
var datahtml = GetDataHtmlList(resulthtml.Html, "id=\"tbData\"", "</table>");
datahtml = datahtml.Remove(datahtml.IndexOf("</tr>"), 5);
datahtml = datahtml.Remove(0, datahtml.IndexOf(">") + 1);
if (datahtml != "")
{
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr") + 3);
recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
recdatastr = recdatastr.Replace(" ", "");
recdatastr = recdatastr.Replace("/r/n ", "");
var fieldno = 1;
var istrue = false;
if (i != 1 && i != 2 && (recdatastr.Length > 40))
{
MsOpSeaeCustomStatus data = new MsOpSeaeCustomStatus();
while (recdatastr.IndexOf("<td") >= 0)
{
var fieldlength = recdatastr.IndexOf("</td>");
var fielddatastr = recdatastr.Substring(0, fieldlength + 5);
recdatastr = recdatastr.Substring(fieldlength + 5, recdatastr.Length - fieldlength - 5);
fielddatastr = fielddatastr.Remove(fielddatastr.IndexOf("</td>"), 5);
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
fielddatastr = fielddatastr.Replace("\r\n", "");
fielddatastr = fielddatastr.Replace(" ", "");
if (fieldno == 1)
{
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
if (fielddatastr == "合计:" || fielddatastr == "<bstyle=\"color:Red\">暂无相关数据</b>") istrue = false; else istrue = true;
}
if (fieldno == 11)
{
data.PREPAREDSTR = fielddatastr;//箱号
}
if (fieldno == 12)
{
if (fielddatastr.IndexOf("接受申报") >= 0)
data.ISPREPARED = true;//箱号
}
if (fieldno == 13)
{
data.ARRIVALSTR = fielddatastr;//箱号
}
if (fieldno == 14)
{
if (fielddatastr.IndexOf("运抵正常") >= 0)
data.ISARRIVAL = true;//箱号
}
if (fieldno == 15)
{
if (fielddatastr.IndexOf("单证放行") >= 0)
{
data.ISCUSTOMCLEAR = true;//箱号
data.CUSTOMCLEARSTR = fielddatastr.Replace("单证放行", "");
}
}
if (fieldno == 16)
{
data.BILLCLEARSTR = fielddatastr;//箱号
}
if (fieldno == 17)
{
if (fielddatastr.IndexOf("已放行") >= 0)
data.ISBILLCLEAR = true;//箱号
}
if (fieldno == 19)
{
data.LOADCLEARSTR = fielddatastr;//箱号
}
if (fieldno == 20)
{
if (fielddatastr.IndexOf("同意装载") >= 0)
data.ISLOADCLEAR = true;//箱号
}
fieldno = fieldno + 1;
}
if (istrue)
bodyList.Add(data);
}
i = i + 1;
}
}
if (bodyList.Count != 0)
{
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var strSql = new StringBuilder();
strSql.Append("update op_apply set MANIFESTSTATUS=@MANIFESTSTATUS ");
strSql.Append(" where BSNO=@BSNO ");
var cmdupdate =
db.GetSqlStringCommand(strSql.ToString());
if (bodyList != null)
{
var manifeststatus = bodyList[0];
if (manifeststatus.ISPREPARED == false)
{
}
else
{
var statusref = "无状态";
var status = "0";
if (manifeststatus.ISLOADCLEAR)
{
status = "5";
statusref = "装载放行";
}
else if (manifeststatus.ISBILLCLEAR)
{
status = "4";
statusref = "提单放行";
}
else if (manifeststatus.ISCUSTOMCLEAR)
{
status = "3";
statusref = "报关放行";
}
else if (manifeststatus.ISARRIVAL)
{
status = "2";
statusref = "运抵正常";
}
else if (manifeststatus.ISPREPARED)
{
status = "1";
statusref = "预配舱单";
}
cmdupdate.Parameters.Clear();
db.AddInParameter(cmdupdate, "@MANIFESTSTATUS", DbType.String, status);
db.AddInParameter(cmdupdate, "@BSNO", DbType.String, bsno);
db.ExecuteNonQuery(cmdupdate);
result.Message = statusref;
}
}
}
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
return result;
}
static public MsOpSeaeCustomStatus GetManifestSTATUSList(string mblno, string bsno)
{
var bodyList = new List<MsOpSeaeCustomStatus>();
try
{
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://cdp.qdcdc.com/CDP/Login.aspx",//URL这里都是测试 必需项
Referer = "http://cdp.qdcdc.com/CDP/Login.aspx",
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "56.qdcdc.com",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",
Postdata = "__VIEWSTATE=%2FwEPDwULLTE2NDY3NDYxOTEPFgIeCWF1dGhMZXZlbAIBZGQFDBMiaM5jeSqYOP96II7WoW0oyc%2BSfvVv%2FGIrZ%2FP5bg%3D%3D&__EVENTVALIDATION=%2FwEWAgLO2Kj0DALLr40TnsCiM32qLiMK44G5moITtUwkOOjKlsY5RQB7pzBatDk%3D&user_name=user1&password=88888888&hdSuccess=true",
Method = "POST",//URL 可选项 默认为Get
};
HttpResult resulthtml = http.GetHtml(item);
var mycookie = resulthtml.Cookie;
http = new HttpHelper();
item = new HttpItem()
{
URL = "http://cdp.qdcdc.com/CDP/MftQuery/BillExportQuery.aspx",//URL这里都是测试 必需项
Referer = "http://cdp.qdcdc.com/CDP/MftQuery/BillExportQuery.aspx",
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "cdp.qdcdc.com",
Cookie = mycookie,
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",
Postdata = "__VIEWSTATE=%2FwEPDwUKLTExMzU1MTk4OGRktjQbcTwrtROJIB0DnKW%2FD24wHlo1MdO2yN13vwaX7GI%3D"
+ "&__EVENTVALIDATION=%2FwEWGAK%2FttbiCQKj%2B6LoDwLooeTACQLu%2F%2Fi7CwLa9PCNDgLp7r6qDgLblJqhCgLV3JG"
+ "HCALkwOjWBQLD2Y%2F%2FAwKYnc6YDwLJ7LFVAuDmrTwCvf3v3AcCluH%2BPgKs37SpCwKqgp2pDQLZ1tnQDQLol%2BuuCQL"
+ "T4ZKcAQKklPGiDwLB043aDwLAkeEVAoba9d8KBTCeVFBSa01eOoxl%2FjKz%2Fc7CpJUHsEtTic89nJEP3hM%3D&txtIMO="
+ "&txtTransportName=&txtVoyageNo=&txtBillNo=" + mblno + "&LinkButtonQuery=%E6%9F%A5%E8%AF%A2&hdSelectRow="
+ "&hdData=&hdCols=%E5%BA%8F%E5%8F%B7%2C%E5%87%BA%E5%8F%A3%E6%8F%90%E5%8D%95%E5%8F%B7%2C%E8%BF%90%E8%BE"
+ "%93%E5%B7%A5%E5%85%B7%E4%BF%A1%E6%81%AF%2C%E6%80%BB%E5%8D%95%2F%E5%88%86%E5%8D%95%2C%E9%A2%84%E9%85%"
+ "8D%E8%88%B1%E5%8D%95%2C%E5%87%BA%E5%8F%A3%E8%BF%90%E6%8A%B5%E6%8A%A5%E5%91%8A%2C%E8%90%BD%E8%B4%A7%E"
+ "6%94%B9%E9%85%8D%E7%8A%B6%E6%80%81%2C%E5%87%BA%E5%8F%A3%E8%A3%85%E8%BD%BD%2C%E5%87%BA%E5%8F%A3%E7%90"
+ "%86%E8%B4%A7%2C%E5%87%BA%E5%8F%A3%E6%8A%A5%E5%85%B3%E7%8A%B6%E6%80%81%2C%E6%8F%90%E5%8D%95%E6%94%BE%"
+ "E8%A1%8C%2C%E8%BD%AC%E5%8F%91%E7%8A%B6%E6%80%81&hdChildHide=&hdColsHide=&hdColSpan=%E6%8F%90%E5%8D%95"
+ "%E5%8F%B7&hdMutiQuery=&hdReturnResult=&hdLoadMarkText=&hdArrivalMarkText=&hdEmptyResult=&hdTalMarkText=&hdBillRelStatus=",
Method = "POST",//URL 可选项 默认为Get
};
resulthtml = http.GetHtml(item);
var datahtml = GetDataHtmlList(resulthtml.Html, "id=\"tbData\"", "</table>");
datahtml = datahtml.Remove(datahtml.IndexOf("</tr>"), 5);
datahtml = datahtml.Remove(0, datahtml.IndexOf(">") + 1);
if (datahtml != "")
{
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr") + 3);
recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
recdatastr = recdatastr.Replace(" ", "");
recdatastr = recdatastr.Replace("/r/n ", "");
var fieldno = 1;
var istrue = false;
if (i != 1 && i != 2 && (recdatastr.Length > 40))
{
MsOpSeaeCustomStatus data = new MsOpSeaeCustomStatus();
while (recdatastr.IndexOf("<td") >= 0)
{
var fieldlength = recdatastr.IndexOf("</td>");
var fielddatastr = recdatastr.Substring(0, fieldlength + 5);
recdatastr = recdatastr.Substring(fieldlength + 5, recdatastr.Length - fieldlength - 5);
fielddatastr = fielddatastr.Remove(fielddatastr.IndexOf("</td>"), 5);
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
fielddatastr = fielddatastr.Replace("\r\n", "");
fielddatastr = fielddatastr.Replace(" ", "");
if (fieldno == 1)
{
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
if (fielddatastr == "合计:" || fielddatastr == "<bstyle=\"color:Red\">暂无相关数据</b>") istrue = false; else istrue = true;
}
if (fieldno == 11)
{
data.PREPAREDSTR = fielddatastr;//箱号
}
if (fieldno == 12)
{
if (fielddatastr.IndexOf("接受申报") >= 0)
data.ISPREPARED = true;//箱号
}
if (fieldno == 13)
{
data.ARRIVALSTR = fielddatastr;//箱号
}
if (fieldno == 14)
{
if (fielddatastr.IndexOf("运抵正常") >= 0)
data.ISARRIVAL = true;//箱号
}
if (fieldno == 15)
{
if (fielddatastr.IndexOf("单证放行") >= 0)
{
data.ISCUSTOMCLEAR = true;//箱号
data.CUSTOMCLEARSTR = fielddatastr.Replace("单证放行", "");
}
}
if (fieldno == 16)
{
data.BILLCLEARSTR = fielddatastr;//箱号
}
if (fieldno == 17)
{
if (fielddatastr.IndexOf("已放行") >= 0)
data.ISBILLCLEAR = true;//箱号
}
if (fieldno == 19)
{
data.LOADCLEARSTR = fielddatastr;//箱号
}
if (fieldno == 20)
{
if (fielddatastr.IndexOf("同意装载") >= 0)
data.ISLOADCLEAR = true;//箱号
}
fieldno = fieldno + 1;
}
if (istrue)
bodyList.Add(data);
}
i = i + 1;
}
}
}
catch
{
}
if (bodyList.Count > 0)
return bodyList[0];
return new MsOpSeaeCustomStatus();
}
#endregion
#region 修改
public static DBResult Modify(List<MsOpApply> bodyList, MsOpApply modifydata, string companyid)
{
var result = new DBResult();
var head = ChMonthCloseDAL.ChMonthCloseDAL.GetData("", companyid);
string errstr = "";
int i = 0;
var ACCDATESAMEETD = MsSysParamSetDAL.GetData("PARAMNAME='ACCDATESAMEETD'").PARAMVALUE;
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var strSql = new StringBuilder();
strSql.Append("update op_apply set bsno=bsno ");
if (modifydata.HBLNO != "" && modifydata.HBLNO != null)
strSql.Append(",HBLNO=@HBLNO");
if (modifydata.CUSTOMSER != "" && modifydata.CUSTOMSER != null)
strSql.Append(",CUSTOMSER=@CUSTOMSER");
if (modifydata.CUSTOMERNAME != "" && modifydata.CUSTOMERNAME != null)
strSql.Append(",CUSTOMERNAME=@CUSTOMERNAME");
if (modifydata.PORTLOAD != "" && modifydata.PORTLOAD != null)
strSql.Append(",PORTLOAD=@PORTLOAD");
if (modifydata.PORTDISCHARGE != "" && modifydata.PORTDISCHARGE != null)
strSql.Append(",PORTDISCHARGE=@PORTDISCHARGE");
if (modifydata.VESSEL != "" && modifydata.VESSEL != null)
strSql.Append(",VESSEL=@VESSEL");
if (modifydata.ISCLEAR != "" && modifydata.ISCLEAR != null)
strSql.Append(",ISCLEAR=@ISCLEAR");
if (modifydata.VOYNO != "" && modifydata.VOYNO != null)
strSql.Append(",VOYNO=@VOYNO");
if (modifydata.ETD != "" && modifydata.ETD != null)
{
strSql.Append(",ETD=@ETD");
if (ACCDATESAMEETD == "1") strSql.Append(",ACCDATE=@ACCDATE");
}
if (modifydata.ACCDATE != "" && modifydata.ACCDATE != null)
strSql.Append(",ACCDATE=@ACCDATE");
if (modifydata.CUSTOMDATE != "" && modifydata.CUSTOMDATE != null)
{
strSql.Append(",CUSTOMDATE=@CUSTOMDATE");
}
if (modifydata.CLEARCUSTOMDATE != "" && modifydata.CLEARCUSTOMDATE != null)
{
strSql.Append(",CLEARCUSTOMDATE=@CLEARCUSTOMDATE");
}
if (modifydata.SALE != "" && modifydata.SALE != null)
strSql.Append(",SALE=@SALE");
if (modifydata.OP != "" && modifydata.OP != null)
strSql.Append(",OP=@OP");
if (modifydata.BSSOURCE != "" && modifydata.BSSOURCE != null)
strSql.Append(",BSSOURCE=@BSSOURCE");
if (modifydata.CUSTOMTYPE != "" && modifydata.CUSTOMTYPE != null)
strSql.Append(",CUSTOMTYPE=@CUSTOMTYPE");
if (modifydata.SERVICE1=="true") strSql.Append(",IsSERVICE1='1'");
if (modifydata.SERVICE2 == "true") strSql.Append(",IsSERVICE2='1'");
if (modifydata.SERVICE3 == "true") strSql.Append(",IsSERVICE3='1'");
if (modifydata.SERVICE4 == "true") strSql.Append(",IsSERVICE4='1'");
if (modifydata.SERVICE5 == "true") strSql.Append(",IsSERVICE5='1'");
if (modifydata.SERVICE6 == "true") strSql.Append(",IsSERVICE6='1'");
if (modifydata.SERVICE7 == "true") strSql.Append(",IsSERVICE7='1'");
if (modifydata.SERVICE8 == "true") strSql.Append(",IsSERVICE8='1'");
if (modifydata.SERVICE9 == "true") strSql.Append(",IsSERVICE9='1'");
if (modifydata.SERVICE10 == "true") strSql.Append(",IsSERVICE10='1'");
if (modifydata.SERVICE11 == "true") strSql.Append(",IsSERVICE11='1'");
if (modifydata.SERVICE12 == "true") strSql.Append(",IsSERVICE12='1'");
if (modifydata.SERVICE13 == "true") strSql.Append(",IsSERVICE13='1'");
if (modifydata.SERVICE14 == "true") strSql.Append(",IsSERVICE14='1'");
if (modifydata.SERVICE15 == "true") strSql.Append(",IsSERVICE15='1'");
if (modifydata.SERVICE16 == "true") strSql.Append(",IsSERVICE16='1'");
strSql.Append(" where BSNO=@BSNO ");
var cmdupdate =
db.GetSqlStringCommand(strSql.ToString());
if (bodyList != null)
{
foreach (var enumValue in bodyList)
{
var opseae = GetData("BSNO='" + enumValue.BSNO + "'");
if (Convert.ToDateTime(head.PERIOD + "-01") > Convert.ToDateTime(enumValue.ACCDATE + "-01"))
{
if (errstr == "")
errstr = enumValue.CUSTNO + "此票所在业务已月末结账";
else
errstr = errstr + "," + enumValue.CUSTNO + "此票所在业务已月末结账";
}
else if (opseae.BSSTATUS)
{
if (errstr == "")
errstr = enumValue.CUSTNO + "此票所在业务已业务锁定";
else
errstr = errstr + "," + enumValue.CUSTNO + "此票所在业务已业务锁定";
}
else
{
cmdupdate.Parameters.Clear();
if (modifydata.HBLNO != "" && modifydata.HBLNO != null)
db.AddInParameter(cmdupdate, "@HBLNO", DbType.String, modifydata.HBLNO);
if (modifydata.CUSTOMSER != "" && modifydata.CUSTOMSER != null)
db.AddInParameter(cmdupdate, "@CUSTOMSER", DbType.String, modifydata.CUSTOMSER);
if (modifydata.CUSTOMERNAME != "" && modifydata.CUSTOMERNAME != null)
db.AddInParameter(cmdupdate, "@CUSTOMERNAME", DbType.String, modifydata.CUSTOMERNAME);
if (modifydata.PORTLOAD != "" && modifydata.PORTLOAD != null)
db.AddInParameter(cmdupdate, "@PORTLOAD", DbType.String, modifydata.PORTLOAD);
if (modifydata.PORTDISCHARGE != "" && modifydata.PORTDISCHARGE != null)
db.AddInParameter(cmdupdate, "@PORTDISCHARGE", DbType.String, modifydata.PORTDISCHARGE);
if (modifydata.VESSEL != "" && modifydata.VESSEL != null)
db.AddInParameter(cmdupdate, "@VESSEL", DbType.String, modifydata.VESSEL);
if (modifydata.ISCLEAR!= "" && modifydata.ISCLEAR != null)
db.AddInParameter(cmdupdate, "@ISCLEAR", DbType.String, modifydata.ISCLEAR);
if (modifydata.VOYNO != "" && modifydata.VOYNO != null)
db.AddInParameter(cmdupdate, "@VOYNO", DbType.String, modifydata.VOYNO);
if (modifydata.ETD != "" && modifydata.ETD != null)
{
db.AddInParameter(cmdupdate, "@ETD", DbType.String, modifydata.ETD);
if (ACCDATESAMEETD == "1")
{
var ACCDATE = Convert.ToDateTime(modifydata.ETD).ToString("yyyy-MM");
db.AddInParameter(cmdupdate, "@ACCDATE", DbType.String, ACCDATE);
}
}
if (modifydata.ACCDATE != "" && modifydata.ACCDATE != null)
db.AddInParameter(cmdupdate, "@ACCDATE", DbType.String, modifydata.ACCDATE);
if (modifydata.CUSTOMDATE != "" && modifydata.CUSTOMDATE != null)
{
db.AddInParameter(cmdupdate, "@CUSTOMDATE", DbType.String, modifydata.CUSTOMDATE);
}
if (modifydata.CLEARCUSTOMDATE != "" && modifydata.CLEARCUSTOMDATE != null)
{
db.AddInParameter(cmdupdate, "@CLEARCUSTOMDATE", DbType.String, modifydata.CLEARCUSTOMDATE);
}
if (modifydata.SALE != "" && modifydata.SALE != null)
db.AddInParameter(cmdupdate, "@SALE", DbType.String, modifydata.SALE);
if (modifydata.OP != "" && modifydata.OP != null)
db.AddInParameter(cmdupdate, "@OP", DbType.String, modifydata.OP);
if (modifydata.BSSOURCE != "" && modifydata.BSSOURCE != null)
db.AddInParameter(cmdupdate, "@BSSOURCE", DbType.String, modifydata.BSSOURCE);
if (modifydata.CUSTOMTYPE != "" && modifydata.CUSTOMTYPE != null)
db.AddInParameter(cmdupdate, "@CUSTOMTYPE", DbType.String, modifydata.CUSTOMTYPE);
db.AddInParameter(cmdupdate, "@BSNO", DbType.String, enumValue.BSNO);
db.ExecuteNonQuery(cmdupdate, tran);
i = i + 1;
}
}
}
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "修改出现错误,请重试或联系系统管理员";
return result;
}
}
result.Success = true;
result.Message = "修改成功" + i.ToString() + "票";
if (errstr != "")
{
result.Message = result.Message + "(其中" + errstr + " 无法修改)";
}
return result;
}
#endregion
#region 参照部分
/// <summary>
///
/// </summary>
/// <param name="tb"></param>
/// <param name="userid">用于在VW_User_Authority中查询权限</param>
/// <param name="username">用于产生查询子句</param>
/// <param name="companyid"></param>
/// <returns></returns>
public static string GetRangDAStr(string tb, string userid, string username, string companyid)
{
string str = "";
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append(" VISIBLERANGE,OPERATERANGE,AUTHORITYID,VSSQL ");
strSql.Append(" from VW_User_Authority ");
strSql.Append(" where [NAME]='modOpApplyOpwt' and USERID='" + userid + "' and ISDELETE=0");
string visiblerange = "4";
string operaterange = "4";
string AUTHORITYID = "";
string VSSQL = "";
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
visiblerange = Convert.ToString(reader["VISIBLERANGE"]);
operaterange = Convert.ToString(reader["OPERATERANGE"]);
AUTHORITYID = Convert.ToString(reader["AUTHORITYID"]);
VSSQL = Convert.ToString(reader["VSSQL"]);
break;
}
reader.Close();
}
if (visiblerange == "4")
{
str = " (OP='" + username + "' OR INPUTBY='"+username+ "' OR CUSTSERVICE='" + username + "')";
}
else if (visiblerange == "3")
{
str = " (OP='" + username + "' OR INPUTBY='" + username + "' OR CUSTSERVICE='" + username + "')";
}
else if (visiblerange == "2")
{
var rangeDa = new RangeDA();
var deptid = rangeDa.GetDEPTGID(userid);
str = " (OP in (select SHOWNAME from vw_user where deptgid='" + deptid + "') OR INPUTBY in (select SHOWNAME from vw_user where deptgid='" + deptid + "') OR CUSTSERVICE in (select SHOWNAME from vw_user where deptgid='" + deptid + "') ) ";
}
else if (visiblerange == "1")
{
str = " (UPPER(Corpid)='" + companyid + "' or SALECORPID='" + companyid + "') ";
}
else if (visiblerange == "5")
{
if (tb == "index")
{
var userstr = new StringBuilder();
userstr.Append(" select COMPANYID from user_authority_range_company where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1");
Database userdb = DatabaseFactory.CreateDatabase();
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
{
str = "";
while (reader.Read())
{
if (str == "")
{
str = " (B.Corpid='" + Convert.ToString(reader["COMPANYID"]) + "'";
}
else
{
str = str + " or B.Corpid='" + Convert.ToString(reader["COMPANYID"]) + "' ";
};
}
str = str + ")";
reader.Close();
}
}
else
{
str = " (UPPER(B.Corpid)='" + companyid + "') ";
}
}
else if (visiblerange == "6")
{
if (tb == "index")
{
var userstr = new StringBuilder();
userstr.Append(" select OPID,(select SHOWNAME from [user] where GID=user_authority_range_op.OPID) SHOWNAME from user_authority_range_op where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1");
Database userdb = DatabaseFactory.CreateDatabase();
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
{
str = "";
while (reader.Read())
{
if (str == "")
{
str = " (OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR INPUTBY='" + Convert.ToString(reader["SHOWNAME"]) + "' OR CUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "'";
}
else
{
str = str + " or OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR INPUTBY='" + Convert.ToString(reader["SHOWNAME"]) + "' OR CUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "'";
};
}
str = str + ")";
reader.Close();
}
}
else
{
str = " (UPPER(B.Corpid)='" + companyid + "') ";
}
}
else if (visiblerange == "0")
{
str = " 1=1 ";
}
VSSQL = VSSQL.Trim();
if (!string.IsNullOrEmpty(VSSQL))
{
if (!string.IsNullOrEmpty(str))
{
str = str + " and (" + VSSQL + ") ";
}
else
{
str = " (" + VSSQL + ") ";
}
}
return str;
}
#endregion
}
}