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.MsAireOrderDAL { public class MsAireOrderDAL { #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(",B.ORSTATUS,B.AUDITOPERATOR,B.AUDITOPERATOR2,B.SERVICECONTRACTNO "); strSql.Append(" from crm_AireOrder 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,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,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(",dbo.F_GetBillCrFeeStatus(B.BSNO) CRFEESTATUS,ISPRINTPR"); strSql.Append(",b.ORSTATUS,b.AUDITOPERATOR,b.AUDITOPERATOR2,b.SERVICECONTRACTNO "); strSql.Append(" from crm_AireOrder 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(",(CASE BSSTATUS WHEN 1 THEN '锁定' else '未锁定' end) as BSSTATUSREF "); strSql.Append(",ORSTATUS,AUDITOPERATOR,AUDITOPERATOR2,SERVICECONTRACTNO "); strSql.Append(",(CASE ORSTATUS WHEN '8' THEN '确认订舱' WHEN '0' THEN '审核通过' WHEN '1' THEN '提交审核' WHEN '2' THEN '驳回' WHEN '4' THEN '退舱' else '录入状态' end) as ORSTATUSREF "); strSql.Append(" from crm_AireOrder B"); //data.ORSTATUS = Convert.ToString(reader["ORSTATUS"]);// //data.ORSTATUSREF = GetORSTATUSREF(data.ORSTATUS);// //data.AUDITOPERATOR = Convert.ToString(reader["AUDITOPERATOR"]);// //data.AUDITOPERATOR2 = Convert.ToString(reader["AUDITOPERATOR2"]);// //data.SERVICECONTRACTNO = Convert.ToString(reader["SERVICECONTRACTNO"]);// 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 MsAireOrder GetData(string condition,string USERID) { 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(",b.ORSTATUS,b.AUDITOPERATOR,b.AUDITOPERATOR2,b.SERVICECONTRACTNO "); strSql.Append(" from crm_AireOrder B"); if (!string.IsNullOrEmpty(condition)) { strSql.Append(" where " + condition); } var list=SetData(strSql); if (list.Count > 0) return list[0]; return new MsAireOrder(); } 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,"); 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 crm_AireOrder 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); } public static int getTotalCount(string strCondition, string userid, string usercode, string companyid) { var rangstr = GetRangDAStr("index", userid, usercode, companyid); if (!string.IsNullOrEmpty(rangstr)) { if (!string.IsNullOrEmpty(strCondition)) { strCondition = strCondition + " and " + rangstr; } else { strCondition = rangstr; } } StringBuilder strSql = new StringBuilder(); strSql.Append("select count(*) "); strSql.Append(" from crm_AireOrder B "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } int cnt = 0; Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { cnt = Convert.ToInt32(reader[0]); } } return cnt; } private static string GetORSTATUSREF(string ORSTATUS) { //strSql.Append(",(CASE ORSTATUS WHEN '8' THEN '确认订舱' WHEN '0' THEN '审核通过' WHEN '1' THEN '提交审核' WHEN '2' THEN '驳回' WHEN '4' THEN '退舱' else '录入状态' end) as ORSTATUSREF "); switch (ORSTATUS) { case "8": return "确认订舱"; case "0": return "审核通过"; case "1": return "提交审核"; case "2": return "驳回"; case "4": return "退舱"; default: //return "录入状态"; break; } return "录入状态"; } 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()) { MsAireOrder data = new MsAireOrder(); #region Set DB data to Object data.ORSTATUS = Convert.ToString(reader["ORSTATUS"]);// data.ORSTATUSREF = GetORSTATUSREF(data.ORSTATUS);// data.AUDITOPERATOR = Convert.ToString(reader["AUDITOPERATOR"]);// data.AUDITOPERATOR2 = Convert.ToString(reader["AUDITOPERATOR2"]);// data.SERVICECONTRACTNO = Convert.ToString(reader["SERVICECONTRACTNO"]);// 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 判断是否有费用 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 权限范围 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"); if (tb == "audit") { //strSql.Append(" where [NAME]='modSeaeOrderAudit' and USERID='" + userid + "' and ISDELETE=0"); str = " (AUDITOPERATOR='" + username + "' OR AUDITOPERATOR2='" + username + "' )"; return str; } else { strSql.Append(" where [NAME]='modAireOrder' 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 = " (OP='" + username + "' OR SALE='" + username + "' or CUSTSERVICE='" + username + "' or DOC='" + username + "' or INPUTBY='" + username + "')"; } else if (visiblerange == "5") { var userstr = new StringBuilder(); userstr.Append(" select SHOWNAME from VW_user where COMPANYID in (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 = " (OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR SALE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR CUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR DOC='" + Convert.ToString(reader["SHOWNAME"]) + "' OR INPUTBY='" + Convert.ToString(reader["SHOWNAME"]) + "' "; } else { str = str + " or OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR SALE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR CUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR DOC='" + Convert.ToString(reader["SHOWNAME"]) + "' OR INPUTBY='" + Convert.ToString(reader["SHOWNAME"]) + "' "; }; } str = str + ")"; reader.Close(); } } else if (visiblerange == "6") { var userstr = new StringBuilder(); userstr.Append(" select OPID,(select SHOWNAME from [user] where GID=user_authority_range_op.OPID) SHOWNAME from user_authority_range_op where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1"); Database userdb = DatabaseFactory.CreateDatabase(); using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString())) { str = ""; while (reader.Read()) { if (str == "") { str = " (OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR SALE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR CUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR DOC='" + Convert.ToString(reader["SHOWNAME"]) + "' OR INPUTBY='" + Convert.ToString(reader["SHOWNAME"]) + "' "; } else { str = str + " or OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR SALE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR CUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR DOC='" + Convert.ToString(reader["SHOWNAME"]) + "' OR INPUTBY='" + Convert.ToString(reader["SHOWNAME"]) + "' "; }; } str = str + ")"; reader.Close(); } } else if (visiblerange == "2") { var rangeDa = new RangeDA(); var deptname = rangeDa.GetDEPTNAME(userid); var userstr = new StringBuilder(); userstr.Append(" select SHOWNAME from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')"); Database userdb = DatabaseFactory.CreateDatabase(); using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString())) { str = ""; while (reader.Read()) { if (str == "") { str = " (OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR SALE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR CUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR DOC='" + Convert.ToString(reader["SHOWNAME"]) + "' OR INPUTBY='" + Convert.ToString(reader["SHOWNAME"]) + "' "; } else { str = str + " or OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR SALE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR CUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR DOC='" + Convert.ToString(reader["SHOWNAME"]) + "' OR INPUTBY='" + Convert.ToString(reader["SHOWNAME"]) + "' "; }; } str = str + ")"; reader.Close(); } } else if (visiblerange == "1") { var rangeDa = new RangeDA(); var userstr = new StringBuilder(); userstr.Append(" select SHOWNAME from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') "); Database userdb = DatabaseFactory.CreateDatabase(); using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString())) { str = ""; while (reader.Read()) { if (str == "") { str = " (OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR SALE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR CUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR DOC='" + Convert.ToString(reader["SHOWNAME"]) + "' OR INPUTBY='" + Convert.ToString(reader["SHOWNAME"]) + "' "; } else { str = str + " or OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR SALE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR CUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR DOC='" + Convert.ToString(reader["SHOWNAME"]) + "' OR INPUTBY='" + Convert.ToString(reader["SHOWNAME"]) + "'"; }; } str = str + ")"; reader.Close(); } } 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 } }