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/MsTruckPlu/MsTruckPluDAL.cs

126 lines
4.8 KiB
C#

3 years ago
using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using DSWeb.Areas.TruckMng.Models.MsTruckPlu;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.Areas.CommMng.Models;
namespace DSWeb.Areas.TruckMng.DAL.MsTruckPlu
{
public partial class MsTruckPluDAL
{
#region Inquery DataList
static public List<Models.MsTruckPlu.MsTruckPlu> GetDataList(string strCondition, string sort = null)
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("PluCode,PluName,Spec,Unit");
strSql.Append(",CargoNo,ScEtpName,Weight,Volume,Produce,Grade");
strSql.Append(",Price,PluCcYq,LrDate,UserCode,UserName,PluType,");
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99036 and EnumValueID=tMsTruckPlu.PluType) as PluType_Ref");
strSql.Append(" from tMsTruckPlu ");
if (strCondition.Trim() != String.Empty)
{
strSql.Append(" where " + strCondition);
}
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
return SetData(strSql);
}
static public Models.MsTruckPlu.MsTruckPlu GetData(string condition)
{
var list = GetDataList(condition);
if (list.Count > 0)
return list[0];
return new Models.MsTruckPlu.MsTruckPlu();
}
private static List<Models.MsTruckPlu.MsTruckPlu> SetData(StringBuilder strSql)
{
var headList = new List<Models.MsTruckPlu.MsTruckPlu>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
Models.MsTruckPlu.MsTruckPlu data = new Models.MsTruckPlu.MsTruckPlu();
#region Set DB data to Object
data.PluCode = Convert.ToString(reader["PluCode"]);
data.PluName = Convert.ToString(reader["PluName"]);
data.Unit = Convert.ToString(reader["Unit"]);
data.Spec = Convert.ToString(reader["Spec"]);
data.Weight = Convert.ToDecimal(reader["Weight"]);
data.Volume = Convert.ToString(reader["Volume"]);
data.Produce = Convert.ToString(reader["Produce"]);
data.Grade = Convert.ToString(reader["Grade"]);
data.ScEtpName = Convert.ToString(reader["ScEtpName"]);
data.CargoNo = Convert.ToString(reader["CargoNo"]);
if (reader["LrDate"] != DBNull.Value)
data.LrDate = Convert.ToDateTime(reader["LrDate"]);
data.UserCode = Convert.ToString(reader["UserCode"]);
data.UserName = Convert.ToString(reader["UserName"]);
data.Price = Convert.ToDecimal(reader["Price"]);
data.PluCcYq = Convert.ToString(reader["PluCcYq"]);
data.PluType = Convert.ToString(reader["PluType"]);
data.PluType_Ref = Convert.ToString(reader["PluType_Ref"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 参照部分
internal static List<MsTruckPluRefSysEnumValue> GetUnitList()
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append(" EnumValueName,EnumValueID,EnumValueName + '-' + EnumValueID as CodeAndName");
strSql.Append(" from tSysEnumValue");
strSql.Append(" where EnumTypeID = 99002 ");
var dataList = new List<MsTruckPluRefSysEnumValue>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var data = new MsTruckPluRefSysEnumValue();
#region Set DB data to Object
data.EnumValueName = Convert.ToString(reader["EnumValueName"]);
data.EnumValueID = Convert.ToString(reader["EnumValueID"]);
data.CodeAndName = Convert.ToString(reader["CodeAndName"]);
#endregion
dataList.Add(data);
}
reader.Close();
}
return dataList;
}
#endregion
}
}