You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/MvcShipping/DAL/MsOpAirn/MsOpAirnDAL.cs

2426 lines
128 KiB
C#

2 years ago
using System;
using System.Data;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using DSWeb.MvcShipping.Models.MsOpAirn;
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 System.Web;
using DSWeb.TruckMng.Comm.Cookie;
using DSWeb.MvcShipping.Controllers;
namespace DSWeb.MvcShipping.DAL.MsOpAirnDAL
{
public class MsOpAirnDAL
{
#region 查询
static public List<MsOpAirn> GetDataList(string strCondition, string bltype, 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 B.BSNO,MASTERNO,ORDERTYPE,ORDTYPE,ORDERNO,BSSTATUS,FEESTATUS,dbo.trimtime(BSDATE) BSDATE,ACCDATE,MBLNO,HBLNO,CUSTNO,TRANSNO,CUSTOMERNAME,BLTYPE,SHIPPERID,");
strSql.Append("CONSIGNEEID,NOTIFYPARTYID,SHIPPER,CONSIGNEE,NOTIFYPARTY,AGENTID,AGENT,VESSEL,VESSELHEAD,ETD,ETA,");
strSql.Append("PORTLOADID,PORTLOAD,PORTDISCHARGEID,PORTDISCHARGE,BLTYPE,");
strSql.Append("BLFRT,OTFRT,HBLBLFRT,HBLOTFRT,MARKS,[DESCRIPTION],KINDPKGS,UNIT,");
strSql.Append("CURR,CUSTVALUE,CUSTOMVALUE,CLASS,FEEKGS,TTLFREIGHT,OTFEE,HANDINGINFO,ACCOUNTINFO,");
strSql.Append("INPUTBY,OP,CUSTSERVICE,SALE,AIRLINES,FORWARDER,CUSTOMSER,TRUCKER,INVNO,");
strSql.Append("CARGOID,BSSOURCE,BSSOURCEDETAIL,ORDERNO,INSURANCEER,INSURANCENO,INAMOUT,");
strSql.Append("ISVOU,VOUNO,REMARK,CORPID,SALEDEPT,dbo.trimtime(CREATETIME) 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(",(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,dbo.trimtime(ISSUEDATE) 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(",CY1,CY2,CY3,PORT1,PORT2,PORT3,SUPERVISE,TRANSFER,TRANSFER_REMARK,PVALUEFEE,CVALUEFEE,convert(bigint ,TimeMark) as TimeMark");
strSql.Append(",STREMARK,TRANSREMARK,FLYTIME,FLYTIME1,FLYTIME2,INVOICENO ");
strSql.Append(" ,HDEMO,c.CARGONAME GOODSNAME,c.BOXCOUNT PKGS,c.M_WEIGHT M_WEIGHT,c.WEIGHT KGS,c.CBM ");
strSql.Append(" ,c.PRICE price,ISVOID ");
strSql.Append(" ,(select isnull(ISAGENTCN,0) from info_client where shortname=B.AIRLINES) ISAGENTCN ");
strSql.Append(" ,(select CODENAME from info_client where shortname=B.AIRLINES) AIRLINESCODE ");
strSql.Append(" ,(select name from company where gid=CORPID) CORPREF ");
2 years ago
strSql.Append(" from OP_AIRN B ");
//sql主分单过滤条件已在where中体现无需再join中嵌套case 2018年1月27日10:44:14
// strSql.Append(" left join OP_AIRN_CARGO C on c.bsno =( CASE b.BLTYPE when '国内分单' then B.bsno else (select top 1 bsno from OP_AIRN where HBLNO=b.HBLNO and BLTYPE='国内分单') end) ");
// strSql.Append(" left join OP_AIRN_CARGO C on c.bsno =b.bsno ");
//strSql.Append(" left join (select f.mblno as FMBLNO,c1.CARGOGID,c1.CARGONAME ,c1.BOXCOUNT ,c1.M_WEIGHT ,c1.WEIGHT ,c1.CBM,c1.price from op_airn f left join OP_AIRN_CARGO C1 on f.BSNO=c1.bsno where bltype='国内分单') C on c.fMBLNO =b.mblno ");
if (bltype == "国内分单")
{
strSql.Append(" left join OP_AIRN_CARGO C on c.bsno =b.bsno ");
}
else
{
strSql.Append(" left join OP_AIRN_CARGO C on c.bsno =(select top 1 bsno from OP_AIRN where HBLNO=b.HBLNO and BLTYPE='国内分单') ");
}
strSql.Append(" left join Import_cargoName icn on icn.gid=c.CARGOGID ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
else {
strSql.Append("");
}
//
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,dbo.trimtime(BSDATE) BSDATE,ACCDATE,MBLNO,HBLNO,CUSTNO,TRANSNO,CUSTOMERNAME,SHIPPERID,");
strSql.Append("CONSIGNEEID,NOTIFYPARTYID,SHIPPER,CONSIGNEE,NOTIFYPARTY,AGENTID,AGENT,VESSEL,VESSELHEAD,ETD,ETA,");
strSql.Append("PORTLOADID,PORTLOAD,PORTDISCHARGEID,PORTDISCHARGE,BLTYPE,");
strSql.Append("BLFRT,OTFRT,HBLBLFRT,HBLOTFRT,MARKS,[DESCRIPTION],KINDPKGS,UNIT,");
strSql.Append("CURR,CUSTVALUE,CUSTOMVALUE,CLASS,FEEKGS,TTLFREIGHT,OTFEE,HANDINGINFO,ACCOUNTINFO,");
strSql.Append("INPUTBY,OP,CUSTSERVICE,SALE,AIRLINES,FORWARDER,CUSTOMSER,TRUCKER,INVNO,");
strSql.Append("CARGOID,BSSOURCE,BSSOURCEDETAIL,ORDERNO,INSURANCEER,INSURANCENO,INAMOUT,");
strSql.Append("ISVOU,VOUNO,REMARK,CORPID,SALEDEPT,dbo.trimtime(CREATETIME) 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(",(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,dbo.trimtime(ISSUEDATE) ISSUEDATE,ISSUEPLACE");
strSql.Append(",IsService1,IsService2,IsService3,IsService4,IsService5,IsService6,IsService7,IsService8,IsService9,IsService10,ISPRINTPR,STREMARK,TRANSREMARK,FLYTIME ");
strSql.Append(" ,icn.cnname+'_'+icn.CodeName GOODSNAME,c.BOXCOUNT PKGS,c.M_WEIGHT M_WEIGHT,c.WEIGHT KGS,c.CBM ");
strSql.Append(" ,c.PRICE price,ISVOID ");
strSql.Append(" ,(select isnull(ISAGENTCN,0) from info_client where shortname=B.AIRLINES) ISAGENTCN ");
strSql.Append(" ,(select CODENAME from info_client where shortname=B.AIRLINES) AIRLINESCODE ");
strSql.Append(" ,(select name from company where gid=CORPID) CORPREF ");
2 years ago
strSql.Append(" from OP_AIRN B ");
strSql.Append(" left join OP_AIRN_CARGO C on c.bsno =( CASE b.BLTYPE when '国内分单' then B.bsno else (select top 1 bsno from OP_AIRN where HBLNO=b.HBLNO and BLTYPE='国内分单') end) ");
strSql.Append(" left join Import_cargoName icn on icn.gid=c.CARGOGID ");
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 MsOpAirn GetData(string condition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT B.BSNO,MASTERNO,ORDERTYPE,ORDTYPE,ORDERNO,BSSTATUS,FEESTATUS,dbo.trimtime(BSDATE) BSDATE,ACCDATE,MBLNO,HBLNO,CUSTNO,TRANSNO,CUSTOMERNAME,SHIPPERID,");
strSql.Append("CONSIGNEEID,NOTIFYPARTYID,SHIPPER,CONSIGNEE,NOTIFYPARTY,AGENTID,AGENT,VESSEL,VESSELHEAD,ETD,ETA,");
strSql.Append("PORTLOADID,PORTLOAD,PORTDISCHARGEID,PORTDISCHARGE,BLTYPE,");
strSql.Append("BLFRT,OTFRT,HBLBLFRT,HBLOTFRT,MARKS,[DESCRIPTION],KINDPKGS,UNIT,");
strSql.Append("CURR,CUSTVALUE,CUSTOMVALUE,CLASS,FEEKGS,TTLFREIGHT,OTFEE,HANDINGINFO,ACCOUNTINFO,");
strSql.Append("INPUTBY,OP,CUSTSERVICE,SALE,AIRLINES,FORWARDER,CUSTOMSER,TRUCKER,INVNO,");
strSql.Append("CARGOID,BSSOURCE,BSSOURCEDETAIL,ORDERNO,INSURANCEER,INSURANCENO,INAMOUT,");
strSql.Append("ISVOU,VOUNO,REMARK,CORPID,SALEDEPT,dbo.trimtime(CREATETIME) 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(",(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(",'' DRFEESTATUS");
strSql.Append(",'' CRFEESTATUS,ISPRINTPR");
strSql.Append(",CY1,CY2,CY3,PORT1,PORT2,PORT3,SUPERVISE,TRANSFER,TRANSFER_REMARK,PVALUEFEE,CVALUEFEE,convert(bigint ,TimeMark) as TimeMark,STREMARK,TRANSREMARK,FLYTIME,FLYTIME1,FLYTIME2,INVOICENO");
strSql.Append(" ,HDEMO,icn.cnname+'_'+icn.CodeName GOODSNAME,c.BOXCOUNT PKGS,c.M_WEIGHT M_WEIGHT,c.WEIGHT KGS,c.CBM ");
strSql.Append(" ,c.PRICE price,ISVOID ");
strSql.Append(" ,(select isnull(ISAGENTCN,0) from info_client where shortname=B.AIRLINES) ISAGENTCN ");
strSql.Append(" ,(select CODENAME from info_client where shortname=B.AIRLINES) AIRLINESCODE ");
strSql.Append(" ,(select name from company where gid=CORPID) CORPREF ");
2 years ago
strSql.Append(" from OP_AIRN B ");
strSql.Append(" left join OP_AIRN_CARGO C on c.bsno =( CASE b.BLTYPE when '国内分单' then B.bsno else (select top 1 bsno from OP_AIRN where HBLNO=b.HBLNO and BLTYPE='国内分单') end) ");
strSql.Append(" left join Import_cargoName icn on icn.gid=c.CARGOGID ");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" where " + condition);
}
var list = SetData(strSql);
if (list.Count > 0)
return list[0];
return new MsOpAirn();
}
static public List<MsOpAirn> 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,dbo.trimtime(BSDATE) BSDATE,ACCDATE,MBLNO,HBLNO,CUSTNO,TRANSNO,CUSTOMERNAME,SHIPPERID,");
strSql.Append("CONSIGNEEID,NOTIFYPARTYID,SHIPPER,CONSIGNEE,NOTIFYPARTY,AGENTID,AGENT,VESSEL,VESSELHEAD,ETD,ETA,");
strSql.Append("PORTLOADID,PORTLOAD,PORTDISCHARGEID,PORTDISCHARGE,BLTYPE,");
strSql.Append("BLFRT,OTFRT,HBLBLFRT,HBLOTFRT,MARKS,[DESCRIPTION],KINDPKGS,UNIT,");
strSql.Append("CURR,CUSTVALUE,CUSTOMVALUE,CLASS,FEEKGS,TTLFREIGHT,OTFEE,HANDINGINFO,ACCOUNTINFO,");
strSql.Append("INPUTBY,OP,CUSTSERVICE,SALE,AIRLINES,FORWARDER,CUSTOMSER,TRUCKER,INVNO,");
strSql.Append("CARGOID,BSSOURCE,BSSOURCEDETAIL,ORDERNO,INSURANCEER,INSURANCENO,INAMOUT,");
strSql.Append("ISVOU,VOUNO,REMARK,CORPID,SALEDEPT,dbo.trimtime(CREATETIME) 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(",(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,STREMARK,TRANSREMARK,FLYTIME,FLYTIME1,FLYTIME2,INVOICENO");
strSql.Append(" ,icn.cnname+'_'+icn.CodeName GOODSNAME,c.BOXCOUNT PKGS,c.M_WEIGHT M_WEIGHT,c.WEIGHT KGS,c.CBM ");
strSql.Append(" ,c.PRICE price ,ISVOID,HDEMO");
strSql.Append(" ,(select isnull(ISAGENTCN,0) from info_client where shortname=B.AIRLINES) ISAGENTCN ");
strSql.Append(" ,(select CODENAME from info_client where shortname=B.AIRLINES) AIRLINESCODE,HDEMO ");
strSql.Append(" ,(select name from company where gid=CORPID) CORPREF ");
strSql.Append(" ,(select name from company where gid=CORPID) CORPREF ");
2 years ago
strSql.Append(" from OP_AIRN B ");
strSql.Append(" left join OP_AIRN_CARGO C on c.bsno =( CASE b.BLTYPE when '国内分单' then B.bsno else (select top 1 bsno from OP_AIRN where HBLNO=b.HBLNO and BLTYPE='国内分单') end) ");
strSql.Append(" left join Import_cargoName icn on icn.gid=c.CARGOGID ");
strSql.Append(" from OP_AIRN 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<MsOpAirn> SetData(StringBuilder strSql)
{
var headList = new List<MsOpAirn>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsOpAirn data = new MsOpAirn();
#region Set DB data to Object
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.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.SALE = Convert.ToString(reader["SALE"]);//揽货人
data.CORPID = Convert.ToString(reader["CORPID"]);//分公司代码
data.SALEDEPT = Convert.ToString(reader["SALEDEPT"]);//所属部门
data.CREATETIME = Convert.ToString(reader["CREATETIME"]);//创建时间
var ISAGENTCN = Convert.ToString(reader["ISAGENTCN"]);
data.VESSEL = Convert.ToString(reader["VESSEL"]);//航班号
data.VESSELHEAD = Convert.ToString(reader["VESSELHEAD"]);//航班号
data.VESSEL_REF = data.VESSELHEAD + data.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"]);//品名
data.TRADETYPE = Convert.ToString(reader["TRADETYPE"]);//贸易方式
data.TRADETERM = Convert.ToString(reader["TRADETERM"]);//贸易条款
if (reader["KGS"] != DBNull.Value)
data.KGS = Convert.ToDecimal(reader["KGS"]);//计费重
data.CUSTOMSER = Convert.ToString(reader["CUSTOMSER"]);//报关行
if (reader["PKGS"] != DBNull.Value)
data.PKGS = Convert.ToInt32(reader["PKGS"]);//件数
if (reader["M_WEIGHT"] != DBNull.Value)
data.M_WEIGHT = Convert.ToInt32(reader["M_WEIGHT"]);//实际重
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.ToDecimal(reader["CBM"]);//立方数/尺码
data.AIRLINES = Convert.ToString(reader["AIRLINES"]);//船公司
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.ToDecimal(reader["FEEKGS"]);//
if (reader["PRICE"] != DBNull.Value)
data.PRICE = Convert.ToDecimal(reader["PRICE"]);//
if (reader["TTLFREIGHT"] != DBNull.Value)
data.TTLFREIGHT = Convert.ToDecimal(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.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.ToDecimal(reader["OTFEE1AMOUNT"]);//
data.OTFEE2 = Convert.ToString(reader["OTFEE2"]);//
if (reader["OTFEE2AMOUNT"] != DBNull.Value)
data.OTFEE2AMOUNT = Convert.ToDecimal(reader["OTFEE2AMOUNT"]);//
data.OTFEE3 = Convert.ToString(reader["OTFEE3"]);//
if (reader["OTFEE3AMOUNT"] != DBNull.Value)
data.OTFEE3AMOUNT = Convert.ToDecimal(reader["OTFEE3AMOUNT"]);//
data.OTFEE4 = Convert.ToString(reader["OTFEE4"]);//
if (reader["OTFEE4AMOUNT"] != DBNull.Value)
data.OTFEE4AMOUNT = Convert.ToDecimal(reader["OTFEE4AMOUNT"]);//
data.OTFEE5 = Convert.ToString(reader["OTFEE5"]);//
if (reader["OTFEE5AMOUNT"] != DBNull.Value)
data.OTFEE5AMOUNT = Convert.ToDecimal(reader["OTFEE5AMOUNT"]);//
data.OTFEE6 = Convert.ToString(reader["OTFEE6"]);//
if (reader["OTFEE6AMOUNT"] != DBNull.Value)
data.OTFEE6AMOUNT = Convert.ToDecimal(reader["OTFEE6AMOUNT"]);//
data.OTFEE7 = Convert.ToString(reader["OTFEE7"]);//
if (reader["OTFEE7AMOUNT"] != DBNull.Value)
data.OTFEE7AMOUNT = Convert.ToDecimal(reader["OTFEE7AMOUNT"]);//
data.OTFEE8 = Convert.ToString(reader["OTFEE8"]);//
if (reader["OTFEE8AMOUNT"] != DBNull.Value)
data.OTFEE8AMOUNT = Convert.ToDecimal(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"]);
data.CY1 = Convert.ToString(reader["CY1"]);
data.CY2 = Convert.ToString(reader["CY2"]);
data.CY3 = Convert.ToString(reader["CY3"]);
data.PORT1 = Convert.ToString(reader["PORT1"]);
data.PORT2 = Convert.ToString(reader["PORT2"]);
data.PORT3 = Convert.ToString(reader["PORT3"]);
data.SUPERVISE = Convert.ToString(reader["SUPERVISE"]);
data.TRANSFER = Convert.ToString(reader["TRANSFER"]);
data.TRANSFER_REMARK = Convert.ToString(reader["TRANSFER_REMARK"]);
data.PVALUEFEE = Convert.ToString(reader["PVALUEFEE"]);
data.CVALUEFEE = Convert.ToString(reader["CVALUEFEE"]);
data.TimeMark = Convert.ToDecimal(reader["TimeMark"]);
data.STREMARK = Convert.ToString(reader["STREMARK"]);
data.TRANSREMARK = Convert.ToString(reader["TRANSREMARK"]);
data.FLYTIME = Convert.ToString(reader["FLYTIME"]);
data.FLYTIME1 = Convert.ToString(reader["FLYTIME1"]);
data.FLYTIME2 = Convert.ToString(reader["FLYTIME2"]);
data.INVOICENO = Convert.ToString(reader["INVOICENO"]);
data.ISVOID = Convert.ToDecimal(reader["ISVOID"]);
data.HDEMO = Convert.ToString(reader["HDEMO"]);
data.CORPREF = Convert.ToString(reader["CORPREF"]);
2 years ago
#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("0:") > -1)
{
return "部分审核";
}
else if (feestatusint.IndexOf("2:") > -1)
{
return "部分提交";
}
else if (feestatusint.IndexOf("6:") > -1)
{
return "驳回提交";
}
else if (feestatusint.IndexOf("7:") > -1)
{
return "驳回申请";
}
return result;
}
#endregion
#region 商品信息
static public List<MsOpAirn_Cargomb> GetCargoList(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append("select C.GID,C.BSNO,C.SEQUENCE,C.CARGOGID,C.BOXCOUNT,C.M_WEIGHT,C.WEIGHT,C.CBM,C.CBM_REMARK,C.PRICETYPE,C.PRICE,C.AMOUNT,C.PACKAGE,C.TH1,C.TH2 ");
strSql.Append(" ,cn.CODENAME CARGO_CODE,C.CARGONAME,C.PRICE_2,C.AMOUNT_2,C.WEIGHT_2 ");
strSql.Append(" from OP_AIRN_CARGO C left join Import_Cargoname cn on CARGOGID=cn.GID");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
else
{
strSql.Append(" order by BSDATE desc");
}
return SetCargoData(strSql);
}
private static List<MsOpAirn_Cargomb> SetCargoData(StringBuilder strSql)
{
var headList = new List<MsOpAirn_Cargomb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsOpAirn_Cargomb data = new MsOpAirn_Cargomb();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.BSNO = Convert.ToString(reader["BSNO"]);
data.SEQUENCE = Convert.ToString(reader["SEQUENCE"]);
data.CARGOGID = Convert.ToString(reader["CARGOGID"]);
data.CARGO_CODE = Convert.ToString(reader["CARGO_CODE"]);
data.CARGONAME = Convert.ToString(reader["CARGONAME"]);
data.BOXCOUNT = Convert.ToString(reader["BOXCOUNT"]);
data.M_WEIGHT = Convert.ToString(reader["M_WEIGHT"]);
data.WEIGHT = Convert.ToString(reader["WEIGHT"]);
data.CBM = Convert.ToString(reader["CBM"]);
data.CBM_REMARK = Convert.ToString(reader["CBM_REMARK"]);
data.PRICETYPE = Convert.ToString(reader["PRICETYPE"]);
data.PRICE = Convert.ToString(reader["PRICE"]);
data.AMOUNT = Convert.ToString(reader["AMOUNT"]);
data.PRICE_2 = Convert.ToString(reader["PRICE_2"]);
data.AMOUNT_2 = Convert.ToString(reader["AMOUNT_2"]);
data.PACKAGE = Convert.ToString(reader["PACKAGE"]);
data.TH1 = Convert.ToString(reader["TH1"]);
data.TH2 = Convert.ToString(reader["TH2"]);
data.WEIGHT_2 = Convert.ToString(reader["WEIGHT_2"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#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_airn (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 GETFDMBLNO(string HBLNO)
{
var haveZD = false;
var strSql = new StringBuilder();
strSql.Append("Select MBLNO ");
strSql.Append(" from OP_AIRN ");
strSql.Append(" where HBLNO='" + HBLNO + "' and BLTYPE='国内分单' ");
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var MBLNO = Convert.ToString(reader["MBLNO"]);
if (MBLNO != "") { haveZD = true; };
}
reader.Close();
}
return haveZD;
}
#endregion
#region 提单信息
static public List<MsOpAireBill> 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,ISSUEBY,ISSUEDATE,ISSUEPLACE");
strSql.Append(",OTFEE1,OTFEE1AMOUNT,OTFEE2,OTFEE2AMOUNT,OTFEE3,OTFEE3AMOUNT,OTFEE4,OTFEE4AMOUNT,OTFEE5,OTFEE5AMOUNT");
strSql.Append(",OTFEE6,OTFEE6AMOUNT,OTFEE7,OTFEE7AMOUNT,OTFEE8,OTFEE8AMOUNT");
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,ISSUEBY,ISSUEDATE,ISSUEPLACE");
strSql.Append(",OTFEE1,OTFEE1AMOUNT,OTFEE2,OTFEE2AMOUNT,OTFEE3,OTFEE3AMOUNT,OTFEE4,OTFEE4AMOUNT,OTFEE5,OTFEE5AMOUNT");
strSql.Append(",OTFEE6,OTFEE6AMOUNT,OTFEE7,OTFEE7AMOUNT,OTFEE8,OTFEE8AMOUNT");
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<MsOpAireBill> SetBillData(StringBuilder strSql)
{
var headList = new List<MsOpAireBill>();
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.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"]);//
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.ISSUEDATE = Convert.ToString(reader["ISSUEDATE"]);//
data.ISSUEPLACE = Convert.ToString(reader["ISSUEPLACE"]);//
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#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 ");
strSql.Append(" from VW_User_Authority ");
strSql.Append(" where [NAME]='modOpAirnList' and USERID='" + userid + "' and ISDELETE=0");
string visiblerange = "4";
string operaterange = "4";
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"]);
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 + "')";
}
else if (visiblerange == "2")
{
if (tb == "index")
{
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 = " (B.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.CUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "' ";
}
else
{
str = str + " or B.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.CUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "' ";
};
}
str = str + ")";
reader.Close();
}
}
else
{
str = " UPPER(B.Corpid)='" + companyid + "'";
}
}
else if (visiblerange == "1")
{
str = " UPPER(B.Corpid)='" + companyid + "'";
}
return str;
}
#endregion
#region 直接执行sql命令
static public int ExecSql(string StrSql)
{
/*var strSql = new StringBuilder();
strSql.Append(" delete from [Import_KC] where cargo_id in( " + cargo_id + ")");
strSql.Append(" insert into [Import_KC] ");
strSql.Append(" (ContractNo,cargo_id,CZState,InNum,OutNum,KFstate,CZdate,CORPID,deptgid) ");
strSql.Append(" (select [ContractNo],convert(varchar(50),id) [cargo_id],1 [CZState] ");
strSql.Append(" ,boxcount as [InNum],0 [OutNum],0 kfstate,(getdate()) CZdate ");
strSql.Append(" ,(select gid from company where codename='" + corpcode + "'),(select deptgid from vw_user where userid='" + userid + "') ");
strSql.Append(" from import_cargo where id in( " + cargo_id + ") )");*/
Database db = DatabaseFactory.CreateDatabase();
var _count = db.ExecuteNonQuery(CommandType.Text, StrSql);
return _count;
}
#endregion
}
public class MsOpAirn_FreightDAL
{
#region 查询
static public List<MsOpAirn_FreightPLANmb> GetDataList ( string strCondition, string sort = null )
{
var strSql = new StringBuilder();
strSql.Append("select GID,convert(bigint ,TimeMark) as TimeMarkref");
strSql.Append(",DESCRIPTION,CUSTCODE,CUSTOMERNAME,AREA,BLTYPE");
strSql.Append(",dbo.trimtime(STARTDATE) STARTDATE,dbo.trimtime(ENDDATE) ENDDATE");
strSql.Append(",dbo.trimtime(ENTERDATE) ENTERDATE,ENTEROPERATOR,INUSE");
strSql.Append(" from OpAirn_FreightPLAN");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
else
{
}
//
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" order by STARTDATE,CUSTCODE desc");
}
return SetData(strSql);
}
static public MsOpAirn_FreightPLANmb GetData ( string condition )
{
var _t = "";
var list = GetDataList(condition, _t);
if (list.Count > 0)
return list[0];
return new MsOpAirn_FreightPLANmb();
}
private static List<MsOpAirn_FreightPLANmb> SetData ( StringBuilder strSql )
{
var headList = new List<MsOpAirn_FreightPLANmb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsOpAirn_FreightPLANmb data = new MsOpAirn_FreightPLANmb();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.DESCRIPTION = Convert.ToString(reader["DESCRIPTION"]);
data.CUSTCODE = Convert.ToString(reader["CUSTCODE"]);
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
data.AREA = Convert.ToString(reader["AREA"]);
data.BLTYPE = Convert.ToString(reader["BLTYPE"]);
data.STARTDATE = Convert.ToString(reader["STARTDATE"]);
data.ENDDATE = Convert.ToString(reader["ENDDATE"]);
data.ENTERDATE = Convert.ToString(reader["ENTERDATE"]);
data.ENTEROPERATOR = Convert.ToString(reader["ENTEROPERATOR"]);
data.INUSE = Convert.ToString(reader["INUSE"]);
data.TimeMark = Convert.ToDecimal(reader["TimeMarkref"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#region 复制添加费用方案
static public int COPYNEW ( string OLDGID, string NEWGID )
{
var strSql = new StringBuilder();
strSql.Append(" INSERT INTO [OpAirn_Freight_Detail] ");
strSql.Append(" (GID,[DESCRIPTION],[PLAN_GID],[CARGOGID],[MINFEE],[MINWEIGHT],[W_5],[W_10],[W_N],[W_45],[W_100],[W_300] ");
strSql.Append(" ,[W_500],[W_1000],[REMARK],[REMARK_2],[REMARK_3],[PORTLOADID],[PORTDISCHARGEID],[VESSEL]) ");
strSql.Append(" select newid(),[DESCRIPTION],'" + NEWGID + "',[CARGOGID],[MINFEE],[MINWEIGHT],[W_5],[W_10],[W_N],[W_45],[W_100],[W_300] ");
strSql.Append(" ,[W_500],[W_1000],[REMARK],[REMARK_2],[REMARK_3],[PORTLOADID],[PORTDISCHARGEID],[VESSEL] from [OpAirn_Freight_Detail] ");
strSql.Append(" where [PLAN_GID]='" + OLDGID + "' ");
var _count = 0;
Database db = DatabaseFactory.CreateDatabase();
_count = db.ExecuteNonQuery(CommandType.Text, strSql.ToString());
return _count;
}
#endregion
#endregion
#region 查询方案明细
static public List<MsOpAirn_Freight_Detailmb> GetBodyList ( string strCondition, string sort = null )
{
var strSql = new StringBuilder();
strSql.Append("select D.*,CN.CODENAME+'_'+CN.CNNAME CARGO_CODE,CN.CNNAME CARGO_NAME,P.CUSTCODE,P1.PORTID+'-'+P1.PORTCNAME PORTLOADID_REF,P2.PORTID+'-'+P2.PORTCNAME PORTDISCHARGEID_REF");
strSql.Append(",P1.PORTCNAME PORTCNAME1,P2.PORTCNAME PORTCNAME2,P.CUSTCODE,(select isnull(ISAGENTCN,0) from info_client where shortname=P.CUSTOMERNAME) ISAGENTCN");
strSql.Append(" ,(isnull(w_45,0)*45/case isnull(w_n,1) when 0 then 1 else isnull(w_n,1) end) wm_n ");
strSql.Append(" ,(isnull(w_100,0)*100/case isnull(w_45,1) when 0 then 1 else isnull(w_45,1) end) wm_45 ");
strSql.Append(" ,(isnull(w_300,0)*300/case isnull(w_100,1) when 0 then 1 else isnull(w_100,1) end) wm_100 ");
strSql.Append(" ,(isnull(w_500,0)*500/case isnull(w_300,1) when 0 then 1 else isnull(w_300,1) end) wm_300 ");
strSql.Append(" ,(isnull(w_1000,0)*1000/case isnull(w_500,1) when 0 then 1 else isnull(w_500,1) end) wm_500 ");
strSql.Append(" from OpAirn_Freight_Detail D ");
strSql.Append(" left join code_air_port P1 on P1.PORTID=D.PORTLOADID ");
strSql.Append(" left join code_air_port P2 on P2.PORTID=D.PORTDISCHARGEID ");
strSql.Append(" left join OpAirn_FreightPLAN P on P.GID=D.PLAN_GID ");
strSql.Append(" left join Import_Cargoname cn on cn.GID=D.CARGOGID ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
else
{
}
//
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" order by STARTDATE,P.CUSTCODE desc");
}
return SetBody(strSql);
}
private static List<MsOpAirn_Freight_Detailmb> SetBody ( StringBuilder strSql )
{
var headList = new List<MsOpAirn_Freight_Detailmb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsOpAirn_Freight_Detailmb data = new MsOpAirn_Freight_Detailmb();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.DESCRIPTION = Convert.ToString(reader["DESCRIPTION"]);
data.PLAN_GID = Convert.ToString(reader["PLAN_GID"]);
data.CARGOGID = Convert.ToString(reader["CARGOGID"]);
data.CARGO_CODE = Convert.ToString(reader["CARGO_CODE"]);
data.CARGO_NAME = Convert.ToString(reader["CARGO_NAME"]);
data.MINFEE = Convert.ToString(reader["MINFEE"]);
data.MINWEIGHT = Convert.ToString(reader["MINWEIGHT"]);
data.W_5 = Convert.ToString(reader["W_5"]);
data.W_10 = Convert.ToString(reader["W_10"]);
data.W_N = Convert.ToString(reader["W_N"]);
data.W_45 = Convert.ToString(reader["W_45"]);
data.W_100 = Convert.ToString(reader["W_100"]);
data.W_300 = Convert.ToString(reader["W_300"]);
data.W_500 = Convert.ToString(reader["W_500"]);
data.W_1000 = Convert.ToString(reader["W_1000"]);
data.REMARK = Convert.ToString(reader["REMARK"]);
data.REMARK_2 = Convert.ToString(reader["REMARK_2"]);
data.REMARK_3 = Convert.ToString(reader["REMARK_3"]);
data.PORTLOADID = Convert.ToString(reader["PORTLOADID"]);
data.PORTDISCHARGEID = Convert.ToString(reader["PORTDISCHARGEID"]);
data.VESSEL = Convert.ToString(reader["VESSEL"]);
data.VESSELHEAD = Convert.ToString(reader["VESSELHEAD"]);
data.PORTLOADID_REF = Convert.ToString(reader["PORTLOADID_REF"]);
data.PORTDISCHARGEID_REF = Convert.ToString(reader["PORTDISCHARGEID_REF"]);
data.wm_n = Convert.ToDecimal(reader["wm_n"]);
data.wm_45 = Convert.ToDecimal(reader["wm_45"]);
data.wm_100 = Convert.ToDecimal(reader["wm_100"]);
data.wm_300 = Convert.ToDecimal(reader["wm_300"]);
data.wm_500 = Convert.ToDecimal(reader["wm_500"]);
var ISAGENTCN = Convert.ToString(reader["ISAGENTCN"]);
var CUSTCODE = Convert.ToString(reader["CUSTCODE"]);
if (ISAGENTCN == "1" || ISAGENTCN == "True")
{
data.D_INFO = Convert.ToString(reader["PORTCNAME1"]) + "-" + Convert.ToString(reader["PORTCNAME2"]) + "-" + data.CARGO_NAME + "-"
//+ Convert.ToString(reader["CUSTCODE"])
+ data.VESSEL + "-" + "(" + data.CARGO_CODE + ")";
}
else {
data.D_INFO = Convert.ToString(reader["PORTCNAME1"]) + "-" + Convert.ToString(reader["PORTCNAME2"]) + "-" + data.CARGO_NAME + "-"
+ Convert.ToString(reader["CUSTCODE"])
+ data.VESSEL + "-" + "(" + data.CARGO_CODE + ")";
}
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#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_airn (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;
}
#endregion
#region 提单信息
static public List<MsOpAireBill> 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,ISSUEBY,ISSUEDATE,ISSUEPLACE");
strSql.Append(",OTFEE1,OTFEE1AMOUNT,OTFEE2,OTFEE2AMOUNT,OTFEE3,OTFEE3AMOUNT,OTFEE4,OTFEE4AMOUNT,OTFEE5,OTFEE5AMOUNT");
strSql.Append(",OTFEE6,OTFEE6AMOUNT,OTFEE7,OTFEE7AMOUNT,OTFEE8,OTFEE8AMOUNT");
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,ISSUEBY,ISSUEDATE,ISSUEPLACE");
strSql.Append(",OTFEE1,OTFEE1AMOUNT,OTFEE2,OTFEE2AMOUNT,OTFEE3,OTFEE3AMOUNT,OTFEE4,OTFEE4AMOUNT,OTFEE5,OTFEE5AMOUNT");
strSql.Append(",OTFEE6,OTFEE6AMOUNT,OTFEE7,OTFEE7AMOUNT,OTFEE8,OTFEE8AMOUNT");
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<MsOpAireBill> SetBillData ( StringBuilder strSql )
{
var headList = new List<MsOpAireBill>();
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.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"]);//
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.ISSUEDATE = Convert.ToString(reader["ISSUEDATE"]);//
data.ISSUEPLACE = Convert.ToString(reader["ISSUEPLACE"]);//
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#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 ");
strSql.Append(" from VW_User_Authority ");
strSql.Append(" where [NAME]='modOpAirnList' and USERID='" + userid + "' and ISDELETE=0");
string visiblerange = "4";
string operaterange = "4";
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"]);
break;
}
reader.Close();
}
if (visiblerange == "4")
{
str = "1=2";
}
else if (visiblerange == "3")
{
str = " (B.OP='" + username + "' OR B.SALE='" + username + "' )";
}
else if (visiblerange == "2")
{
if (tb == "index")
{
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 = " (B.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "' ";
}
else
{
str = str + " or B.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "' ";
};
}
str = str + ")";
reader.Close();
}
}
else
{
str = " UPPER(B.Corpid)='" + companyid + "'";
}
}
else if (visiblerange == "1")
{
str = " UPPER(B.Corpid)='" + companyid + "'";
}
return str;
}
#endregion
#region 导入excel
public enum RowState : uint
{
Insert,
Update,
None
}
public static bool ImportExcelData ( HttpRequestBase request, DataTable table, out string msg,
out Int32 InsertCount, out Int32 UpdateCount, string PLAN_GID, string AIRLINES, out string UnKnowenTruckNo, out List<MsOpAirn_Freight_Detailmb> headList )
{
var isSucess = false;
msg = "";
headList = new List<MsOpAirn_Freight_Detailmb>();
if (table == null) throw new ArgumentNullException("table");
var billNoList = new List<string>();
Database db = DatabaseFactory.CreateDatabase();
InsertCount = 0;
UpdateCount = 0;
UnKnowenTruckNo = "";
var UnKnowenAirPort = "";
var objcodename = db.ExecuteScalar(CommandType.Text, "select ISAGENTCN from Info_Client where shortname='" + AIRLINES + "'");
var ISAGENTCN = Convert.ToString(objcodename);
var AIRCODE_OBJ = db.ExecuteScalar(CommandType.Text, "select codename from Info_Client where shortname='" + AIRLINES + "'");
var AIRCODE = Convert.ToString(AIRCODE_OBJ);
using (DbConnection connection = db.CreateConnection())
//using (SqlTransaction idbTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
connection.Open();
try
{
var orgCode = CookieConfig.GetCookie_OrgCode(request);
var userCode = CookieConfig.GetCookie_UserCode(request);
var userName = CookieConfig.GetCookie_UserName(request);
var _i = -1;
//var ExpDate = "";
foreach (DataRow row in table.Rows)
{
_i++;
//if (_i < 1) continue;
//var _ACCDATE = ACCDATE;
var _p = 0;
var VESSEL = Convert.ToString(row[_p + 5]).Replace(" ", "");//.Trim()
var CARGOCODE = Convert.ToString(row[_p + 6]).Replace(" ", "");
//var CARGONAME = Convert.ToString(row[_p + 7]).Replace(" ", "");
if ( CARGOCODE == "")
{
continue;
}
if (VESSEL.Trim() == "")
{
VESSEL = "ALL";
}
//如果是一个国内代理 则将航班号加上前缀
//var objcodename = db.ExecuteScalar(CommandType.Text, "select ISAGENTCN from Info_Client where shortname='" + AIRLINES + "'");
//var ISAGENTCN = Convert.ToString(objcodename);
/*if (ISAGENTCN == "1" || ISAGENTCN == "True") {
if (VESSEL != "ALL") {
VESSEL = Convert.ToString(row[4]).Replace(" ","") + VESSEL;//.Trim()
}
}*/
//如果不是一个国内代理 则将空白的航司前缀写入该公司缩写
var VESSELHEAD = Convert.ToString(row[_p+4]).Replace(" ", "");
if (ISAGENTCN == "0" || ISAGENTCN == "False")
{
VESSELHEAD = AIRCODE;//.Trim()
}
var infocheck = true;
var objCargo = db.ExecuteScalar(CommandType.Text, "select GID from Import_Cargoname where CODENAME='" + CARGOCODE + "' and CLIENTGID=(select GID from info_client where codename='" + AIRLINES + "')");
var CARGOGID = Convert.ToString(objCargo);
if (string.IsNullOrEmpty(CARGOGID))
{
var Cargo2 = db.ExecuteScalar(CommandType.Text, "select top 1 GID from Import_Cargoname where CNNAME='" + CARGOCODE + "' and CLIENTGID=(select GID from info_client where codename='" + AIRLINES + "')");
CARGOGID = Convert.ToString(Cargo2);
if (string.IsNullOrEmpty(CARGOGID))
{
if (UnKnowenTruckNo == "") { UnKnowenTruckNo = "有如下编码或品名的商品在此公司内不存在,请添加后重新导入:" + CARGOCODE; }
else UnKnowenTruckNo = UnKnowenTruckNo + "/" + CARGOCODE;
infocheck = false;
}
}
var _PORTLOADID = Convert.ToString(row[_p + 1]);
var objPort = db.ExecuteScalar(CommandType.Text, "select PORTID from code_air_port where PORTID='" + _PORTLOADID + "' ");
var PORTLOADID = Convert.ToString(objPort);
if (string.IsNullOrEmpty(PORTLOADID))
{
var Port2 = db.ExecuteScalar(CommandType.Text, "select top 1 PORTID from code_air_port where PORTENAME='" + _PORTLOADID + "' or PORTCNAME='" + _PORTLOADID + "' ");
PORTLOADID = Convert.ToString(Port2);
if (string.IsNullOrEmpty(PORTLOADID))
{
if (UnKnowenAirPort == "") { UnKnowenAirPort = "有如下启运港在系统中还不存在,请添加后重新导入:" + _PORTLOADID; }
else UnKnowenAirPort = UnKnowenAirPort + "/" + _PORTLOADID;
infocheck = false;
}
}
var _PORTDISCHARGEID = Convert.ToString(row[_p + 2]);
objPort = db.ExecuteScalar(CommandType.Text, "select PORTID from code_air_port where PORTID='" + _PORTDISCHARGEID + "' ");
var PORTDISCHARGEID = Convert.ToString(objPort);
if (string.IsNullOrEmpty(PORTDISCHARGEID))
{
var Port2 = db.ExecuteScalar(CommandType.Text, "select top 1 PORTID from code_air_port where PORTENAME='" + _PORTDISCHARGEID + "' or PORTCNAME='" + _PORTDISCHARGEID + "' ");
PORTDISCHARGEID = Convert.ToString(Port2);
if (string.IsNullOrEmpty(PORTDISCHARGEID))
{
if (UnKnowenAirPort == "") { UnKnowenAirPort = "有如下目的港在系统中还不存在,请添加后重新导入:" + _PORTDISCHARGEID; }
else UnKnowenAirPort = UnKnowenAirPort + "/" + _PORTDISCHARGEID;
infocheck = false;
}
}
if (infocheck == false) {
continue;
}
DbTransaction idbTran = connection.BeginTransaction();
//var TotalMil = Convert.ToString(row[3]);
//_TruckNo //第一列
var MINFEE = Convert.ToString(row[_p + 11]).Replace(" ","");
var MINWEIGHT = Convert.ToString(row[_p + 23]).Replace(" ", "");
var W_5 = Convert.ToString(row[_p + 12]).Replace(" ", "");
var W_10 = Convert.ToString(row[_p + 13]).Replace(" ", "");
var W_N = Convert.ToString(row[_p + 14]).Replace(" ", "");
var W_45 = Convert.ToString(row[_p + 15]).Replace(" ", "");
var W_100 = Convert.ToString(row[_p + 16]).Replace(" ", "");
var W_300 = Convert.ToString(row[_p + 17]).Replace(" ", "");
var W_500 = Convert.ToString(row[_p + 18]).Replace(" ", "");
var W_1000 = Convert.ToString(row[_p + 19]).Replace(" ", "");
//var REMARK = Convert.ToString(row[_p + 11]);
var REMARK_2 = Convert.ToString(row[_p + 9]);
var REMARK_3 = Convert.ToString(row[_p + 10]);
if (MINFEE == "") { MINFEE = "0"; }
if (MINWEIGHT == "") { MINWEIGHT = "0"; }
if (W_5 == "") { W_5 = MINWEIGHT; }
if (W_10 == "") { W_10 = W_5; }
if (W_N == "") { W_N = W_10; }
if (W_45 == "") { W_45 = W_N; }
if (W_100 == "") { W_100 = W_45; }
if (W_300 == "") { W_300 = W_100; }
if (W_500 == "") { W_500 = W_300; }
if (W_1000 == "") { W_1000 = W_500; }
var _RowState = RowState.Insert;
string strCheckRow = "select gid from OpAirn_Freight_Detail where PLAN_GID = '" + PLAN_GID + "' and VESSEL='" + VESSEL + "' and CARGOGID='" + CARGOGID + "' and PORTDISCHARGEID='" + PORTDISCHARGEID + "'";
object statusObj = SqlHelper.ExecuteScalar(db.ConnectionString, CommandType.Text, strCheckRow, null);
var gid = Guid.NewGuid().ToString("N").ToUpper();
if (statusObj == null)
{
_RowState = RowState.Insert;
}
else
{
_RowState = RowState.Update;
gid = statusObj.ToString().Trim();
billNoList.Add(gid);
}
if (_RowState == RowState.Insert)
{
#region 数据生成
//var billNo = PubSysDAL.GetBillNo("0119");
//billNoList.Add(ContractNo);
billNoList.Add(gid);
const string insertSql = @"insert into OpAirn_Freight_Detail (GID,PLAN_GID,CARGOGID,MINFEE,MINWEIGHT,W_5,W_10,W_N,W_45,W_100,W_300,W_500,W_1000,REMARK_2,REMARK_3,PORTLOADID,PORTDISCHARGEID,VESSEL,VESSELHEAD)
values(@GID,@PLAN_GID,@CARGOGID,@MINFEE,@MINWEIGHT,@W_5,@W_10,@W_N,@W_45,@W_100,@W_300,@W_500,@W_1000,@REMARK_2,@REMARK_3,@PORTLOADID,@PORTDISCHARGEID,@VESSEL,@VESSELHEAD)
update OpAirn_FreightPLAN set enterdate=getdate() where gid=@PLAN_GID2
";
DbCommand cmd = db.GetSqlStringCommand(insertSql);
db.AddInParameter(cmd, "GID", DbType.String, gid);
db.AddInParameter(cmd, "PLAN_GID", DbType.String, PLAN_GID);
db.AddInParameter(cmd, "CARGOGID", DbType.String, CARGOGID);
db.AddInParameter(cmd, "MINFEE", DbType.String, MINFEE);
db.AddInParameter(cmd, "MINWEIGHT", DbType.String, MINWEIGHT);
db.AddInParameter(cmd, "W_5", DbType.String, W_5);
db.AddInParameter(cmd, "W_10", DbType.String, W_10);
db.AddInParameter(cmd, "W_N", DbType.String, W_N);
db.AddInParameter(cmd, "W_45", DbType.String, W_45);
db.AddInParameter(cmd, "W_100", DbType.String, W_100);
db.AddInParameter(cmd, "W_300", DbType.String, W_300);
db.AddInParameter(cmd, "W_500", DbType.String, W_500);
db.AddInParameter(cmd, "W_1000", DbType.String, W_1000);
db.AddInParameter(cmd, "REMARK_2", DbType.String, REMARK_2);
db.AddInParameter(cmd, "REMARK_3", DbType.String, REMARK_3);
db.AddInParameter(cmd, "PORTLOADID", DbType.String, PORTLOADID);
db.AddInParameter(cmd, "PORTDISCHARGEID", DbType.String, PORTDISCHARGEID);
db.AddInParameter(cmd, "VESSEL", DbType.String, VESSEL);
db.AddInParameter(cmd, "VESSELHEAD", DbType.String, VESSELHEAD);
db.AddInParameter(cmd, "PLAN_GID2", DbType.String, PLAN_GID);
db.ExecuteNonQuery(cmd, idbTran);
idbTran.Commit();
InsertCount++;
#endregion
}
else if (_RowState == RowState.Update)
{
#region 托单数据生成,update
//billNoList.Add(TruckNo+_ACCDATE);
/* const string insertSql = @"insert into tMsWl_Port_Ctn (GID,LINKID,TRUCKNO,Ctn20,Ctn40,Ctn45,MOV,TEU,Price_1,Price_2,AvrOil,Factor,Plus,Amount_1,Amount_2)
values(@GID,@LINKID,@TRUCKNO,@Ctn20,@Ctn40,@Ctn45,@Mov,@TEU,@Price_1,@Price_2,@AvrOil,@Factor,@Plus,@Amount_1,@Amount_2)";*/
const string UpdSql = @"Update OpAirn_Freight_Detail set CARGOGID=@CARGOGID,MINFEE=@MINFEE,MINWEIGHT=@MINWEIGHT
,W_5=@W_5,W_10=@W_10,W_N=@W_N,W_45=@W_45,W_100=@W_100,W_300=@W_300,W_500=@W_500,W_1000=@W_1000
,REMARK_2=@REMARK_2,REMARK_3=@REMARK_3,PORTLOADID=@PORTLOADID,PORTDISCHARGEID=@PORTDISCHARGEID,VESSEL=@VESSEL,VESSELHEAD=@VESSELHEAD
where GID=@GID
update OpAirn_FreightPLAN set enterdate=getdate() where gid=@PLAN_GID2
";
DbCommand cmd = db.GetSqlStringCommand(UpdSql);
db.AddInParameter(cmd, "GID", DbType.String, gid);
db.AddInParameter(cmd, "PLAN_GID", DbType.String, PLAN_GID);
db.AddInParameter(cmd, "CARGOGID", DbType.String, CARGOGID);
db.AddInParameter(cmd, "MINFEE", DbType.String, MINFEE);
db.AddInParameter(cmd, "MINWEIGHT", DbType.String, MINWEIGHT);
db.AddInParameter(cmd, "W_5", DbType.String, W_5);
db.AddInParameter(cmd, "W_10", DbType.String, W_10);
db.AddInParameter(cmd, "W_N", DbType.String, W_N);
db.AddInParameter(cmd, "W_45", DbType.String, W_45);
db.AddInParameter(cmd, "W_100", DbType.String, W_100);
db.AddInParameter(cmd, "W_300", DbType.String, W_300);
db.AddInParameter(cmd, "W_500", DbType.String, W_500);
db.AddInParameter(cmd, "W_1000", DbType.String, W_1000);
db.AddInParameter(cmd, "REMARK_2", DbType.String, REMARK_2);
db.AddInParameter(cmd, "REMARK_3", DbType.String, REMARK_3);
db.AddInParameter(cmd, "PORTLOADID", DbType.String, PORTLOADID);
db.AddInParameter(cmd, "PORTDISCHARGEID", DbType.String, PORTDISCHARGEID);
db.AddInParameter(cmd, "VESSEL", DbType.String, VESSEL);
db.AddInParameter(cmd, "VESSELHEAD", DbType.String, VESSELHEAD);
db.AddInParameter(cmd, "PLAN_GID2", DbType.String, PLAN_GID);
db.ExecuteNonQuery(cmd, idbTran);
idbTran.Commit();
UpdateCount++;
//idbTran.Commit();
#endregion
}
}
isSucess = true;
}
catch (Exception exception)
{
//idbTran.Rollback();
isSucess = false;
msg = exception.Message;
}
}
UnKnowenTruckNo = UnKnowenTruckNo + " " + UnKnowenAirPort;
return isSucess;
}
#endregion
}
public class MsOpAirn_RECEIPTWMSDAL
{
#region 查询
static public List<MsOpAirn_RECEIPTWMSmb> GetDataList(string strCondition, string sort = null)
{
var strSql = new StringBuilder();
strSql.Append(" select convert(bigint ,TimeMark) as TimeMark");
strSql.Append(" ,GID,(select codename FROM info_client where shortname=CUSTOMERNAME) CUSTCODE");
strSql.Append(" ,CUSTOMERNAME,RTYPE,FIRSTCODE,STARTNO,ENDNO,RCOUNT,ISBAOCANG,DEPTGID,OP,OPDATE,REMARK,STATUS");
strSql.Append(" ,(select count(*) from op_airn_RECEIPT where BSNO=op_airn_RECEIPTWMS.GID and RSTATUS in ('入库','领用')) KC");
strSql.Append(" ,(select count(*) from op_airn_RECEIPT where BSNO=op_airn_RECEIPTWMS.GID and RSTATUS = '取用') QY");
strSql.Append(" ,(select count(*) from op_airn_RECEIPT where BSNO=op_airn_RECEIPTWMS.GID and RSTATUS='退单') TD");
strSql.Append(" from op_airn_RECEIPTWMS");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
else
{
}
//
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" order by OPDATE desc");
}
return SetData(strSql);
}
static public MsOpAirn_RECEIPTWMSmb GetData(string condition)
{
var _t = "";
var list = GetDataList(condition, _t);
if (list.Count > 0)
return list[0];
return new MsOpAirn_RECEIPTWMSmb();
}
private static List<MsOpAirn_RECEIPTWMSmb> SetData(StringBuilder strSql)
{
var headList = new List<MsOpAirn_RECEIPTWMSmb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsOpAirn_RECEIPTWMSmb data = new MsOpAirn_RECEIPTWMSmb();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.CUSTCODE = Convert.ToString(reader["CUSTCODE"]);
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
data.RTYPE = Convert.ToString(reader["RTYPE"]);
data.FIRSTCODE = Convert.ToString(reader["FIRSTCODE"]);
data.STARTNO = Convert.ToString(reader["STARTNO"]);
data.ENDNO = Convert.ToString(reader["ENDNO"]);
data.RCOUNT = Convert.ToString(reader["RCOUNT"]);
data.ISBAOCANG = Convert.ToString(reader["ISBAOCANG"]);
data.DEPTGID = Convert.ToString(reader["DEPTGID"]);
data.OP = Convert.ToString(reader["OP"]);
data.OPDATE = Convert.ToString(reader["OPDATE"]);
data.REMARK = Convert.ToString(reader["REMARK"]);
data.STATUS = Convert.ToString(reader["STATUS"]);
data.TimeMark = Convert.ToDecimal(reader["TimeMark"]);
data.KC = Convert.ToString(reader["KC"]);
data.QY = Convert.ToString(reader["QY"]);
data.TD = Convert.ToString(reader["TD"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 查询主单单据明细
static public List<MsOpAirn_RECEIPTmb> GetBodyList(string strCondition, string sort = null)
{
var strSql = new StringBuilder();
strSql.Append("select R.*,RW.CUSTOMERNAME,R.firstcode+'-'+R.RECEIPTNO TOTALNO");
strSql.Append(" from op_airn_RECEIPT R ");
strSql.Append(" left join op_airn_RECEIPTWMS RW on RW.GID=R.BSNO ");
//strSql.Append(" left join Info_client ic on ic.SHORTNAME=R.C ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
else
{
}
strSql.Append(" order by FIRSTCODE,RECEIPTNO ");
return SetBody(strSql);
}
private static List<MsOpAirn_RECEIPTmb> SetBody(StringBuilder strSql)
{
var headList = new List<MsOpAirn_RECEIPTmb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsOpAirn_RECEIPTmb data = new MsOpAirn_RECEIPTmb();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.BSNO = Convert.ToString(reader["BSNO"]);
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
data.FIRSTCODE = Convert.ToString(reader["FIRSTCODE"]);
data.RECEIPTNO = Convert.ToString(reader["RECEIPTNO"]);
data.RTYPE = Convert.ToString(reader["RTYPE"]);
data.ISBAOCANG = Convert.ToString(reader["ISBAOCANG"]);
data.RSTATUS = Convert.ToString(reader["RSTATUS"]);
data.OP = Convert.ToString(reader["OP"]);
data.OPDATE = Convert.ToString(reader["OPDATE"]);
data.REMARK = Convert.ToString(reader["REMARK"]);
data.TOTALNO = Convert.ToString(reader["TOTALNO"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 查询主单单据使用情况
static public List<MsOpAirn_RECEIPTDOmb> GetDoList(string strCondition, string sort = null)
{
var strSql = new StringBuilder();
strSql.Append(" select [GID],[R_GID],[BSNO],[FIRSTCODE],[RECEIPTNO],[RTYPE],[ISBAOCANG],[ISWMS],[RSTATUS],[OP],dbo.trimtime(OPDATE) OPDATE,[REMARK] from op_airn_RECEIPTDO ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
else
{
}
//
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" order by OPDATE desc");
}
return SetDoData(strSql);
}
private static List<MsOpAirn_RECEIPTDOmb> SetDoData ( StringBuilder strSql )
{
var headList = new List<MsOpAirn_RECEIPTDOmb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsOpAirn_RECEIPTDOmb data = new MsOpAirn_RECEIPTDOmb();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.R_GID = Convert.ToString(reader["R_GID"]);
data.BSNO = Convert.ToString(reader["BSNO"]);
data.FIRSTCODE = Convert.ToString(reader["FIRSTCODE"]);
data.RECEIPTNO = Convert.ToString(reader["RECEIPTNO"]);
data.RTYPE = Convert.ToString(reader["RTYPE"]);
data.ISBAOCANG = Convert.ToString(reader["ISBAOCANG"]);
data.ISWMS = Convert.ToString(reader["ISWMS"]);
data.RSTATUS = Convert.ToString(reader["RSTATUS"]);
data.OP = Convert.ToString(reader["OP"]);
data.OPDATE = Convert.ToString(reader["OPDATE"]);
data.REMARK = Convert.ToString(reader["REMARK"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#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 判断是否有费用
static public int GetRdCount(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT Count(BSNO) AS CT from op_airn (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;
}
#endregion
}
}