using Commom.Utility;
using Common;
using Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
namespace BLL.DAL
{
public class DALStroeMat
{
///
/// 获取库存信息
///
///
///
///
public IList GetStroeMat(StroeMat Json, ref PageInfo pageInfo)
{
try
{
IList list = new List();
StringBuilder strSql = new StringBuilder();
strSql.Append("select * from View_StroeMat_Material where 1=1 " + $" AND (DepartGuid='{Json.DepartGuid}' or DepartGuid is null) ");
if (Json.MatNo != null && Json.MatNo != "")
{
strSql.Append(" and MatNo like '%" + Json.MatNo + "%' ");
}
if (Json.MatName != null && Json.MatName != "")
{
strSql.Append(" and MatName like '%" + Json.MatName + "%' ");
}
if (Json.PackFormat != null && Json.PackFormat != "")
{
strSql.Append(" and PackFormat like '%" + Json.PackFormat + "%' ");
}
//if (!string.IsNullOrEmpty(Json.Unit)) // 物料单位不作为条件
//{
// strSql.Append(" and Unit = " + Json.Unit.AddQuotes());
//}
if (!string.IsNullOrEmpty(Json.BrandId))
{
strSql.Append(" and BrandId = " + Json.BrandId.AddQuotes());
}
if (!string.IsNullOrEmpty(Json.MatTypeId))
{
strSql.Append(" and MatTypeId = " + Json.MatTypeId.AddQuotes());
}
SqlParam[] param = null;
DataTable dt = DataFactory.SqlDataBase().GetPageList(strSql.ToString(), param, "MatNo", "ASC", ref pageInfo);
list = ModelConvertHelper.DataTableToModel(dt);
return list;
}
catch
{
throw new NotImplementedException();
}
}
///
/// 获取库存明细
///
///
///
///
public IList GetStroeItems(StroeItems Json, ref PageInfo pageInfo)
{
try
{
IList list = new List();
StringBuilder strSql = new StringBuilder();
strSql.Append("select * from View_StroeItems_Material where 1=1 " + $" AND (DepartGuid='{Json.DepartGuid}' or DepartGuid is null) ");
if (!string.IsNullOrEmpty(Json.LingNo))
{
strSql.Append("and LingNo like '%" + Json.LingNo + "%' ");
}
if (!string.IsNullOrEmpty(Json.Addre))
{
strSql.Append("and Addre like '%" + Json.Addre + "%' ");
}
if (!string.IsNullOrEmpty(Json.Palno))
{
strSql.Append("and Palno like '%" + Json.Palno + "%' ");
}
if (!string.IsNullOrEmpty(Json.TuNo))
{
strSql.Append("and TuNo like '%" + Json.TuNo + "%' ");
}
// 批次号
if (!string.IsNullOrEmpty(Json.BatchNo))
{
strSql.Append("and BatchNo like '%" + Json.BatchNo + "%' ");
}
// 批次描述
if (!string.IsNullOrEmpty(Json.BatchDemo))
{
strSql.Append("and BatchName like '%" + Json.BatchDemo + "%' ");
}
if (!string.IsNullOrEmpty(Json.MatNo))
{
strSql.Append("and MatNo like '%" + Json.MatNo + "%' ");
}
if (!string.IsNullOrEmpty(Json.MatName))
{
strSql.Append("and MatName like '%" + Json.MatName + "%' ");
}
if (!string.IsNullOrEmpty(Json.PackFormat))
{
strSql.Append("and PackFormat like '%" + Json.PackFormat + "%' ");
}
if (!string.IsNullOrEmpty(Json.MatTypeId))
{
strSql.Append("and MatTypeId = " + Json.MatTypeId.AddQuotes());
}
// 序号
if (!string.IsNullOrEmpty(Json.YeNo))
{
strSql.Append(" and YeNo like '%" + Json.YeNo + "%' ");
}
// 合格证判定
if (!string.IsNullOrEmpty(Json.Certificate))
{
if (Json.Certificate == "有")
{
strSql.Append(" and LEN(isnull(certificate,'')) > 0");
}
else
{
strSql.Append(" and LEN(isnull(certificate,'')) = 0");
}
}
SqlParam[] param = null;
DataTable dt = DataFactory.SqlDataBase().GetPageList(strSql.ToString(), param, "[dbo].PadLeft(YeNo,'0',3),MatNo ", "desc", ref pageInfo);
// DataTable dt = DataFactory.SqlDataBase().GetPageList(strSql.ToString(), param, "[dbo].PadLeft(YeNo,'0',3)", "ASC", ref pageInfo);
list = ModelConvertHelper.DataTableToModel(dt);
return list;
}
catch
{
throw new NotImplementedException();
}
}
public DataTable GetStroeMatDetail(StroeMat Json)
{
try
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select * from View_StroeMat_Material where 1=1 ");
if (Json.MatNo != null && Json.MatNo != "")
{
strSql.Append(" and MatNo like '%" + Json.MatNo + "%' ");
}
if (Json.MatName != null && Json.MatName != "")
{
strSql.Append(" and MatName like '%" + Json.MatName + "%' ");
}
if (Json.PackFormat != null && Json.PackFormat != "")
{
strSql.Append(" and PackFormat like '%" + Json.PackFormat + "%' ");
}
if (!string.IsNullOrEmpty(Json.BrandId))
{
strSql.Append(" and BrandId = " + Json.BrandId.AddQuotes());
}
if (!string.IsNullOrEmpty(Json.MatTypeId))
{
strSql.Append(" and MatTypeId = " + Json.MatTypeId.AddQuotes());
}
DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(strSql);
dt.TableName = "View_StroeMat_Material";
return dt;
}
catch
{
throw new NotImplementedException();
}
}
public DataTable GetStroeItems(StroeItems Json)
{
try
{
IList list = new List();
StringBuilder strSql = new StringBuilder();
strSql.Append("select * from View_StroeItems_Material where 1=1 ");
if (!string.IsNullOrEmpty(Json.LingNo))
{
strSql.Append("and LingNo like '%" + Json.LingNo + "%' ");
}
if (!string.IsNullOrEmpty(Json.Addre))
{
strSql.Append("and Addre like '%" + Json.Addre + "%' ");
}
if (!string.IsNullOrEmpty(Json.Palno))
{
strSql.Append("and Palno like '%" + Json.Palno + "%' ");
}
if (!string.IsNullOrEmpty(Json.TuNo))
{
strSql.Append("and TuNo like '%" + Json.TuNo + "%' ");
}
if (!string.IsNullOrEmpty(Json.MatNo))
{
strSql.Append("and MatNo like '%" + Json.MatNo + "%' ");
}
if (!string.IsNullOrEmpty(Json.MatName))
{
strSql.Append("and MatName like '%" + Json.MatName + "%' ");
}
if (!string.IsNullOrEmpty(Json.PackFormat))
{
strSql.Append("and PackFormat like '%" + Json.PackFormat + "%' ");
}
if (!string.IsNullOrEmpty(Json.MatTypeId))
{
strSql.Append("and MatTypeId = " + Json.MatTypeId.AddQuotes());
}
strSql.Append(" order by [dbo].PadLeft(YeNo,'0',3) asc; ");
DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(strSql);
dt.TableName = "TbItems";
return dt;
}
catch
{
throw new NotImplementedException();
}
}
}
}