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.

192 lines
7.9 KiB
C#

11 months ago
using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using DSWeb.Areas.TruckMng.Models.MsWlTyreCk;
using Microsoft.Practices.EnterpriseLibrary.Data;
namespace DSWeb.Areas.TruckMng.DAL.MsWlTyreCk
{
public partial class MsWlTyreCkDAL
{
#region Inquery DataList
static public List<Models.MsWlTyreCk.MsWlTyreCk> GetDataList(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("BillNo,LrDate,JzDate,UserCode,");
strSql.Append("(select CodeAndName from vMsTruckUser where UserCode=tMsWlTyreCk.UserCode) as UserCode_Ref");
strSql.Append(",UserName,OrgCode,");
strSql.Append("(select CodeAndName from vMsTruckOrg where OrgCode=tMsWlTyreCk.OrgCode) as OrgCode_Ref");
strSql.Append(",OrgName,TruckNo,");
strSql.Append("(select TruckSpec from tMsWlTruck where TruckNo=tMsWlTyreCk.TruckNo) as TruckNo_Ref");
strSql.Append(",CargoNo,PluCode,");
strSql.Append("(select CargoNo from tMsJhSparepart where SparepartNo=tMsWlTyreCk.PluCode) as PluCode_Ref");
strSql.Append(",TyreType,");
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99013 and EnumValueID=tMsWlTyreCk.TyreType) as TyreType_Ref");
strSql.Append(",TyrePos,");
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99015 and EnumValueID=tMsWlTyreCk.TyrePos) as TyrePos_Ref");
strSql.Append(",CkDate,EtpName,");
strSql.Append("(select CustName from vMsTruckClient where CustCode=tMsWlTyreCk.EtpName) as EtpName_Ref");
strSql.Append(",Remark");
strSql.Append(" from tMsWlTyreCk ");
if (strCondition.Trim() != String.Empty)
{
strSql.Append(" where " + strCondition);
}
return SetData(strSql);
}
static public Models.MsWlTyreCk.MsWlTyreCk GetData(string condition)
{
var list = GetDataList(condition);
if (list.Count > 0)
return list[0];
return new Models.MsWlTyreCk.MsWlTyreCk();
}
private static List<Models.MsWlTyreCk.MsWlTyreCk> SetData(StringBuilder strSql)
{
var headList = new List<Models.MsWlTyreCk.MsWlTyreCk>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
Models.MsWlTyreCk.MsWlTyreCk data = new Models.MsWlTyreCk.MsWlTyreCk();
#region Set DB data to Object
data.BillNo = Convert.ToString(reader["BillNo"]);
data.LrDate = Convert.ToDateTime(reader["LrDate"]);
data.JzDate = Convert.ToDateTime(reader["JzDate"]);
data.UserCode = Convert.ToString(reader["UserCode"]);
data.UserCode_Ref = Convert.ToString(reader["UserCode_Ref"]);
data.UserName = Convert.ToString(reader["UserName"]);
data.OrgCode = Convert.ToString(reader["OrgCode"]);
data.OrgCode_Ref = Convert.ToString(reader["OrgCode_Ref"]);
data.OrgName = Convert.ToString(reader["OrgName"]);
data.TruckNo = Convert.ToString(reader["TruckNo"]);
data.TruckNo_Ref = Convert.ToString(reader["TruckNo_Ref"]);
data.CargoNo = Convert.ToString(reader["CargoNo"]);
data.PluCode = Convert.ToString(reader["PluCode"]);
data.PluCode_Ref = Convert.ToString(reader["PluCode_Ref"]);
data.TyreType = Convert.ToString(reader["TyreType"]);
data.TyreType_Ref = Convert.ToString(reader["TyreType_Ref"]);
data.TyrePos = Convert.ToString(reader["TyrePos"]);
data.TyrePos_Ref = Convert.ToString(reader["TyrePos_Ref"]);
data.CkDate = Convert.ToString(reader["CkDate"]);
data.EtpName = Convert.ToString(reader["EtpName"]);
data.EtpName_Ref = Convert.ToString(reader["EtpName_Ref"]);
data.Remark = Convert.ToString(reader["Remark"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 参照部分
internal static List<MsWlTyreCkRefMsTruckOrg> GetOrgCodeList()
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append(" OrgCode,OrgName,OrgCode + '-' + CodeAndName as CodeAndName");
strSql.Append(" from vMsTruckOrg");
var dataList = new List<MsWlTyreCkRefMsTruckOrg>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var data = new MsWlTyreCkRefMsTruckOrg();
#region Set DB data to Object
data.OrgCode = Convert.ToString(reader["OrgCode"]);
data.OrgName = Convert.ToString(reader["OrgName"]);
data.CodeAndName = Convert.ToString(reader["CodeAndName"]);
#endregion
dataList.Add(data);
}
reader.Close();
}
return dataList;
}
internal static List<MsWlTyreCkRefMsWlTruck> GetTruckNoList()
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append(" TruckNo,TruckSpec,TruckNo + '-' + TruckSpec as CodeAndName");
strSql.Append(" from tMsWlTruck");
var dataList = new List<MsWlTyreCkRefMsWlTruck>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var data = new MsWlTyreCkRefMsWlTruck();
#region Set DB data to Object
data.TruckNo = Convert.ToString(reader["TruckNo"]);
data.TruckSpec = Convert.ToString(reader["TruckSpec"]);
data.CodeAndName = Convert.ToString(reader["CodeAndName"]);
#endregion
dataList.Add(data);
}
reader.Close();
}
return dataList;
}
internal static List<MsWlTyreCkRefMsJhSparepart> GetPluCodeList()
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append(" SparepartNo,CargoNo,SparepartNo + '-' + CargoNo as CodeAndName");
strSql.Append(" from tMsJhSparepart");
var dataList = new List<MsWlTyreCkRefMsJhSparepart>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var data = new MsWlTyreCkRefMsJhSparepart();
#region Set DB data to Object
data.SparepartNo = Convert.ToString(reader["SparepartNo"]);
data.CargoNo = Convert.ToString(reader["CargoNo"]);
data.CodeAndName = Convert.ToString(reader["CodeAndName"]);
#endregion
dataList.Add(data);
}
reader.Close();
}
return dataList;
}
#endregion
}
}