using System; using System.Data; using System.Collections.Generic; using System.Text; using Microsoft.Practices.EnterpriseLibrary.Data; namespace DSWeb.Areas.TruckMng.DAL.MsJhSparepart { public partial class MsJhSparepartDAL { #region Inquery DataList static public List GetDataList(string strCondition) { var strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append("PcNo,PluCode,"); strSql.Append("(select BarCode from tMsTruckPlu where PluCode=tMsJhSparepart.PluCode) as PluCode_Ref"); strSql.Append(",PluName,Spec,Unit,TyreType,"); strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99013 and EnumValueID=tMsJhSparepart.TyreType) as TyreType_Ref"); strSql.Append(",JhDate,JhBillNo,OrgCode,RealMil"); strSql.Append(",(select top 1 Price from tMsKfJhBody where PluCode=tMsJhSparepart.PluCode and PcNo=tMsJhSparepart.PcNo) as FPrice "); strSql.Append(" from tMsJhSparepart "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } return SetData(strSql); } static public Models.MsJhSparepart.MsJhSparepart GetData(string condition) { var list = GetDataList(condition); if (list.Count > 0) return list[0]; return new Models.MsJhSparepart.MsJhSparepart(); } private static List SetData(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { Models.MsJhSparepart.MsJhSparepart data = new Models.MsJhSparepart.MsJhSparepart(); #region Set DB data to Object data.PcNo = Convert.ToString(reader["PcNo"]); data.PluCode = Convert.ToString(reader["PluCode"]); data.PluCode_Ref = Convert.ToString(reader["PluCode_Ref"]); data.PluName = Convert.ToString(reader["PluName"]); data.Spec = Convert.ToString(reader["Spec"]); data.Unit = Convert.ToString(reader["Unit"]); data.TyreType = Convert.ToString(reader["TyreType"]); data.TyreType_Ref = Convert.ToString(reader["TyreType_Ref"]); data.JhDate = Convert.ToString(reader["JhDate"]); data.JhBillNo = Convert.ToString(reader["JhBillNo"]); data.OrgCode = Convert.ToString(reader["OrgCode"]); data.RealMil = Convert.ToDecimal(reader["RealMil"]); data.FPrice = Convert.ToDecimal(reader["FPrice"]); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 参照部分 #endregion } }