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

53 lines
1.4 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 UnitDAL
{
2021-01-11 09:07:29 +08:00
public IEnumerable<Unit> GetList(string strWhere = "", object Param = null)
2021-01-20 16:31:45 +08:00
{
2021-01-05 11:11:28 +08:00
using (var conn = new System.Data.SqlClient.SqlConnection(U8LoginContext.Instance.Constr4Net))
2021-01-20 16:31:45 +08:00
{
2021-01-05 11:11:28 +08:00
var sql = @"select
2021-01-20 16:31:45 +08:00
cComunitCode AS UnitCode,
cComUnitName AS UnitName,bMainUnit as MainUnit, cGroupCode as GroupCode from ComputationUnit ";
2021-01-11 09:07:29 +08:00
if (!string.IsNullOrEmpty(strWhere))
{
sql += $" where {strWhere}";
}
2021-01-05 11:11:28 +08:00
return conn.Query<Unit>(sql, null);
}
}
2021-01-20 16:31:45 +08:00
public IEnumerable<Unit> GetList(NX.ERP.Model.Request.Unit Params)
{
IList<string> where = new List<string>();
if (string.IsNullOrEmpty(Params.UnitCode))
{
where.Add(" cComunitCode like @UnitCode ");
}
if (string.IsNullOrEmpty(Params.UnitName))
{
where.Add(" cComUnitName like @UnitName ");
}
return this.GetList(string.Join(" and ", where.ToArray()), new
{
UnitCode = $"%{Params.UnitCode}%",
UnitName = $"%{Params.UnitName}%"
});
}
2021-01-05 11:11:28 +08:00
}
}