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/MvcShipping/DAL/MsSeaeFee/MsSeaeFeeDAL.cs

287 lines
12 KiB
C#

using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using DSWeb.MvcShipping.Models.MsSeaeFee;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.EntityDA;
using DSWeb.Areas.CommMng.Models;
using DSWeb.Areas.MvcShipping.Models;
namespace DSWeb.Areas.MvcShipping.DAL
{
public partial class MsSeaeFeeDAL
{
#region Inquery DataList
static public List<MsOpSeae> GetDataList(string strCondition, string userid, string usercode, string orgcode, string sort = null)
{
/*
var rangstr = GetRangDAStr("index", userid, usercode, orgcode);
if (!string.IsNullOrEmpty(rangstr))
{
if (!string.IsNullOrEmpty(strCondition))
{
strCondition = strCondition + " and " + rangstr;
}
else
{
strCondition = rangstr;
}
}
*/
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("BSNO,BSSTATUS,FEESTATUS,BSDATE,ACCDATE,MBLNO,HBLNO,CUSTNO");
strSql.Append(",TRANSNO,CUSTOMERNAME,BLTYPE,SHIPPERID,CONSIGNEEID,NOTIFYPARTYID");
strSql.Append(",AGENTID,YARD,VESSEL,VOYNO,ETD,CLOSINGDATE,ETA,PORTLOAD,PORTDISCHARGEID");
strSql.Append(",PORTDISCHARGE,BLFRT,SERVICE,CNTRTOTAL,INPUTBY,OP,CUSTSERVICE");
strSql.Append(",LANE,SALE,CARRIER,FORWARDER,CUSTOMSER,TRUCKER,BSSOURCE,BSSOURCEDETAIL");
strSql.Append(",ORDTYPE,ORDERNO,ISFUMIGATION,ISSTORAGE,ISLAND,ISCUSTOMS");
strSql.Append(",ISINSPECTION,ISBOOKING,ISAGENT,ISHBLNO,SERVICE9,SERVICE10,CORPID,SALEDEPT,MBLFRT,PKGS,KGS,CBM,CREATETIME");
strSql.Append(" from op_seae ");
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 MsOpSeae GetData(string condition, string userid, string usercode, string orgcode)
{
var list = GetDataList(condition,userid,usercode,orgcode);
if (list.Count > 0)
return list[0];
return new MsOpSeae();
}
private static List<MsOpSeae> SetData(StringBuilder strSql)
{
var headList = new List<MsOpSeae>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsOpSeae data = new MsOpSeae();
#region Set DB data to Object
data.BSNO = Convert.ToString(reader["BSNO"]);
if (reader["BSDATE"] != DBNull.Value)
data.BSDATE = Convert.ToDateTime(reader["BSDATE"]);
if (reader["ETD"] != DBNull.Value)
data.ETD = Convert.ToDateTime(reader["ETD"]);
if (reader["CLOSINGDATE"] != DBNull.Value)
data.CLOSINGDATE = Convert.ToDateTime(reader["CLOSINGDATE"]);
if (reader["ETA"] != DBNull.Value)
data.ETA = Convert.ToDateTime(reader["ETA"]);
data.ACCDATE = Convert.ToString(reader["ACCDATE"]);
data.MBLNO = Convert.ToString(reader["MBLNO"]);
data.HBLNO = Convert.ToString(reader["HBLNO"]);
data.CUSTNO = Convert.ToString(reader["CUSTNO"]);
data.TRANSNO = Convert.ToString(reader["TRANSNO"]);
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
// data.TimeMark = Convert.ToDecimal(reader["TimeMark"]);
data.BLTYPE = Convert.ToString(reader["BLTYPE"]);
data.SHIPPERID = Convert.ToString(reader["SHIPPERID"]);
data.CONSIGNEEID = Convert.ToString(reader["CONSIGNEEID"]);
data.NOTIFYPARTYID = Convert.ToString(reader["NOTIFYPARTYID"]);
data.AGENTID = Convert.ToString(reader["AGENTID"]);
data.YARD = Convert.ToString(reader["YARD"]);
data.VESSEL = Convert.ToString(reader["VESSEL"]);
data.VOYNO = Convert.ToString(reader["VOYNO"]);
data.PORTLOAD = Convert.ToString(reader["PORTLOAD"]);
data.PORTDISCHARGEID = Convert.ToString(reader["PORTDISCHARGEID"]);
data.PORTDISCHARGE = Convert.ToString(reader["PORTDISCHARGE"]);
data.BLFRT = Convert.ToString(reader["BLFRT"]);
data.SERVICE = Convert.ToString(reader["SERVICE"]);
data.CNTRTOTAL = Convert.ToString(reader["CNTRTOTAL"]);
data.INPUTBY = Convert.ToString(reader["INPUTBY"]);
if (reader["CREATETIME"] != DBNull.Value)
data.CREATETIME = Convert.ToDateTime(reader["CREATETIME"]);
data.OP = Convert.ToString(reader["OP"]);
data.CUSTSERVICE = Convert.ToString(reader["CUSTSERVICE"]);
data.LANE = Convert.ToString(reader["LANE"]);
data.SALE = Convert.ToString(reader["SALE"]);
data.CARRIER = Convert.ToString(reader["CARRIER"]);
data.FORWARDER = Convert.ToString(reader["FORWARDER"]);
data.CUSTOMSER = Convert.ToString(reader["CUSTOMSER"]);
data.TRUCKER = Convert.ToString(reader["TRUCKER"]);
data.BSSOURCE = Convert.ToString(reader["BSSOURCE"]);
data.BSSOURCEDETAIL = Convert.ToString(reader["BSSOURCEDETAIL"]);
data.ORDTYPE = Convert.ToString(reader["ORDTYPE"]);
data.ORDERNO = Convert.ToString(reader["ORDERNO"]);
if (reader["ISFUMIGATION"] != DBNull.Value)
data.ISFUMIGATION = Convert.ToBoolean(reader["ISFUMIGATION"]);
if (reader["ISSTORAGE"] != DBNull.Value)
data.ISSTORAGE = Convert.ToBoolean(reader["ISSTORAGE"]);
if (reader["ISLAND"] != DBNull.Value)
data.ISLAND = Convert.ToBoolean(reader["ISLAND"]);
if (reader["ISCUSTOMS"] != DBNull.Value)
data.ISCUSTOMS = Convert.ToBoolean(reader["ISCUSTOMS"]);
if (reader["ISINSPECTION"] != DBNull.Value)
data.ISINSPECTION = Convert.ToBoolean(reader["ISINSPECTION"]);
if (reader["ISBOOKING"] != DBNull.Value)
data.ISBOOKING = Convert.ToBoolean(reader["ISBOOKING"]);
if (reader["ISAGENT"] != DBNull.Value)
data.ISAGENT = Convert.ToBoolean(reader["ISAGENT"]);
if (reader["ISHBLNO"] != DBNull.Value)
data.ISHBLNO = Convert.ToBoolean(reader["ISHBLNO"]);
data.BSSTATUS = Convert.ToBoolean(reader["BSSTATUS"]);
data.FEESTATUS = Convert.ToBoolean(reader["FEESTATUS"]);
if (reader["SERVICE9"] != DBNull.Value)
data.SERVICE9 = Convert.ToBoolean(reader["SERVICE9"]);
if (reader["SERVICE10"] != DBNull.Value)
data.SERVICE10 = Convert.ToBoolean(reader["SERVICE10"]);
data.MBLFRT = Convert.ToString(reader["MBLFRT"]);
data.CORPID = Convert.ToString(reader["CORPID"]);
data.SALEDEPT = Convert.ToString(reader["SALEDEPT"]);
if (reader["PKGS"] != DBNull.Value)
data.PKGS = Convert.ToInt32(reader["PKGS"]);
if (reader["KGS"] != DBNull.Value)
data.KGS = Convert.ToDecimal(reader["KGS"]);
if (reader["CBM"] != DBNull.Value)
data.CBM = Convert.ToDecimal(reader["CBM"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
static public List<MsFeeUnit> GetCtnUnitList(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("SIZE,CTN,SUM(CTNNUM) AS CTNNUM,SUM(TEU) AS TEU,CTNALL");
strSql.Append(" from OP_CTN ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
strSql.Append(" GROUP BY SIZE,CTN,CTNALL ");
return SetCtnUnitData(strSql);
}
private static List<MsFeeUnit> SetCtnUnitData(StringBuilder strSql)
{
var bodyList = new List<MsFeeUnit>();
decimal TEUNUM ;
TEUNUM = 0;
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
MsFeeUnit data = new MsFeeUnit();
while (reader.Read())
{
#region Set DB data to Object
data.UNIT = Convert.ToString(reader["CTNALL"]);
data.QUANTITY = Convert.ToDecimal(reader["CTNNUM"]);
TEUNUM =TEUNUM+Convert.ToDecimal(reader["TEU"]);
#endregion
bodyList.Add(data);
}
data.UNIT = "TEU";
data.QUANTITY = TEUNUM;
reader.Close();
}
return bodyList;
}
#region 参照部分
/*
public static string GetRangDAStr(string tb, string userid, string usercode, string orgcode)
{
string str = "";
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append(" VISIBLERANGE,OPERATERANGE ");
strSql.Append(" from VW_User_Authority ");
strSql.Append(" where [NAME]='modTruckBulk' 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")
{
if (tb == "index")
{
str = " (UserCode='" + usercode + "' or SalesCode='" + usercode + "')";
}
else
{
str = " UPPER(OrgCode)='" + orgcode + "'";
}
}
else if (visiblerange == "2")
{
if (tb == "index")
{
var rangeDa = new RangeDA();
var companyid = rangeDa.GetCORPID(userid);
var deptname = rangeDa.GetDEPTNAME(userid);
str = " (UserCode in (select codename from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "'))"
+ " or SalesCode in (select codename from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')))";
}
else
{
str = " UPPER(OrgCode)='" + orgcode + "'";
}
}
else if (visiblerange == "1")
{
str = " UPPER(OrgCode)='" + orgcode + "'";
}
return str;
}
*/
#endregion
}
}