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/TruckMng/DAL/MsWlCheckAcc/MsWlCheckAccDAL.cs

227 lines
9.9 KiB
C#

using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.Areas.CommMng.DAL;
using DSWeb.TruckMng.Comm.Cookie;
using System.Web.Mvc;
using DSWeb.EntityDA;
using DSWeb.Areas.CommMng.Models;
using DSWeb.TruckMng.Helper;
using System.Linq;
using DSWeb.TruckMng.Helper.Repository;
using HcUtility.Comm;
using HcUtility.Core;
using DSWeb.DataAccess;
namespace DSWeb.Areas.TruckMng.DAL.MsWlCheckAcc
{
[JsonRequestBehavior]
public partial class MsWlCheckAccDAL
{
#region Inquery DataList
static public List<Models.MsWlCheckAcc.MsWlCheckAcc> GetDataList(string strCondition, string USERID, string ORGCODE)
{
var range = BasicDataRefDAL.GetAR("modTruck_dui", USERID);
var rangeSQL = "";
if (range[0].VISIBLERANGE == "0")
{
rangeSQL = "";
}
if (range[0].VISIBLERANGE == "1" || range[0].VISIBLERANGE == "2")
{
rangeSQL = " orgcode='" + ORGCODE + "'";
}
if (range[0].VISIBLERANGE == "3")
{
rangeSQL = " orgcode='" + ORGCODE + "'";
}
if (range[0].VISIBLERANGE == "4")
{
rangeSQL = " 1=2 ";
}
if (!string.IsNullOrEmpty(strCondition))
{
if (rangeSQL != "")
{
strCondition = strCondition + " and " + rangeSQL;
}
}
else {
strCondition = rangeSQL;
}
return GetDataList(strCondition);
}
static public List<Models.MsWlCheckAcc.MsWlCheckAcc> GetDataList(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("BillNo,CustomerName,ContactName,CustDate,MblNo,VoyVeg,Freight,SettleMent,ExtrasFee,ExSettleMent");
strSql.Append(",FeeType,");
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99020 and EnumValueID=vMsWlCheckAcc.FeeType) as FeeType_Ref");
strSql.Append(",SendYardName,DstArea,DetiNation,Con40Qty,Con20Qty,GId");
strSql.Append(" ,f.DZF,f.GSF ");
strSql.Append(" ,f.CZF ,f.GZF ");
strSql.Append(" ,f.SJF ,f.GBF ");
strSql.Append(" ,f.ZHF ,f.JKF ");
strSql.Append(" ,f.DXF ,f.DSF ");
strSql.Append(" ,f.XSF ,f.CWF ");
strSql.Append(" from vMsWlCheckAcc ");
strSql.Append(" left join v_jytruck_fee f on (f.bsno=vMsWlCheckAcc.GId and f.CUSTNAME=vMsWlCheckAcc.CUSTOMERNAME) ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
return SetData(strSql);
}
static public Models.MsWlCheckAcc.MsWlCheckAcc GetData(string condition)
{
var list = GetDataList(condition);
if (list.Count > 0)
return list[0];
return new Models.MsWlCheckAcc.MsWlCheckAcc();
}
private static List<Models.MsWlCheckAcc.MsWlCheckAcc> SetData(StringBuilder strSql)
{
var headList = new List<Models.MsWlCheckAcc.MsWlCheckAcc>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
Models.MsWlCheckAcc.MsWlCheckAcc data = new Models.MsWlCheckAcc.MsWlCheckAcc();
#region Set DB data to Object
data.BillNo = Convert.ToString(reader["BillNo"]);
data.CustomerName = Convert.ToString(reader["CustomerName"]);
data.ContactName = Convert.ToString(reader["ContactName"]);
data.FeeType = Convert.ToDecimal(reader["FeeType"]);
data.FeeType_Ref = Convert.ToString(reader["FeeType_Ref"]);
data.CustDate = Convert.ToString(reader["CustDate"]);
data.MblNo = Convert.ToString(reader["MblNo"]);
data.VoyVeg = Convert.ToString(reader["VoyVeg"]);
data.Freight = Convert.ToDecimal(reader["Freight"]);
data.Settlement = Convert.ToDecimal(reader["Settlement"]);
data.ExtrasFee = Convert.ToDecimal(reader["ExtrasFee"]);
data.ExSettleMent = Convert.ToDecimal(reader["ExSettleMent"]);
data.SendYardName = Convert.ToString(reader["SendYardName"]);
data.DstArea = Convert.ToString(reader["DstArea"]);
data.DetiNation = Convert.ToString(reader["DetiNation"]);
data.Con40Qty = Convert.ToDecimal(reader["Con40Qty"]);
data.Con20Qty = Convert.ToDecimal(reader["Con20Qty"]);
data.GId = Convert.ToString(reader["GId"]);
data.DZF = Convert.ToString(reader["DZF"]);
data.GSF = Convert.ToString(reader["GSF"]);
data.CZF = Convert.ToString(reader["CZF"]);
data.GZF = Convert.ToString(reader["GZF"]);
data.SJF = Convert.ToString(reader["SJF"]);
data.GBF = Convert.ToString(reader["GBF"]);
data.ZHF = Convert.ToString(reader["ZHF"]);
data.JKF = Convert.ToString(reader["JKF"]);
data.DXF = Convert.ToString(reader["DXF"]);
data.DSF = Convert.ToString(reader["DSF"]);
data.XSF = Convert.ToString(reader["XSF"]);
data.CWF = Convert.ToString(reader["CWF"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
static public List<Models.MsWlCheckAcc.MsWlCheckAcc> GetDataPcList(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("WTDW,PcBillNo,BillNo,ContainerNo,TruckNo,VoyVegSe,FactoryAddr,CustomerName,ContactName,CustDate,dbo.trimdate(ExpDate) ExpDate,MblNo,VoyVeg,Freight,SettleMent,ExtrasFee,ExSettleMent");
strSql.Append(",FeeType,");
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99020 and EnumValueID=vMsWlCheckAccPc.FeeType) as FeeType_Ref");
strSql.Append(",SendYardName,DstArea,DetiNation,GId,ContainerType,");
strSql.Append(
"(select CodeAndName from vMsTruckCtn where CtnCode=vMsWlCheckAccPc.ContainerType) as ContainerType_Ref");
strSql.Append(",ContainerQty,UserCode");
strSql.Append(" from vMsWlCheckAccPc ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
return SetPcData(strSql);
}
private static List<Models.MsWlCheckAcc.MsWlCheckAcc> SetPcData(StringBuilder strSql)
{
var headList = new List<Models.MsWlCheckAcc.MsWlCheckAcc>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
Models.MsWlCheckAcc.MsWlCheckAcc data = new Models.MsWlCheckAcc.MsWlCheckAcc();
#region Set DB data to Object
data.PcBillNo = Convert.ToString(reader["PcBillNo"]);
data.BillNo = Convert.ToString(reader["BillNo"]);
data.ContainerNo = Convert.ToString(reader["ContainerNo"]);
data.TruckNo = Convert.ToString(reader["TruckNo"]);
data.VoyVegSe = Convert.ToString(reader["VoyVegSe"]);
data.FactoryAddr = Convert.ToString(reader["FactoryAddr"]);
data.CustomerName = Convert.ToString(reader["CustomerName"]);
data.ContactName = Convert.ToString(reader["ContactName"]);
data.FeeType = Convert.ToDecimal(reader["FeeType"]);
data.FeeType_Ref = Convert.ToString(reader["FeeType_Ref"]);
data.ExpDate = Convert.ToString(reader["ExpDate"]);
data.CustDate = Convert.ToString(reader["CustDate"]);
data.MblNo = Convert.ToString(reader["MblNo"]);
data.VoyVeg = Convert.ToString(reader["VoyVeg"]);
data.Freight = Convert.ToDecimal(reader["Freight"]);
data.Settlement = Convert.ToDecimal(reader["Settlement"]);
data.ExtrasFee = Convert.ToDecimal(reader["ExtrasFee"]);
data.ExSettleMent = Convert.ToDecimal(reader["ExSettleMent"]);
data.SendYardName = Convert.ToString(reader["SendYardName"]);
data.DstArea = Convert.ToString(reader["DstArea"]);
data.DetiNation = Convert.ToString(reader["DetiNation"]);
data.ContainerType = Convert.ToString(reader["ContainerType"]);
data.ContainerType_Ref = Convert.ToString(reader["ContainerType_Ref"]);
data.ContainerQty = Convert.ToDecimal(reader["ContainerQty"]);
data.UserCode = Convert.ToString(reader["UserCode"]);
data.GId = Convert.ToString(reader["GId"]);
data.WTDW = Convert.ToString(reader["WTDW"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#region 参照部分
#endregion
}
}