Files
U8-Import/NX.ERP.U8/Base/BinDAL.cs
2021-06-04 11:22:42 +08:00

71 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Dapper;
using NX.ERP.Model;
namespace NX.ERP.U8.Base
{
public class BinDAL
{
public IEnumerable<Bin> GetList(string strwhere = "", object Params = null)
{
using (var conn = U8LoginContext.Instance.Connection)
{
var sql = @"select cPosCode as BinCode,cPosName as BinName,iPosGrade,bPosEnd,cWhCode as WarehouseCode,
iMaxCubage as VolumeLimit, iMaxweight as WeightLimit,cMemo,cBarCode,CONVERT(BIGINT,pubufts) AS pubufts from Position";
if (!string.IsNullOrEmpty(strwhere))
{
sql += $" where {strwhere}";
}
return conn.Query<Bin>(sql, Params);
}
}
public IEnumerable<Bin> GetList(long Pubufts)
{
return this.GetList("CONVERT(BIGINT,pubufts) > @Pubufts", new { Pubufts });
}
public IEnumerable<Bin> GetListByWhCode(string Code)
{
return this.GetList(" cWhCode=@Code", new { Code });
}
public IEnumerable<Bin> GetList(NX.ERP.Model.Request.Bin Param)
{
List<string> where = new List<string>();
if (!string.IsNullOrEmpty(Param.BinCode))
{
where.Add(" cPosCode like @BinCode");
}
if (!string.IsNullOrEmpty(Param.WarehouseCode))
{
where.Add(" cWhCode like @WarehouseCode");
}
return this.GetList(string.Join(" and ", where.ToArray()), new
{
BinCode = $"%{Param.BinCode}%",
WarehouseCode = $"%{Param.WarehouseCode}%"
});
}
}
}