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/MsLsKcPc/MsLsKcPcDAL.cs

148 lines
5.5 KiB
C#

using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using DSWeb.Areas.TruckMng.Models.MsLsKcPc;
using Microsoft.Practices.EnterpriseLibrary.Data;
namespace DSWeb.Areas.TruckMng.DAL.MsLsKcPc
{
public partial class MsLsKcPcDAL
{
#region Inquery DataList
static public List<Models.MsLsKcPc.MsLsKcPc> GetDataList(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("SerialNo,OrgCode,");
strSql.Append("(select CodeAndName from vMsTruckOrg where OrgCode=tMsLsKcPc.OrgCode) as OrgCode_Ref");
strSql.Append(",CkCode,");
strSql.Append("(select CodeAndName from vMsTruckOrg where OrgCode=tMsLsKcPc.CkCode) as CkCode_Ref");
strSql.Append(",PluCode,");
strSql.Append("(select PluName from tMsTruckPlu where PluCode=tMsLsKcPc.PluCode) as PluCode_Ref");
strSql.Append(",Spec,Unit,PcNo,PluType,");
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99003 and EnumValueID=tMsLsKcPc.PluType) as PluType_Ref");
strSql.Append(",JhCount");
strSql.Append(" from tMsLsKcPc ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
return SetData(strSql);
}
static public Models.MsLsKcPc.MsLsKcPc GetData(string condition)
{
var list = GetDataList(condition);
if (list.Count > 0)
return list[0];
return new Models.MsLsKcPc.MsLsKcPc();
}
private static List<Models.MsLsKcPc.MsLsKcPc> SetData(StringBuilder strSql)
{
var headList = new List<Models.MsLsKcPc.MsLsKcPc>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
Models.MsLsKcPc.MsLsKcPc data = new Models.MsLsKcPc.MsLsKcPc();
#region Set DB data to Object
data.SerialNo = Convert.ToDecimal(reader["SerialNo"]);
data.OrgCode = Convert.ToString(reader["OrgCode"]);
data.OrgCode_Ref = Convert.ToString(reader["OrgCode_Ref"]);
data.CkCode = Convert.ToString(reader["CkCode"]);
data.CkCode_Ref = Convert.ToString(reader["CkCode_Ref"]);
data.PluCode = Convert.ToString(reader["PluCode"]);
data.PluCode_Ref = Convert.ToString(reader["PluCode_Ref"]);
data.Spec = Convert.ToString(reader["Spec"]);
data.Unit = Convert.ToString(reader["Unit"]);
data.PcNo = Convert.ToString(reader["PcNo"]);
data.PluType = Convert.ToString(reader["PluType"]);
data.PluType_Ref = Convert.ToString(reader["PluType_Ref"]);
data.JhCount = Convert.ToDecimal(reader["JhCount"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 参照部分
internal static List<MsLsKcPcRefMsTruckOrg> GetOrgCodeList()
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append(" OrgCode,OrgName,OrgCode + '-' + CodeAndName as CodeAndName");
strSql.Append(" from vMsTruckOrg");
var dataList = new List<MsLsKcPcRefMsTruckOrg>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var data = new MsLsKcPcRefMsTruckOrg();
#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<MsLsKcPcRefMsTruckOrg> GetCkCodeList()
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append(" OrgCode,OrgName,OrgCode + '-' + CodeAndName as CodeAndName");
strSql.Append(" from vMsTruckOrg");
var dataList = new List<MsLsKcPcRefMsTruckOrg>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var data = new MsLsKcPcRefMsTruckOrg();
#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;
}
#endregion
}
}