using Dapper; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace NX.ERP.U8.Store { public class StockDAL { /// /// /// /// /// /// public IEnumerable GetList(string strwhere = "", object Params = null) { using (var conn = U8LoginContext.Instance.Connection) { 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"; if (!string.IsNullOrEmpty(strwhere)) { sql += $" and {strwhere}"; } return conn.Query(sql, Params); } } /// /// /// /// /// public IEnumerable GetListByMaterialCode(string Code) { return this.GetList(" cInvCode like @Code", new { Code = $"%{Code}%" }); } public IEnumerable GetList(NX.ERP.Model.Request.Stock stock) { List where = new List(); 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}%", }); ; } } }