Files
U8-Import/NX.ERP.U8/Base/SupplierDAL.cs
2021-10-28 11:14:04 +08:00

96 lines
2.5 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 SupplierDAL
{
public IEnumerable<Supplier> GetList(string strWhere = "", object Param = null)
{
using (var conn = U8LoginContext.Instance.Connection)
{
var sql = @"select
cVenCode AS SupplierCode,
cVenName AS SupplierName,
cVenPostCode AS PostalCode,
cVenAddress AS Address,
cVenPhone as ContractPhone,
ISNULL(dModifyDate,dVenCreateDatetime) as ModifyDate,
bProxyForeign as ProxyForeign,
CONVERT(BIGINT,pubufts) as pubufts,
cVenPPerson AS VenPPerson,
cVenPerson AS Contract from Vendor ";
if (!string.IsNullOrEmpty(strWhere))
{
sql += $" where {strWhere}";
}
return conn.Query<Supplier>(sql, Param);
}
}
public IEnumerable<Supplier> GetList(long Pubufts)
{
return this.GetList("CONVERT(BIGINT,pubufts) > @Pubufts", new { Pubufts });
}
public Supplier GetModel(string SupplierCode)
{
return this.GetList("cVenCode like @SupplierCode", new { SupplierCode }).FirstOrDefault();
}
public IEnumerable<Supplier> GetList(NX.ERP.Model.Request.Supplier Params)
{
IList<string> where = new List<string>();
if (!string.IsNullOrEmpty(Params.SupplierCode))
{
where.Add(" cVenCode like @SupplierCode ");
}
if (!string.IsNullOrEmpty(Params.SupplierName))
{
where.Add(" cVenName like @SupplierName ");
}
if (Params.ModifyDate != null)
{
where.Add(" ISNULL(dModifyDate,dVenCreateDatetime) >= @ModifyDate ");
}
if (Params.ProxyForeign != null)
{
where.Add(" bProxyForeign=@ProxyForeign ");
}
return this.GetList(string.Join(" and ", where.ToArray()), new
{
SupplierCode = $"%{Params.SupplierCode}%",
SupplierName = $"%{Params.SupplierName}%",
Params.ModifyDate,
Params.ProxyForeign
});
}
}
}