|
|
|
|
using System;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using DSWeb.Areas.TruckMng.Models.MsWlPc;
|
|
|
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
|
|
using DSWeb.EntityDA;
|
|
|
|
|
using DSWeb.Areas.CommMng.Models;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.Areas.TruckMng.DAL.MsWlPc
|
|
|
|
|
{
|
|
|
|
|
public partial class MsWlPcHeadDAL
|
|
|
|
|
{
|
|
|
|
|
#region Inquery DataList
|
|
|
|
|
|
|
|
|
|
static public List<MsWlPcHead> 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("BillNo,LrDate,JzDate,UserCode,UserName,OrgCode,OrgName");
|
|
|
|
|
strSql.Append(",TruckNo,");
|
|
|
|
|
strSql.Append("(select TruckNo from tMsWlTruck where TruckNo=tMsWlPcHead.TruckNo) as TruckNo_Ref");
|
|
|
|
|
strSql.Append(",DrvCode,DrvName,");
|
|
|
|
|
strSql.Append("(select DrvName from tMsWlDriver where DrvCode=tMsWlPcHead.DrvCode) as DrvName_Ref");
|
|
|
|
|
strSql.Append(",Mobile,dbo.trimdate(ExpDate) ExpDate,ContainerType,");
|
|
|
|
|
strSql.Append("(select CodeAndName from vMsTruckCtn where CtnCode=tMsWlPcHead.ContainerType) as ContainerType_Ref");
|
|
|
|
|
strSql.Append(",ContainerQty,VoyVeg,");
|
|
|
|
|
strSql.Append("(select CodeAndName from vMsTruckVoyInfo where VoyCode=tMsWlPcHead.VoyVeg) as VoyVeg_Ref");
|
|
|
|
|
strSql.Append(",EtDate,EndPortDate,MblNo,YardCode,UnitPrice,Amount,");
|
|
|
|
|
strSql.Append(" YardName as YardCode_Ref");
|
|
|
|
|
strSql.Append(",YardName,RtnYardCode,");
|
|
|
|
|
strSql.Append(" RtnYardName as RtnYardCode_Ref");
|
|
|
|
|
strSql.Append(",RtnYardName,FuelQty,OilLrDate,OilUser,");
|
|
|
|
|
strSql.Append("(select CodeAndName from vMsTruckUser where UserCode=tMsWlPcHead.OilUser) as OilUser_Ref,");
|
|
|
|
|
strSql.Append("(select YouLiaoType from tMsWlTruck where TruckNo=tMsWlPcHead.TruckNo) as YouLiaoType");
|
|
|
|
|
strSql.Append(" from tMsWlPcHead ");
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
strSql.Append("SELECT ");
|
|
|
|
|
strSql.Append("BillNo,TruckNo,OilLrDate,");
|
|
|
|
|
strSql.Append("(select CodeAndName from vMsTruckUser where UserCode=tMsWlPcHead.OilUser) as OilUser_Ref,");
|
|
|
|
|
strSql.Append("FuelQty,OilUser,");
|
|
|
|
|
strSql.Append("LrDate,JzDate,UserCode,UserName,OrgCode,OrgName,");
|
|
|
|
|
strSql.Append("(select TruckNo from tMsWlTruck where TruckNo=tMsWlPcHead.TruckNo) as TruckNo_Ref");
|
|
|
|
|
strSql.Append(",DrvCode,DrvName,");
|
|
|
|
|
strSql.Append("(select DrvName from tMsWlDriver where DrvCode=tMsWlPcHead.DrvCode) as DrvName_Ref");
|
|
|
|
|
strSql.Append(",Mobile,ExpDate,ContainerType,");
|
|
|
|
|
strSql.Append("(select CodeAndName from vMsTruckCtn where CtnCode=tMsWlPcHead.ContainerType) as ContainerType_Ref");
|
|
|
|
|
strSql.Append(",ContainerQty,VoyVeg,");
|
|
|
|
|
strSql.Append("(select CodeAndName from vMsTruckVoyInfo where VoyCode=tMsWlPcHead.VoyVeg) as VoyVeg_Ref");
|
|
|
|
|
strSql.Append(",EtDate,EndPortDate,MblNo,YardCode,");
|
|
|
|
|
strSql.Append(" YardName as YardCode_Ref");
|
|
|
|
|
strSql.Append(",YardName,RtnYardCode,");
|
|
|
|
|
strSql.Append(" RtnYardName as RtnYardCode_Ref");
|
|
|
|
|
strSql.Append(",RtnYardName");
|
|
|
|
|
strSql.Append(" from tMsWlPcHead ");
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return SetData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static public MsWlPcHead 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 MsWlPcHead();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static List<MsWlPcHead> SetData(StringBuilder strSql)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<MsWlPcHead>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
MsWlPcHead data = new MsWlPcHead();
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.BillNo = Convert.ToString(reader["BillNo"]);
|
|
|
|
|
if (reader["LrDate"] != DBNull.Value)
|
|
|
|
|
data.LrDate = Convert.ToDateTime(reader["LrDate"]);
|
|
|
|
|
if (reader["JzDate"] != DBNull.Value)
|
|
|
|
|
data.JzDate = Convert.ToDateTime(reader["JzDate"]);
|
|
|
|
|
data.UserCode = Convert.ToString(reader["UserCode"]);
|
|
|
|
|
data.UserName = Convert.ToString(reader["UserName"]);
|
|
|
|
|
data.OrgCode = Convert.ToString(reader["OrgCode"]);
|
|
|
|
|
data.OrgName = Convert.ToString(reader["OrgName"]);
|
|
|
|
|
data.TruckNo = Convert.ToString(reader["TruckNo"]);
|
|
|
|
|
data.TruckNo_Ref = Convert.ToString(reader["TruckNo_Ref"]);
|
|
|
|
|
data.DrvCode = Convert.ToString(reader["DrvCode"]);
|
|
|
|
|
data.DrvName = Convert.ToString(reader["DrvName"]);
|
|
|
|
|
data.DrvName_Ref = Convert.ToString(reader["DrvName_Ref"]);
|
|
|
|
|
data.Mobile = Convert.ToString(reader["Mobile"]);
|
|
|
|
|
data.ExpDate = Convert.ToString(reader["ExpDate"]);
|
|
|
|
|
data.ContainerType = Convert.ToString(reader["ContainerType"]);
|
|
|
|
|
data.ContainerType_Ref = Convert.ToString(reader["ContainerType_Ref"]);
|
|
|
|
|
data.ContainerQty = Convert.ToDecimal(reader["ContainerQty"]);
|
|
|
|
|
data.VoyVeg = Convert.ToString(reader["VoyVeg"]);
|
|
|
|
|
data.VoyVeg_Ref = Convert.ToString(reader["VoyVeg_Ref"]);
|
|
|
|
|
data.EtDate = Convert.ToString(reader["EtDate"]);
|
|
|
|
|
data.EndPortDate = Convert.ToString(reader["EndPortDate"]);
|
|
|
|
|
data.MblNo = Convert.ToString(reader["MblNo"]);
|
|
|
|
|
data.YardCode = Convert.ToString(reader["YardCode"]);
|
|
|
|
|
data.YardCode_Ref = Convert.ToString(reader["YardCode_Ref"]);
|
|
|
|
|
data.YardName = Convert.ToString(reader["YardName"]);
|
|
|
|
|
data.RtnYardCode = Convert.ToString(reader["RtnYardCode"]);
|
|
|
|
|
data.RtnYardCode_Ref = Convert.ToString(reader["RtnYardCode_Ref"]);
|
|
|
|
|
data.RtnYardName = Convert.ToString(reader["RtnYardName"]);
|
|
|
|
|
data.FuelQty = Convert.ToDecimal(reader["FuelQty"]);
|
|
|
|
|
data.OilLrDate = Convert.ToString(reader["OilLrDate"]);
|
|
|
|
|
data.OilUser = Convert.ToString(reader["OilUser"]);
|
|
|
|
|
data.OilUser_Ref = Convert.ToString(reader["OilUser_Ref"]);
|
|
|
|
|
|
|
|
|
|
data.YouLiaoType = Convert.ToString(reader["YouLiaoType"] == DBNull.Value ? "" : reader["YouLiaoType"]);
|
|
|
|
|
//data.FeeStatus = "0";//临时添加
|
|
|
|
|
data.Amount = float.Parse(reader["Amount"].ToString());
|
|
|
|
|
|
|
|
|
|
data.UnitPrice = float.Parse(reader["UnitPrice"].ToString());
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
headList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
return headList;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 参照部分
|
|
|
|
|
|
|
|
|
|
internal static List<MsWlTruckRef> GetTruckNoList(string userid, string usercode, string orgcode)
|
|
|
|
|
{
|
|
|
|
|
var rangstr = GetRangDAStr("", userid, usercode, orgcode);
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT ");
|
|
|
|
|
strSql.Append(" A.TruckNo,A.DrvCode,isnull((select Mobile from tMsWlDriver B where B.DrvCode=A.DrvCode),'') as Mobile");
|
|
|
|
|
strSql.Append(" from tMsWlTruck A");
|
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" where " + rangstr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var dataList = new List<MsWlTruckRef>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
var data = new MsWlTruckRef();
|
|
|
|
|
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
|
|
|
|
|
data.TruckNo = Convert.ToString(reader["TruckNo"]);
|
|
|
|
|
data.DrvCode = Convert.ToString(reader["DrvCode"]);
|
|
|
|
|
data.Mobile = Convert.ToString(reader["Mobile"]);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
dataList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return dataList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal static List<MsWlDriverRef> GetDrvNameList(string userid, string usercode, string orgcode)
|
|
|
|
|
{
|
|
|
|
|
var rangstr = GetRangDAStr("", userid, usercode, orgcode);
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT ");
|
|
|
|
|
strSql.Append(" DrvCode,DrvName");
|
|
|
|
|
strSql.Append(" from tMsWlDriver");
|
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" where " + rangstr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var dataList = new List<MsWlDriverRef>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
var data = new MsWlDriverRef();
|
|
|
|
|
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.DrvCode = Convert.ToString(reader["DrvCode"]);
|
|
|
|
|
data.DrvName = Convert.ToString(reader["DrvName"]);
|
|
|
|
|
data.CodeAndName = data.DrvCode + "-" + Convert.ToString(reader["DrvName"]);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
dataList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return dataList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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]='modTruckYl' 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 + "'";
|
|
|
|
|
}
|
|
|
|
|
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 + "'))";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
str = " UPPER(OrgCode)='" + orgcode + "'";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "1")
|
|
|
|
|
{
|
|
|
|
|
str = " UPPER(OrgCode)='" + orgcode + "'";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|