Files
U8-Import/NX.ERP.U8/Base/WarehouseDAL.cs
2021-01-19 10:19:10 +08:00

56 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Dapper;
using NX.ERP.Model;
namespace NX.ERP.U8
{
public class WarehouseDAL
{
public IEnumerable<Warehouse> GetList(string strWhere = "", object Param = null)
{
using (var conn = new System.Data.SqlClient.SqlConnection(U8LoginContext.Instance.Constr4Net))
{
var sql = "select cWhCode as WarehouseCode,cWhName as WarehouseName from Warehouse";
if (!string.IsNullOrEmpty(strWhere))
{
sql += $" where {strWhere}";
}
return conn.Query<Warehouse>(sql, Param);
}
}
public IEnumerable<Warehouse> GetList(NX.ERP.Model.Request.Warehouse Params)
{
List<string> where = new List<string>();
if (!string.IsNullOrEmpty(Params.WarehouseCode))
{
where.Add(" cWhCode like @WarehouseCode");
}
if (!string.IsNullOrEmpty(Params.WarehouseName))
{
where.Add(" cWhName like @WarehouseName");
}
return this.GetList(string.Join(" and ", where.ToArray()), new
{
WarehouseCode = $"%{Params.WarehouseCode}%",
WarehouseName = $"%{Params.WarehouseName}%"
});
}
}
}