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/RptChFeeInvoiceDutyFree/RptChFeeInvoiceDutyFreeDAL.cs

182 lines
14 KiB
C#

3 years ago
using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using DSWeb.MvcShipping.Models.RptChFeeInvoiceDutyFree;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.EntityDA;
using DSWeb.Areas.CommMng.Models;
using HcUtility.Comm;
using System.Data.SqlClient;
using DSWeb.DataAccess;
using HcUtility.Core;
using DSWeb.Areas.CommMng.DAL;
namespace DSWeb.MvcShipping.DAL.RptChFeeInvoiceDutyFreeDAL
{
public class RptChFeeInvoiceDutyFreeDAL
{
#region 查询
static public List<RptChFeeInvoiceDutyFree> GetDataList(string strCondition, string userid, string usercode, string companyid, string sort = null)
{
var strSql = new StringBuilder();
string sSql = GetDataListSQL(strCondition, userid, usercode, companyid);
strSql.Append(sSql);
//
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" order by INVOICENO,CUSTOMERNAME_i,MBLNO");
}
return SetData(strSql);
}
static public string GetDataListStr(string strCondition, string userid, string usercode, string companyid)
{
var strSql = new StringBuilder();
string sSql = GetDataListSQL(strCondition, userid, usercode, companyid);
string strDataIndex = "CUSTOMERNAME_i as 委托方名称,INVOICENO as 发票号,MBLNO as [(运)提单号],VESSEL as 船名,VOYNO as 航次,PORTLOAD as 起运港,PORTDISCHARGE as 卸货港,REMARK as 备注,gjUSD as [国际运费USD],gjRMB as [国际运费RMB],gkRMB as 港口码头费,qtRMB as 其他收费项";//字段名称
//
strSql.Append("select " + strDataIndex + " from (" + sSql + ") as a");
strSql.Append(" order by INVOICENO,CUSTOMERNAME_i,MBLNO");
return strSql.ToString();
}
static public string GetDataListSQL(string strCondition, string userid, string usercode, string companyid)
{
var strSql = new StringBuilder();
strSql.Append("select GID_i,CUSTOMERNAME_i,INVOICENO,MBLNO,VESSEL,VOYNO,PORTLOAD,PORTDISCHARGE,REMARK,SUM(gjUSD) as gjUSD,SUM(gjRMB) as gjRMB,SUM(gkRMB) as gkRMB,SUM(qtRMB) as qtRMB from vw_ch_fee_invoice_duty_free where 1=1");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
//strSql.Append(" and COMPANYID='" + companyid + "'");
strSql.Append(" group by GID_i,CUSTOMERNAME_i,INVOICENO,MBLNO,VESSEL,VOYNO,PORTLOAD,PORTDISCHARGE,REMARK");
return strSql.ToString();
}
private static List<RptChFeeInvoiceDutyFree> SetData(StringBuilder strSql)
{
var headList = new List<RptChFeeInvoiceDutyFree>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
RptChFeeInvoiceDutyFree data = new RptChFeeInvoiceDutyFree();
#region Set DB data to Object
data.GID_i = (reader["GID_i"] == null ? "" : Convert.ToString(reader["GID_i"]));//GID_i
data.CUSTOMERNAME_i = (reader["CUSTOMERNAME_i"] == null ? "" : Convert.ToString(reader["CUSTOMERNAME_i"]));//CUSTOMERNAME_i
data.INVOICENO = (reader["INVOICENO"] == null ? "" : Convert.ToString(reader["INVOICENO"]));//INVOICENO
data.MBLNO = (reader["MBLNO"] == null ? "" : Convert.ToString(reader["MBLNO"]));//MBLNO
data.VESSEL = (reader["VESSEL"] == null ? "" : Convert.ToString(reader["VESSEL"]));//VESSEL
data.VOYNO = (reader["VOYNO"] == null ? "" : Convert.ToString(reader["VOYNO"]));//VOYNO
data.PORTLOAD = (reader["PORTLOAD"] == null ? "" : Convert.ToString(reader["PORTLOAD"]));//PORTLOAD
data.PORTDISCHARGE = (reader["PORTDISCHARGE"] == null ? "" : Convert.ToString(reader["PORTDISCHARGE"]));//PORTDISCHARGE
data.REMARK = (reader["REMARK"] == null ? "" : Convert.ToString(reader["REMARK"]));//REMARK
data.gjUSD = (reader["gjUSD"] == null ? 0 : Convert.ToDecimal(reader["gjUSD"]));//gjUSD
data.gjRMB = (reader["gjRMB"] == null ? 0 : Convert.ToDecimal(reader["gjRMB"]));//gjRMB
data.gkRMB = (reader["gkRMB"] == null ? 0 : Convert.ToDecimal(reader["gkRMB"]));//gkRMB
data.qtRMB = (reader["qtRMB"] == null ? 0 : Convert.ToDecimal(reader["qtRMB"]));//qtRMB
//data.CUSTOMERNAME_d = (reader["CUSTOMERNAME_d"] == null ? "" : Convert.ToString(reader["CUSTOMERNAME_d"]));//CUSTOMERNAME_d
//data.BSTYPE = (reader["BSTYPE"] == null ? 0 : Convert.ToInt32(reader["BSTYPE"]));//BSTYPE
//data.FEEID = (reader["FEEID"] == null ? "" : Convert.ToString(reader["FEEID"]));//FEEID
//data.FEENAME = (reader["FEENAME"] == null ? "" : Convert.ToString(reader["FEENAME"]));//FEENAME
//data.CURRENCY_d = (reader["CURRENCY_d"] == null ? "" : Convert.ToString(reader["CURRENCY_d"]));//CURRENCY_d
//data.AMOUNT_d = (reader["AMOUNT_d"] == null ? 0 : Convert.ToDecimal(reader["AMOUNT_d"]));//AMOUNT_d
//data.DOAMOUNT = (reader["DOAMOUNT"] == null ? 0 : Convert.ToDecimal(reader["DOAMOUNT"]));//DOAMOUNT
//data.FEETYPE = (reader["FEETYPE"] == null ? 0 : Convert.ToInt32(reader["FEETYPE"]));//FEETYPE
//data.CATEGORY = (reader["CATEGORY"] == null ? 0 : Convert.ToInt32(reader["CATEGORY"]));//CATEGORY
//data.BILLSTATUS_d = (reader["BILLSTATUS_d"] == null ? 0 : Convert.ToInt32(reader["BILLSTATUS_d"]));//BILLSTATUS_d
//data.REMARK_d = (reader["REMARK_d"] == null ? "" : Convert.ToString(reader["REMARK_d"]));//REMARK_d
//data.ISDELETED = (reader["ISDELETED"] == null ? false : Convert.ToBoolean(reader["ISDELETED"]));//ISDELETED
//data.EXCHANGERATE_d = (reader["EXCHANGERATE_d"] == null ? 0 : Convert.ToDecimal(reader["EXCHANGERATE_d"]));//EXCHANGERATE_d
//data.ORIGCURRENCY = (reader["ORIGCURRENCY"] == null ? "" : Convert.ToString(reader["ORIGCURRENCY"]));//ORIGCURRENCY
//data.ORIGAMOUNT = (reader["ORIGAMOUNT"] == null ? 0 : Convert.ToDecimal(reader["ORIGAMOUNT"]));//ORIGAMOUNT
//data.INVOICESETTLENO = (reader["INVOICESETTLENO"] == null ? "" : Convert.ToString(reader["INVOICESETTLENO"]));//INVOICESETTLENO
//data.ORIGSTLAMOUNT = (reader["ORIGSTLAMOUNT"] == null ? 0 : Convert.ToDecimal(reader["ORIGSTLAMOUNT"]));//ORIGSTLAMOUNT
//data.BSNO = (reader["BSNO"] == null ? "" : Convert.ToString(reader["BSNO"]));//BSNO
//data.OPTYPE = (reader["OPTYPE"] == null ? "" : Convert.ToString(reader["OPTYPE"]));//OPTYPE
//data.OPLB = (reader["OPLB"] == null ? "" : Convert.ToString(reader["OPLB"]));//OPLB
//data.OPLBNAME = (reader["OPLBNAME"] == null ? "" : Convert.ToString(reader["OPLBNAME"]));//OPLBNAME
//data.CUSTOMERNAME = (reader["CUSTOMERNAME"] == null ? "" : Convert.ToString(reader["CUSTOMERNAME"]));//CUSTOMERNAME
//data.CUSTNO = (reader["CUSTNO"] == null ? "" : Convert.ToString(reader["CUSTNO"]));//CUSTNO
//data.ORDERNO = (reader["ORDERNO"] == null ? "" : Convert.ToString(reader["ORDERNO"]));//ORDERNO
//data.HBLNO = (reader["HBLNO"] == null ? "" : Convert.ToString(reader["HBLNO"]));//HBLNO
//data.ETD = (reader["ETD"] == null ? "" : Convert.ToString(reader["ETD"]));//ETD
//data.INPUTBY = (reader["INPUTBY"] == null ? "" : Convert.ToString(reader["INPUTBY"]));//INPUTBY
//if (reader["CREATETIME"] != null && reader["CREATETIME"].ToString().Trim().IndexOf("0001") < 0 && reader["CREATETIME"].ToString().Trim().IndexOf("1900") < 0 && reader["CREATETIME"].ToString().Trim() != "")
//{
// data.CREATETIME = Convert.ToDateTime(reader["CREATETIME"]);
//}
//data.BSSTATUS = (reader["BSSTATUS"] == null ? 0 : Convert.ToInt32(reader["BSSTATUS"]));//BSSTATUS
//data.SALE = (reader["SALE"] == null ? "" : Convert.ToString(reader["SALE"]));//SALE
//data.OP = (reader["OP"] == null ? "" : Convert.ToString(reader["OP"]));//OP
//data.DOC = (reader["DOC"] == null ? "" : Convert.ToString(reader["DOC"]));//DOC
//data.CUSTSERVICE = (reader["CUSTSERVICE"] == null ? "" : Convert.ToString(reader["CUSTSERVICE"]));//CUSTSERVICE
//data.CUSTOMNO = (reader["CUSTOMNO"] == null ? "" : Convert.ToString(reader["CUSTOMNO"]));//CUSTOMNO
//data.ACCDATE = (reader["ACCDATE"] == null ? "" : Convert.ToString(reader["ACCDATE"]));//ACCDATE
//data.CARRIER = (reader["CARRIER"] == null ? "" : Convert.ToString(reader["CARRIER"]));//CARRIER
//data.BSSOURCE = (reader["BSSOURCE"] == null ? "" : Convert.ToString(reader["BSSOURCE"]));//BSSOURCE
//data.BSSOURCEDETAIL = (reader["BSSOURCEDETAIL"] == null ? "" : Convert.ToString(reader["BSSOURCEDETAIL"]));//BSSOURCEDETAIL
//data.LANE = (reader["LANE"] == null ? "" : Convert.ToString(reader["LANE"]));//LANE
//data.FORWARDER = (reader["FORWARDER"] == null ? "" : Convert.ToString(reader["FORWARDER"]));//FORWARDER
//data.NETWEIGHT = (reader["NETWEIGHT"] == null ? 0 : Convert.ToInt32(reader["NETWEIGHT"]));//NETWEIGHT
//data.KGS = (reader["KGS"] == null ? 0 : Convert.ToDecimal(reader["KGS"]));//KGS
//data.TEU = (reader["TEU"] == null ? 0 : Convert.ToInt32(reader["TEU"]));//TEU
//data.CNTRTOTAL = (reader["CNTRTOTAL"] == null ? "" : Convert.ToString(reader["CNTRTOTAL"]));//CNTRTOTAL
//data.CORPID = (reader["CORPID"] == null ? "" : Convert.ToString(reader["CORPID"]));//CORPID
//data.CNTR1 = (reader["CNTR1"] == null ? 0 : Convert.ToInt32(reader["CNTR1"]));//CNTR1
//data.CNTR2 = (reader["CNTR2"] == null ? 0 : Convert.ToInt32(reader["CNTR2"]));//CNTR2
//data.CNTR3 = (reader["CNTR3"] == null ? 0 : Convert.ToInt32(reader["CNTR3"]));//CNTR3
//data.CNTR4 = (reader["CNTR4"] == null ? 0 : Convert.ToInt32(reader["CNTR4"]));//CNTR4
//data.CNTR5 = (reader["CNTR5"] == null ? 0 : Convert.ToInt32(reader["CNTR5"]));//CNTR5
//data.CNTR6 = (reader["CNTR6"] == null ? 0 : Convert.ToInt32(reader["CNTR6"]));//CNTR6
//data.CNTR7 = (reader["CNTR7"] == null ? 0 : Convert.ToInt32(reader["CNTR7"]));//CNTR7
//data.CNTR8 = (reader["CNTR8"] == null ? 0 : Convert.ToInt32(reader["CNTR8"]));//CNTR8
//data.CNTR9 = (reader["CNTR9"] == null ? 0 : Convert.ToInt32(reader["CNTR9"]));//CNTR9
//data.CNTR10 = (reader["CNTR10"] == null ? 0 : Convert.ToInt32(reader["CNTR10"]));//CNTR10
//data.OTCNTR = (reader["OTCNTR"] == null ? 0 : Convert.ToInt32(reader["OTCNTR"]));//OTCNTR
//data.TRADETYPE = (reader["TRADETYPE"] == null ? "" : Convert.ToString(reader["TRADETYPE"]));//TRADETYPE
//data.GOODSNAME = (reader["GOODSNAME"] == null ? "" : Convert.ToString(reader["GOODSNAME"]));//GOODSNAME
//data.FEESTATUS = (reader["FEESTATUS"] == null ? 0 : Convert.ToInt32(reader["FEESTATUS"]));//FEESTATUS
//if (reader["OPDATE"] != null && reader["OPDATE"].ToString().Trim().IndexOf("0001") < 0 && reader["OPDATE"].ToString().Trim().IndexOf("1900") < 0 && reader["OPDATE"].ToString().Trim() != "")
//{
// data.OPDATE = Convert.ToDateTime(reader["OPDATE"]);
//}
//if (reader["CUSTOMDATE"] != null && reader["CUSTOMDATE"].ToString().Trim().IndexOf("0001") < 0 && reader["CUSTOMDATE"].ToString().Trim().IndexOf("1900") < 0 && reader["CUSTOMDATE"].ToString().Trim() != "")
//{
// data.CUSTOMDATE = Convert.ToDateTime(reader["CUSTOMDATE"]);
//}
//data.ENTERP = (reader["ENTERP"] == null ? "" : Convert.ToString(reader["ENTERP"]));//ENTERP
//data.INVOICECUSTNAME = (reader["INVOICECUSTNAME"] == null ? "" : Convert.ToString(reader["INVOICECUSTNAME"]));//INVOICECUSTNAME
//if (reader["INVOICEMAKETIME"] != null && reader["INVOICEMAKETIME"].ToString().Trim().IndexOf("0001") < 0 && reader["INVOICEMAKETIME"].ToString().Trim().IndexOf("1900") < 0 && reader["INVOICEMAKETIME"].ToString().Trim() != "")
//{
// data.INVOICEMAKETIME = Convert.ToDateTime(reader["INVOICEMAKETIME"]);
//}
//data.BANK = (reader["BANK"] == null ? "" : Convert.ToString(reader["BANK"]));//BANK
//data.ACCOUNT = (reader["ACCOUNT"] == null ? "" : Convert.ToString(reader["ACCOUNT"]));//ACCOUNT
//data.AMOUNT = (reader["AMOUNT"] == null ? 0 : Convert.ToDecimal(reader["AMOUNT"]));//AMOUNT
//data.AMOUNTCAPITAL = (reader["AMOUNTCAPITAL"] == null ? "" : Convert.ToString(reader["AMOUNTCAPITAL"]));//AMOUNTCAPITAL
//data.CURRENCY = (reader["CURRENCY"] == null ? "" : Convert.ToString(reader["CURRENCY"]));//CURRENCY
//data.COMPANYID = (reader["COMPANYID"] == null ? "" : Convert.ToString(reader["COMPANYID"]));//COMPANYID
//data.KEYVALUE_k1 = (reader["KEYVALUE_k1"] == null ? "" : Convert.ToString(reader["KEYVALUE_k1"]));//KEYVALUE_k1
//data.KEYVALUE_k2 = (reader["KEYVALUE_k2"] == null ? "" : Convert.ToString(reader["KEYVALUE_k2"]));//KEYVALUE_k2
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
//
}
}