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 GetList(string strWhere = "", object Param = null) { using (var conn = new System.Data.SqlClient.SqlConnection(U8LoginContext.Instance.Constr4Net)) { var sql = @"select cVenCode AS Code, cVenName AS Name, cVenPostCode AS PostalCode, cVenAddress AS Address, cVenPhone as ContractPhone, cVenPerson AS Contract from Vendor "; if (!string.IsNullOrEmpty(strWhere)) { sql += $" where {strWhere}"; } return conn.Query(sql, Param); } } public IEnumerable GetList(NX.ERP.Model.Request.Supplier Params) { IList where = new List(); if (!string.IsNullOrEmpty(Params.SupplierCode)) { where.Add(" cVenCode like @SupplierCode "); } if (!string.IsNullOrEmpty(Params.SupplierName)) { where.Add(" cVenName like @SupplierName "); } return this.GetList(string.Join(" and ", where.ToArray()), new { SupplierCode = $"%{Params.SupplierCode}%", SupplierName = $"%{Params.SupplierName}%" }); } } }