using System; using System.Data; using System.Collections.Generic; using System.Text; using DSWeb.Areas.Import.Models.CWAdvancePayment; using DSWeb.Areas.Import.Models.XXH; using Microsoft.Practices.EnterpriseLibrary.Data; using HcUtility.Comm; using HcUtility.Core; using DSWeb.Areas.CommMng.Models; using DSWeb.MvcShipping.DAL.MsBaseInfoDAL; using DSWeb.Areas.CommMng.DAL; namespace DSWeb.Areas.Import.DAL.CW { public partial class CWAdvancePaymentDAL { #region GetDataList static public List GetDataList(string strCondition,string userid) { string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(userid); var strSql = new StringBuilder(); strSql.Append(" SELECT ap.gid,ap.linkgid,ap.billno,ap.CUSTOMERNAME,ap.currency,convert(numeric(18,2),ap.amount) amount,convert(numeric(18,2),ap.doamount) doamount "); strSql.Append(" ,convert(numeric(18,2),(ap.amount-ap.doamount)) REMAIN,ap.CREATEUSER,ISNULL(ap.BLSTATUS,'新建') BLSTATUS, "); strSql.Append(" dbo.trimdate(ap.CREATETIME) CREATETIME,ap.REMARK, "); strSql.Append(" (select top 1 showname from [user] where gid=ap.createuser) CREATEUSERREF,ap.COMPANYID, "); strSql.Append(" (select top 1 NAME from [company] where gid=ap.companyid) COMPANYREF, "); strSql.Append(" ap.feetype,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99020 and EnumValueID=ap.Feetype) FEETYPEREF, "); strSql.Append(" case ISFINISH when 0 then '否' else '是' end ISFINISHREF,BANKACCID, "); strSql.Append(" (CASE WHEN ISNULL((select top 1 VOUALLNO from cw_vouno_bs_gl WITH(NOLOCK) where BSGID=ap.billno and BSTABLENAME='ch_fee_advance_payment'),'')='' THEN '否' ELSE '是' end) ISVOU,"); strSql.Append(" VOUCHERNO=(select top 1 VOUALLNO from cw_vouno_bs_gl WITH(NOLOCK) where BSGID=ap.billno and BSTABLENAME='ch_fee_advance_payment' and STARTGID='" + strCwSTARTGID + "'),"); strSql.Append(" (select top 1 ACCNAME from [cw_accitems] where ACCID=ap.BANKACCID) BANKACCIDNAME,EXCHANGERATE,REASON "); strSql.Append(" ,isnull((select sum(DoAmount) from SalesAdvancePay_state where AD_BILLNO=ap.BILLNO),0) RKAmount"); strSql.Append(" FROM ch_fee_advance_payment ap "); strSql.Append(" where ap.isdelete=0 "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" and " + strCondition); } /* strSql.Append(" union all "); strSql.Append(" select 'zzzz','','zzzz','总计','',sum(amount),sum(doamount),sum(amount-doamount),'','','','','','','',0,'','','','','',0 from ch_fee_advance_payment ap"); strSql.Append(" where ap.isdelete=0 "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" and " + strCondition); }*/ strSql.Append(" order by billno "); return SetData(strSql); } static public string GetDataListStr(string strCondition, string userid) { string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(userid); var strSql = new StringBuilder(); strSql.Append(" SELECT ap.gid,ap.linkgid,ap.billno,ap.CUSTOMERNAME,ap.currency,convert(numeric(18,2),ap.amount) amount,convert(numeric(18,2),ap.doamount) doamount "); strSql.Append(" ,convert(numeric(18,2),(ap.amount-ap.doamount)) REMAIN,ap.CREATEUSER,ISNULL(ap.BLSTATUS,'新建') BLSTATUS, "); strSql.Append(" dbo.trimdate(ap.CREATETIME) CREATETIME,ap.REMARK, "); strSql.Append(" (select top 1 showname from [user] where gid=ap.createuser) CREATEUSERREF,ap.COMPANYID, "); strSql.Append(" (select top 1 NAME from [company] where gid=ap.companyid) COMPANYREF, "); strSql.Append(" ap.feetype,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99020 and EnumValueID=ap.Feetype) FEETYPEREF, "); strSql.Append(" case ISFINISH when 0 then '否' else '是' end ISFINISHREF,BANKACCID, "); strSql.Append(" (CASE WHEN ISNULL((select top 1 VOUALLNO from cw_vouno_bs_gl WITH(NOLOCK) where BSGID=ap.billno and BSTABLENAME='ch_fee_advance_payment'),'')='' THEN '否' ELSE '是' end) ISVOU,"); strSql.Append(" VOUCHERNO=(select top 1 VOUALLNO from cw_vouno_bs_gl WITH(NOLOCK) where BSGID=ap.billno and BSTABLENAME='ch_fee_advance_payment' and STARTGID='" + strCwSTARTGID + "'),"); strSql.Append(" (select top 1 ACCNAME from [cw_accitems] where ACCID=ap.BANKACCID) BANKACCIDNAME,EXCHANGERATE,REASON "); strSql.Append(" ,isnull((select sum(DoAmount) from SalesAdvancePay_state where AD_BILLNO=ap.BILLNO),0) RKAmount"); strSql.Append(" FROM ch_fee_advance_payment ap "); strSql.Append(" where ap.isdelete=0 "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" and " + strCondition); } /* strSql.Append(" union all "); strSql.Append(" select 'zzzz','','zzzz','总计','',sum(amount),sum(doamount),sum(amount-doamount),'','','','','','','',0,'','','','','',0 from ch_fee_advance_payment ap"); strSql.Append(" where ap.isdelete=0 "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" and " + strCondition); }*/ strSql.Append(" order by CUSTOMERNAME "); return strSql.ToString(); } static public CWAdvancePayment GetData(string condition,string userid) { var list = GetDataList(condition, userid); if (list.Count > 0) return list[0]; return new CWAdvancePayment(); } private static List SetData(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { CWAdvancePayment data = new CWAdvancePayment(); #region Set DB data to Object data.GID = Convert.ToString(reader["GID"]); data.LINKGID = Convert.ToString(reader["LINKGID"]); data.BILLNO = Convert.ToString(reader["BILLNO"]); data.BLSTATUS = Convert.ToString(reader["BLSTATUS"]); data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]); data.CURRENCY = Convert.ToString(reader["CURRENCY"]); data.AMOUNT = Convert.ToString(reader["AMOUNT"]); data.DOAMOUNT = Convert.ToString(reader["DOAMOUNT"]); data.REMAIN = Convert.ToString(reader["REMAIN"]); data.CREATEUSER = Convert.ToString(reader["CREATEUSER"]); data.CREATETIME = Convert.ToString(reader["CREATETIME"]); //data.SETTLEUSER = Convert.ToString(reader["SETTLEUSER"]); //data.SETTLETIME = Convert.ToString(reader["SETTLETIME"]); data.REMARK = Convert.ToString(reader["REMARK"]); //data.ISDELETE = Convert.ToString(reader["ISDELETE"]); //data.DELETEUSER = Convert.ToString(reader["DELETEUSER"]); //data.DELETETIME = Convert.ToString(reader["DELETETIME"]); //data.ISFINISH = Convert.ToString(reader["ISFINISH"]); data.EXCHANGERATE = Convert.ToString(reader["EXCHANGERATE"]); data.COMPANYID = Convert.ToString(reader["COMPANYID"]); data.VOUCHERNO = Convert.ToString(reader["VOUCHERNO"]); data.ISVOU = Convert.ToString(reader["ISVOU"]); data.BANKACCID = Convert.ToString(reader["BANKACCID"]); data.BANKACCIDNAME = Convert.ToString(reader["BANKACCIDNAME"]); data.CREATEUSERREF = Convert.ToString(reader["CREATEUSERREF"]); data.COMPANYREF = Convert.ToString(reader["COMPANYREF"]); data.FEETYPE = Convert.ToString(reader["FEETYPE"]); data.FEETYPEREF = Convert.ToString(reader["FEETYPEREF"]); data.ISFINISHREF = Convert.ToString(reader["ISFINISHREF"]); data.REASON = Convert.ToString(reader["REASON"]); data.RKAMOUNT = Convert.ToString(reader["RKAMOUNT"]); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region GetDataList static public List GetDataList_Import ( string strCondition ) { var strSql = new StringBuilder(); strSql.Append(" SELECT ap.gid,ap.linkgid,ap.billno,ap.CUSTOMERNAME,ap.currency,convert(numeric(18,2),ap.amount) amount,convert(numeric(18,2),ap.doamount) doamount "); strSql.Append(" ,convert(numeric(18,2),(ap.amount-ap.doamount)) REMAIN,ap.CREATEUSER,ap.BLSTATUS, "); strSql.Append(" dbo.trimdate(ap.CREATETIME) CREATETIME,ap.VOUCHERNO,ap.REMARK, "); strSql.Append(" (select showname from [user] where gid=ap.createuser) CREATEUSERREF,ap.COMPANYID, "); strSql.Append(" (select NAME from [company] where gid=ap.companyid) COMPANYREF, "); strSql.Append(" ap.feetype,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=21 and EnumValueID=ap.Feetype) FEETYPEREF, "); strSql.Append(" case ISFINISH when 0 then '否' else '是' end ISFINISHREF,case ap.ISVOU when 1 then '是' else '否' end as ISVOU,BANKACCID, "); strSql.Append(" (select top 1 ACCNAME from [cw_accitems] where ACCID=ap.BANKACCID) BANKACCIDNAME,EXCHANGERATE,REASON "); strSql.Append(" ,isnull((select sum(DoAmount) from SalesAdvancePay_state where AD_BILLNO=ap.BILLNO),0) RKAmount"); //strSql.Append(" ,ap.amount-isnull((select sum(DoAmount) from SalesAdvancePay_state where AD_BILLNO=ap.BILLNO),0) UnRKAmount "); strSql.Append(" FROM ch_fee_advance_payment ap "); strSql.Append(" where ap.isdelete=0 "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" and " + strCondition); } /* strSql.Append(" union all "); strSql.Append(" select 'zzzz','','zzzz','总计','',sum(amount),sum(doamount),sum(amount-doamount),'','','','','','','',0,'','','','','',0 from ch_fee_advance_payment ap"); strSql.Append(" where ap.isdelete=0 "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" and " + strCondition); }*/ strSql.Append(" order by billno "); return SetData_Import(strSql); } private static List SetData_Import ( StringBuilder strSql ) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { CWAdvancePayment data = new CWAdvancePayment(); #region Set DB data to Object data.GID = Convert.ToString(reader["GID"]); data.LINKGID = Convert.ToString(reader["LINKGID"]); data.BILLNO = Convert.ToString(reader["BILLNO"]); data.BLSTATUS = Convert.ToString(reader["BLSTATUS"]); data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]); data.CURRENCY = Convert.ToString(reader["CURRENCY"]); data.AMOUNT = Convert.ToString(reader["AMOUNT"]); data.DOAMOUNT = Convert.ToString(reader["DOAMOUNT"]); data.REMAIN = Convert.ToString(reader["REMAIN"]); data.CREATEUSER = Convert.ToString(reader["CREATEUSER"]); data.CREATETIME = Convert.ToString(reader["CREATETIME"]); //data.SETTLEUSER = Convert.ToString(reader["SETTLEUSER"]); //data.SETTLETIME = Convert.ToString(reader["SETTLETIME"]); data.REMARK = Convert.ToString(reader["REMARK"]); //data.ISDELETE = Convert.ToString(reader["ISDELETE"]); //data.DELETEUSER = Convert.ToString(reader["DELETEUSER"]); //data.DELETETIME = Convert.ToString(reader["DELETETIME"]); //data.ISFINISH = Convert.ToString(reader["ISFINISH"]); data.EXCHANGERATE = Convert.ToString(reader["EXCHANGERATE"]); data.COMPANYID = Convert.ToString(reader["COMPANYID"]); data.VOUCHERNO = Convert.ToString(reader["VOUCHERNO"]); data.ISVOU = Convert.ToString(reader["ISVOU"]); data.BANKACCID = Convert.ToString(reader["BANKACCID"]); data.BANKACCIDNAME = Convert.ToString(reader["BANKACCIDNAME"]); data.CREATEUSERREF = Convert.ToString(reader["CREATEUSERREF"]); data.COMPANYREF = Convert.ToString(reader["COMPANYREF"]); data.FEETYPE = Convert.ToString(reader["FEETYPE"]); data.FEETYPEREF = Convert.ToString(reader["FEETYPEREF"]); data.ISFINISHREF = Convert.ToString(reader["ISFINISHREF"]); data.REASON = Convert.ToString(reader["REASON"]); data.RKAMOUNT = Convert.ToString(reader["RKAMOUNT"]); data.UnRKAMOUNT = Convert.ToString(Convert.ToDecimal(reader["AMOUNT"]) - Convert.ToDecimal(reader["RKAMOUNT"])); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region GetBodyList static public List GetBodyList(string strCondition) { var strSql = new StringBuilder(); strSql.Append(" SELECT apd.*, "); strSql.Append(" (select showname from [user] where gid=apd.SETTLEUSER) SETTLEUSERREF, "); strSql.Append(" (select NAME from [company] where gid=apd.companyid) COMPANYREF "); strSql.Append(" FROM ch_fee_advance_payment_detail apd "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where BILLNO='" + strCondition+"'"); } return SetBodyData(strSql); } static public List GetBodyList2(string strCondition) { var strSql = new StringBuilder(); strSql.Append(" SELECT apd.*, "); strSql.Append(" (select showname from [user] where gid=apd.SETTLEUSER) SETTLEUSERREF, "); strSql.Append(" (select NAME from [company] where gid=apd.companyid) COMPANYREF "); strSql.Append(" FROM ch_fee_advance_payment_detail apd "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition ); } return SetBodyData(strSql); } static public CWAdvancePaymentBody GetBodyData(string condition) { var list = GetBodyList(condition); if (list.Count > 0) return list[0]; return new CWAdvancePaymentBody(); } private static List SetBodyData(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { CWAdvancePaymentBody data = new CWAdvancePaymentBody(); #region Set DB data to Object data.GID = Convert.ToString(reader["GID"]); data.LINKGID = Convert.ToString(reader["LINKGID"]); data.BILLNO = Convert.ToString(reader["BILLNO"]); data.SETTLELINKGID = Convert.ToString(reader["SETTLELINKGID"]); data.SETTLEBILLNO = Convert.ToString(reader["SETTLEBILLNO"]); data.FEETYPE = Convert.ToString(reader["FEETYPE"]); data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]); data.CURRENCY = Convert.ToString(reader["CURRENCY"]); data.DOAMOUNT = Convert.ToString(reader["DOAMOUNT"]); data.SETTLEUSER = Convert.ToString(reader["SETTLEUSER"]); data.SETTLETIME = Convert.ToString(reader["SETTLETIME"]); data.REMARK = Convert.ToString(reader["REMARK"]); data.ISDELETE = Convert.ToString(reader["ISDELETE"]); data.DELETEUSER = Convert.ToString(reader["DELETEUSER"]); data.DELETETIME = Convert.ToString(reader["DELETETIME"]); data.COMPANYID = Convert.ToString(reader["COMPANYID"]); data.VOUCHERNO = Convert.ToString(reader["VOUCHERNO"]); data.SETTLEUSERREF = Convert.ToString(reader["SETTLEUSERREF"]); data.COMPANYREF = Convert.ToString(reader["COMPANYREF"]); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion static public List GetAuditDataList ( string strCondition, string sort, string USERID ) { //合同信息/商品信息 var strSql = new StringBuilder(); //var isopen = MsBaseInfoDAL.GetUserModuleEnable("modFeenotopen", USERID); strSql.Append(" SELECT M.[id],M.[ContractNo],[HTH],[seller],M.[company],comp.name as companyname,[buyer],[STT], "); strSql.Append(" M.[countryid],[creator],[Auditor],[MainState],[printed],[AutoAPP],dbo.F_YN(convert(int,AutoAPP)) AutoAPPRef, "); strSql.Append(" dbo.F_YN(convert(int,printed)) printedRef, [ShipCompany_id], [BillNo] ,[BillType],[Vessel],[Voyage], "); strSql.Append(" convert(varchar,dbo.trimdate(BillTime),23) BillTime, convert(varchar,dbo.trimdate(Ex_sailingdate),23) Ex_sailingdate, "); strSql.Append(" convert(varchar,dbo.trimdate(m.Sailingdate),23) Sailingdate, convert(varchar,dbo.trimdate(ArrivalDate),23) ArrivalDate, "); strSql.Append(" [ContainerNo],[SealNo],[TransactionMethod],[PaymentMethods],[SecurityDeposit],dbo.F_str(M.contractno) name, "); strSql.Append(" dbo.trimdate(CustomsReleaseDate) CustomsReleaseDate,convert(varchar,dbo.trimdate(SamplingDate_Plan),23) SamplingDate_Plan, "); strSql.Append(" convert(varchar,dbo.trimdate(SamplingDate_Act),23) SamplingDate_Act,convert(varchar,dbo.trimdate(inspection_Signup_date),23) inspection_Signup_date,[inspection_no], "); strSql.Append(" convert(varchar,dbo.trimdate(inspection_date),23) inspection_date,c.country,convert(bigint ,M.TimeMark) as TimeMark , "); strSql.Append(" convert(varchar,dbo.trimdate(creattime),23) creattime , convert(varchar,dbo.trimdate(Audittime),23) Audittime , "); strSql.Append(" Freetime,CIQ_licence,CIQ_canbesearch,dbo.F_YN(convert(int,CIQ_canbesearch)) CIQ_canbesearchRef , "); strSql.Append(" convert(varchar,dbo.trimdate(tax_date),23) tax_date , convert(varchar,dbo.trimdate(tax_paydate),23) tax_paydate , "); strSql.Append(" (select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=3 and EnumValueID=M.MainState) as MainStateRef, "); strSql.Append(" (select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=10 and EnumValueID=M.port) as portRef, "); strSql.Append(" (select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=5 and EnumValueID=M.ShipCompany_id) as ShipCompanyRef, "); strSql.Append(" M.port, M.remark,M.Writeoffs,M.ReceiptStatus,M.Receiptremark,dbo.F_YN(convert(int,ReceiptStatus)) ReceiptStatusRef, "); strSql.Append(" dbo.F_YN(convert(int,Writeoffs)) WriteoffsRef ,M.OwnApp,M.FinanceStatus,M.remark_2,M.remark_3,M.remark_4, "); strSql.Append(" M.Sampling_need,M.DeclareNumber,M.Inspection_Storage,M.DeliveryAddress,M.Contacter,M.Tel,M.Overfilled, "); strSql.Append(" convert(varchar,dbo.trimdate(Paydate),23) Paydate, convert(varchar,dbo.trimdate(M.E_Billtime),23) E_Billtime , "); strSql.Append(" convert(varchar,dbo.trimdate(HDtime),23) HDtime ,convert(varchar,dbo.trimdate(DeliveryDate),23) DeliveryDate , "); strSql.Append(" dbo.f_FactoryNo(M.contractno) FactoryNo,dbo.f_count(M.contractno) boxcount, "); strSql.Append(" dbo.f_pay_Amount_single(m.contractno) amount,dbo.f_weight(M.contractno) [weight], "); strSql.Append(" dbo.f_price(M.contractno) price,dbo.f_validdate(M.contractno) validdate, "); strSql.Append(" '' cicode,'' ciname,'' AppNo ,M.TRADINGAGENCY"); strSql.Append(" ,vx.FHPROFIT,vx.LCPROFIT,vx.OTPROFIT,vx.HK_profit,vx.RZ_profit "); strSql.Append(" ,(select sum(f1.amount*f1.exchangerate) from ch_fee f1 where f1.feetype=1 and f1.bsno=m.contractno and feestatus in (0,1,2,8,9,11)) -(select sum(f1.amount*f1.exchangerate) from ch_fee f1 where f1.feetype=2 and f1.bsno=m.contractno and feestatus in (0,1,2,8,9,11) "); /* if (isopen == false) { strSql.Append(" and (ISOPEN=0 or EnteroPerator='" + USERID + "')"); } strSql.Append(" ) "); strSql.Append(" -(select sum(f1.amount*f1.exchangerate) from ch_fee f1 where f1.feetype=2 and f1.bsno=m.contractno and feestatus in (0,1,2,8,9) "); if (isopen == false) { strSql.Append(" and (ISOPEN=0 or EnteroPerator='" + USERID + "')"); }*/ strSql.Append(" ) as Maoli "); strSql.Append(" FROM [dbo].[Import_main] M left join code_country c on m.countryid=c.countryid "); strSql.Append(" left join company comp on comp.gid=M.company "); strSql.Append(" left join vxxhprofitsum vx on vx.bsno=M.contractno "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } var sortstring = DatasetSort.Getsortstring(sort); if (!string.IsNullOrEmpty(sortstring)) { strSql.Append(" order by " + sortstring); } return SetAuditData(strSql); } #region 合同列表 private static List SetAuditData(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { XXHmb data = new XXHmb(); #region Set DB data to Object data.name = Convert.ToString(reader["name"]); data.country = Convert.ToString(reader["country"]); data.weight = Convert.ToString(reader["weight"]); data.id = Convert.ToDecimal(reader["id"]); data.ContractNo = Convert.ToString(reader["ContractNo"]); data.HTH = Convert.ToString(reader["HTH"]); data.seller = Convert.ToString(reader["seller"]); data.companyname = Convert.ToString(reader["companyname"]); data.buyer = Convert.ToString(reader["buyer"]); data.STT = Convert.ToString(reader["STT"]); data.countryid = Convert.ToString(reader["countryid"]); data.creator = Convert.ToString(reader["creator"]); data.Auditor = Convert.ToString(reader["Auditor"]); data.Mainstate = Convert.ToString(reader["Mainstate"]); data.MainstateRef = Convert.ToString(reader["MainstateRef"]); data.Printed = Convert.ToString(reader["Printed"]); data.AutoAPP = Convert.ToString(reader["AutoAPP"]); data.ShipCompany_id = Convert.ToString(reader["ShipCompany_id"]); data.BillNo = Convert.ToString(reader["BillNo"]); data.BillType = Convert.ToString(reader["BillType"]); data.BillTime = Convert.ToString(reader["BillTime"]); data.Vessel = Convert.ToString(reader["Vessel"]); data.Voyage = Convert.ToString(reader["Voyage"]); data.Ex_sailingdate = Convert.ToString(reader["Ex_sailingdate"]); data.Sailingdate = Convert.ToString(reader["Sailingdate"]); data.ArrivalDate = Convert.ToString(reader["ArrivalDate"]); data.ContainerNo = Convert.ToString(reader["ContainerNo"]); data.SealNo = Convert.ToString(reader["SealNo"]); data.TransactionMethod = Convert.ToString(reader["TransactionMethod"]); data.PaymentMethods = Convert.ToString(reader["PaymentMethods"]); data.SecurityDeposit = Convert.ToString(reader["SecurityDeposit"]); data.SamplingDate_Plan = Convert.ToString(reader["SamplingDate_Plan"]); data.SamplingDate_Act = Convert.ToString(reader["SamplingDate_Act"]); data.CustomsReleaseDate = Convert.ToString(reader["CustomsReleaseDate"]); data.inspection_Signup_date = Convert.ToString(reader["inspection_Signup_date"]); data.inspection_no = Convert.ToString(reader["inspection_no"]); data.inspection_date = Convert.ToString(reader["inspection_date"]); data.TimeMark = Convert.ToDecimal(reader["TimeMark"]); data.cicode = Convert.ToString(reader["cicode"]); data.ciname = Convert.ToString(reader["ciname"]); data.company = Convert.ToString(reader["company"]); data.creattime = Convert.ToString(reader["creattime"]); data.Audittime = Convert.ToString(reader["Audittime"]); data.Freetime = Convert.ToString(reader["Freetime"]); data.CIQ_licence = Convert.ToString(reader["CIQ_licence"]); data.CIQ_canbesearch = Convert.ToString(reader["CIQ_canbesearch"]); data.CIQ_canbesearchRef = Convert.ToString(reader["CIQ_canbesearchRef"]); data.tax_date = Convert.ToString(reader["tax_date"]); data.tax_paydate = Convert.ToString(reader["tax_paydate"]); data.port = Convert.ToString(reader["port"]); data.remark = Convert.ToString(reader["remark"]); data.portRef = Convert.ToString(reader["portRef"]); data.AppNo = Convert.ToString(reader["AppNo"]); data.ValidDate = Convert.ToString(reader["ValidDate"]); data.Writeoffs = Convert.ToString(reader["Writeoffs"]); data.WriteoffsRef = Convert.ToString(reader["WriteoffsRef"]); data.AutoAPPRef = Convert.ToString(reader["AutoAPPRef"]); data.printedRef = Convert.ToString(reader["printedRef"]); data.ShipCompanyRef = Convert.ToString(reader["ShipCompanyRef"]); data.Paydate = Convert.ToString(reader["Paydate"]); data.E_Billtime = Convert.ToString(reader["E_Billtime"]); data.HDtime = Convert.ToString(reader["HDtime"]); data.FinanceStatus = Convert.ToString(reader["FinanceStatus"]); data.remark_2 = Convert.ToString(reader["remark_2"]); data.remark_3 = Convert.ToString(reader["remark_3"]); data.remark_4 = Convert.ToString(reader["remark_4"]); data.Sampling_need = Convert.ToString(reader["Sampling_need"]); data.DeclareNumber = Convert.ToString(reader["DeclareNumber"]); data.Inspection_Storage = Convert.ToString(reader["Inspection_Storage"]); data.DeliveryDate = Convert.ToString(reader["DeliveryDate"]); data.DeliveryAddress = Convert.ToString(reader["DeliveryAddress"]); data.Contacter = Convert.ToString(reader["Contacter"]); data.Tel = Convert.ToString(reader["Tel"]); data.Overfilled = Convert.ToString(reader["Overfilled"]); data.OwnApp = Convert.ToString(reader["OwnApp"]); data.ReceiptStatus = Convert.ToString(reader["ReceiptStatus"]); data.ReceiptStatusRef = Convert.ToString(reader["ReceiptStatusRef"]); data.Receiptremark = Convert.ToString(reader["Receiptremark"]); data.FactoryNo = Convert.ToString(reader["FactoryNo"]); //data.boxcount = Convert.ToString(reader["boxcount"]); //data.amount = Convert.ToString(reader["amount"]); data.weight = Convert.ToString(reader["weight"]); //data.price = Convert.ToString(reader["price"]); data.FHPROFIT = Convert.ToString(reader["FHPROFIT"]); data.LCPROFIT = Convert.ToString(reader["LCPROFIT"]); data.OTPROFIT = Convert.ToString(reader["OTPROFIT"]); data.RZ_profit = Convert.ToString(reader["RZ_profit"]); data.HK_profit = Convert.ToString(reader["HK_profit"]); data.Maoli = Convert.ToString(reader["Maoli"]); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 锁定 public static DBResult LockList(String bills) { var result = new DBResult(); var billList = bills.Split(','); Database db = DatabaseFactory.CreateDatabase(); using (var conn = db.CreateConnection()) { conn.Open(); var tran = conn.BeginTransaction(); try { foreach (var bill in billList) { var cmdupdate = db.GetSqlStringCommand("update ch_fee_advance_payment set BLSTATUS='锁定' where GID=@BILLNO"); cmdupdate.Parameters.Clear(); db.AddInParameter(cmdupdate, "@BILLNO", DbType.String, bill); db.ExecuteNonQuery(cmdupdate, tran); result = new DBResult(); result.Success = true; result.Message = "锁定成功"; } tran.Commit(); } catch (Exception) { tran.Rollback(); result.Success = false; result.Message = "锁定错误,请重试或联系系统管理员"; return result; } } return result; } public static DBResult UnLockList(String bills) { var result = new DBResult(); var billList = bills.Split(','); Database db = DatabaseFactory.CreateDatabase(); using (var conn = db.CreateConnection()) { conn.Open(); var tran = conn.BeginTransaction(); try { foreach (var bill in billList) { var cmdupdate = db.GetSqlStringCommand("update ch_fee_advance_payment set BLSTATUS='新建' where GID=@BILLNO"); cmdupdate.Parameters.Clear(); db.AddInParameter(cmdupdate, "@BILLNO", DbType.String, bill); db.ExecuteNonQuery(cmdupdate, tran); result = new DBResult(); result.Success = true; result.Message = "撤销锁定成功"; } tran.Commit(); } catch (Exception) { tran.Rollback(); result.Success = false; result.Message = "撤销锁定错误,请重试或联系系统管理员"; return result; } } return result; } #endregion #region 重新计算头表的doamount static public int ResetDoamount ( string BILLNO ) { var strSql = new StringBuilder(); strSql.Append(" update ch_fee_advance_payment set DOAMOUNT=isnull((select sum(isnull(doamount,0)) from ch_fee_advance_payment_detail where LINKGID=ch_fee_advance_payment.GID ),0) where BILLNO='" + BILLNO + "'"); var _count = 0; Database db = DatabaseFactory.CreateDatabase(); _count = db.ExecuteNonQuery(CommandType.Text, strSql.ToString()); return _count; } #endregion #region 参照部分 #endregion } }