Files
U8-Import/NX.ERP.U8/Base/SupplierDAL.cs

79 lines
2.1 KiB
C#
Raw Normal View History

2021-01-05 11:11:28 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Dapper;
using NX.ERP.Model;
namespace NX.ERP.U8
{
public class SupplierDAL
{
2021-01-11 09:07:29 +08:00
public IEnumerable<Supplier> GetList(string strWhere = "", object Param = null)
2021-01-05 11:11:28 +08:00
{
2021-01-25 09:47:41 +08:00
using (var conn = U8LoginContext.Instance.Connection)
2021-01-05 11:11:28 +08:00
{
var sql = @"select
2021-01-22 14:06:09 +08:00
cVenCode AS SupplierCode,
cVenName AS SupplierName,
2021-01-05 11:11:28 +08:00
cVenPostCode AS PostalCode,
cVenAddress AS Address,
2021-01-20 16:31:45 +08:00
cVenPhone as ContractPhone,
2021-05-28 09:21:23 +08:00
ISNULL(dModifyDate,dVenCreateDatetime) as ModifyDate,
2021-05-28 09:49:57 +08:00
bProxyForeign as ProxyForeign,
2021-01-05 11:11:28 +08:00
cVenPerson AS Contract from Vendor ";
2021-01-11 09:07:29 +08:00
if (!string.IsNullOrEmpty(strWhere))
{
sql += $" where {strWhere}";
}
2021-01-22 13:48:45 +08:00
return conn.Query<Supplier>(sql, Param);
2021-01-05 11:11:28 +08:00
}
}
2021-01-20 16:31:45 +08:00
public IEnumerable<Supplier> GetList(NX.ERP.Model.Request.Supplier Params)
{
IList<string> where = new List<string>();
2021-01-22 13:48:45 +08:00
if (!string.IsNullOrEmpty(Params.SupplierCode))
2021-01-20 16:31:45 +08:00
{
where.Add(" cVenCode like @SupplierCode ");
}
2021-01-22 13:48:45 +08:00
if (!string.IsNullOrEmpty(Params.SupplierName))
2021-01-20 16:31:45 +08:00
{
where.Add(" cVenName like @SupplierName ");
}
2021-05-28 09:21:23 +08:00
if (Params.ModifyDate != null)
{
where.Add(" ISNULL(dModifyDate,dVenCreateDatetime) >= @ModifyDate ");
}
2021-05-28 09:49:57 +08:00
if (Params.ProxyForeign !=null)
{
where.Add(" bProxyForeign=@ProxyForeign ");
}
2021-01-20 16:31:45 +08:00
return this.GetList(string.Join(" and ", where.ToArray()), new
{
SupplierCode = $"%{Params.SupplierCode}%",
2021-05-28 09:21:23 +08:00
SupplierName = $"%{Params.SupplierName}%",
2021-05-28 09:49:57 +08:00
Params.ModifyDate,
Params.ProxyForeign
});
2021-01-20 16:31:45 +08:00
}
2021-01-05 11:11:28 +08:00
}
}