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/MsOpAiri/MsOpAiriDAL.cs

1474 lines
74 KiB
C#

3 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.MsOpAiri;
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;
namespace DSWeb.MvcShipping.DAL.MsOpAiriDAL
{
public class MsOpAiriDAL
{
#region 查询
static public List<MsOpAiri> GetDataList(string strCondition, string userid, string usercode, string companyid,string sort = null,string load=null)
{
var rangstr = GetRangDAStr("index", userid, usercode, companyid);
if (!string.IsNullOrEmpty(rangstr))
{
if (!string.IsNullOrEmpty(strCondition))
{
strCondition = strCondition + " and " + rangstr;
}
else
{
strCondition = rangstr;
}
}
// if (!string.IsNullOrEmpty(strCondition))
//{
// strCondition = " MASTERNO=BSNO and "+strCondition;
// }
// else
//{
// strCondition = " MASTERNO=BSNO ";
//}
//
var strSql = new StringBuilder();
if (load == "true")
{
strSql.Append("SELECT top 200 OP_AIRI.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 OP_AIRI.BSNO,MASTERNO,ORDERTYPE,ORDTYPE,ORDERNO,BSSTATUS,FEESTATUS,BSDATE,ACCDATE,MBLNO,HBLNO,CUSTNO,TRANSNO,CUSTOMERNAME,BLTYPE,SHIPPERID,");
strSql.Append("CONSIGNEEID,NOTIFYPARTYID,SHIPPER,CONSIGNEE,NOTIFYPARTY,AGENTID,AGENT,VESSEL,ETD,ETA,");
}
strSql.Append("PORTLOADID,PORTLOAD,PORTDISCHARGEID,PORTDISCHARGE,BLTYPE,ISSUETYPE,");
strSql.Append("BLFRT,OTFRT,MARKS,[DESCRIPTION],GOODSNAME,PKGS,KINDPKGS,UNIT,");
strSql.Append("KGS,CBM,FEEKGS,");
strSql.Append("INPUTBY,OP,CUSTSERVICE,SALE,AIRLINES,FORWARDER,CUSTOMSER,TRUCKER,INVNO,FRCUSTSERVICE,");
strSql.Append("CARGOID,BSSOURCE,BSSOURCEDETAIL,ORDERNO,");
strSql.Append("ISVOU,VOUNO,REMARK,CORPID,SALEDEPT,CREATETIME,STLNAME,STLDATE,ORDERTYPE,");
strSql.Append("OPERATORCODE,OPERATOR,OPERATOREMAIL,OPERATORTEL,OPERATORFAX,");
strSql.Append("FINANCIALSTAFFCODE,FINANCIALSTAFF,FINANCIALSTAFFEMAIL,FINANCIALSTAFFTEL,FINANCIALSTAFFFAX");
strSql.Append(",(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=OP_AIRI.BSNO ORDER BY COMPTIME DESC,INPUTTIME DESC) as OPSTATUS ");
strSql.Append(",CUSTOMNO,ENTERPID,ENTERP,INSPECTIONNO,INSPECTIONDATE,CUSTOMDATE,CHANGEDOCDATE,SERVICE,CUSTOMVALUE,CLASS,TRADETYPE,TRADETERM,CONTRACTNO");
strSql.Append(",IsService1,IsService2,IsService3,IsService4,IsService5,IsService6,IsService7,IsService8,IsService9,IsService10");
strSql.Append(",0 as FENPIAO ");
strSql.Append(",dbo.F_GetBillDrFeeStatus(OP_AIRI.BSNO) DRFEESTATUS");
strSql.Append(",dbo.F_GetBillCrFeeStatus(OP_AIRI.BSNO) CRFEESTATUS,ISPRINTPR");
strSql.Append(",I.TTLDR,I.TTLINVDR,I.TTLDUIDR,CURRENCY,CARGOVALUE");
strSql.Append(",(SELECT COUNT(*) FROM OP_APPLY WHERE MASTERNO=OP_AIRI.BSNO) as APPLYCOUNT ");
strSql.Append(",(SELECT TOP 1 BLSTATUS FROM op_blissue WHERE BSNO=OP_AIRI.BSNO) BLISSUESTATUS,DOC,OP_AIRI.BillFeeStatus ");
strSql.Append(",SALECORPID,(select [NAME] from [company] where GID=OP_AIRI.SALECORPID) as SALECORP,LANE,DELIVERYDATE,HSCODE");
//SR2020060200003
strSql.Append(",isnull(ISBONDED,0) ISBONDED");
strSql.Append(" from OP_AIRI ");
strSql.Append(" LEFT JOIN v_op_gain_dr_INV I ON (I.BSNO=OP_AIRI.BSNO) ");
if (!string.IsNullOrEmpty(strCondition))
{
//strSql.Append(" where 1=1 AND " + strCondition);
strSql.Append(" where OP_AIRI.MASTERNO=OP_AIRI.BSNO AND EXISTS ( select 1 from OP_AIRI B WHERE OP_AIRI.BSNO=B.MASTERNO AND " + strCondition + " )");
}
else {
//strSql.Append(" where 1=1 " );
strSql.Append(" where OP_AIRI.MASTERNO=OP_AIRI.BSNO ");
}
//
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else
{
var SeaeDefaultSort = MsSysParamSetDAL.GetData("PARAMNAME='AiriDefaultSort'");
if (SeaeDefaultSort.PARAMVALUE != "")
strSql.Append(" order by " + SeaeDefaultSort.PARAMVALUE );
else
strSql.Append(" order by BSDATE desc");
}
return SetData(strSql);
}
static public List<MsOpAiri> GetSaleDataList(string strCondition, string username, string sort = null, string load = null,string userid="",string companyid="")
{
var rangstr = GetSaleRangDAStr("index", userid, username, companyid);
if (!string.IsNullOrEmpty(rangstr))
{
if (!string.IsNullOrEmpty(strCondition.Trim()))
{
strCondition = strCondition + " and " + rangstr;
}
else
{
strCondition = rangstr;
}
}
var strSql = new StringBuilder();
strSql.Append("SELECT B.BSNO,MASTERNO,ORDERTYPE,ORDTYPE,ORDERNO,BSSTATUS,FEESTATUS,BSDATE,ACCDATE,MBLNO,HBLNO,CUSTNO,TRANSNO,CUSTOMERNAME,BLTYPE,SHIPPERID,");
strSql.Append("CONSIGNEEID,NOTIFYPARTYID,SHIPPER,CONSIGNEE,NOTIFYPARTY,AGENTID,AGENT,VESSEL,ETD,ETA,");
strSql.Append("PORTLOADID,PORTLOAD,PORTDISCHARGEID,PORTDISCHARGE,BLTYPE,ISSUETYPE,");
strSql.Append("BLFRT,OTFRT,MARKS,[DESCRIPTION],GOODSNAME,PKGS,KINDPKGS,UNIT,");
strSql.Append("KGS,CBM,FEEKGS,");
strSql.Append("INPUTBY,OP,CUSTSERVICE,SALE,AIRLINES,FORWARDER,CUSTOMSER,TRUCKER,INVNO,FRCUSTSERVICE,");
strSql.Append("CARGOID,BSSOURCE,BSSOURCEDETAIL,ORDERNO,");
strSql.Append("ISVOU,VOUNO,REMARK,CORPID,SALEDEPT,CREATETIME,STLNAME,STLDATE,ORDERTYPE,");
strSql.Append("OPERATORCODE,OPERATOR,OPERATOREMAIL,OPERATORTEL,OPERATORFAX,");
strSql.Append("FINANCIALSTAFFCODE,FINANCIALSTAFF,FINANCIALSTAFFEMAIL,FINANCIALSTAFFTEL,FINANCIALSTAFFFAX");
strSql.Append(",(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,CHANGEDOCDATE,SERVICE,CUSTOMVALUE,CLASS,TRADETYPE,TRADETERM,CONTRACTNO");
strSql.Append(",IsService1,IsService2,IsService3,IsService4,IsService5,IsService6,IsService7,IsService8,IsService9,IsService10");
strSql.Append(",0 as FENPIAO ");
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,CURRENCY,CARGOVALUE");
strSql.Append(",(SELECT COUNT(*) FROM OP_APPLY WHERE MASTERNO=B.BSNO) as APPLYCOUNT ");
strSql.Append(",(SELECT TOP 1 BLSTATUS FROM op_blissue WHERE BSNO=B.BSNO) BLISSUESTATUS,DOC,B.BillFeeStatus ");
strSql.Append(",SALECORPID,(select [NAME] from [company] where GID=B.SALECORPID) as SALECORP,LANE,DELIVERYDATE,HSCODE");
//SR2020060200003
strSql.Append(",isnull(ISBONDED,0) ISBONDED");
strSql.Append(" from OP_AIRI B");
strSql.Append(" LEFT JOIN v_op_gain_dr_INV I ON (I.BSNO=B.BSNO) ");
if (!string.IsNullOrEmpty(strCondition.Trim()))
{
strSql.Append(" where 1=1 AND " + strCondition);
}
//
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" order by BSDATE desc");
}
return SetData(strSql);
}
static public string GetDataListStr(string strCondition, string userid, string usercode, string companyid, string sort = null)
{
var rangstr = GetRangDAStr("index", userid, usercode, companyid);
if (!string.IsNullOrEmpty(rangstr))
{
if (!string.IsNullOrEmpty(strCondition))
{
strCondition = strCondition + " and " + rangstr;
}
else
{
strCondition = rangstr;
}
}
//
var strSql = new StringBuilder();
strSql.Append("SELECT B.BSNO,MASTERNO,ORDERTYPE,ORDTYPE,ORDERNO,BSSTATUS,FEESTATUS,BSDATE,ACCDATE,MBLNO,HBLNO,CUSTNO,TRANSNO,CUSTOMERNAME,SHIPPERID,");
strSql.Append("CONSIGNEEID,NOTIFYPARTYID,SHIPPER,CONSIGNEE,NOTIFYPARTY,AGENTID,AGENT,VESSEL,ETD,ETA,");
strSql.Append("PORTLOADID,PORTLOAD,PORTDISCHARGEID,PORTDISCHARGE,BLTYPE,ISSUETYPE,");
strSql.Append("BLFRT,OTFRT,MARKS,[DESCRIPTION],GOODSNAME,PKGS,KINDPKGS,UNIT,");
strSql.Append("KGS,CBM,FEEKGS,");
strSql.Append("INPUTBY,OP,CUSTSERVICE,SALE,AIRLINES,FORWARDER,CUSTOMSER,TRUCKER,INVNO,FRCUSTSERVICE,");
strSql.Append("CARGOID,BSSOURCE,BSSOURCEDETAIL,ORDERNO,");
strSql.Append("ISVOU,VOUNO,REMARK,CORPID,SALEDEPT,CREATETIME,STLNAME,STLDATE,ORDERTYPE,");
strSql.Append("OPERATORCODE,OPERATOR,OPERATOREMAIL,OPERATORTEL,OPERATORFAX,");
strSql.Append("FINANCIALSTAFFCODE,FINANCIALSTAFF,FINANCIALSTAFFEMAIL,FINANCIALSTAFFTEL,FINANCIALSTAFFFAX");
strSql.Append(",(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,CHANGEDOCDATE,SERVICE,CUSTOMVALUE,CLASS,TRADETYPE,TRADETERM,CONTRACTNO");
strSql.Append(",IsService1,IsService2,IsService3,IsService4,IsService5,IsService6,IsService7,IsService8,IsService9,IsService10,0 FENPIAO");
strSql.Append(",ISPRINTPR,LANE,CURRENCY,CARGOVALUE,DELIVERYDATE,HSCODE");
strSql.Append(" from OP_AIRI B");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
if (!string.IsNullOrEmpty(sort))
{
strSql.Append(" order by " + sort);
}
else
{
strSql.Append(" order by ETD,MBLNO");
}
return strSql.ToString();
}
static public List<MsOpAiri> 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,BLTYPE,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,MARKS,[DESCRIPTION],GOODSNAME,PKGS,KINDPKGS,UNIT,");
strSql.Append("KGS,CBM,FEEKGS,");
strSql.Append("INPUTBY,OP,CUSTSERVICE,SALE,AIRLINES,FORWARDER,CUSTOMSER,TRUCKER,INVNO,FRCUSTSERVICE,");
strSql.Append("CARGOID,BSSOURCE,BSSOURCEDETAIL,ORDERNO,");
strSql.Append("ISVOU,VOUNO,REMARK,CORPID,SALEDEPT,CREATETIME,STLNAME,STLDATE,ORDERTYPE,");
strSql.Append("OPERATORCODE,OPERATOR,OPERATOREMAIL,OPERATORTEL,OPERATORFAX,");
strSql.Append("FINANCIALSTAFFCODE,FINANCIALSTAFF,FINANCIALSTAFFEMAIL,FINANCIALSTAFFTEL,FINANCIALSTAFFFAX");
strSql.Append(",(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,CHANGEDOCDATE,SERVICE,CUSTOMVALUE,CLASS,TRADETYPE,TRADETERM,CONTRACTNO");
strSql.Append(",IsService1,IsService2,IsService3,IsService4,IsService5,IsService6,IsService7,IsService8,IsService9,IsService10,0 FENPIAO");
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,B.DOC ");
strSql.Append(",SALECORPID,(select [NAME] from [company] where GID=B.SALECORPID) as SALECORP,LANE,CURRENCY,CARGOVALUE,DELIVERYDATE,HSCODE");
//SR2020060200003
strSql.Append(",isnull(ISBONDED,0) ISBONDED");
strSql.Append(" from OP_AIRI 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);
}
static public MsOpAiri GetData(string condition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT B.BSNO,MASTERNO,ORDERTYPE,ORDTYPE,ORDERNO,BSSTATUS,FEESTATUS,BSDATE,ACCDATE,MBLNO,HBLNO,CUSTNO,TRANSNO,CUSTOMERNAME,SHIPPERID,");
strSql.Append("CONSIGNEEID,NOTIFYPARTYID,SHIPPER,CONSIGNEE,NOTIFYPARTY,AGENTID,AGENT,VESSEL,ETD,ETA,");
strSql.Append("PORTLOADID,PORTLOAD,PORTDISCHARGEID,PORTDISCHARGE,BLTYPE,ISSUETYPE,");
strSql.Append("BLFRT,OTFRT,MARKS,[DESCRIPTION],GOODSNAME,PKGS,KINDPKGS,UNIT,");
strSql.Append("KGS,CBM,FEEKGS,");
strSql.Append("INPUTBY,OP,CUSTSERVICE,SALE,AIRLINES,FORWARDER,CUSTOMSER,TRUCKER,INVNO,FRCUSTSERVICE,");
strSql.Append("CARGOID,BSSOURCE,BSSOURCEDETAIL,ORDERNO,");
strSql.Append("ISVOU,VOUNO,REMARK,CORPID,SALEDEPT,CREATETIME,STLNAME,STLDATE,ORDERTYPE,");
strSql.Append("OPERATORCODE,OPERATOR,OPERATOREMAIL,OPERATORTEL,OPERATORFAX,");
strSql.Append("FINANCIALSTAFFCODE,FINANCIALSTAFF,FINANCIALSTAFFEMAIL,FINANCIALSTAFFTEL,FINANCIALSTAFFFAX");
strSql.Append(",(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,CHANGEDOCDATE,SERVICE,CUSTOMVALUE,CLASS,TRADETYPE,TRADETERM,CONTRACTNO");
strSql.Append(",IsService1,IsService2,IsService3,IsService4,IsService5,IsService6,IsService7,IsService8,IsService9,IsService10,0 FENPIAO");
strSql.Append(",'' DRFEESTATUS");
strSql.Append(",'' CRFEESTATUS,ISPRINTPR,0 TTLDR,0 TTLINVDR,0 TTLDUIDR,0 APPLYCOUNT,DOC,B.BillFeeStatus ");
strSql.Append(",SALECORPID,(select [NAME] from [company] where GID=B.SALECORPID) as SALECORP,LANE,CURRENCY,CARGOVALUE,DELIVERYDATE,HSCODE");
//SR2020060200003
strSql.Append(",isnull(ISBONDED,0) ISBONDED");
strSql.Append(" from OP_AIRI B");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" where " + condition);
}
var list=SetData(strSql);
if (list.Count > 0)
return list[0];
return new MsOpAiri();
}
private static List<MsOpAiri> SetData(StringBuilder strSql)
{
var headList = new List<MsOpAiri>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsOpAiri data = new MsOpAiri();
#region Set DB data to Object
data.BillFeeStatus = Convert.ToString(reader["BillFeeStatus"]);
data.BSNO = Convert.ToString(reader["BSNO"]);//业务编号
data.ORDERTYPE = Convert.ToString(reader["ORDERTYPE"]);//委托方式
data.MASTERNO = Convert.ToString(reader["MASTERNO"]);//主编号
data.CUSTNO = Convert.ToString(reader["CUSTNO"]);//委托编号
data.MBLNO = Convert.ToString(reader["MBLNO"]);//主提单号
data.HBLNO = Convert.ToString(reader["HBLNO"]);//分提单号
data.BSSTATUS = Convert.ToBoolean(reader["BSSTATUS"]);//业务状态
data.FEESTATUS = Convert.ToBoolean(reader["FEESTATUS"]);//费用状态
data.BSSTATUSREF = Convert.ToString(reader["BSSTATUSREF"]);// 业务状态
data.FEESTATUSREF = Convert.ToString(reader["FEESTATUSREF"]);// 费用状态
data.DRFEESTATUS = getfeestatus(Convert.ToString(reader["DRFEESTATUS"]));
data.CRFEESTATUS = getfeestatus(Convert.ToString(reader["CRFEESTATUS"]));
if (Convert.ToString(reader["OPSTATUS"])!="")
data.OPSTATUS = Convert.ToString(reader["OPSTATUS"]);// 费用状态
data.BLISSUESTATUS = Convert.ToString(reader["BLISSUESTATUS"]);// 费用状态
data.CURRENCY = Convert.ToString(reader["CURRENCY"]);
data.CARGOVALUE = Convert.ToString(reader["CARGOVALUE"]);
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.SALECORPID = Convert.ToString(reader["SALECORPID"]);//分公司代码
data.SALECORP = Convert.ToString(reader["SALECORP"]);//分公司代码
data.SALEDEPT = Convert.ToString(reader["SALEDEPT"]);//所属部门
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.ISSUETYPE = Convert.ToString(reader["ISSUETYPE"]);//签单方式
data.GOODSNAME = Convert.ToString(reader["GOODSNAME"]);//品名
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["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.BLTYPE = Convert.ToString(reader["BLTYPE"]);//货物描述
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"]);//付费方式
if (reader["FEEKGS"] != DBNull.Value)
data.FEEKGS = Convert.ToDecimal(reader["FEEKGS"]);//
data.MARKS = Convert.ToString(reader["MARKS"]);//唛头
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.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.CUSTOMNO = Convert.ToString(reader["CUSTOMNO"]);//报关单号
data.CONTRACTNO = Convert.ToString(reader["CONTRACTNO"]);//运费协议号
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"]);//经营单位代码
if (reader["CHANGEDOCDATE"] != DBNull.Value)
data.CHANGEDOCDATE = Convert.ToDateTime(reader["CHANGEDOCDATE"]).ToString("yyyy-MM-dd");//
data.SERVICE = Convert.ToString(reader["SERVICE"]);//
data.CUSTOMVALUE = Convert.ToString(reader["CUSTOMVALUE"]);//
data.CLASS = Convert.ToString(reader["CLASS"]);//
data.TRADETYPE = Convert.ToString(reader["TRADETYPE"]);//
data.TRADETERM = Convert.ToString(reader["TRADETERM"]);//贸易条款
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"]);
if (Convert.ToString(reader["BLTYPE"]) == "空运主票")
data.FENPIAO = "1";//件数
else
data.FENPIAO = "0";//件数
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"]);//是否生成报关
data.DOC = reader["DOC"].ToString();
if (reader["DELIVERYDATE"] != DBNull.Value)
data.DELIVERYDATE = Convert.ToDateTime(reader["DELIVERYDATE"]).ToString("yyyy-MM-dd");//预抵日期
data.HSCODE = reader["HSCODE"].ToString();
data.ISBONDED = reader["ISBONDED"].ToString();
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
public static string getfeestatus(string feestatusint)
{
var result = "";
if (feestatusint == "0:")
{
return "审核通过";
}
else if (feestatusint == "1:")
{
return "录入状态";
}
else if (feestatusint == "2:")
{
return "提交审核";
}
else if (feestatusint == "8:")
{
return "部分结算";
}
else if (feestatusint == "9:")
{
return "结算完毕";
}
else if (feestatusint == "")
{
return "未录入";
}
else if (feestatusint == "3:")
{
return "申请修改";
}
else if (feestatusint == "4:")
{
return "申请删除";
}
else if (feestatusint == "6:")
{
return "驳回提交";
}
else if (feestatusint == "7:")
{
return "驳回申请";
}
else if (feestatusint.IndexOf("9:") > -1)
{
return "部分结算";
}
else if (feestatusint.IndexOf("8:") > -1)
{
return "部分结算";
}
else if (feestatusint.IndexOf("0:") > -1)
{
return "部分审核";
}
else if (feestatusint.IndexOf("2:") > -1)
{
return "部分提交";
}
else if (feestatusint.IndexOf("6:") > -1)
{
return "驳回提交";
}
else if (feestatusint.IndexOf("7:") > -1)
{
return "驳回申请";
}
return result;
}
#endregion
#region 删除
public static 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 List<MsOpAiriSum> GetDataListSum(string strCondition, string userid, string usercode, string companyid, string sort = null)
{
var rangstr = GetRangDAStr("index", userid, usercode, companyid);
if (!string.IsNullOrEmpty(rangstr))
{
if (!string.IsNullOrEmpty(strCondition))
{
strCondition = strCondition + " and " + rangstr;
}
else
{
strCondition = rangstr;
}
}
//
var strSql = new StringBuilder();
strSql.Append("SELECT Count(B.BSNO) as NOBILL,");
strSql.Append("sum(B.PKGS) as PKGS,sum(B.KGS) as KGS,sum(B.CBM) as CBM,sum(B.FEEKGS) as FEEKGS");
strSql.Append(" from OP_AIRI B ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
return SetDataSum(strSql);
}
private static List<MsOpAiriSum> SetDataSum(StringBuilder strSql)
{
var headList = new List<MsOpAiriSum>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsOpAiriSum data = new MsOpAiriSum();
#region Set DB data to Object
data.NOBILL = Convert.ToInt32(reader["NOBILL"]);//票数
if (reader["KGS"] != DBNull.Value)
data.KGS = Convert.ToDecimal(reader["KGS"]);//毛重
if (reader["PKGS"] != DBNull.Value)
data.PKGS = Convert.ToInt32(reader["PKGS"]);//件数
if (reader["CBM"] != DBNull.Value)
data.CBM = Convert.ToDecimal(reader["CBM"]);//立方数/尺码
if (reader["FEEKGS"] != DBNull.Value)
data.FEEKGS = Convert.ToDecimal(reader["FEEKGS"]);//立方数/尺码
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
public static DBResult SaveFenList(string bsno, List<MsOpAiri> bodyList, string corpid)
{
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdInsert =
db.GetSqlStringCommand(
@"INSERT INTO op_airi([BSNO],[MASTERNO],[ORDERTYPE],[CUSTNO],[MBLNO],[HBLNO],[BSSTATUS],[FEESTATUS],[BSDATE]
,[ACCDATE],[CUSTOMERNAME],[INPUTBY],[OP],[CUSTSERVICE],[SALE],[CORPID]
,[SALEDEPT],[CREATETIME],[VESSEL],[ETD],[ETA]
,[SHIPPERID],[SHIPPER],[CONSIGNEEID],[CONSIGNEE],[NOTIFYPARTYID],[NOTIFYPARTY],[BSSOURCE]
,[BSSOURCEDETAIL],[GOODSNAME],[MARKS],[DESCRIPTION]
,[PORTLOADID],[PORTLOAD],[PORTDISCHARGEID],[PORTDISCHARGE],[BLTYPE],[AGENTID],[AGENT]
,[BLFRT],[OTFRT],[PKGS],[KINDPKGS],[CBM],[KGS],[AIRLINES],[FORWARDER]
,[CARGOID],[REMARK],ISVOU,FEEKGS)
VALUES
(@BSNO,@MASTERNO,@ORDERTYPE,@CUSTNO,@MBLNO,@HBLNO,@BSSTATUS,@FEESTATUS,@BSDATE
,@ACCDATE,@CUSTOMERNAME,@INPUTBY,@OP,@CUSTSERVICE,@SALE,@CORPID
,@SALEDEPT,@CREATETIME,@VESSEL,@ETD,@ETA
,@SHIPPERID,@SHIPPER,@CONSIGNEEID,@CONSIGNEE,@NOTIFYPARTYID,@NOTIFYPARTY,@BSSOURCE
,@BSSOURCEDETAIL,@GOODSNAME,@MARKS,@DESCRIPTION
,@PORTLOADID,@PORTLOAD,@PORTDISCHARGEID,@PORTDISCHARGE,
@BLTYPE,@AGENTID,@AGENT
,@BLFRT,@OTFRT,@PKGS,@KINDPKGS,@CBM,@KGS,@AIRLINES,@FORWARDER
,@CARGOID,@REMARK,@ISVOU,@FEEKGS) ");
var cmdupdate =
db.GetSqlStringCommand(@"update op_airi set [MBLNO]=@MBLNO,[HBLNO]=@HBLNO,[BSSTATUS]=@BSSTATUS,[FEESTATUS]=@FEESTATUS,[BSDATE]=@BSDATE
,[ACCDATE]=@ACCDATE,[CUSTOMERNAME]=@CUSTOMERNAME,[INPUTBY]=@INPUTBY,[OP]=@OP,[CUSTSERVICE]=@CUSTSERVICE,[SALE]=@SALE
,[SALEDEPT]=@SALEDEPT,[VESSEL]=@VESSEL,[ETD]=@ETD,[ETA]=@ETA,[GOODSNAME]=@GOODSNAME
,[PORTLOADID]=@PORTLOADID,[PORTLOAD]=@PORTLOAD,[PORTDISCHARGEID]=@PORTDISCHARGEID,[PORTDISCHARGE]=@PORTDISCHARGE
,[AGENTID]=@AGENTID,[AGENT]=@AGENT,[BLFRT]=@BLFRT,[OTFRT]=@OTFRT
,[MARKS]=@MARKS,[PKGS]=@PKGS,[KINDPKGS]=@KINDPKGS,
[CBM]=@CBM,[KGS]=@KGS,[AIRLINES]=@AIRLINES,[FORWARDER]=@FORWARDER ,[CARGOID]=@CARGOID
,[REMARK]=@REMARK,[FEEKGS]=@FEEKGS WHERE [BSNO]=@BSNO");
if (bodyList != null)
{
foreach (var enumValue in bodyList)
{
if (enumValue.MASTERNO == "*")
{
cmdInsert.Parameters.Clear();
db.AddInParameter(cmdInsert, "@BSNO", DbType.String, enumValue.BSNO);
db.AddInParameter(cmdInsert, "@MASTERNO", DbType.String, bsno);
db.AddInParameter(cmdInsert, "@ORDERTYPE", DbType.String, "操作录入");
db.AddInParameter(cmdInsert, "@CUSTNO", DbType.String, enumValue.CUSTNO);
db.AddInParameter(cmdInsert, "@MBLNO", DbType.String, enumValue.MBLNO);
db.AddInParameter(cmdInsert, "@HBLNO", DbType.String, enumValue.HBLNO);
db.AddInParameter(cmdInsert, "@BSSTATUS", DbType.Boolean, enumValue.BSSTATUS);
db.AddInParameter(cmdInsert, "@FEESTATUS", DbType.Boolean, enumValue.FEESTATUS);
db.AddInParameter(cmdInsert, "@BSDATE", DbType.Date, DateTime.Now);
db.AddInParameter(cmdInsert, "@ACCDATE", DbType.String, enumValue.ACCDATE);
db.AddInParameter(cmdInsert, "@CUSTOMERNAME", DbType.String, enumValue.CUSTOMERNAME);
db.AddInParameter(cmdInsert, "@INPUTBY", DbType.String, enumValue.INPUTBY);
db.AddInParameter(cmdInsert, "@OP", DbType.String, enumValue.OP);
db.AddInParameter(cmdInsert, "@CUSTSERVICE", DbType.String, enumValue.CUSTSERVICE);
db.AddInParameter(cmdInsert, "@SALE", DbType.String, enumValue.SALE);
db.AddInParameter(cmdInsert, "@CORPID", DbType.String, corpid);
db.AddInParameter(cmdInsert, "@SALEDEPT", DbType.String, enumValue.SALEDEPT);
db.AddInParameter(cmdInsert, "@SHIPPERID", DbType.String, enumValue.SHIPPERID);
db.AddInParameter(cmdInsert, "@SHIPPER", DbType.String, enumValue.SHIPPER);
db.AddInParameter(cmdInsert, "@CONSIGNEEID", DbType.String, enumValue.CONSIGNEEID);
db.AddInParameter(cmdInsert, "@CONSIGNEE", DbType.String, enumValue.CONSIGNEE);
db.AddInParameter(cmdInsert, "@NOTIFYPARTYID", DbType.String, enumValue.NOTIFYPARTYID);
db.AddInParameter(cmdInsert, "@NOTIFYPARTY", DbType.String, enumValue.NOTIFYPARTY);
db.AddInParameter(cmdInsert, "@BSSOURCE", DbType.String, enumValue.BSSOURCE);
db.AddInParameter(cmdInsert, "@BSSOURCEDETAIL", DbType.String, enumValue.BSSOURCEDETAIL);
db.AddInParameter(cmdInsert, "@GOODSNAME", DbType.String, enumValue.GOODSNAME);
db.AddInParameter(cmdInsert, "@MARKS", DbType.String, enumValue.MARKS);
db.AddInParameter(cmdInsert, "@DESCRIPTION", DbType.String, enumValue.DESCRIPTION);
db.AddInParameter(cmdInsert, "@CREATETIME", DbType.Date, DateTime.Now);
db.AddInParameter(cmdInsert, "@VESSEL", DbType.String, enumValue.VESSEL);
db.AddInParameter(cmdInsert, "@ETD", DbType.Date, enumValue.ETD);
db.AddInParameter(cmdInsert, "@ETA", DbType.Date, enumValue.ETA);
db.AddInParameter(cmdInsert, "@PORTLOADID", DbType.String, enumValue.PORTLOADID);
db.AddInParameter(cmdInsert, "@PORTLOAD", DbType.String, enumValue.PORTLOAD);
db.AddInParameter(cmdInsert, "@PORTDISCHARGEID", DbType.String, enumValue.PORTDISCHARGEID);
db.AddInParameter(cmdInsert, "@PORTDISCHARGE", DbType.String, enumValue.PORTDISCHARGE);
db.AddInParameter(cmdInsert, "@BLTYPE", DbType.String, enumValue.BLTYPE);
db.AddInParameter(cmdInsert, "@AGENTID", DbType.String, enumValue.AGENTID);
db.AddInParameter(cmdInsert, "@AGENT", DbType.String, enumValue.AGENT);
db.AddInParameter(cmdInsert, "@BLFRT", DbType.String, enumValue.BLFRT);
db.AddInParameter(cmdInsert, "@OTFRT", DbType.String, enumValue.OTFRT);
db.AddInParameter(cmdInsert, "@PKGS", DbType.String, enumValue.PKGS);
db.AddInParameter(cmdInsert, "@KINDPKGS", DbType.String, enumValue.KINDPKGS);
db.AddInParameter(cmdInsert, "@CBM", DbType.String, enumValue.CBM);
db.AddInParameter(cmdInsert, "@KGS", DbType.String, enumValue.KGS);
db.AddInParameter(cmdInsert, "@FEEKGS", DbType.String, enumValue.FEEKGS);
db.AddInParameter(cmdInsert, "@AIRLINES", DbType.String, enumValue.AIRLINES);
db.AddInParameter(cmdInsert, "@FORWARDER", DbType.String, enumValue.FORWARDER);
db.AddInParameter(cmdInsert, "@CARGOID", DbType.String, enumValue.CARGOID);
db.AddInParameter(cmdInsert, "@REMARK", DbType.String, enumValue.REMARK);
db.AddInParameter(cmdInsert, "@ISVOU", DbType.Boolean, enumValue.ISVOU);
db.ExecuteNonQuery(cmdInsert, tran);
}
else
{
cmdupdate.Parameters.Clear();
db.AddInParameter(cmdupdate, "@BSNO", DbType.String, enumValue.BSNO);
db.AddInParameter(cmdupdate, "@MBLNO", DbType.String, enumValue.MBLNO);
db.AddInParameter(cmdupdate, "@HBLNO", DbType.String, enumValue.HBLNO);
db.AddInParameter(cmdupdate, "@BSSTATUS", DbType.Boolean, enumValue.BSSTATUS);
db.AddInParameter(cmdupdate, "@FEESTATUS", DbType.Boolean, enumValue.FEESTATUS);
db.AddInParameter(cmdupdate, "@BSDATE", DbType.Date, DateTime.Now);
db.AddInParameter(cmdupdate, "@ACCDATE", DbType.String, enumValue.ACCDATE);
db.AddInParameter(cmdupdate, "@CUSTOMERNAME", DbType.String, enumValue.CUSTOMERNAME);
db.AddInParameter(cmdupdate, "@INPUTBY", DbType.String, enumValue.INPUTBY);
db.AddInParameter(cmdupdate, "@OP", DbType.String, enumValue.OP);
db.AddInParameter(cmdupdate, "@CUSTSERVICE", DbType.String, enumValue.CUSTSERVICE);
db.AddInParameter(cmdupdate, "@SALE", DbType.String, enumValue.SALE);
db.AddInParameter(cmdupdate, "@SALEDEPT", DbType.String, enumValue.SALEDEPT);
db.AddInParameter(cmdupdate, "@VESSEL", DbType.String, enumValue.VESSEL);
db.AddInParameter(cmdupdate, "@ETD", DbType.Date, enumValue.ETD);
db.AddInParameter(cmdupdate, "@GOODSNAME", DbType.String, enumValue.GOODSNAME);
db.AddInParameter(cmdupdate, "@ETA", DbType.Date, enumValue.ETA);
db.AddInParameter(cmdupdate, "@PORTLOADID", DbType.String, enumValue.PORTLOADID);
db.AddInParameter(cmdupdate, "@PORTLOAD", DbType.String, enumValue.PORTLOAD);
db.AddInParameter(cmdupdate, "@PORTDISCHARGEID", DbType.String, enumValue.PORTDISCHARGEID);
db.AddInParameter(cmdupdate, "@PORTDISCHARGE", DbType.String, enumValue.PORTDISCHARGE);
db.AddInParameter(cmdupdate, "@AGENTID", DbType.String, enumValue.AGENTID);
db.AddInParameter(cmdupdate, "@AGENT", DbType.String, enumValue.AGENT);
db.AddInParameter(cmdupdate, "@BLFRT", DbType.String, enumValue.BLFRT);
db.AddInParameter(cmdupdate, "@OTFRT", DbType.String, enumValue.OTFRT);
db.AddInParameter(cmdupdate, "@MARKS", DbType.String, enumValue.MARKS);
db.AddInParameter(cmdupdate, "@PKGS", DbType.String, enumValue.PKGS);
db.AddInParameter(cmdupdate, "@KINDPKGS", DbType.String, enumValue.KINDPKGS);
db.AddInParameter(cmdupdate, "@CBM", DbType.String, enumValue.CBM);
db.AddInParameter(cmdupdate, "@KGS", DbType.String, enumValue.KGS);
db.AddInParameter(cmdupdate, "@FEEKGS", DbType.String, enumValue.FEEKGS);
db.AddInParameter(cmdupdate, "@AIRLINES", DbType.String, enumValue.AIRLINES);
db.AddInParameter(cmdupdate, "@FORWARDER", DbType.String, enumValue.FORWARDER);
db.AddInParameter(cmdupdate, "@CARGOID", DbType.String, enumValue.CARGOID);
db.AddInParameter(cmdupdate, "@REMARK", DbType.String, enumValue.REMARK);
db.ExecuteNonQuery(cmdupdate, tran);
}
}
}
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "更新出现错误,请重试或联系系统管理员";
return result;
}
}
result.Success = true;
result.Message = "更新成功" + result.Message;
return result;
}
public static DBResult DeleteFen(string bsno)
{
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdDelete = db.GetSqlStringCommand("delete from op_airi where BSNO='" + bsno + "'");
db.ExecuteNonQuery(cmdDelete, tran);
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "删除出现错误,请重试或联系系统管理员";
return result;
}
}
result.Success = true;
result.Message = "操作成功";
return result;
}
public static DBResult CancelFenAdd(string bsno)
{
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdDelete = db.GetSqlStringCommand("update op_airi set MASTERNO=BSNO where BSNO='" + bsno + "'");
db.ExecuteNonQuery(cmdDelete, tran);
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "更新出现错误,请重试或联系系统管理员";
return result;
}
}
result.Success = true;
result.Message = "操作成功";
return result;
}
public static DBResult AddFenAdd(string bsno, List<MsOpAiri> bodyList)
{
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdupdate =
db.GetSqlStringCommand(@"update op_airi set MASTERNO=@MASTERNO WHERE [BSNO]=@BSNO");
if (bodyList != null)
{
foreach (var enumValue in bodyList)
{
cmdupdate.Parameters.Clear();
db.AddInParameter(cmdupdate, "@BSNO", DbType.String, enumValue.BSNO);
db.AddInParameter(cmdupdate, "@MASTERNO", DbType.String, bsno);
db.ExecuteNonQuery(cmdupdate, tran);
}
}
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "更新出现错误,请重试或联系系统管理员";
return result;
}
}
result.Success = true;
result.Message = "更新成功" + result.Message;
return result;
}
#endregion
#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_airi (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 权限范围
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]='modOpAiriList' and USERID='" + userid + "' and ISDELETE=0");
string visiblerange = "4";
string operaterange = "4";
string AUTHORITYID = "";
string VSSQL = "";
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
visiblerange = Convert.ToString(reader["VISIBLERANGE"]);
operaterange = Convert.ToString(reader["OPERATERANGE"]);
AUTHORITYID = Convert.ToString(reader["AUTHORITYID"]);
VSSQL = Convert.ToString(reader["VSSQL"]);
break;
}
reader.Close();
}
if (visiblerange == "4")
{
str = "1=2";
}
else if (visiblerange == "3")
{
str = " (B.OP='" + username + "' OR B.SALE='" + username + "' OR B.CUSTSERVICE='" + username + "' OR B.FRCUSTSERVICE='" + username + "' OR B.INPUTBY='" + username + "')";
}
else if (visiblerange == "2")
{
if (tb == "index")
{
var rangeDa = new RangeDA();
var deptid = rangeDa.GetDEPTGID(userid);
str = " (B.OP in (select showname from vw_user where deptgid='" + deptid + "') OR B.SALE in (select showname from vw_user where deptgid='" + deptid + "') OR B.CUSTSERVICE in (select showname from vw_user where deptgid='" + deptid + "') "
+ " OR B.DOC in (select showname from vw_user where deptgid='" + deptid + "') OR B.FRCUSTSERVICE in (select showname from vw_user where deptgid='" + deptid + "') OR B.INPUTBY in (select showname from vw_user where deptgid='" + deptid + "'))";
}
else if (visiblerange == "5")
{
if (tb == "index")
{
var userstr = new StringBuilder();
userstr.Append(" select COMPANYID from user_authority_range_company where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1");
Database userdb = DatabaseFactory.CreateDatabase();
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
{
str = "";
while (reader.Read())
{
if (str == "")
{
str = " (B.Corpid='" + Convert.ToString(reader["COMPANYID"]) + "' or B.SALECORPID='" + Convert.ToString(reader["COMPANYID"]) + "' ";
}
else
{
str = str + " or B.Corpid='" + Convert.ToString(reader["COMPANYID"]) + "' or B.SALECORPID='" + Convert.ToString(reader["COMPANYID"]) + "'";
};
}
str = str + ")";
reader.Close();
}
}
else
{
str = " (UPPER(B.Corpid)='" + companyid + "' or B.SALECORPID='" + companyid + "') ";
}
}
else if (visiblerange == "6")
{
if (tb == "index")
{
var opstr = "";
var userstr = new StringBuilder();
userstr.Append(" select OPID,(select SHOWNAME from [user] where GID=user_authority_range_op.OPID) SHOWNAME from user_authority_range_op where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1");
Database userdb = DatabaseFactory.CreateDatabase();
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
{
while (reader.Read())
{
if (opstr == "")
{
opstr = " ('" + Convert.ToString(reader["SHOWNAME"]) + "'";
}
else
{
opstr = opstr + ",'" + Convert.ToString(reader["SHOWNAME"]) + "'";
};
}
if (opstr != "") opstr = opstr + ")";
reader.Close();
}
if (opstr == "") opstr = "('" + username + "')";
str = " (B.OP in " + opstr + " or B.SALE in " + opstr + " or B.CUSTSERVICE IN " + opstr + " or B.DOC IN " + opstr + " or B.FRCUSTSERVICE IN " + opstr + " or B.INPUTBY IN " + opstr + ")";
}
else
{
str = " (UPPER(B.Corpid)='" + companyid + "' or B.SALECORPID='" + companyid + "') ";
}
}
else
{
str = " UPPER(B.Corpid)='" + companyid + "'";
}
}
else if (visiblerange == "1")
{
str = " (UPPER(B.Corpid)='" + companyid + "' or B.SALECORPID='" + companyid + "') ";
}
VSSQL = VSSQL.Trim();
if (!string.IsNullOrEmpty(VSSQL))
{
if (!string.IsNullOrEmpty(str))
{
str = str + " and (" + VSSQL + ") ";
}
else
{
str = " (" + VSSQL + ") ";
}
}
return str;
}
public static string GetSaleRangDAStr(string tb, string userid, string username, string companyid)
{
string str = "";
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append(" VISIBLERANGE,OPERATERANGE,AUTHORITYID,VSSQL ");
strSql.Append(" from VW_User_Authority ");
strSql.Append(" where [NAME]='modAiriSaleList' 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
}
}