|
|
|
|
using System;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using DSWeb.Areas.TruckMng.Models.MsWlRk;
|
|
|
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.Areas.TruckMng.DAL.MsWlRk
|
|
|
|
|
{
|
|
|
|
|
public partial class MsWlRkDAL
|
|
|
|
|
{
|
|
|
|
|
#region 主表
|
|
|
|
|
|
|
|
|
|
static public List<MsWlRkHead> GetDataList(string strCondition)
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT ");
|
|
|
|
|
strSql.Append("BillNo,LrDate,JzDate,UserCode,UserName,TimeMark,YwBillNo");
|
|
|
|
|
strSql.Append(",YwType,");
|
|
|
|
|
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99008 and EnumValueID=tMsWlRkHead.YwType) as YwType_Ref");
|
|
|
|
|
strSql.Append(",EtpCode,EtpName,OrgCode,OrgName,RkCount,Remark");
|
|
|
|
|
strSql.Append(" from tMsWlRkHead ");
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
|
|
}
|
|
|
|
|
return SetData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static List<MsWlRkHead> SetData(StringBuilder strSql)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<MsWlRkHead>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
MsWlRkHead data = new MsWlRkHead();
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.BillNo = Convert.ToString(reader["BillNo"]);
|
|
|
|
|
if (reader["LrDate"] != DBNull.Value)
|
|
|
|
|
data.LrDate = Convert.ToDateTime(reader["LrDate"]);
|
|
|
|
|
if (reader["JzDate"] != DBNull.Value)
|
|
|
|
|
data.JzDate = Convert.ToDateTime(reader["JzDate"]);
|
|
|
|
|
data.UserCode = Convert.ToString(reader["UserCode"]);
|
|
|
|
|
data.UserName = Convert.ToString(reader["UserName"]);
|
|
|
|
|
data.TimeMark = Convert.ToDecimal(reader["TimeMark"]);
|
|
|
|
|
data.YwBillNo = Convert.ToString(reader["YwBillNo"]);
|
|
|
|
|
data.YwType = Convert.ToString(reader["YwType"]);
|
|
|
|
|
data.YwType_Ref = Convert.ToString(reader["YwType_Ref"]);
|
|
|
|
|
data.EtpCode = Convert.ToString(reader["EtpCode"]);
|
|
|
|
|
data.EtpName = Convert.ToString(reader["EtpName"]);
|
|
|
|
|
data.OrgCode = Convert.ToString(reader["OrgCode"]);
|
|
|
|
|
data.OrgName = Convert.ToString(reader["OrgName"]);
|
|
|
|
|
data.RkCount = Convert.ToDecimal(reader["RkCount"]);
|
|
|
|
|
data.Remark = Convert.ToString(reader["Remark"]);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
headList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return headList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static public MsWlRkHead GetHeadDataByBillNo(string billno)
|
|
|
|
|
{
|
|
|
|
|
MsWlRkHead data = null;
|
|
|
|
|
var list = GetDataList(" BillNo='" + billno + "'");
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
data = list[0];
|
|
|
|
|
|
|
|
|
|
if (data == null)
|
|
|
|
|
{
|
|
|
|
|
data = new MsWlRkHead();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 明细表
|
|
|
|
|
|
|
|
|
|
static public List<MsWlRkBody> GetBodyList(string strCondition)
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT ");
|
|
|
|
|
strSql.Append("BillNo,SerialNo,WlCode,CwCode,PluCode,");
|
|
|
|
|
strSql.Append("(select BarCode from tMsTruckPlu where PluCode=tMsWlRkBody.PluCode) as PluCode_Ref");
|
|
|
|
|
strSql.Append(",PluName,Spec,Weight,Volume,Unit,PcNo,RkCount");
|
|
|
|
|
strSql.Append(",Remark");
|
|
|
|
|
strSql.Append(" from tMsWlRkBody ");
|
|
|
|
|
|
|
|
|
|
if (strCondition.Trim() != String.Empty)
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
|
|
}
|
|
|
|
|
return SetBodyData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static List<MsWlRkBody> SetBodyData(StringBuilder strSql)
|
|
|
|
|
{
|
|
|
|
|
var bodyList = new List<MsWlRkBody>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
MsWlRkBody data = new MsWlRkBody();
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.BillNo = Convert.ToString(reader["BillNo"]);
|
|
|
|
|
data.SerialNo = Convert.ToDecimal(reader["SerialNo"]);
|
|
|
|
|
data.WlCode = Convert.ToString(reader["WlCode"]);
|
|
|
|
|
data.CwCode = Convert.ToString(reader["CwCode"]);
|
|
|
|
|
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.Weight = Convert.ToDecimal(reader["Weight"]);
|
|
|
|
|
data.Volume = Convert.ToString(reader["Volume"]);
|
|
|
|
|
data.Unit = Convert.ToString(reader["Unit"]);
|
|
|
|
|
data.PcNo = Convert.ToString(reader["PcNo"]);
|
|
|
|
|
data.RkCount = Convert.ToDecimal(reader["RkCount"]);
|
|
|
|
|
data.Remark = Convert.ToString(reader["Remark"]);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
bodyList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return bodyList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 参照部分
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|