using System; using System.Collections.Generic; using System.Linq; using System.Text; using Dapper; using NX.ERP.Model; namespace NX.ERP.U8 { public class CustomerDAL { public IEnumerable GetList(string strWhere = "", object Param = null) { using (var conn = U8LoginContext.Instance.Connection) { var sql = @" select cCusCode AS CustomerCode, cCusName AS CustomerName, cCusPostCode AS PostalCode, cCusAddress AS Address, CONVERT(BIGINT,pubufts) as pubufts, cCusPerson AS Contract,cCusPhone AS ContractPhone from Customer "; if (!string.IsNullOrEmpty(strWhere)) { sql += $" where {strWhere} "; } return conn.Query(sql, Param); } } public IEnumerable GetList(long Pubufts) { return this.GetList("CONVERT(BIGINT,pubufts) > @Pubufts", new { Pubufts }); } public IEnumerable GetList(NX.ERP.Model.Request.Customer Params) { IList where = new List(); if (!string.IsNullOrEmpty(Params.CustomerCode)) { where.Add(" cCusCode like @CustomerCode "); } if (!string.IsNullOrEmpty(Params.CustomerName)) { where.Add(" cCusName like @CustomerName "); } return this.GetList(string.Join(" and ", where.ToArray()), new { CustomerCode = $"%{Params.CustomerCode}%", CustomerName = $"%{Params.CustomerName}%" }); } } }