2021-03-23 15:06:34 +08:00
|
|
|
|
using Dapper;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
|
|
namespace NX.ERP.U8.Store
|
|
|
|
|
|
{
|
|
|
|
|
|
public class StockDAL
|
|
|
|
|
|
{
|
2021-05-20 09:47:35 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="strwhere"></param>
|
|
|
|
|
|
/// <param name="Params"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2021-03-23 15:06:34 +08:00
|
|
|
|
public IEnumerable<Model.Response.Store.Stock> GetList(string strwhere = "", object Params = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
using (var conn = U8LoginContext.Instance.Connection)
|
|
|
|
|
|
{
|
2021-05-21 13:06:45 +08:00
|
|
|
|
var sql = @" select a.cInvCode as MaterialCode ,cPosCode as BinCode,iQuantity as Qty,b.cInvName as MaterialName from InvPositionSum as a
|
|
|
|
|
|
left join Inventory as b on a.cInvCode=b.cInvCode where ISNULL(iQuantity,0)<>0";
|
2021-03-23 15:06:34 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(strwhere))
|
|
|
|
|
|
{
|
2021-05-20 09:47:35 +08:00
|
|
|
|
sql += $" and {strwhere}";
|
2021-03-23 15:06:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
return conn.Query<Model.Response.Store.Stock>(sql, Params);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-05-20 09:47:35 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="Code"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public IEnumerable<Model.Response.Store.Stock> GetListByMaterialCode(string Code)
|
|
|
|
|
|
{
|
2021-05-20 10:18:42 +08:00
|
|
|
|
return this.GetList(" cInvCode like @Code", new { Code = $"%{Code}%" });
|
2021-05-20 09:47:35 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-05-21 13:06:45 +08:00
|
|
|
|
public IEnumerable<Model.Response.Store.Stock> GetList(NX.ERP.Model.Request.Stock stock)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<string> where = new List<string>();
|
|
|
|
|
|
if (!string.IsNullOrEmpty(stock.MaterialCode))
|
|
|
|
|
|
{
|
|
|
|
|
|
where.Add(" a.cInvCode = @MaterialCode ");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(stock.MaterialName))
|
|
|
|
|
|
{
|
|
|
|
|
|
where.Add(" b.cInvName like @MaterialName ");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return this.GetList(string.Join(" and ", where.ToArray()), new
|
|
|
|
|
|
{
|
|
|
|
|
|
MaterialCode = stock.MaterialCode,
|
|
|
|
|
|
MaterialName = $"%{stock.MaterialName}%",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-05-20 09:47:35 +08:00
|
|
|
|
|
2021-03-23 15:06:34 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|