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

105 lines
3.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using DSWeb.Areas.TruckMng.Models.WlTruck;
using Microsoft.Practices.EnterpriseLibrary.Data;
namespace DSWeb.Areas.TruckMng.DAL
{
public class WlTruckDAL
{
#region Inquery DataList
static public List<WlTruck> GetDataList(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("OrgCode,TruckNo,TruckSpec,TruckType,");
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99001 and EnumValueID=tWlTruck.TruckType) as TruckType_Ref");
strSql.Append(",TrunkColor,TrunkBrand,LoadCount,CjNo,FdjNo,GzDate,ZrDate");
strSql.Append(",DrvCode,");
strSql.Append("(select DrvName from tWlDriver where DrvCode=tWlTruck.DrvCode) as DrvCode_Ref");
strSql.Append(",NowStatus,DepCode,TruncClass,Remark");
strSql.Append(" from tWlTruck ");
if (strCondition.Trim() != String.Empty)
{
strSql.Append(" where " + strCondition);
}
return SetData(strSql);
}
private static List<WlTruck> SetData(StringBuilder strSql)
{
var headList = new List<WlTruck>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
WlTruck data = new WlTruck();
#region Set DB data to Object
data.OrgCode = Convert.ToString(reader["OrgCode"]);
data.TruckNo = Convert.ToString(reader["TruckNo"]);
data.TruckSpec = Convert.ToString(reader["TruckSpec"]);
data.TruckType = Convert.ToString(reader["TruckType"]);
data.TruckType_Ref = Convert.ToString(reader["TruckType_Ref"]);
data.TrunkColor = Convert.ToString(reader["TrunkColor"]);
data.TrunkBrand = Convert.ToString(reader["TrunkBrand"]);
data.LoadCount = Convert.ToDecimal(reader["LoadCount"]);
data.CjNo = Convert.ToString(reader["CjNo"]);
data.FdjNo = Convert.ToString(reader["FdjNo"]);
data.GzDate = Convert.ToString(reader["GzDate"]);
data.ZrDate = Convert.ToString(reader["ZrDate"]);
data.DrvCode = Convert.ToString(reader["DrvCode"]);
data.DrvCode_Ref = Convert.ToString(reader["DrvCode_Ref"]);
data.NowStatus = Convert.ToString(reader["NowStatus"]);
data.DepCode = Convert.ToString(reader["DepCode"]);
data.TruncClass = Convert.ToString(reader["TruncClass"]);
data.Remark = Convert.ToString(reader["Remark"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 参照部分
internal static List<WlTruckRefWlDriver> GetDrvCodeList()
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append(" DrvCode,DrvName");
strSql.Append(" from tWlDriver");
var dataList = new List<WlTruckRefWlDriver>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var data = new WlTruckRefWlDriver();
#region Set DB data to Object
data.DrvCode = Convert.ToString(reader["DrvCode"]);
data.DrvName = data.DrvCode + "-" + Convert.ToString(reader["DrvName"]);
#endregion
dataList.Add(data);
}
reader.Close();
}
return dataList;
}
#endregion
}
}