using System; using System.Data; using System.Data.Common; using System.Collections; using System.Collections.Generic; using System.Text; using DSWeb.MvcShipping.Models.MsOpAire; using DSWeb.MvcShipping.Models.MsOpAireBill; using Microsoft.Practices.EnterpriseLibrary.Data; using DSWeb.EntityDA; using DSWeb.Areas.CommMng.Models; using HcUtility.Comm; using System.Data.SqlClient; using DSWeb.DataAccess; using System.IO; using HcUtility.Core; using DSWeb.Areas.CommMng.DAL; using DSWeb.MvcShipping.DAL.MsSysParamSet; using DSWeb.MvcShipping.Models.MsSeaeOrder; namespace DSWeb.MvcShipping.DAL.MsOpAireDAL { public class MsOpAireDAL { #region 查询 static public List GetDataList(int start, int limit, string strCondition, string userid, string usercode, string companyid,string sort = null,string load=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 * from (SELECT row_number() over ("); var sortstring = DatasetSort.Getsortstring(sort); if (!string.IsNullOrEmpty(sortstring)) { strSql.Append(" order by " + sortstring); } else { var SeaeDefaultSort = MsSysParamSetDAL.GetData("PARAMNAME='SeaeOrderDefaultSort'"); if (SeaeDefaultSort.PARAMVALUE != "") strSql.Append(" order by " + SeaeDefaultSort.PARAMVALUE); else strSql.Append(" order by BSDATE desc"); } strSql.Append(@") as num , "); //if (load == "true") //{ // strSql.Append("SELECT top 200 B.BSNO,MASTERNO,ORDERTYPE,ORDTYPE,ORDERNO,BSSTATUS,FEESTATUS,BSDATE,ACCDATE,MBLNO,HBLNO,CUSTNO,TRANSNO,CUSTOMERNAME,SHIPPERID,"); // strSql.Append("CONSIGNEEID,NOTIFYPARTYID,'' SHIPPER,'' CONSIGNEE,'' NOTIFYPARTY,AGENTID,'' AGENT,VESSEL,ETD,ETA,"); //} //else //{ // strSql.Append("SELECT B.BSNO,MASTERNO,ORDERTYPE,ORDTYPE,ORDERNO,BSSTATUS,FEESTATUS,BSDATE,ACCDATE,MBLNO,HBLNO,CUSTNO,TRANSNO,CUSTOMERNAME,BLTYPE,SHIPPERID,"); // strSql.Append("CONSIGNEEID,NOTIFYPARTYID,SHIPPER,CONSIGNEE,NOTIFYPARTY,AGENTID,AGENT,VESSEL,ETD,ETA,"); //} strSql.Append("B.BSNO,MASTERNO,ORDERTYPE,ORDTYPE,ORDERNO,BSSTATUS,FEESTATUS,BSDATE,ACCDATE,MBLNO,HBLNO,CUSTNO,TRANSNO,CUSTOMERNAME,SHIPPERID,"); strSql.Append("CONSIGNEEID,NOTIFYPARTYID, SHIPPER, CONSIGNEE, NOTIFYPARTY,AGENTID, AGENT,VESSEL,ETD,ETA,"); strSql.Append("PORTLOADID,PORTLOAD,PORTDISCHARGEID,PORTDISCHARGE,BLTYPE,ISSUETYPE,TRANSPORTID,TRANSPORT,TRANSPORT2ID,TRANSPORT2,TRANSPORT3ID,TRANSPORT3,"); strSql.Append("BLFRT,OTFRT,HBLBLFRT,HBLOTFRT,MARKS,[DESCRIPTION],GOODSNAME,PKGS,KINDPKGS,UNIT,"); strSql.Append("KGS,CBM,CURR,CUSTVALUE,CUSTOMVALUE,CLASS,FEEKGS,PRICE,TTLFREIGHT,OTFEE,HANDINGINFO,ACCOUNTINFO,"); strSql.Append("INPUTBY,OP,CUSTSERVICE,SALE,AIRLINES,TRANSAIRLINES,FORWARDER,CUSTOMSER,TRUCKER,INVNO,FRCUSTSERVICE,"); strSql.Append("CARGOID,BSSOURCE,BSSOURCEDETAIL,INSURANCEER,INSURANCENO,INAMOUT,"); strSql.Append("ISVOU,VOUNO,REMARK,CORPID,SALEDEPT,CREATETIME,STLNAME,STLDATE,"); strSql.Append("OPERATORCODE,OPERATOR,OPERATOREMAIL,OPERATORTEL,OPERATORFAX,"); strSql.Append("FINANCIALSTAFFCODE,FINANCIALSTAFF,FINANCIALSTAFFEMAIL,FINANCIALSTAFFTEL,FINANCIALSTAFFFAX"); strSql.Append(",OTFEE1,OTFEE1AMOUNT,OTFEE2,OTFEE2AMOUNT,OTFEE3,OTFEE3AMOUNT,OTFEE4,OTFEE4AMOUNT,OTFEE5,OTFEE5AMOUNT"); strSql.Append(",OTFEE6,OTFEE6AMOUNT,OTFEE7,OTFEE7AMOUNT,OTFEE8,OTFEE8AMOUNT"); strSql.Append(",PFREIGHT,CFREIGHT,PSTATEMENT,CSTATEMENT,PTAX,CTAX,POTFREIGHT,COTFREIGHT,PCARRIEROT,CCARRIEROT,PTOTAL,CTOTAL"); strSql.Append(",(SELECT TOP 1 BLSTATUS FROM op_blissue WHERE BSNO=B.BSNO) BLISSUESTATUS"); 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 TOP 1 STATUS FROM OP_STATUS WHERE BSNO=B.BSNO ORDER BY COMPTIME DESC,INPUTTIME DESC) as OPSTATUS "); strSql.Append(",CUSTOMNO,ENTERPID,ENTERP,INSPECTIONNO,INSPECTIONDATE,CUSTOMDATE,TRADETYPE,TRADETERM,ISSUEBY,ISSUEDATE,ISSUEPLACE"); strSql.Append(",IsService1,IsService2,IsService3,IsService4,IsService5,IsService6,IsService7,IsService8,IsService9,IsService10"); strSql.Append(",dbo.F_GetBillDrFeeStatus(B.BSNO) DRFEESTATUS"); strSql.Append(",dbo.F_GetBillCrFeeStatus(B.BSNO) CRFEESTATUS,ISPRINTPR"); strSql.Append(",I.TTLDR,I.TTLINVDR,I.TTLDUIDR"); strSql.Append(",(SELECT COUNT(*) FROM OP_APPLY WHERE MASTERNO=B.BSNO) as APPLYCOUNT,B.BillFeeStatus "); strSql.Append(",SALECORPID,(select [NAME] from [company] where GID=B.SALECORPID) as SALECORP,CONTRACTNO,LANE,DELIVERYDATE,DOC,HSCODE,ISCANCEL"); strSql.Append(" from OP_AIRE B"); strSql.Append(" LEFT JOIN v_op_gain_dr_INV I ON (I.BSNO=B.BSNO) "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where B.MASTERNO=B.BSNO AND EXISTS ( select 1 from OP_AIRE WHERE B.BSNO=OP_AIRE.MASTERNO AND " + strCondition + " )"); } else { strSql.Append(" where B.MASTERNO=B.BSNO "); } strSql.Append(@")as t "); strSql.Append(string.Format("where t.num>{0} and t.num<={1} order by t.num ", start, start + limit)); // //var sortstring = DatasetSort.Getsortstring(sort); //if (!string.IsNullOrEmpty(sortstring)) //{ // strSql.Append(" order by " + sortstring); //} //else //{ // var SeaeDefaultSort = MsSysParamSetDAL.GetData("PARAMNAME='AireDefaultSort'"); // if (SeaeDefaultSort.PARAMVALUE != "") // strSql.Append(" order by " + SeaeDefaultSort.PARAMVALUE ); // else // strSql.Append(" order by BSDATE desc"); //} return SetData(strSql); } static public List GetSaleDataList(int start, int limit, string strCondition, string username, string sort = null, string load = null,string userid="",string companyid="") { var rangstr = GetSaleRangDAStr("index", userid, username, companyid); if (!string.IsNullOrEmpty(rangstr)) { if (!string.IsNullOrEmpty(strCondition)) { strCondition = strCondition + " and " + rangstr; } else { strCondition = rangstr; } } var strSql = new StringBuilder(); strSql.Append(@"SELECT * from (SELECT row_number() over ("); var sortstring = DatasetSort.Getsortstring(sort); if (!string.IsNullOrEmpty(sortstring)) { strSql.Append(" order by " + sortstring); } else { var SeaeDefaultSort = MsSysParamSetDAL.GetData("PARAMNAME='SeaeOrderDefaultSort'"); if (SeaeDefaultSort.PARAMVALUE != "") strSql.Append(" order by " + SeaeDefaultSort.PARAMVALUE); else strSql.Append(" order by BSDATE desc"); } strSql.Append(@") as num , "); strSql.Append(" B.BSNO,MASTERNO,ORDERTYPE,ORDTYPE,ORDERNO,BSSTATUS,FEESTATUS,BSDATE,ACCDATE,MBLNO,HBLNO,CUSTNO,TRANSNO,CUSTOMERNAME,SHIPPERID,"); strSql.Append("CONSIGNEEID,NOTIFYPARTYID,SHIPPER,CONSIGNEE,NOTIFYPARTY,AGENTID,AGENT,VESSEL,ETD,ETA,"); strSql.Append("PORTLOADID,PORTLOAD,PORTDISCHARGEID,PORTDISCHARGE,TRANSPORTID,TRANSPORT,TRANSPORT2ID,TRANSPORT2,TRANSPORT3ID,TRANSPORT3,BLTYPE,ISSUETYPE,"); strSql.Append("BLFRT,OTFRT,HBLBLFRT,HBLOTFRT,MARKS,[DESCRIPTION],GOODSNAME,PKGS,KINDPKGS,UNIT,"); strSql.Append("KGS,CBM,CURR,CUSTVALUE,CUSTOMVALUE,CLASS,FEEKGS,PRICE,TTLFREIGHT,OTFEE,HANDINGINFO,ACCOUNTINFO,"); strSql.Append("INPUTBY,OP,CUSTSERVICE,SALE,AIRLINES,TRANSAIRLINES,FORWARDER,CUSTOMSER,TRUCKER,INVNO,FRCUSTSERVICE,"); strSql.Append("CARGOID,BSSOURCE,BSSOURCEDETAIL,INSURANCEER,INSURANCENO,INAMOUT,"); strSql.Append("ISVOU,VOUNO,REMARK,CORPID,SALEDEPT,CREATETIME,STLNAME,STLDATE,"); strSql.Append("OPERATORCODE,OPERATOR,OPERATOREMAIL,OPERATORTEL,OPERATORFAX,"); strSql.Append("FINANCIALSTAFFCODE,FINANCIALSTAFF,FINANCIALSTAFFEMAIL,FINANCIALSTAFFTEL,FINANCIALSTAFFFAX"); strSql.Append(",OTFEE1,OTFEE1AMOUNT,OTFEE2,OTFEE2AMOUNT,OTFEE3,OTFEE3AMOUNT,OTFEE4,OTFEE4AMOUNT,OTFEE5,OTFEE5AMOUNT"); strSql.Append(",OTFEE6,OTFEE6AMOUNT,OTFEE7,OTFEE7AMOUNT,OTFEE8,OTFEE8AMOUNT"); strSql.Append(",PFREIGHT,CFREIGHT,PSTATEMENT,CSTATEMENT,PTAX,CTAX,POTFREIGHT,COTFREIGHT,PCARRIEROT,CCARRIEROT,PTOTAL,CTOTAL"); strSql.Append(",(SELECT TOP 1 BLSTATUS FROM op_blissue WHERE BSNO=B.BSNO) BLISSUESTATUS"); 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 TOP 1 STATUS FROM OP_STATUS WHERE BSNO=B.BSNO ORDER BY COMPTIME DESC,INPUTTIME DESC) as OPSTATUS "); strSql.Append(",CUSTOMNO,ENTERPID,ENTERP,INSPECTIONNO,INSPECTIONDATE,CUSTOMDATE,TRADETYPE,TRADETERM,ISSUEBY,ISSUEDATE,ISSUEPLACE"); strSql.Append(",IsService1,IsService2,IsService3,IsService4,IsService5,IsService6,IsService7,IsService8,IsService9,IsService10"); strSql.Append(",dbo.F_GetBillDrFeeStatus(B.BSNO) DRFEESTATUS"); strSql.Append(",dbo.F_GetBillCrFeeStatus(B.BSNO) CRFEESTATUS,ISPRINTPR"); strSql.Append(",I.TTLDR,I.TTLINVDR,I.TTLDUIDR,0 APPLYCOUNT,B.BillFeeStatus "); strSql.Append(",SALECORPID,(select [NAME] from [company] where GID=B.SALECORPID) as SALECORP,CONTRACTNO,LANE,DELIVERYDATE,DOC,HSCODE,ISCANCEL"); strSql.Append(" from OP_AIRE B"); strSql.Append(" LEFT JOIN v_op_gain_dr_INV I ON (I.BSNO=B.BSNO) "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } strSql.Append(@")as t "); strSql.Append(string.Format("where t.num>{0} and t.num<={1} order by t.num ", start, start + limit)); //// //var sortstring = DatasetSort.Getsortstring(sort); //if (!string.IsNullOrEmpty(sortstring)) //{ // 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 B.BSNO,MASTERNO,ORDERTYPE,ORDTYPE,ORDERNO,BSSTATUS,FEESTATUS,BSDATE,ACCDATE,MBLNO,HBLNO,CUSTNO,TRANSNO,CUSTOMERNAME,SHIPPERID,"); strSql.Append("CONSIGNEEID,NOTIFYPARTYID,SHIPPER,CONSIGNEE,NOTIFYPARTY,AGENTID,AGENT,VESSEL,ETD,ETA,"); strSql.Append("PORTLOADID,PORTLOAD,PORTDISCHARGEID,PORTDISCHARGE,BLTYPE,ISSUETYPE,"); strSql.Append("BLFRT,OTFRT,HBLBLFRT,HBLOTFRT,MARKS,[DESCRIPTION],GOODSNAME,PKGS,KINDPKGS,UNIT,"); strSql.Append("KGS,CBM,CURR,CUSTVALUE,CUSTOMVALUE,CLASS,FEEKGS,PRICE,TTLFREIGHT,OTFEE,HANDINGINFO,ACCOUNTINFO,"); strSql.Append("INPUTBY,OP,CUSTSERVICE,SALE,AIRLINES,TRANSAIRLINES,FORWARDER,CUSTOMSER,TRUCKER,INVNO,FRCUSTSERVICE,"); strSql.Append("CARGOID,BSSOURCE,BSSOURCEDETAIL,INSURANCEER,INSURANCENO,INAMOUT,"); strSql.Append("ISVOU,VOUNO,REMARK,CORPID,SALEDEPT,CREATETIME,STLNAME,STLDATE,"); strSql.Append("OPERATORCODE,OPERATOR,OPERATOREMAIL,OPERATORTEL,OPERATORFAX,"); strSql.Append("FINANCIALSTAFFCODE,FINANCIALSTAFF,FINANCIALSTAFFEMAIL,FINANCIALSTAFFTEL,FINANCIALSTAFFFAX"); strSql.Append(",OTFEE1,OTFEE1AMOUNT,OTFEE2,OTFEE2AMOUNT,OTFEE3,OTFEE3AMOUNT,OTFEE4,OTFEE4AMOUNT,OTFEE5,OTFEE5AMOUNT"); strSql.Append(",OTFEE6,OTFEE6AMOUNT,OTFEE7,OTFEE7AMOUNT,OTFEE8,OTFEE8AMOUNT"); strSql.Append(",PFREIGHT,CFREIGHT,PSTATEMENT,CSTATEMENT,PTAX,CTAX,POTFREIGHT,COTFREIGHT,PCARRIEROT,CCARRIEROT,PTOTAL,CTOTAL"); strSql.Append(",(SELECT TOP 1 BLSTATUS FROM op_blissue WHERE BSNO=B.BSNO) BLISSUESTATUS"); 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 TOP 1 STATUS FROM OP_STATUS WHERE BSNO=B.BSNO ORDER BY COMPTIME DESC,INPUTTIME DESC) as OPSTATUS "); strSql.Append(",CUSTOMNO,ENTERPID,ENTERP,INSPECTIONNO,INSPECTIONDATE,CUSTOMDATE,TRADETYPE,TRADETERM,ISSUEBY,ISSUEDATE,ISSUEPLACE"); strSql.Append(",IsService1,IsService2,IsService3,IsService4,IsService5,IsService6,IsService7,IsService8,IsService9,IsService10,ISPRINTPR,CONTRACTNO,LANE,DELIVERYDATE,DOC,HSCODE,ISCANCEL"); strSql.Append(" from OP_AIRE B"); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } if (!string.IsNullOrEmpty(sort)) { strSql.Append(" order by " + sort); } else { strSql.Append(" order by ETD,MBLNO"); } return strSql.ToString(); } static public MsOpAire GetData(string condition) { var strSql = new StringBuilder(); strSql.Append("SELECT B.BSNO,MASTERNO,ORDERTYPE,ORDTYPE,ORDERNO,BSSTATUS,FEESTATUS,BSDATE,ACCDATE,MBLNO,HBLNO,CUSTNO,TRANSNO,CUSTOMERNAME,SHIPPERID,"); strSql.Append("CONSIGNEEID,NOTIFYPARTYID,SHIPPER,CONSIGNEE,NOTIFYPARTY,AGENTID,AGENT,VESSEL,ETD,ETA,"); strSql.Append("PORTLOADID,PORTLOAD,PORTDISCHARGEID,PORTDISCHARGE,TRANSPORTID,TRANSPORT,TRANSPORT2ID,TRANSPORT2,TRANSPORT3ID,TRANSPORT3,BLTYPE,ISSUETYPE,"); strSql.Append("BLFRT,OTFRT,HBLBLFRT,HBLOTFRT,MARKS,[DESCRIPTION],GOODSNAME,PKGS,KINDPKGS,UNIT,"); strSql.Append("KGS,CBM,CURR,CUSTVALUE,CUSTOMVALUE,CLASS,FEEKGS,PRICE,TTLFREIGHT,OTFEE,HANDINGINFO,ACCOUNTINFO,"); strSql.Append("INPUTBY,OP,CUSTSERVICE,SALE,AIRLINES,TRANSAIRLINES,FORWARDER,CUSTOMSER,TRUCKER,INVNO,FRCUSTSERVICE,"); strSql.Append("CARGOID,BSSOURCE,BSSOURCEDETAIL,INSURANCEER,INSURANCENO,INAMOUT,"); strSql.Append("ISVOU,VOUNO,REMARK,CORPID,SALEDEPT,CREATETIME,STLNAME,STLDATE,"); strSql.Append("OPERATORCODE,OPERATOR,OPERATOREMAIL,OPERATORTEL,OPERATORFAX,"); strSql.Append("FINANCIALSTAFFCODE,FINANCIALSTAFF,FINANCIALSTAFFEMAIL,FINANCIALSTAFFTEL,FINANCIALSTAFFFAX"); strSql.Append(",OTFEE1,OTFEE1AMOUNT,OTFEE2,OTFEE2AMOUNT,OTFEE3,OTFEE3AMOUNT,OTFEE4,OTFEE4AMOUNT,OTFEE5,OTFEE5AMOUNT"); strSql.Append(",OTFEE6,OTFEE6AMOUNT,OTFEE7,OTFEE7AMOUNT,OTFEE8,OTFEE8AMOUNT"); strSql.Append(",PFREIGHT,CFREIGHT,PSTATEMENT,CSTATEMENT,PTAX,CTAX,POTFREIGHT,COTFREIGHT,PCARRIEROT,CCARRIEROT,PTOTAL,CTOTAL"); strSql.Append(",(SELECT TOP 1 BLSTATUS FROM op_blissue WHERE BSNO=B.BSNO) BLISSUESTATUS"); strSql.Append(",(CASE BSSTATUS WHEN 1 THEN '锁定' else '未锁定' end) as BSSTATUSREF "); strSql.Append(",(CASE FEESTATUS WHEN 1 THEN '锁定' else '未锁定' end) as FEESTATUSREF "); strSql.Append(",'' as OPSTATUS "); strSql.Append(",CUSTOMNO,ENTERPID,ENTERP,INSPECTIONNO,INSPECTIONDATE,CUSTOMDATE,TRADETYPE,TRADETERM,ISSUEBY,ISSUEDATE,ISSUEPLACE"); strSql.Append(",IsService1,IsService2,IsService3,IsService4,IsService5,IsService6,IsService7,IsService8,IsService9,IsService10"); strSql.Append(",'' DRFEESTATUS"); strSql.Append(",'' CRFEESTATUS,ISPRINTPR,0 TTLDR,0 TTLINVDR,0 TTLDUIDR,0 APPLYCOUNT,B.BillFeeStatus "); strSql.Append(",SALECORPID,(select [NAME] from [company] where GID=B.SALECORPID) as SALECORP,CONTRACTNO,LANE,DELIVERYDATE,DOC,HSCODE,ISCANCEL"); strSql.Append(" from OP_AIRE B"); if (!string.IsNullOrEmpty(condition)) { strSql.Append(" where " + condition); } var list=SetData(strSql); if (list.Count > 0) return list[0]; return new MsOpAire(); } static public List GetFenList(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 B.BSNO,MASTERNO,ORDERTYPE,ORDTYPE,ORDERNO,BSSTATUS,FEESTATUS,BSDATE,ACCDATE,MBLNO,HBLNO,CUSTNO,TRANSNO,CUSTOMERNAME,SHIPPERID,"); strSql.Append("CONSIGNEEID,NOTIFYPARTYID,SHIPPER,CONSIGNEE,NOTIFYPARTY,AGENTID,AGENT,VESSEL,ETD,ETA,"); strSql.Append("PORTLOADID,PORTLOAD,PORTDISCHARGEID,PORTDISCHARGE,TRANSPORTID,TRANSPORT,TRANSPORT2ID,TRANSPORT2,TRANSPORT3ID,TRANSPORT3,BLTYPE,ISSUETYPE,"); strSql.Append("BLFRT,OTFRT,HBLBLFRT,HBLOTFRT,MARKS,[DESCRIPTION],GOODSNAME,PKGS,KINDPKGS,UNIT,"); strSql.Append("KGS,CBM,CURR,CUSTVALUE,CUSTOMVALUE,CLASS,FEEKGS,PRICE,TTLFREIGHT,OTFEE,HANDINGINFO,ACCOUNTINFO,"); strSql.Append("INPUTBY,OP,CUSTSERVICE,SALE,AIRLINES,TRANSAIRLINES,FORWARDER,CUSTOMSER,TRUCKER,INVNO,FRCUSTSERVICE,"); strSql.Append("CARGOID,BSSOURCE,BSSOURCEDETAIL,INSURANCEER,INSURANCENO,INAMOUT,"); strSql.Append("ISVOU,VOUNO,REMARK,CORPID,SALEDEPT,CREATETIME,STLNAME,STLDATE,ORDERTYPE,"); strSql.Append("OPERATORCODE,OPERATOR,OPERATOREMAIL,OPERATORTEL,OPERATORFAX,"); strSql.Append("FINANCIALSTAFFCODE,FINANCIALSTAFF,FINANCIALSTAFFEMAIL,FINANCIALSTAFFTEL,FINANCIALSTAFFFAX"); strSql.Append(",OTFEE1,OTFEE1AMOUNT,OTFEE2,OTFEE2AMOUNT,OTFEE3,OTFEE3AMOUNT,OTFEE4,OTFEE4AMOUNT,OTFEE5,OTFEE5AMOUNT"); strSql.Append(",OTFEE6,OTFEE6AMOUNT,OTFEE7,OTFEE7AMOUNT,OTFEE8,OTFEE8AMOUNT"); strSql.Append(",PFREIGHT,CFREIGHT,PSTATEMENT,CSTATEMENT,PTAX,CTAX,POTFREIGHT,COTFREIGHT,PCARRIEROT,CCARRIEROT,PTOTAL,CTOTAL"); strSql.Append(",(SELECT TOP 1 BLSTATUS FROM op_blissue WHERE BSNO=B.BSNO) BLISSUESTATUS"); 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 TOP 1 STATUS FROM OP_STATUS WHERE BSNO=B.BSNO ORDER BY COMPTIME DESC,INPUTTIME DESC) as OPSTATUS "); strSql.Append(",CUSTOMNO,ENTERPID,ENTERP,INSPECTIONNO,INSPECTIONDATE,CUSTOMDATE,TRADETYPE,TRADETERM,ISSUEBY,ISSUEDATE,ISSUEPLACE"); strSql.Append(",IsService1,IsService2,IsService3,IsService4,IsService5,IsService6,IsService7,IsService8,IsService9,IsService10"); strSql.Append(",dbo.F_GetBillDrFeeStatus(B.BSNO) DRFEESTATUS"); strSql.Append(",dbo.F_GetBillCrFeeStatus(B.BSNO) CRFEESTATUS,ISPRINTPR,0 TTLDR,0 TTLINVDR,0 TTLDUIDR,0 APPLYCOUNT,B.BillFeeStatus "); strSql.Append(",SALECORPID,(select [NAME] from [company] where GID=B.SALECORPID) as SALECORP,CONTRACTNO,LANE,DELIVERYDATE,DOC,HSCODE,ISCANCEL"); strSql.Append(" from OP_AIRE B"); 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 SetData(strSql); } 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()) { MsOpAire data = new MsOpAire(); #region Set DB data to Object data.BillFeeStatus = Convert.ToString(reader["BillFeeStatus"]); data.BSNO = Convert.ToString(reader["BSNO"]);//业务编号 data.ORDERTYPE = Convert.ToString(reader["ORDERTYPE"]);//委托方式 data.MASTERNO = Convert.ToString(reader["MASTERNO"]);//主编号 data.CUSTNO = Convert.ToString(reader["CUSTNO"]);//委托编号 data.MBLNO = Convert.ToString(reader["MBLNO"]);//主提单号 data.HBLNO = Convert.ToString(reader["HBLNO"]);//分提单号 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 (Convert.ToString(reader["OPSTATUS"])!="") data.OPSTATUS = Convert.ToString(reader["OPSTATUS"]);// 费用状态 data.BLISSUESTATUS = Convert.ToString(reader["BLISSUESTATUS"]);// 费用状态 data.BSDATE = Convert.ToDateTime(reader["BSDATE"]);//接单日期 data.ACCDATE = Convert.ToString(reader["ACCDATE"]);//会计期间 data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);//委托单位 data.BSSOURCE = Convert.ToString(reader["BSSOURCE"]);//业务来源 data.BSSOURCEDETAIL = Convert.ToString(reader["BSSOURCEDETAIL"]);//来源明细 data.INPUTBY = Convert.ToString(reader["INPUTBY"]);//录入人 data.OP = Convert.ToString(reader["OP"]);//操作员 data.CUSTSERVICE = Convert.ToString(reader["CUSTSERVICE"]);//客服员 data.FRCUSTSERVICE = Convert.ToString(reader["FRCUSTSERVICE"]);//客服员 data.SALE = Convert.ToString(reader["SALE"]);//揽货人 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.CREATETIME = Convert.ToString(reader["CREATETIME"]);//创建时间 data.VESSEL = Convert.ToString(reader["VESSEL"]);//船名 if (reader["ETD"] != DBNull.Value) data.ETD = Convert.ToDateTime(reader["ETD"]).ToString("yyyy-MM-dd");//到港日期 data.LANE = Convert.ToString(reader["LANE"]);//航线 data.PORTLOADID = Convert.ToString(reader["PORTLOADID"]);//装货港代码 data.PORTLOAD = Convert.ToString(reader["PORTLOAD"]);//装货港 data.PORTDISCHARGEID = Convert.ToString(reader["PORTDISCHARGEID"]);//卸货港代码 data.PORTDISCHARGE = Convert.ToString(reader["PORTDISCHARGE"]);//卸货港 data.TRANSPORTID = Convert.ToString(reader["TRANSPORTID"]);//中转港代码 data.TRANSPORT = Convert.ToString(reader["TRANSPORT"]);//中转港 data.TRANSPORT2ID = Convert.ToString(reader["TRANSPORT2ID"]);//中转港代码2 data.TRANSPORT2 = Convert.ToString(reader["TRANSPORT2"]);//中转港2 data.TRANSPORT3ID = Convert.ToString(reader["TRANSPORT3ID"]);//中转港代码3 data.TRANSPORT3 = Convert.ToString(reader["TRANSPORT3"]);//中转港3 data.GOODSNAME = Convert.ToString(reader["GOODSNAME"]);//品名 data.TRADETYPE = Convert.ToString(reader["TRADETYPE"]);//贸易方式 data.TRADETERM = Convert.ToString(reader["TRADETERM"]);//贸易条款 data.ISSUETYPE = Convert.ToString(reader["ISSUETYPE"]);//签单方式 if (reader["KGS"] != DBNull.Value) data.KGS = Convert.ToString(reader["KGS"]);//毛重 data.CUSTOMSER = Convert.ToString(reader["CUSTOMSER"]);//报关行 if (reader["PKGS"] != DBNull.Value) data.PKGS = Convert.ToString(reader["PKGS"]);//件数 if (reader["ISVOU"] != DBNull.Value) data.ISVOU = Convert.ToBoolean(reader["ISVOU"]);//是否生成凭证 data.VOUNO = Convert.ToString(reader["VOUNO"]);//凭证号 data.KINDPKGS = Convert.ToString(reader["KINDPKGS"]);//件数包装 data.UNIT = Convert.ToString(reader["UNIT"]);//件数包装 data.REMARK = Convert.ToString(reader["REMARK"]);//备注 if (reader["CBM"] != DBNull.Value) data.CBM = Convert.ToString(reader["CBM"]);//立方数/尺码 data.AIRLINES = Convert.ToString(reader["AIRLINES"]);//航司 data.TRANSAIRLINES = Convert.ToString(reader["TRANSAIRLINES"]);//中转航司 data.TRUCKER = Convert.ToString(reader["TRUCKER"]);//承运车队 data.DESCRIPTION = Convert.ToString(reader["DESCRIPTION"]);//货物描述 data.TRANSNO = Convert.ToString(reader["TRANSNO"]);//运单号 data.SHIPPERID = Convert.ToString(reader["SHIPPERID"]);//发货人 data.CONSIGNEEID = Convert.ToString(reader["CONSIGNEEID"]);//收货人 data.NOTIFYPARTYID = Convert.ToString(reader["NOTIFYPARTYID"]);//通知人 data.SHIPPER = Convert.ToString(reader["SHIPPER"]);//发货人内容 data.CONSIGNEE = Convert.ToString(reader["CONSIGNEE"]);//收货人内容 data.NOTIFYPARTY = Convert.ToString(reader["NOTIFYPARTY"]);//通知人内容 data.AGENTID = Convert.ToString(reader["AGENTID"]);//国外代理 data.AGENT = Convert.ToString(reader["AGENT"]);//国外代理内容 if (reader["ETA"] != DBNull.Value) data.ETA = Convert.ToDateTime(reader["ETA"]).ToString("yyyy-MM-dd");//预抵日期 data.BLFRT = Convert.ToString(reader["BLFRT"]);//付费方式 data.OTFRT = Convert.ToString(reader["OTFRT"]);//付费方式 data.HBLBLFRT = Convert.ToString(reader["HBLBLFRT"]);//付费方式 data.HBLOTFRT = Convert.ToString(reader["HBLOTFRT"]);//付费方式 data.ISSUEBY = Convert.ToString(reader["ISSUEBY"]);//付费方式 data.ISSUEDATE = Convert.ToString(reader["ISSUEDATE"]);//付费方式 data.ISSUEPLACE = Convert.ToString(reader["ISSUEPLACE"]);//付费方式 data.CURR = Convert.ToString(reader["CURR"]);// data.CUSTVALUE = Convert.ToString(reader["CUSTVALUE"]);// data.CUSTOMVALUE = Convert.ToString(reader["CUSTOMVALUE"]);// data.CLASS = Convert.ToString(reader["CLASS"]);// if (reader["FEEKGS"] != DBNull.Value) data.FEEKGS = Convert.ToString(reader["FEEKGS"]);// if (reader["PRICE"] != DBNull.Value) data.PRICE = Convert.ToString(reader["PRICE"]);// if (reader["TTLFREIGHT"] != DBNull.Value) data.TTLFREIGHT = Convert.ToString(reader["TTLFREIGHT"]);// data.OTFEE = Convert.ToString(reader["OTFEE"]);//唛头 data.HANDINGINFO = Convert.ToString(reader["HANDINGINFO"]);//唛头 data.ACCOUNTINFO = Convert.ToString(reader["ACCOUNTINFO"]);//唛头 data.MARKS = Convert.ToString(reader["MARKS"]);//唛头 data.CONTRACTNO = Convert.ToString(reader["CONTRACTNO"]);//唛头 data.BLTYPE = Convert.ToString(reader["BLTYPE"]);//唛头 data.FORWARDER = Convert.ToString(reader["FORWARDER"]);//订舱公司 data.INVNO = Convert.ToString(reader["INVNO"]);//发票号 data.CARGOID = Convert.ToString(reader["CARGOID"]);//货物标识 data.ORDTYPE = Convert.ToString(reader["ORDTYPE"]);//订舱类型 data.ORDERNO = Convert.ToString(reader["ORDERNO"]);//订舱编号 data.INSURANCEER = Convert.ToString(reader["INSURANCEER"]);//保险人 data.INSURANCENO = Convert.ToString(reader["INSURANCENO"]);//保险单号 data.INAMOUT = Convert.ToString(reader["INAMOUT"]);//保险金额 data.STLNAME = Convert.ToString(reader["STLNAME"]);//结算方式 data.STLDATE = Convert.ToString(reader["STLDATE"]);//结算时间 data.OPERATORCODE = Convert.ToString(reader["OPERATORCODE"]);//客户操作代码 data.OPERATOR = Convert.ToString(reader["OPERATOR"]);//客户操作名称 data.OPERATOREMAIL = Convert.ToString(reader["OPERATOREMAIL"]);//操作电子邮箱 data.OPERATORTEL = Convert.ToString(reader["OPERATORTEL"]);//操作电话 data.OPERATORFAX = Convert.ToString(reader["OPERATORFAX"]);//操作传真 data.FINANCIALSTAFFCODE = Convert.ToString(reader["FINANCIALSTAFFCODE"]);//客户财务代码 data.FINANCIALSTAFF = Convert.ToString(reader["FINANCIALSTAFF"]);//客户财务名称 data.FINANCIALSTAFFEMAIL = Convert.ToString(reader["FINANCIALSTAFFEMAIL"]);//财务电子邮箱 data.FINANCIALSTAFFTEL = Convert.ToString(reader["FINANCIALSTAFFTEL"]);//财务电话 data.FINANCIALSTAFFFAX = Convert.ToString(reader["FINANCIALSTAFFFAX"]);//财务传真 data.PFREIGHT = Convert.ToString(reader["PFREIGHT"]);// data.CFREIGHT = Convert.ToString(reader["CFREIGHT"]);// data.PSTATEMENT = Convert.ToString(reader["PSTATEMENT"]);// data.CSTATEMENT = Convert.ToString(reader["CSTATEMENT"]);// data.PTAX = Convert.ToString(reader["PTAX"]);// data.CTAX = Convert.ToString(reader["CTAX"]);// data.POTFREIGHT = Convert.ToString(reader["POTFREIGHT"]);// data.COTFREIGHT = Convert.ToString(reader["COTFREIGHT"]);// data.PCARRIEROT = Convert.ToString(reader["PCARRIEROT"]);// data.CCARRIEROT = Convert.ToString(reader["CCARRIEROT"]);// data.PTOTAL = Convert.ToString(reader["PTOTAL"]);// data.CTOTAL = Convert.ToString(reader["CTOTAL"]);// data.OTFEE1 = Convert.ToString(reader["OTFEE1"]);// if (reader["OTFEE1AMOUNT"] != DBNull.Value) data.OTFEE1AMOUNT = Convert.ToString(reader["OTFEE1AMOUNT"]);// data.OTFEE2 = Convert.ToString(reader["OTFEE2"]);// if (reader["OTFEE2AMOUNT"] != DBNull.Value) data.OTFEE2AMOUNT = Convert.ToString(reader["OTFEE2AMOUNT"]);// data.OTFEE3 = Convert.ToString(reader["OTFEE3"]);// if (reader["OTFEE3AMOUNT"] != DBNull.Value) data.OTFEE3AMOUNT = Convert.ToString(reader["OTFEE3AMOUNT"]);// data.OTFEE4 = Convert.ToString(reader["OTFEE4"]);// if (reader["OTFEE4AMOUNT"] != DBNull.Value) data.OTFEE4AMOUNT = Convert.ToString(reader["OTFEE4AMOUNT"]);// data.OTFEE5 = Convert.ToString(reader["OTFEE5"]);// if (reader["OTFEE5AMOUNT"] != DBNull.Value) data.OTFEE5AMOUNT = Convert.ToString(reader["OTFEE5AMOUNT"]);// data.OTFEE6 = Convert.ToString(reader["OTFEE6"]);// if (reader["OTFEE6AMOUNT"] != DBNull.Value) data.OTFEE6AMOUNT = Convert.ToString(reader["OTFEE6AMOUNT"]);// data.OTFEE7 = Convert.ToString(reader["OTFEE7"]);// if (reader["OTFEE7AMOUNT"] != DBNull.Value) data.OTFEE7AMOUNT = Convert.ToString(reader["OTFEE7AMOUNT"]);// data.OTFEE8 = Convert.ToString(reader["OTFEE8"]);// if (reader["OTFEE8AMOUNT"] != DBNull.Value) data.OTFEE8AMOUNT = Convert.ToString(reader["OTFEE8AMOUNT"]);// data.CUSTOMNO = Convert.ToString(reader["CUSTOMNO"]);//报关单号 if (reader["CUSTOMDATE"] != DBNull.Value) data.CUSTOMDATE = Convert.ToDateTime(reader["CUSTOMDATE"]).ToString("yyyy-MM-dd");// data.INSPECTIONNO = Convert.ToString(reader["INSPECTIONNO"]);//商检号 if (reader["INSPECTIONDATE"] != DBNull.Value) data.INSPECTIONDATE = Convert.ToDateTime(reader["INSPECTIONDATE"]).ToString("yyyy-MM-dd");// data.ENTERP = Convert.ToString(reader["ENTERP"]);//经营单位 data.ENTERPID = Convert.ToString(reader["ENTERPID"]);//经营单位代码 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.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 = "部分对账"; if (reader["APPLYCOUNT"] != DBNull.Value) data.ISAPPLY = Convert.ToString(reader["APPLYCOUNT"]);//是否生成报关 if (reader["DELIVERYDATE"] != DBNull.Value) data.DELIVERYDATE = Convert.ToDateTime(reader["DELIVERYDATE"]).ToString("yyyy-MM-dd"); data.DOC = Convert.ToString(reader["DOC"]);//唛头 data.HSCODE = Convert.ToString(reader["HSCODE"]);//HSCODE data.ISCANCEL = Convert.ToString(reader["ISCANCEL"]); #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 体积明细 public static List GetAirCbmDetail(string strCondition) { var strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append("GID,BSNO,[LENGTH],WIDTH,HEIGHT,PKGS,CBM"); strSql.Append(" from op_air_cbm_detail "); if (strCondition.Trim() != String.Empty) { strSql.Append(" where " + strCondition); } var bodyList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { MsOpAirCbmDetail data = new MsOpAirCbmDetail(); #region Set DB data to Object if (reader["LENGTH"] != DBNull.Value) data.LENGTH = Convert.ToDecimal(reader["LENGTH"]); if (reader["WIDTH"] != DBNull.Value) data.WIDTH = Convert.ToDecimal(reader["WIDTH"]); if (reader["HEIGHT"] != DBNull.Value) data.HEIGHT = Convert.ToDecimal(reader["HEIGHT"]); if (reader["CBM"] != DBNull.Value) data.CBM = Convert.ToDecimal(reader["CBM"]); if (reader["PKGS"] != DBNull.Value) data.PKGS = Convert.ToInt32(reader["PKGS"]); data.GID = Convert.ToString(reader["GID"]); data.BSNO = Convert.ToString(reader["BSNO"]); #endregion bodyList.Add(data); } reader.Close(); } return bodyList; } public static DBResult SaveOpAirCbmDetail(List bodyList,string bsno,string userid, string companyid) { var result = new DBResult(); Database db = DatabaseFactory.CreateDatabase(); using (var conn = db.CreateConnection()) { conn.Open(); var tran = conn.BeginTransaction(); try { var cmdInsert = db.GetSqlStringCommand( @"insert into op_air_cbm_detail (GID,BSNO,[LENGTH],WIDTH,HEIGHT,PKGS,CBM,INPUTBY,INPUTTIME) values (@GID,@BSNO,@LENGTH,@WIDTH,@HEIGHT,@PKGS,@CBM,@INPUTBY,@INPUTTIME ) "); var cmdUpdate = db.GetSqlStringCommand( @"update op_air_cbm_detail set [LENGTH]=@LENGTH,WIDTH=@WIDTH,HEIGHT=@HEIGHT,PKGS=@PKGS ,CBM=@CBM,INPUTBY=@INPUTBY,INPUTTIME=@INPUTTIME where GID=@GID "); if (bodyList != null) { foreach (var enumValue in bodyList) { if (enumValue.BSNO == "*" || enumValue.BSNO == "") { cmdInsert.Parameters.Clear(); db.AddInParameter(cmdInsert, "@GID", DbType.String, Guid.NewGuid().ToString()); db.AddInParameter(cmdInsert, "@BSNO", DbType.String, bsno); db.AddInParameter(cmdInsert, "@LENGTH", DbType.Decimal, enumValue.LENGTH); db.AddInParameter(cmdInsert, "@WIDTH", DbType.Decimal, enumValue.WIDTH); db.AddInParameter(cmdInsert, "@HEIGHT", DbType.Decimal, enumValue.HEIGHT); db.AddInParameter(cmdInsert, "@PKGS", DbType.Int32, enumValue.PKGS); db.AddInParameter(cmdInsert, "@CBM", DbType.Decimal, enumValue.CBM); db.AddInParameter(cmdInsert, "@INPUTBY", DbType.String, userid); db.AddInParameter(cmdInsert, "@INPUTTIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); db.ExecuteNonQuery(cmdInsert, tran); } else { cmdUpdate.Parameters.Clear(); db.AddInParameter(cmdUpdate, "@GID", DbType.String, enumValue.GID); db.AddInParameter(cmdUpdate, "@LENGTH", DbType.Decimal, enumValue.LENGTH); db.AddInParameter(cmdUpdate, "@WIDTH", DbType.Decimal, enumValue.WIDTH); db.AddInParameter(cmdUpdate, "@HEIGHT", DbType.Decimal, enumValue.HEIGHT); db.AddInParameter(cmdUpdate, "@PKGS", DbType.Int32, enumValue.PKGS); db.AddInParameter(cmdUpdate, "@CBM", DbType.Decimal, enumValue.CBM); db.AddInParameter(cmdUpdate, "@INPUTBY", DbType.String, userid); db.AddInParameter(cmdUpdate, "@INPUTTIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); db.ExecuteNonQuery(cmdUpdate, tran); } } } tran.Commit(); } catch (Exception) { tran.Rollback(); result.Success = false; result.Message = "保存出现错误,请重试或联系系统管理员"; return result; } } result.Success = true; result.Message = "保存成功" + result.Message; return result; } public static DBResult DeleteOpAirCbmDetail(MsOpAirCbmDetail 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_air_cbm_detail where GID=@GID "); cmdDelete.Parameters.Clear(); db.AddInParameter(cmdDelete, "@GID", DbType.String, headData.GID); db.ExecuteNonQuery(cmdDelete, tran); tran.Commit(); result.Success = true; result.Message = "保存成功" + result.Message; } catch (Exception e) { tran.Rollback(); result.Success = false; result.Message = "保存出现错误,请重试或联系系统管理员"+e.Message; return result; } } return result; } #endregion #region 删除 public static DBResult DeleteDetail(string bsno) { var result = new DBResult(); Database db = DatabaseFactory.CreateDatabase(); using (var conn = db.CreateConnection()) { conn.Open(); var tran = conn.BeginTransaction(); try { var cmdDeletebill = db.GetSqlStringCommand("delete from op_aire_bill where BSNO='" + bsno + "'"); db.ExecuteNonQuery(cmdDeletebill, tran); tran.Commit(); } catch (Exception) { tran.Rollback(); result.Success = false; result.Message = "删除出现错误,请重试或联系系统管理员"; return result; } } result.Success = true; result.Message = "操作成功"; return result; } #endregion #region 编码生成 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=1"); 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_Seae] 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 ""; } #endregion #region 判断是否有费用 static public int GetRdCount(string strCondition) { var strSql = new StringBuilder(); strSql.Append("SELECT Count(BSNO) AS CT from op_aire (NOLOCK) "); 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; } public static bool GetFeeCount(string BSNO) { var isfee = false; var strSql = new StringBuilder(); strSql.Append("Select count(*) as count "); strSql.Append(" from ch_fee "); strSql.Append(" where BSNO='" + BSNO+"'"); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { var evData = Convert.ToInt32(reader["count"]); if (evData > 0) { isfee = true; }; } reader.Close(); } return isfee; } public static bool GetAmendCount(string BSNO) { var isfee = false; var strSql = new StringBuilder(); strSql.Append("Select count(*) as count "); strSql.Append(" from op_amend "); strSql.Append(" where PARENTID='" + BSNO + "'"); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { var evData = Convert.ToInt32(reader["count"]); if (evData > 0) { isfee = true; }; } reader.Close(); } return isfee; } public static bool GetFenCount(string BSNO) { var isfee = false; var strSql = new StringBuilder(); strSql.Append("Select count(*) as count "); strSql.Append(" from op_aire "); strSql.Append(" where BSNO<>'" + BSNO + "' AND MASTERNO='" + 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; } #endregion #region 提单信息 static public List GetBillList(string strCondition,string sort = null) { var strSql = new StringBuilder(); strSql.Append("SELECT AS_ID,BSNO,MBLNO,HBLNO,TEMPLATE,BILLTYPE,SHIPPERID,"); strSql.Append("CONSIGNEEID,NOTIFYPARTYID,SHIPPER,CONSIGNEE,NOTIFYPARTY,AGENTID,AGENT,VESSEL,ETD,ETA,"); strSql.Append("PORTLOADID,PORTLOAD,PORTDISCHARGEID,PORTDISCHARGE,"); strSql.Append("ISSUEBY,ISSUEDATE,ISSUEPLACE,MARKS,[DESCRIPTION],GOODSNAME,PKGS,KINDPKGS,KGS,CBM,INPUTBY,UNIT"); strSql.Append(",AIRLINES,IATANO,ACCOUNTCODE,ACCOUNTINFO,HANDINGINFO,CURR,BLFRT,"); strSql.Append("OTFRT,TRANSTATEMENT,CUSTOMSTATEMENT,INAMOUNT,CLASS,FEEKGS,PRICE,"); strSql.Append("TTLFREIGHT,TOTALAMOUNT,OTFEE,PFREIGHT,CFREIGHT,PSTATEMENT,CSTATEMENT,"); strSql.Append("PTAX,CTAX,POTFREIGHT,COTFREIGHT,PCARRIEROT,CCARRIEROT,PTOTAL,CTOTAL,GOODSNAME"); strSql.Append(",OTFEE1,OTFEE1AMOUNT,OTFEE2,OTFEE2AMOUNT,OTFEE3,OTFEE3AMOUNT,OTFEE4,OTFEE4AMOUNT,OTFEE5,OTFEE5AMOUNT"); strSql.Append(",OTFEE6,OTFEE6AMOUNT,OTFEE7,OTFEE7AMOUNT,OTFEE8,OTFEE8AMOUNT,REMARK,CUSTVALUE,CUSTOMVALUE,INPUTTIME,MODIFYTIME,MODIFYUSER"); strSql.Append(" from op_aire_bill "); 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 MBLNO,HBLNO desc"); } return SetBillData(strSql); } static public MsOpAireBill GetBillData(string condition) { var strSql = new StringBuilder(); strSql.Append("SELECT AS_ID,BSNO,MBLNO,HBLNO,TEMPLATE,BILLTYPE,SHIPPERID,"); strSql.Append("CONSIGNEEID,NOTIFYPARTYID,SHIPPER,CONSIGNEE,NOTIFYPARTY,AGENTID,AGENT,VESSEL,ETD,ETA,"); strSql.Append("PORTLOADID,PORTLOAD,PORTDISCHARGEID,PORTDISCHARGE,"); strSql.Append("ISSUEBY,ISSUEDATE,ISSUEPLACE,MARKS,[DESCRIPTION],GOODSNAME,PKGS,KINDPKGS,KGS,CBM,INPUTBY,UNIT"); strSql.Append(",AIRLINES,IATANO,ACCOUNTCODE,ACCOUNTINFO,HANDINGINFO,CURR,BLFRT,"); strSql.Append("OTFRT,TRANSTATEMENT,CUSTOMSTATEMENT,INAMOUNT,CLASS,FEEKGS,PRICE,"); strSql.Append("TTLFREIGHT,TOTALAMOUNT,OTFEE,PFREIGHT,CFREIGHT,PSTATEMENT,CSTATEMENT,"); strSql.Append("PTAX,CTAX,POTFREIGHT,COTFREIGHT,PCARRIEROT,CCARRIEROT,PTOTAL,CTOTAL"); strSql.Append(",OTFEE1,OTFEE1AMOUNT,OTFEE2,OTFEE2AMOUNT,OTFEE3,OTFEE3AMOUNT,OTFEE4,OTFEE4AMOUNT,OTFEE5,OTFEE5AMOUNT"); strSql.Append(",OTFEE6,OTFEE6AMOUNT,OTFEE7,OTFEE7AMOUNT,OTFEE8,OTFEE8AMOUNT,REMARK,CUSTVALUE,CUSTOMVALUE,INPUTTIME,MODIFYTIME,MODIFYUSER"); strSql.Append(" from op_aire_bill "); if (!string.IsNullOrEmpty(condition)) { strSql.Append(" where " + condition); } var list = SetBillData(strSql); if (list.Count > 0) return list[0]; return new MsOpAireBill(); } private static List SetBillData(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { MsOpAireBill data = new MsOpAireBill(); #region Set DB data to Object data.AS_ID = Convert.ToString(reader["AS_ID"]);//业务编号 data.BSNO = Convert.ToString(reader["BSNO"]);//业务编号 data.MBLNO = Convert.ToString(reader["MBLNO"]);//主提单号 data.HBLNO = Convert.ToString(reader["HBLNO"]);//分提单号 data.TEMPLATE = Convert.ToString(reader["TEMPLATE"]);// 业务状态 data.BILLTYPE = Convert.ToString(reader["BILLTYPE"]);// 费用状态 data.INPUTBY = Convert.ToString(reader["INPUTBY"]);//录入人 data.VESSEL = Convert.ToString(reader["VESSEL"]);//船名 if (reader["ETD"] != DBNull.Value) data.ETD = Convert.ToDateTime(reader["ETD"]).ToString("yyyy-MM-dd");//到港日期 data.PORTLOADID = Convert.ToString(reader["PORTLOADID"]);//装货港代码 data.PORTLOAD = Convert.ToString(reader["PORTLOAD"]);//装货港 data.PORTDISCHARGEID = Convert.ToString(reader["PORTDISCHARGEID"]);//卸货港代码 data.PORTDISCHARGE = Convert.ToString(reader["PORTDISCHARGE"]);//卸货港 data.GOODSNAME = Convert.ToString(reader["GOODSNAME"]);//品名 if (reader["KGS"] != DBNull.Value) data.KGS = Convert.ToString(reader["KGS"]);//毛重 if (reader["PKGS"] != DBNull.Value) data.PKGS = Convert.ToString(reader["PKGS"]);//件数 if (reader["CBM"] != DBNull.Value) data.CBM = Convert.ToString(reader["CBM"]);//立方数/尺码 data.KINDPKGS = Convert.ToString(reader["KINDPKGS"]);//件数包装 data.UNIT = Convert.ToString(reader["UNIT"]);//件数包装 data.DESCRIPTION = Convert.ToString(reader["DESCRIPTION"]);//货物描述 data.SHIPPERID = Convert.ToString(reader["SHIPPERID"]);//发货人 data.CONSIGNEEID = Convert.ToString(reader["CONSIGNEEID"]);//收货人 data.NOTIFYPARTYID = Convert.ToString(reader["NOTIFYPARTYID"]);//通知人 data.SHIPPER = Convert.ToString(reader["SHIPPER"]);//发货人内容 data.CONSIGNEE = Convert.ToString(reader["CONSIGNEE"]);//收货人内容 data.NOTIFYPARTY = Convert.ToString(reader["NOTIFYPARTY"]);//通知人内容 data.AGENTID = Convert.ToString(reader["AGENTID"]);//国外代理 data.AGENT = Convert.ToString(reader["AGENT"]);//国外代理内容 if (reader["ETA"] != DBNull.Value) data.ETA = Convert.ToDateTime(reader["ETA"]).ToString("yyyy-MM-dd");//预抵日期 if (reader["ISSUEDATE"] != DBNull.Value) data.ISSUEDATE = Convert.ToDateTime(reader["ISSUEDATE"]).ToString("yyyy-MM-dd");//签单日期 data.ISSUEPLACE = Convert.ToString(reader["ISSUEPLACE"]);//签单地点 data.BLFRT = Convert.ToString(reader["BLFRT"]);//付费方式 data.MARKS = Convert.ToString(reader["MARKS"]);//唛头 data.AIRLINES = Convert.ToString(reader["AIRLINES"]);// data.IATANO = Convert.ToString(reader["IATANO"]);// data.ACCOUNTCODE = Convert.ToString(reader["ACCOUNTCODE"]);// data.ACCOUNTINFO = Convert.ToString(reader["ACCOUNTINFO"]);// data.HANDINGINFO = Convert.ToString(reader["HANDINGINFO"]);// data.CURR = Convert.ToString(reader["CURR"]);// data.BLFRT = Convert.ToString(reader["BLFRT"]);// data.OTFRT = Convert.ToString(reader["OTFRT"]);// data.TRANSTATEMENT = Convert.ToString(reader["TRANSTATEMENT"]);// data.CUSTOMSTATEMENT = Convert.ToString(reader["CUSTOMSTATEMENT"]);// data.CUSTVALUE = Convert.ToString(reader["CUSTVALUE"]);// data.CUSTOMVALUE = Convert.ToString(reader["CUSTOMVALUE"]);// data.INAMOUNT = Convert.ToString(reader["INAMOUNT"]);// data.CLASS = Convert.ToString(reader["CLASS"]);// if (reader["FEEKGS"] != DBNull.Value) data.FEEKGS = Convert.ToString(reader["FEEKGS"]);// if (reader["PRICE"] != DBNull.Value) data.PRICE = Convert.ToString(reader["PRICE"]);// if (reader["TTLFREIGHT"] != DBNull.Value) data.TTLFREIGHT = Convert.ToString(reader["TTLFREIGHT"]);// if (reader["TOTALAMOUNT"] != DBNull.Value) data.TOTALAMOUNT = Convert.ToString(reader["TOTALAMOUNT"]);// data.OTFEE = Convert.ToString(reader["OTFEE"]);// data.PFREIGHT = Convert.ToString(reader["PFREIGHT"]);// data.CFREIGHT = Convert.ToString(reader["CFREIGHT"]);// data.PSTATEMENT = Convert.ToString(reader["PSTATEMENT"]);// data.CSTATEMENT = Convert.ToString(reader["CSTATEMENT"]);// data.PTAX = Convert.ToString(reader["PTAX"]);// data.CTAX = Convert.ToString(reader["CTAX"]);// data.POTFREIGHT = Convert.ToString(reader["POTFREIGHT"]);// data.COTFREIGHT = Convert.ToString(reader["COTFREIGHT"]);// data.PCARRIEROT = Convert.ToString(reader["PCARRIEROT"]);// data.CCARRIEROT = Convert.ToString(reader["CCARRIEROT"]);// data.PTOTAL = Convert.ToString(reader["PTOTAL"]);// data.CTOTAL = Convert.ToString(reader["CTOTAL"]);// data.OTFEE1 = Convert.ToString(reader["OTFEE1"]);// if (reader["OTFEE1AMOUNT"] != DBNull.Value) data.OTFEE1AMOUNT = Convert.ToString(reader["OTFEE1AMOUNT"]);// data.OTFEE2 = Convert.ToString(reader["OTFEE2"]);// if (reader["OTFEE2AMOUNT"] != DBNull.Value) data.OTFEE2AMOUNT = Convert.ToString(reader["OTFEE2AMOUNT"]);// data.OTFEE3 = Convert.ToString(reader["OTFEE3"]);// if (reader["OTFEE3AMOUNT"] != DBNull.Value) data.OTFEE3AMOUNT = Convert.ToString(reader["OTFEE3AMOUNT"]);// data.OTFEE4 = Convert.ToString(reader["OTFEE4"]);// if (reader["OTFEE4AMOUNT"] != DBNull.Value) data.OTFEE4AMOUNT = Convert.ToString(reader["OTFEE4AMOUNT"]);// data.OTFEE5 = Convert.ToString(reader["OTFEE5"]);// if (reader["OTFEE5AMOUNT"] != DBNull.Value) data.OTFEE5AMOUNT = Convert.ToString(reader["OTFEE5AMOUNT"]);// data.OTFEE6 = Convert.ToString(reader["OTFEE6"]);// if (reader["OTFEE6AMOUNT"] != DBNull.Value) data.OTFEE6AMOUNT = Convert.ToString(reader["OTFEE6AMOUNT"]);// data.OTFEE7 = Convert.ToString(reader["OTFEE7"]);// if (reader["OTFEE7AMOUNT"] != DBNull.Value) data.OTFEE7AMOUNT = Convert.ToString(reader["OTFEE7AMOUNT"]);// data.OTFEE8 = Convert.ToString(reader["OTFEE8"]);// if (reader["OTFEE8AMOUNT"] != DBNull.Value) data.OTFEE8AMOUNT = Convert.ToString(reader["OTFEE8AMOUNT"]);// data.ISSUEBY = Convert.ToString(reader["ISSUEBY"]);// data.ISSUEPLACE = Convert.ToString(reader["ISSUEPLACE"]);// data.REMARK = Convert.ToString(reader["REMARK"]);// if (reader["INPUTTIME"] != DBNull.Value) data.INPUTTIME = Convert.ToDateTime(reader["INPUTTIME"]).ToString("yyyy-MM-dd HH:mm:ss"); data.MODIFYUSER = Convert.ToString(reader["MODIFYUSER"]); if (reader["MODIFYTIME"] != DBNull.Value) data.MODIFYTIME = Convert.ToDateTime(reader["MODIFYTIME"]).ToString("yyyy-MM-dd HH:mm:ss"); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 退舱 public static DBResult CancelOrder(string bsno, string type, string op) { var result = new DBResult(); Database db = DatabaseFactory.CreateDatabase(); using (var conn = db.CreateConnection()) { conn.Open(); var tran = conn.BeginTransaction(); try { if (type == "1") { var cmdUpdate = db.GetSqlStringCommand("update op_aire set iscancel='" + type + "' where bsno='" + bsno + "'"); db.ExecuteNonQuery(cmdUpdate, tran); var cmdDelete = db.GetSqlStringCommand("insert into op_status(ST_ID,BSNO,STATUS,ISCOMP,COMPTIME,INPUTTIME,STTYPE,COMPOP,INPUTBY) values(NEWID(),'" + bsno + "','退舱',1,'" + DateTime.Now.ToString() + "','" + DateTime.Now.ToString() + "','1','" + op + "','" + op + "')"); db.ExecuteNonQuery(cmdDelete, tran); } else { var cmdUpdate = db.GetSqlStringCommand("update op_aire set iscancel='" + type + "' where bsno='" + bsno + "'"); db.ExecuteNonQuery(cmdUpdate, tran); var cmdDelete = db.GetSqlStringCommand("insert into op_status(ST_ID,BSNO,STATUS,ISCOMP,COMPTIME,INPUTTIME,STTYPE,COMPOP,INPUTBY) values(NEWID(),'" + bsno + "','接受委托',1,'" + DateTime.Now.ToString() + "','" + DateTime.Now.ToString() + "','1','" + op + "','" + op + "')"); db.ExecuteNonQuery(cmdDelete, tran); } tran.Commit(); } catch (Exception) { tran.Rollback(); result.Success = false; result.Message = "退舱出现错误,请重试或联系系统管理员"; return result; } } result.Success = true; result.Message = "操作成功"; return result; } #endregion #region 权限范围 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]='modOpAireList' 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 = "1=2"; } else if (visiblerange == "3") { str = " (B.OP='" + username + "' OR B.SALE='" + username + "' OR B.CUSTSERVICE='" + username + "' OR B.FRCUSTSERVICE='" + username + "')"; } else if (visiblerange == "2") { if (tb == "index") { var rangeDa = new RangeDA(); var deptid = rangeDa.GetDEPTGID(userid); str = " (B.OP in (select showname from vw_user where deptgid='" + deptid + "') OR B.SALE in (select showname from vw_user where deptgid='" + deptid + "') OR B.CUSTSERVICE in (select showname from vw_user where deptgid='" + deptid + "') " + " OR B.DOC in (select showname from vw_user where deptgid='" + deptid + "') OR B.FRCUSTSERVICE in (select showname from vw_user where deptgid='" + deptid + "') OR B.INPUTBY in (select showname from vw_user where deptgid='" + deptid + "'))"; } else { str = " UPPER(B.Corpid)='" + 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"]) + "' or B.SALECORPID='" + Convert.ToString(reader["COMPANYID"]) + "' "; } else { str = str + " or B.Corpid='" + Convert.ToString(reader["COMPANYID"]) + "' or B.SALECORPID='" + Convert.ToString(reader["COMPANYID"]) + "'"; }; } str = str + ")"; reader.Close(); } } else { str = " (UPPER(B.Corpid)='" + companyid + "' or B.SALECORPID='" + companyid + "') "; } } else if (visiblerange == "6") { if (tb == "index") { var opstr = ""; 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())) { while (reader.Read()) { if (opstr == "") { opstr = " ('" + Convert.ToString(reader["SHOWNAME"]) + "'"; } else { opstr = opstr + ",'" + Convert.ToString(reader["SHOWNAME"]) + "'"; }; } if (opstr != "") opstr = opstr + ")"; reader.Close(); } if (opstr == "") opstr = "('" + username + "')"; str = " (B.OP in " + opstr + " or B.SALE in " + opstr + " or B.CUSTSERVICE IN " + opstr + " or B.DOC IN " + opstr + " or B.FRCUSTSERVICE IN " + opstr + " or B.INPUTBY IN " + opstr + ")"; } else { str = " (UPPER(B.Corpid)='" + companyid + "' or B.SALECORPID='" + companyid + "') "; } } else if (visiblerange == "1") { str = " UPPER(B.Corpid)='" + companyid + "'"; } VSSQL = VSSQL.Trim(); if (!string.IsNullOrEmpty(VSSQL)) { if (!string.IsNullOrEmpty(str)) { str = str + " and (" + VSSQL + ") "; } else { str = " (" + VSSQL + ") "; } } return str; } public static string GetSaleRangDAStr(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]='modAireSaleList' 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 = " B.SALE='" + username + "' "; } else if (visiblerange == "3") { str = " B.SALE='" + username + "' "; } else if (visiblerange == "2") { if (tb == "index") { var rangeDa = new RangeDA(); var deptid = rangeDa.GetDEPTGID(userid); str = " (B.SALE in (select showname from vw_user where deptgid='" + deptid + "') )"; } else { str = " UPPER(B.Corpid)='" + 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 opstr = ""; 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())) { while (reader.Read()) { if (opstr == "") { opstr = " ('" + Convert.ToString(reader["SHOWNAME"]) + "'"; } else { opstr = opstr + ",'" + Convert.ToString(reader["SHOWNAME"]) + "'"; }; } if (opstr != "") opstr = opstr + ")"; reader.Close(); } if (opstr == "") opstr = "('" + username + "')"; str = " (B.SALE in " + opstr + ")"; } else { str = " (UPPER(B.Corpid)='" + companyid + "' or B.SALECORPID='" + companyid + "') "; } } else if (visiblerange == "1") { str = " UPPER(B.Corpid)='" + companyid + "'"; } VSSQL = VSSQL.Trim(); if (!string.IsNullOrEmpty(VSSQL)) { if (!string.IsNullOrEmpty(str)) { str = str + " and (" + VSSQL + ") "; } else { str = " (" + VSSQL + ") "; } } return str; } #endregion } //public class MsAireOrderDAL //{ // #region 查询 // static public List GetDataList(string strCondition, string userid, string usercode, string companyid, string sort = null, string load = 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(); // if (load == "true") // { // strSql.Append("SELECT top 200 B.BSNO,MASTERNO,ORDERTYPE,ORDTYPE,ORDERNO,BSSTATUS,FEESTATUS,BSDATE,ACCDATE,MBLNO,HBLNO,CUSTNO,TRANSNO,CUSTOMERNAME,SHIPPERID,"); // strSql.Append("CONSIGNEEID,NOTIFYPARTYID,'' SHIPPER,'' CONSIGNEE,'' NOTIFYPARTY,AGENTID,'' AGENT,VESSEL,ETD,ETA,"); // } // else // { // strSql.Append("SELECT B.BSNO,MASTERNO,ORDERTYPE,ORDTYPE,ORDERNO,BSSTATUS,FEESTATUS,BSDATE,ACCDATE,MBLNO,HBLNO,CUSTNO,TRANSNO,CUSTOMERNAME,BLTYPE,SHIPPERID,"); // strSql.Append("CONSIGNEEID,NOTIFYPARTYID,SHIPPER,CONSIGNEE,NOTIFYPARTY,AGENTID,AGENT,VESSEL,ETD,ETA,"); // } // strSql.Append("PORTLOADID,PORTLOAD,PORTDISCHARGEID,PORTDISCHARGE,BLTYPE,ISSUETYPE,TRANSPORTID,TRANSPORT,TRANSPORT2ID,TRANSPORT2,TRANSPORT3ID,TRANSPORT3,"); // strSql.Append("BLFRT,OTFRT,HBLBLFRT,HBLOTFRT,MARKS,[DESCRIPTION],GOODSNAME,PKGS,KINDPKGS,UNIT,"); // strSql.Append("KGS,CBM,CURR,CUSTVALUE,CUSTOMVALUE,CLASS,FEEKGS,PRICE,TTLFREIGHT,OTFEE,HANDINGINFO,ACCOUNTINFO,"); // strSql.Append("INPUTBY,OP,CUSTSERVICE,SALE,AIRLINES,TRANSAIRLINES,FORWARDER,CUSTOMSER,TRUCKER,INVNO,FRCUSTSERVICE,"); // strSql.Append("CARGOID,BSSOURCE,BSSOURCEDETAIL,ORDERNO,INSURANCEER,INSURANCENO,INAMOUT,"); // strSql.Append("ISVOU,VOUNO,REMARK,CORPID,SALEDEPT,CREATETIME,STLNAME,STLDATE,ORDERTYPE,"); // strSql.Append("OPERATORCODE,OPERATOR,OPERATOREMAIL,OPERATORTEL,OPERATORFAX,"); // strSql.Append("FINANCIALSTAFFCODE,FINANCIALSTAFF,FINANCIALSTAFFEMAIL,FINANCIALSTAFFTEL,FINANCIALSTAFFFAX"); // strSql.Append(",OTFEE1,OTFEE1AMOUNT,OTFEE2,OTFEE2AMOUNT,OTFEE3,OTFEE3AMOUNT,OTFEE4,OTFEE4AMOUNT,OTFEE5,OTFEE5AMOUNT"); // strSql.Append(",OTFEE6,OTFEE6AMOUNT,OTFEE7,OTFEE7AMOUNT,OTFEE8,OTFEE8AMOUNT"); // strSql.Append(",PFREIGHT,CFREIGHT,PSTATEMENT,CSTATEMENT,PTAX,CTAX,POTFREIGHT,COTFREIGHT,PCARRIEROT,CCARRIEROT,PTOTAL,CTOTAL"); // strSql.Append(",(SELECT TOP 1 BLSTATUS FROM op_blissue WHERE BSNO=B.BSNO) BLISSUESTATUS"); // 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 TOP 1 STATUS FROM OP_STATUS WHERE BSNO=B.BSNO ORDER BY COMPTIME DESC,INPUTTIME DESC) as OPSTATUS "); // strSql.Append(",CUSTOMNO,ENTERPID,ENTERP,INSPECTIONNO,INSPECTIONDATE,CUSTOMDATE,TRADETYPE,TRADETERM,ISSUEBY,ISSUEDATE,ISSUEPLACE"); // strSql.Append(",IsService1,IsService2,IsService3,IsService4,IsService5,IsService6,IsService7,IsService8,IsService9,IsService10"); // strSql.Append(",dbo.F_GetBillDrFeeStatus(B.BSNO) DRFEESTATUS"); // strSql.Append(",dbo.F_GetBillCrFeeStatus(B.BSNO) CRFEESTATUS,ISPRINTPR"); // strSql.Append(",I.TTLDR,I.TTLINVDR,I.TTLDUIDR"); // strSql.Append(",(SELECT COUNT(*) FROM OP_APPLY WHERE MASTERNO=B.BSNO) as APPLYCOUNT,B.BillFeeStatus "); // strSql.Append(",SALECORPID,(select [NAME] from [company] where GID=B.SALECORPID) as SALECORP,CONTRACTNO,LANE,DELIVERYDATE,DOC,HSCODE,ISCANCEL"); // strSql.Append(" from OP_AIRE B"); // strSql.Append(" LEFT JOIN v_op_gain_dr_INV I ON (I.BSNO=B.BSNO) "); // if (!string.IsNullOrEmpty(strCondition)) // { // strSql.Append(" where B.MASTERNO=B.BSNO AND EXISTS ( select 1 from OP_AIRE WHERE B.BSNO=OP_AIRE.MASTERNO AND " + strCondition + " )"); // } // else // { // strSql.Append(" where B.MASTERNO=B.BSNO "); // } // // // var sortstring = DatasetSort.Getsortstring(sort); // if (!string.IsNullOrEmpty(sortstring)) // { // strSql.Append(" order by " + sortstring); // } // else // { // var SeaeDefaultSort = MsSysParamSetDAL.GetData("PARAMNAME='AireDefaultSort'"); // if (SeaeDefaultSort.PARAMVALUE != "") // strSql.Append(" order by " + SeaeDefaultSort.PARAMVALUE); // else // strSql.Append(" order by BSDATE desc"); // } // return SetData(strSql); // } // static public List GetSaleDataList(string strCondition, string username, string sort = null, string load = null, string userid = "", string companyid = "") // { // var rangstr = GetSaleRangDAStr("index", userid, username, companyid); // if (!string.IsNullOrEmpty(rangstr)) // { // if (!string.IsNullOrEmpty(strCondition)) // { // strCondition = strCondition + " and " + rangstr; // } // else // { // strCondition = rangstr; // } // } // var strSql = new StringBuilder(); // strSql.Append("SELECT B.BSNO,MASTERNO,ORDERTYPE,ORDTYPE,ORDERNO,BSSTATUS,FEESTATUS,BSDATE,ACCDATE,MBLNO,HBLNO,CUSTNO,TRANSNO,CUSTOMERNAME,BLTYPE,SHIPPERID,"); // strSql.Append("CONSIGNEEID,NOTIFYPARTYID,SHIPPER,CONSIGNEE,NOTIFYPARTY,AGENTID,AGENT,VESSEL,ETD,ETA,"); // strSql.Append("PORTLOADID,PORTLOAD,PORTDISCHARGEID,PORTDISCHARGE,TRANSPORTID,TRANSPORT,TRANSPORT2ID,TRANSPORT2,TRANSPORT3ID,TRANSPORT3,BLTYPE,ISSUETYPE,"); // strSql.Append("BLFRT,OTFRT,HBLBLFRT,HBLOTFRT,MARKS,[DESCRIPTION],GOODSNAME,PKGS,KINDPKGS,UNIT,"); // strSql.Append("KGS,CBM,CURR,CUSTVALUE,CUSTOMVALUE,CLASS,FEEKGS,PRICE,TTLFREIGHT,OTFEE,HANDINGINFO,ACCOUNTINFO,"); // strSql.Append("INPUTBY,OP,CUSTSERVICE,SALE,AIRLINES,TRANSAIRLINES,FORWARDER,CUSTOMSER,TRUCKER,INVNO,FRCUSTSERVICE,"); // strSql.Append("CARGOID,BSSOURCE,BSSOURCEDETAIL,ORDERNO,INSURANCEER,INSURANCENO,INAMOUT,"); // strSql.Append("ISVOU,VOUNO,REMARK,CORPID,SALEDEPT,CREATETIME,STLNAME,STLDATE,ORDERTYPE,"); // strSql.Append("OPERATORCODE,OPERATOR,OPERATOREMAIL,OPERATORTEL,OPERATORFAX,"); // strSql.Append("FINANCIALSTAFFCODE,FINANCIALSTAFF,FINANCIALSTAFFEMAIL,FINANCIALSTAFFTEL,FINANCIALSTAFFFAX"); // strSql.Append(",OTFEE1,OTFEE1AMOUNT,OTFEE2,OTFEE2AMOUNT,OTFEE3,OTFEE3AMOUNT,OTFEE4,OTFEE4AMOUNT,OTFEE5,OTFEE5AMOUNT"); // strSql.Append(",OTFEE6,OTFEE6AMOUNT,OTFEE7,OTFEE7AMOUNT,OTFEE8,OTFEE8AMOUNT"); // strSql.Append(",PFREIGHT,CFREIGHT,PSTATEMENT,CSTATEMENT,PTAX,CTAX,POTFREIGHT,COTFREIGHT,PCARRIEROT,CCARRIEROT,PTOTAL,CTOTAL"); // strSql.Append(",(SELECT TOP 1 BLSTATUS FROM op_blissue WHERE BSNO=B.BSNO) BLISSUESTATUS"); // 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 TOP 1 STATUS FROM OP_STATUS WHERE BSNO=B.BSNO ORDER BY COMPTIME DESC,INPUTTIME DESC) as OPSTATUS "); // strSql.Append(",CUSTOMNO,ENTERPID,ENTERP,INSPECTIONNO,INSPECTIONDATE,CUSTOMDATE,TRADETYPE,TRADETERM,ISSUEBY,ISSUEDATE,ISSUEPLACE"); // strSql.Append(",IsService1,IsService2,IsService3,IsService4,IsService5,IsService6,IsService7,IsService8,IsService9,IsService10"); // strSql.Append(",dbo.F_GetBillDrFeeStatus(B.BSNO) DRFEESTATUS"); // strSql.Append(",dbo.F_GetBillCrFeeStatus(B.BSNO) CRFEESTATUS,ISPRINTPR"); // strSql.Append(",I.TTLDR,I.TTLINVDR,I.TTLDUIDR,0 APPLYCOUNT,B.BillFeeStatus "); // strSql.Append(",SALECORPID,(select [NAME] from [company] where GID=B.SALECORPID) as SALECORP,CONTRACTNO,LANE,DELIVERYDATE,DOC,HSCODE,ISCANCEL"); // strSql.Append(" from OP_AIRE B"); // strSql.Append(" LEFT JOIN v_op_gain_dr_INV I ON (I.BSNO=B.BSNO) "); // 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 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 B.BSNO,MASTERNO,ORDERTYPE,ORDTYPE,ORDERNO,BSSTATUS,FEESTATUS,BSDATE,ACCDATE,MBLNO,HBLNO,CUSTNO,TRANSNO,CUSTOMERNAME,SHIPPERID,"); // strSql.Append("CONSIGNEEID,NOTIFYPARTYID,SHIPPER,CONSIGNEE,NOTIFYPARTY,AGENTID,AGENT,VESSEL,ETD,ETA,"); // strSql.Append("PORTLOADID,PORTLOAD,PORTDISCHARGEID,PORTDISCHARGE,BLTYPE,ISSUETYPE,"); // strSql.Append("BLFRT,OTFRT,HBLBLFRT,HBLOTFRT,MARKS,[DESCRIPTION],GOODSNAME,PKGS,KINDPKGS,UNIT,"); // strSql.Append("KGS,CBM,CURR,CUSTVALUE,CUSTOMVALUE,CLASS,FEEKGS,PRICE,TTLFREIGHT,OTFEE,HANDINGINFO,ACCOUNTINFO,"); // strSql.Append("INPUTBY,OP,CUSTSERVICE,SALE,AIRLINES,TRANSAIRLINES,FORWARDER,CUSTOMSER,TRUCKER,INVNO,FRCUSTSERVICE,"); // strSql.Append("CARGOID,BSSOURCE,BSSOURCEDETAIL,ORDERNO,INSURANCEER,INSURANCENO,INAMOUT,"); // strSql.Append("ISVOU,VOUNO,REMARK,CORPID,SALEDEPT,CREATETIME,STLNAME,STLDATE,ORDERTYPE,"); // strSql.Append("OPERATORCODE,OPERATOR,OPERATOREMAIL,OPERATORTEL,OPERATORFAX,"); // strSql.Append("FINANCIALSTAFFCODE,FINANCIALSTAFF,FINANCIALSTAFFEMAIL,FINANCIALSTAFFTEL,FINANCIALSTAFFFAX"); // strSql.Append(",OTFEE1,OTFEE1AMOUNT,OTFEE2,OTFEE2AMOUNT,OTFEE3,OTFEE3AMOUNT,OTFEE4,OTFEE4AMOUNT,OTFEE5,OTFEE5AMOUNT"); // strSql.Append(",OTFEE6,OTFEE6AMOUNT,OTFEE7,OTFEE7AMOUNT,OTFEE8,OTFEE8AMOUNT"); // strSql.Append(",PFREIGHT,CFREIGHT,PSTATEMENT,CSTATEMENT,PTAX,CTAX,POTFREIGHT,COTFREIGHT,PCARRIEROT,CCARRIEROT,PTOTAL,CTOTAL"); // strSql.Append(",(SELECT TOP 1 BLSTATUS FROM op_blissue WHERE BSNO=B.BSNO) BLISSUESTATUS"); // 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 TOP 1 STATUS FROM OP_STATUS WHERE BSNO=B.BSNO ORDER BY COMPTIME DESC,INPUTTIME DESC) as OPSTATUS "); // strSql.Append(",CUSTOMNO,ENTERPID,ENTERP,INSPECTIONNO,INSPECTIONDATE,CUSTOMDATE,TRADETYPE,TRADETERM,ISSUEBY,ISSUEDATE,ISSUEPLACE"); // strSql.Append(",IsService1,IsService2,IsService3,IsService4,IsService5,IsService6,IsService7,IsService8,IsService9,IsService10,ISPRINTPR,CONTRACTNO,LANE,DELIVERYDATE,DOC,HSCODE,ISCANCEL"); // strSql.Append(" from OP_AIRE B"); // if (!string.IsNullOrEmpty(strCondition)) // { // strSql.Append(" where " + strCondition); // } // if (!string.IsNullOrEmpty(sort)) // { // strSql.Append(" order by " + sort); // } // else // { // strSql.Append(" order by ETD,MBLNO"); // } // return strSql.ToString(); // } // static public MsOpAire GetData(string condition) // { // var strSql = new StringBuilder(); // strSql.Append("SELECT B.BSNO,MASTERNO,ORDERTYPE,ORDTYPE,ORDERNO,BSSTATUS,FEESTATUS,BSDATE,ACCDATE,MBLNO,HBLNO,CUSTNO,TRANSNO,CUSTOMERNAME,SHIPPERID,"); // strSql.Append("CONSIGNEEID,NOTIFYPARTYID,SHIPPER,CONSIGNEE,NOTIFYPARTY,AGENTID,AGENT,VESSEL,ETD,ETA,"); // strSql.Append("PORTLOADID,PORTLOAD,PORTDISCHARGEID,PORTDISCHARGE,TRANSPORTID,TRANSPORT,TRANSPORT2ID,TRANSPORT2,TRANSPORT3ID,TRANSPORT3,BLTYPE,ISSUETYPE,"); // strSql.Append("BLFRT,OTFRT,HBLBLFRT,HBLOTFRT,MARKS,[DESCRIPTION],GOODSNAME,PKGS,KINDPKGS,UNIT,"); // strSql.Append("KGS,CBM,CURR,CUSTVALUE,CUSTOMVALUE,CLASS,FEEKGS,PRICE,TTLFREIGHT,OTFEE,HANDINGINFO,ACCOUNTINFO,"); // strSql.Append("INPUTBY,OP,CUSTSERVICE,SALE,AIRLINES,TRANSAIRLINES,FORWARDER,CUSTOMSER,TRUCKER,INVNO,FRCUSTSERVICE,"); // strSql.Append("CARGOID,BSSOURCE,BSSOURCEDETAIL,ORDERNO,INSURANCEER,INSURANCENO,INAMOUT,"); // strSql.Append("ISVOU,VOUNO,REMARK,CORPID,SALEDEPT,CREATETIME,STLNAME,STLDATE,ORDERTYPE,"); // strSql.Append("OPERATORCODE,OPERATOR,OPERATOREMAIL,OPERATORTEL,OPERATORFAX,"); // strSql.Append("FINANCIALSTAFFCODE,FINANCIALSTAFF,FINANCIALSTAFFEMAIL,FINANCIALSTAFFTEL,FINANCIALSTAFFFAX"); // strSql.Append(",OTFEE1,OTFEE1AMOUNT,OTFEE2,OTFEE2AMOUNT,OTFEE3,OTFEE3AMOUNT,OTFEE4,OTFEE4AMOUNT,OTFEE5,OTFEE5AMOUNT"); // strSql.Append(",OTFEE6,OTFEE6AMOUNT,OTFEE7,OTFEE7AMOUNT,OTFEE8,OTFEE8AMOUNT"); // strSql.Append(",PFREIGHT,CFREIGHT,PSTATEMENT,CSTATEMENT,PTAX,CTAX,POTFREIGHT,COTFREIGHT,PCARRIEROT,CCARRIEROT,PTOTAL,CTOTAL"); // strSql.Append(",(SELECT TOP 1 BLSTATUS FROM op_blissue WHERE BSNO=B.BSNO) BLISSUESTATUS"); // strSql.Append(",(CASE BSSTATUS WHEN 1 THEN '锁定' else '未锁定' end) as BSSTATUSREF "); // strSql.Append(",(CASE FEESTATUS WHEN 1 THEN '锁定' else '未锁定' end) as FEESTATUSREF "); // strSql.Append(",'' as OPSTATUS "); // strSql.Append(",CUSTOMNO,ENTERPID,ENTERP,INSPECTIONNO,INSPECTIONDATE,CUSTOMDATE,TRADETYPE,TRADETERM,ISSUEBY,ISSUEDATE,ISSUEPLACE"); // strSql.Append(",IsService1,IsService2,IsService3,IsService4,IsService5,IsService6,IsService7,IsService8,IsService9,IsService10"); // strSql.Append(",'' DRFEESTATUS"); // strSql.Append(",'' CRFEESTATUS,ISPRINTPR,0 TTLDR,0 TTLINVDR,0 TTLDUIDR,0 APPLYCOUNT,B.BillFeeStatus "); // strSql.Append(",SALECORPID,(select [NAME] from [company] where GID=B.SALECORPID) as SALECORP,CONTRACTNO,LANE,DELIVERYDATE,DOC,HSCODE,ISCANCEL"); // strSql.Append(" from OP_AIRE B"); // if (!string.IsNullOrEmpty(condition)) // { // strSql.Append(" where " + condition); // } // var list = SetData(strSql); // if (list.Count > 0) // return list[0]; // return new MsOpAire(); // } // static public List GetFenList(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 B.BSNO,MASTERNO,ORDERTYPE,ORDTYPE,ORDERNO,BSSTATUS,FEESTATUS,BSDATE,ACCDATE,MBLNO,HBLNO,CUSTNO,TRANSNO,CUSTOMERNAME,SHIPPERID,"); // strSql.Append("CONSIGNEEID,NOTIFYPARTYID,SHIPPER,CONSIGNEE,NOTIFYPARTY,AGENTID,AGENT,VESSEL,ETD,ETA,"); // strSql.Append("PORTLOADID,PORTLOAD,PORTDISCHARGEID,PORTDISCHARGE,TRANSPORTID,TRANSPORT,TRANSPORT2ID,TRANSPORT2,TRANSPORT3ID,TRANSPORT3,BLTYPE,ISSUETYPE,"); // strSql.Append("BLFRT,OTFRT,HBLBLFRT,HBLOTFRT,MARKS,[DESCRIPTION],GOODSNAME,PKGS,KINDPKGS,UNIT,"); // strSql.Append("KGS,CBM,CURR,CUSTVALUE,CUSTOMVALUE,CLASS,FEEKGS,PRICE,TTLFREIGHT,OTFEE,HANDINGINFO,ACCOUNTINFO,"); // strSql.Append("INPUTBY,OP,CUSTSERVICE,SALE,AIRLINES,TRANSAIRLINES,FORWARDER,CUSTOMSER,TRUCKER,INVNO,FRCUSTSERVICE,"); // strSql.Append("CARGOID,BSSOURCE,BSSOURCEDETAIL,ORDERNO,INSURANCEER,INSURANCENO,INAMOUT,"); // strSql.Append("ISVOU,VOUNO,REMARK,CORPID,SALEDEPT,CREATETIME,STLNAME,STLDATE,ORDERTYPE,"); // strSql.Append("OPERATORCODE,OPERATOR,OPERATOREMAIL,OPERATORTEL,OPERATORFAX,"); // strSql.Append("FINANCIALSTAFFCODE,FINANCIALSTAFF,FINANCIALSTAFFEMAIL,FINANCIALSTAFFTEL,FINANCIALSTAFFFAX"); // strSql.Append(",OTFEE1,OTFEE1AMOUNT,OTFEE2,OTFEE2AMOUNT,OTFEE3,OTFEE3AMOUNT,OTFEE4,OTFEE4AMOUNT,OTFEE5,OTFEE5AMOUNT"); // strSql.Append(",OTFEE6,OTFEE6AMOUNT,OTFEE7,OTFEE7AMOUNT,OTFEE8,OTFEE8AMOUNT"); // strSql.Append(",PFREIGHT,CFREIGHT,PSTATEMENT,CSTATEMENT,PTAX,CTAX,POTFREIGHT,COTFREIGHT,PCARRIEROT,CCARRIEROT,PTOTAL,CTOTAL"); // strSql.Append(",(SELECT TOP 1 BLSTATUS FROM op_blissue WHERE BSNO=B.BSNO) BLISSUESTATUS"); // 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 TOP 1 STATUS FROM OP_STATUS WHERE BSNO=B.BSNO ORDER BY COMPTIME DESC,INPUTTIME DESC) as OPSTATUS "); // strSql.Append(",CUSTOMNO,ENTERPID,ENTERP,INSPECTIONNO,INSPECTIONDATE,CUSTOMDATE,TRADETYPE,TRADETERM,ISSUEBY,ISSUEDATE,ISSUEPLACE"); // strSql.Append(",IsService1,IsService2,IsService3,IsService4,IsService5,IsService6,IsService7,IsService8,IsService9,IsService10"); // strSql.Append(",dbo.F_GetBillDrFeeStatus(B.BSNO) DRFEESTATUS"); // strSql.Append(",dbo.F_GetBillCrFeeStatus(B.BSNO) CRFEESTATUS,ISPRINTPR,0 TTLDR,0 TTLINVDR,0 TTLDUIDR,0 APPLYCOUNT,B.BillFeeStatus "); // strSql.Append(",SALECORPID,(select [NAME] from [company] where GID=B.SALECORPID) as SALECORP,CONTRACTNO,LANE,DELIVERYDATE,DOC,HSCODE,ISCANCEL"); // strSql.Append(" from OP_AIRE B"); // 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 SetData(strSql); // } // 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()) // { // MsOpAire data = new MsOpAire(); // #region Set DB data to Object // data.BillFeeStatus = Convert.ToString(reader["BillFeeStatus"]); // data.BSNO = Convert.ToString(reader["BSNO"]);//业务编号 // data.ORDERTYPE = Convert.ToString(reader["ORDERTYPE"]);//委托方式 // data.MASTERNO = Convert.ToString(reader["MASTERNO"]);//主编号 // data.CUSTNO = Convert.ToString(reader["CUSTNO"]);//委托编号 // data.MBLNO = Convert.ToString(reader["MBLNO"]);//主提单号 // data.HBLNO = Convert.ToString(reader["HBLNO"]);//分提单号 // 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 (Convert.ToString(reader["OPSTATUS"]) != "") // data.OPSTATUS = Convert.ToString(reader["OPSTATUS"]);// 费用状态 // data.BLISSUESTATUS = Convert.ToString(reader["BLISSUESTATUS"]);// 费用状态 // data.BSDATE = Convert.ToDateTime(reader["BSDATE"]);//接单日期 // data.ACCDATE = Convert.ToString(reader["ACCDATE"]);//会计期间 // data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);//委托单位 // data.BSSOURCE = Convert.ToString(reader["BSSOURCE"]);//业务来源 // data.BSSOURCEDETAIL = Convert.ToString(reader["BSSOURCEDETAIL"]);//来源明细 // data.INPUTBY = Convert.ToString(reader["INPUTBY"]);//录入人 // data.OP = Convert.ToString(reader["OP"]);//操作员 // data.CUSTSERVICE = Convert.ToString(reader["CUSTSERVICE"]);//客服员 // data.FRCUSTSERVICE = Convert.ToString(reader["FRCUSTSERVICE"]);//客服员 // data.SALE = Convert.ToString(reader["SALE"]);//揽货人 // 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.CREATETIME = Convert.ToString(reader["CREATETIME"]);//创建时间 // data.VESSEL = Convert.ToString(reader["VESSEL"]);//船名 // if (reader["ETD"] != DBNull.Value) // data.ETD = Convert.ToDateTime(reader["ETD"]).ToString("yyyy-MM-dd");//到港日期 // data.LANE = Convert.ToString(reader["LANE"]);//航线 // data.PORTLOADID = Convert.ToString(reader["PORTLOADID"]);//装货港代码 // data.PORTLOAD = Convert.ToString(reader["PORTLOAD"]);//装货港 // data.PORTDISCHARGEID = Convert.ToString(reader["PORTDISCHARGEID"]);//卸货港代码 // data.PORTDISCHARGE = Convert.ToString(reader["PORTDISCHARGE"]);//卸货港 // data.TRANSPORTID = Convert.ToString(reader["TRANSPORTID"]);//中转港代码 // data.TRANSPORT = Convert.ToString(reader["TRANSPORT"]);//中转港 // data.TRANSPORT2ID = Convert.ToString(reader["TRANSPORT2ID"]);//中转港代码2 // data.TRANSPORT2 = Convert.ToString(reader["TRANSPORT2"]);//中转港2 // data.TRANSPORT3ID = Convert.ToString(reader["TRANSPORT3ID"]);//中转港代码3 // data.TRANSPORT3 = Convert.ToString(reader["TRANSPORT3"]);//中转港3 // data.GOODSNAME = Convert.ToString(reader["GOODSNAME"]);//品名 // data.TRADETYPE = Convert.ToString(reader["TRADETYPE"]);//贸易方式 // data.TRADETERM = Convert.ToString(reader["TRADETERM"]);//贸易条款 // data.ISSUETYPE = Convert.ToString(reader["ISSUETYPE"]);//签单方式 // if (reader["KGS"] != DBNull.Value) // data.KGS = Convert.ToString(reader["KGS"]);//毛重 // data.CUSTOMSER = Convert.ToString(reader["CUSTOMSER"]);//报关行 // if (reader["PKGS"] != DBNull.Value) // data.PKGS = Convert.ToString(reader["PKGS"]);//件数 // if (reader["ISVOU"] != DBNull.Value) // data.ISVOU = Convert.ToBoolean(reader["ISVOU"]);//是否生成凭证 // data.VOUNO = Convert.ToString(reader["VOUNO"]);//凭证号 // data.KINDPKGS = Convert.ToString(reader["KINDPKGS"]);//件数包装 // data.UNIT = Convert.ToString(reader["UNIT"]);//件数包装 // data.REMARK = Convert.ToString(reader["REMARK"]);//备注 // if (reader["CBM"] != DBNull.Value) // data.CBM = Convert.ToString(reader["CBM"]);//立方数/尺码 // data.AIRLINES = Convert.ToString(reader["AIRLINES"]);//航司 // data.TRANSAIRLINES = Convert.ToString(reader["TRANSAIRLINES"]);//中转航司 // data.TRUCKER = Convert.ToString(reader["TRUCKER"]);//承运车队 // data.DESCRIPTION = Convert.ToString(reader["DESCRIPTION"]);//货物描述 // data.TRANSNO = Convert.ToString(reader["TRANSNO"]);//运单号 // data.SHIPPERID = Convert.ToString(reader["SHIPPERID"]);//发货人 // data.CONSIGNEEID = Convert.ToString(reader["CONSIGNEEID"]);//收货人 // data.NOTIFYPARTYID = Convert.ToString(reader["NOTIFYPARTYID"]);//通知人 // data.SHIPPER = Convert.ToString(reader["SHIPPER"]);//发货人内容 // data.CONSIGNEE = Convert.ToString(reader["CONSIGNEE"]);//收货人内容 // data.NOTIFYPARTY = Convert.ToString(reader["NOTIFYPARTY"]);//通知人内容 // data.AGENTID = Convert.ToString(reader["AGENTID"]);//国外代理 // data.AGENT = Convert.ToString(reader["AGENT"]);//国外代理内容 // if (reader["ETA"] != DBNull.Value) // data.ETA = Convert.ToDateTime(reader["ETA"]).ToString("yyyy-MM-dd");//预抵日期 // data.BLFRT = Convert.ToString(reader["BLFRT"]);//付费方式 // data.OTFRT = Convert.ToString(reader["OTFRT"]);//付费方式 // data.HBLBLFRT = Convert.ToString(reader["HBLBLFRT"]);//付费方式 // data.HBLOTFRT = Convert.ToString(reader["HBLOTFRT"]);//付费方式 // data.ISSUEBY = Convert.ToString(reader["ISSUEBY"]);//付费方式 // data.ISSUEDATE = Convert.ToString(reader["ISSUEDATE"]);//付费方式 // data.ISSUEPLACE = Convert.ToString(reader["ISSUEPLACE"]);//付费方式 // data.CURR = Convert.ToString(reader["CURR"]);// // data.CUSTVALUE = Convert.ToString(reader["CUSTVALUE"]);// // data.CUSTOMVALUE = Convert.ToString(reader["CUSTOMVALUE"]);// // data.CLASS = Convert.ToString(reader["CLASS"]);// // if (reader["FEEKGS"] != DBNull.Value) // data.FEEKGS = Convert.ToString(reader["FEEKGS"]);// // if (reader["PRICE"] != DBNull.Value) // data.PRICE = Convert.ToString(reader["PRICE"]);// // if (reader["TTLFREIGHT"] != DBNull.Value) // data.TTLFREIGHT = Convert.ToString(reader["TTLFREIGHT"]);// // data.OTFEE = Convert.ToString(reader["OTFEE"]);//唛头 // data.HANDINGINFO = Convert.ToString(reader["HANDINGINFO"]);//唛头 // data.ACCOUNTINFO = Convert.ToString(reader["ACCOUNTINFO"]);//唛头 // data.MARKS = Convert.ToString(reader["MARKS"]);//唛头 // data.CONTRACTNO = Convert.ToString(reader["CONTRACTNO"]);//唛头 // data.BLTYPE = Convert.ToString(reader["BLTYPE"]);//唛头 // data.FORWARDER = Convert.ToString(reader["FORWARDER"]);//订舱公司 // data.INVNO = Convert.ToString(reader["INVNO"]);//发票号 // data.CARGOID = Convert.ToString(reader["CARGOID"]);//货物标识 // data.ORDTYPE = Convert.ToString(reader["ORDTYPE"]);//订舱类型 // data.ORDERNO = Convert.ToString(reader["ORDERNO"]);//订舱编号 // data.INSURANCEER = Convert.ToString(reader["INSURANCEER"]);//保险人 // data.INSURANCENO = Convert.ToString(reader["INSURANCENO"]);//保险单号 // data.INAMOUT = Convert.ToString(reader["INAMOUT"]);//保险金额 // data.STLNAME = Convert.ToString(reader["STLNAME"]);//结算方式 // data.STLDATE = Convert.ToString(reader["STLDATE"]);//结算时间 // data.OPERATORCODE = Convert.ToString(reader["OPERATORCODE"]);//客户操作代码 // data.OPERATOR = Convert.ToString(reader["OPERATOR"]);//客户操作名称 // data.OPERATOREMAIL = Convert.ToString(reader["OPERATOREMAIL"]);//操作电子邮箱 // data.OPERATORTEL = Convert.ToString(reader["OPERATORTEL"]);//操作电话 // data.OPERATORFAX = Convert.ToString(reader["OPERATORFAX"]);//操作传真 // data.FINANCIALSTAFFCODE = Convert.ToString(reader["FINANCIALSTAFFCODE"]);//客户财务代码 // data.FINANCIALSTAFF = Convert.ToString(reader["FINANCIALSTAFF"]);//客户财务名称 // data.FINANCIALSTAFFEMAIL = Convert.ToString(reader["FINANCIALSTAFFEMAIL"]);//财务电子邮箱 // data.FINANCIALSTAFFTEL = Convert.ToString(reader["FINANCIALSTAFFTEL"]);//财务电话 // data.FINANCIALSTAFFFAX = Convert.ToString(reader["FINANCIALSTAFFFAX"]);//财务传真 // data.PFREIGHT = Convert.ToString(reader["PFREIGHT"]);// // data.CFREIGHT = Convert.ToString(reader["CFREIGHT"]);// // data.PSTATEMENT = Convert.ToString(reader["PSTATEMENT"]);// // data.CSTATEMENT = Convert.ToString(reader["CSTATEMENT"]);// // data.PTAX = Convert.ToString(reader["PTAX"]);// // data.CTAX = Convert.ToString(reader["CTAX"]);// // data.POTFREIGHT = Convert.ToString(reader["POTFREIGHT"]);// // data.COTFREIGHT = Convert.ToString(reader["COTFREIGHT"]);// // data.PCARRIEROT = Convert.ToString(reader["PCARRIEROT"]);// // data.CCARRIEROT = Convert.ToString(reader["CCARRIEROT"]);// // data.PTOTAL = Convert.ToString(reader["PTOTAL"]);// // data.CTOTAL = Convert.ToString(reader["CTOTAL"]);// // data.OTFEE1 = Convert.ToString(reader["OTFEE1"]);// // if (reader["OTFEE1AMOUNT"] != DBNull.Value) // data.OTFEE1AMOUNT = Convert.ToString(reader["OTFEE1AMOUNT"]);// // data.OTFEE2 = Convert.ToString(reader["OTFEE2"]);// // if (reader["OTFEE2AMOUNT"] != DBNull.Value) // data.OTFEE2AMOUNT = Convert.ToString(reader["OTFEE2AMOUNT"]);// // data.OTFEE3 = Convert.ToString(reader["OTFEE3"]);// // if (reader["OTFEE3AMOUNT"] != DBNull.Value) // data.OTFEE3AMOUNT = Convert.ToString(reader["OTFEE3AMOUNT"]);// // data.OTFEE4 = Convert.ToString(reader["OTFEE4"]);// // if (reader["OTFEE4AMOUNT"] != DBNull.Value) // data.OTFEE4AMOUNT = Convert.ToString(reader["OTFEE4AMOUNT"]);// // data.OTFEE5 = Convert.ToString(reader["OTFEE5"]);// // if (reader["OTFEE5AMOUNT"] != DBNull.Value) // data.OTFEE5AMOUNT = Convert.ToString(reader["OTFEE5AMOUNT"]);// // data.OTFEE6 = Convert.ToString(reader["OTFEE6"]);// // if (reader["OTFEE6AMOUNT"] != DBNull.Value) // data.OTFEE6AMOUNT = Convert.ToString(reader["OTFEE6AMOUNT"]);// // data.OTFEE7 = Convert.ToString(reader["OTFEE7"]);// // if (reader["OTFEE7AMOUNT"] != DBNull.Value) // data.OTFEE7AMOUNT = Convert.ToString(reader["OTFEE7AMOUNT"]);// // data.OTFEE8 = Convert.ToString(reader["OTFEE8"]);// // if (reader["OTFEE8AMOUNT"] != DBNull.Value) // data.OTFEE8AMOUNT = Convert.ToString(reader["OTFEE8AMOUNT"]);// // data.CUSTOMNO = Convert.ToString(reader["CUSTOMNO"]);//报关单号 // if (reader["CUSTOMDATE"] != DBNull.Value) // data.CUSTOMDATE = Convert.ToDateTime(reader["CUSTOMDATE"]).ToString("yyyy-MM-dd");// // data.INSPECTIONNO = Convert.ToString(reader["INSPECTIONNO"]);//商检号 // if (reader["INSPECTIONDATE"] != DBNull.Value) // data.INSPECTIONDATE = Convert.ToDateTime(reader["INSPECTIONDATE"]).ToString("yyyy-MM-dd");// // data.ENTERP = Convert.ToString(reader["ENTERP"]);//经营单位 // data.ENTERPID = Convert.ToString(reader["ENTERPID"]);//经营单位代码 // 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.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 = "部分对账"; // if (reader["APPLYCOUNT"] != DBNull.Value) // data.ISAPPLY = Convert.ToString(reader["APPLYCOUNT"]);//是否生成报关 // if (reader["DELIVERYDATE"] != DBNull.Value) // data.DELIVERYDATE = Convert.ToDateTime(reader["DELIVERYDATE"]).ToString("yyyy-MM-dd"); // data.DOC = Convert.ToString(reader["DOC"]);//唛头 // data.HSCODE = Convert.ToString(reader["HSCODE"]);//HSCODE // data.ISCANCEL = Convert.ToString(reader["ISCANCEL"]); // #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 权限范围 // 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]='modOpAireList' 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 = "1=2"; // } // else if (visiblerange == "3") // { // str = " (B.OP='" + username + "' OR B.SALE='" + username + "' OR B.CUSTSERVICE='" + username + "' OR B.FRCUSTSERVICE='" + username + "')"; // } // else if (visiblerange == "2") // { // if (tb == "index") // { // var rangeDa = new RangeDA(); // var deptid = rangeDa.GetDEPTGID(userid); // str = " (B.OP in (select showname from vw_user where deptgid='" + deptid + "') OR B.SALE in (select showname from vw_user where deptgid='" + deptid + "') OR B.CUSTSERVICE in (select showname from vw_user where deptgid='" + deptid + "') " // + " OR B.DOC in (select showname from vw_user where deptgid='" + deptid + "') OR B.FRCUSTSERVICE in (select showname from vw_user where deptgid='" + deptid + "') OR B.INPUTBY in (select showname from vw_user where deptgid='" + deptid + "'))"; // } // else // { // str = " UPPER(B.Corpid)='" + 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"]) + "' or B.SALECORPID='" + Convert.ToString(reader["COMPANYID"]) + "' "; // } // else // { // str = str + " or B.Corpid='" + Convert.ToString(reader["COMPANYID"]) + "' or B.SALECORPID='" + Convert.ToString(reader["COMPANYID"]) + "'"; // }; // } // str = str + ")"; // reader.Close(); // } // } // else // { // str = " (UPPER(B.Corpid)='" + companyid + "' or B.SALECORPID='" + companyid + "') "; // } // } // else if (visiblerange == "6") // { // if (tb == "index") // { // var opstr = ""; // 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())) // { // while (reader.Read()) // { // if (opstr == "") // { // opstr = " ('" + Convert.ToString(reader["SHOWNAME"]) + "'"; // } // else // { // opstr = opstr + ",'" + Convert.ToString(reader["SHOWNAME"]) + "'"; // }; // } // if (opstr != "") opstr = opstr + ")"; // reader.Close(); // } // if (opstr == "") opstr = "('" + username + "')"; // str = " (B.OP in " + opstr + " or B.SALE in " + opstr + " or B.CUSTSERVICE IN " + opstr + " or B.DOC IN " + opstr + " or B.FRCUSTSERVICE IN " + opstr + " or B.INPUTBY IN " + opstr + ")"; // } // else // { // str = " (UPPER(B.Corpid)='" + companyid + "' or B.SALECORPID='" + companyid + "') "; // } // } // else if (visiblerange == "1") // { // str = " UPPER(B.Corpid)='" + companyid + "'"; // } // VSSQL = VSSQL.Trim(); // if (!string.IsNullOrEmpty(VSSQL)) // { // if (!string.IsNullOrEmpty(str)) // { // str = str + " and (" + VSSQL + ") "; // } // else // { // str = " (" + VSSQL + ") "; // } // } // return str; // } // public static string GetSaleRangDAStr(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]='modAireSaleList' 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 = " B.SALE='" + username + "' "; // } // else if (visiblerange == "3") // { // str = " B.SALE='" + username + "' "; // } // else if (visiblerange == "2") // { // if (tb == "index") // { // var rangeDa = new RangeDA(); // var deptid = rangeDa.GetDEPTGID(userid); // str = " (B.SALE in (select showname from vw_user where deptgid='" + deptid + "') )"; // } // else // { // str = " UPPER(B.Corpid)='" + 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 opstr = ""; // 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())) // { // while (reader.Read()) // { // if (opstr == "") // { // opstr = " ('" + Convert.ToString(reader["SHOWNAME"]) + "'"; // } // else // { // opstr = opstr + ",'" + Convert.ToString(reader["SHOWNAME"]) + "'"; // }; // } // if (opstr != "") opstr = opstr + ")"; // reader.Close(); // } // if (opstr == "") opstr = "('" + username + "')"; // str = " (B.SALE in " + opstr + ")"; // } // else // { // str = " (UPPER(B.Corpid)='" + companyid + "' or B.SALECORPID='" + companyid + "') "; // } // } // else if (visiblerange == "1") // { // str = " UPPER(B.Corpid)='" + companyid + "'"; // } // VSSQL = VSSQL.Trim(); // if (!string.IsNullOrEmpty(VSSQL)) // { // if (!string.IsNullOrEmpty(str)) // { // str = str + " and (" + VSSQL + ") "; // } // else // { // str = " (" + VSSQL + ") "; // } // } // return str; // } // #endregion //} }