|
|
|
|
using System;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using DSWeb.Areas.TruckMng.Models;
|
|
|
|
|
using DSWeb.Areas.TruckMng.Models.MsWlCk;
|
|
|
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.Areas.TruckMng.DAL.MsWlCk
|
|
|
|
|
{
|
|
|
|
|
public partial class MsWlCkDAL
|
|
|
|
|
{
|
|
|
|
|
#region 主表
|
|
|
|
|
|
|
|
|
|
static public List<MsWlCkHead> 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=tMsWlCkHead.YwType) as YwType_Ref");
|
|
|
|
|
strSql.Append(",EtpCode,");
|
|
|
|
|
strSql.Append("(select CodeAndName from vMsTruckOrg where OrgCode=tMsWlCkHead.EtpCode) as EtpCode_Ref");
|
|
|
|
|
strSql.Append(",EtpName,OrgCode,");
|
|
|
|
|
strSql.Append("(select CodeAndName from vMsTruckOrg where OrgCode=tMsWlCkHead.OrgCode) as OrgCode_Ref");
|
|
|
|
|
strSql.Append(",OrgName,CkCount,Remark");
|
|
|
|
|
strSql.Append(" from tMsWlCkHead ");
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
|
|
}
|
|
|
|
|
return SetData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static List<MsWlCkHead> SetData(StringBuilder strSql)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<MsWlCkHead>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
MsWlCkHead data = new MsWlCkHead();
|
|
|
|
|
#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.EtpCode_Ref = Convert.ToString(reader["EtpCode_Ref"]);
|
|
|
|
|
data.EtpName = Convert.ToString(reader["EtpName"]);
|
|
|
|
|
data.OrgCode = Convert.ToString(reader["OrgCode"]);
|
|
|
|
|
data.OrgCode_Ref = Convert.ToString(reader["OrgCode_Ref"]);
|
|
|
|
|
data.OrgName = Convert.ToString(reader["OrgName"]);
|
|
|
|
|
data.CkCount = Convert.ToDecimal(reader["CkCount"]);
|
|
|
|
|
data.Remark = Convert.ToString(reader["Remark"]);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
headList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return headList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static public MsWlCkHead GetHeadDataByBillNo(string billno)
|
|
|
|
|
{
|
|
|
|
|
MsWlCkHead data = null;
|
|
|
|
|
var list = GetDataList(" BillNo='" + billno + "'");
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
data = list[0];
|
|
|
|
|
|
|
|
|
|
if (data == null)
|
|
|
|
|
{
|
|
|
|
|
data = new MsWlCkHead();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 明细表
|
|
|
|
|
|
|
|
|
|
static public List<MsWlCkBody> 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=tMsWlCkBody.PluCode) as PluCode_Ref");
|
|
|
|
|
strSql.Append(",PluName,Spec,Weight,Volume,Unit,PcNo,CkCount");
|
|
|
|
|
strSql.Append(",Remark");
|
|
|
|
|
strSql.Append(" from tMsWlCkBody ");
|
|
|
|
|
|
|
|
|
|
if (strCondition.Trim() != String.Empty)
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
|
|
}
|
|
|
|
|
return SetBodyData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static List<MsWlCkBody> SetBodyData(StringBuilder strSql)
|
|
|
|
|
{
|
|
|
|
|
var bodyList = new List<MsWlCkBody>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
MsWlCkBody data = new MsWlCkBody();
|
|
|
|
|
#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.CkCount = Convert.ToDecimal(reader["CkCount"]);
|
|
|
|
|
data.Remark = Convert.ToString(reader["Remark"]);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
bodyList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return bodyList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 参照部分
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|