90 lines
3.0 KiB
C#
90 lines
3.0 KiB
C#
using Dapper;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace NX.ERP.U8.Sale
|
|
{
|
|
public class DispatchListDAL
|
|
{
|
|
public IEnumerable<Model.Sale.DispatchList> GetList(string strWhere = "", object Params = null)
|
|
{
|
|
var strSql = @"select a.DLID as SalesOrderId ,a.dDate as SalesOrderDate,a.cDLCode as SalesOrderNo ,A.cCusCode AS CustomerCode,b.DLID as id,b.AutoID as SalesOrderDtlId,b.DLID as SalesOrderId ,b.cInvCode as MaterialCode ,b.cInvName as InvName,b.iQuantity AS Qty
|
|
from DispatchList as a
|
|
left join DispatchLists as b on a.DLID = b.DLID where ISNULL( a.cverifier,'')<>''";
|
|
|
|
if (!string.IsNullOrEmpty(strWhere))
|
|
{
|
|
strSql += $" and {strWhere} ";
|
|
}
|
|
|
|
using (var conn = U8LoginContext.Instance.Connection)
|
|
{
|
|
var lookup = new Dictionary<int, Model.Sale.DispatchList>();
|
|
// return conn.Query<Model.Purchase.Arrival>(strSQL,null);
|
|
var list = conn.Query<NX.ERP.Model.Sale.DispatchList, NX.ERP.Model.Sale.DispatchListDetail, NX.ERP.Model.Sale.DispatchList>(strSql, (Dispatch, DispatchDetail) =>
|
|
{
|
|
if (!lookup.TryGetValue(Dispatch.SalesOrderId, out var _Dispatch))
|
|
{
|
|
lookup.Add(Dispatch.SalesOrderId, Dispatch);
|
|
}
|
|
else
|
|
{
|
|
Dispatch = _Dispatch;
|
|
}
|
|
|
|
Dispatch.SalesOrderDtlLst.Add(DispatchDetail);
|
|
return Dispatch;
|
|
}, Params, null, true, "id", 10, System.Data.CommandType.Text);
|
|
return lookup.Values;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public Model.Sale.DispatchList GetModel(int id)
|
|
{
|
|
return this.GetList(" a.DLID=@id", new { id }).FirstOrDefault();
|
|
}
|
|
|
|
|
|
public IEnumerable<Model.Sale.DispatchList> GetList(Model.Request.Dispatch dispatch)
|
|
{
|
|
string where = "";
|
|
if (!string.IsNullOrEmpty(dispatch.SalesOrderNo))
|
|
{
|
|
where = "a.cDLCode like @SalesOrderNo";
|
|
}
|
|
return this.GetList(where, new { SalesOrderNo = $"%{dispatch.SalesOrderNo}%" });
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public Model.Sale.DispatchList GetModel(string Code)
|
|
{
|
|
return this.GetList(" a.cDLCode=@Code", new { Code }).FirstOrDefault();
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="ID"></param>
|
|
/// <returns></returns>
|
|
public IEnumerable<Model.Sale.DispatchList> GetListByLastID(int ID)
|
|
{
|
|
return this.GetList(" a.DLID>=@ID ", new { ID });
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|