using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using Model;
|
using Common;
|
using System.Data;
|
using System.Collections;
|
|
namespace BLL.DAL
|
{
|
public class DALDeliveryOutDetail
|
{
|
public IList<DeliveryOutDetail> GetList(AjaxOutDetail Json, ref PageInfo page)
|
{
|
try
|
{
|
string viewName = "View_DeliveryOutDetail";
|
if (Json.OrdnoType == "IN")
|
{
|
viewName = "View_DeliveryInDetail";
|
}
|
|
StringBuilder sqlString = new StringBuilder();
|
sqlString.Append("select * from " + viewName + " where 1=1 " + $" AND DepartGuid='{Json.DepartGuid}' ");
|
if (!string.IsNullOrEmpty(Json.LingNo))
|
{
|
sqlString.Append("and LingNo like '%" + Json.LingNo + "%' ");
|
}
|
if (!string.IsNullOrEmpty(Json.PageNo))
|
{
|
sqlString.Append("and PageNo like '%" + Json.PageNo + "%' ");
|
}
|
if (!string.IsNullOrEmpty(Json.MatNo))
|
{
|
sqlString.Append("and MatNo like '%" + Json.MatNo + "%' ");
|
}
|
if (!string.IsNullOrEmpty(Json.MatName))
|
{
|
sqlString.Append("and MatName like '%" + Json.MatName + "%' ");
|
}
|
if (!string.IsNullOrEmpty(Json.PickerUser))
|
{
|
sqlString.Append("and PickerUser like '%" + Json.PickerUser + "%' ");
|
}
|
if (!string.IsNullOrEmpty(Json.MatType))
|
{
|
sqlString.Append("and MatType = '" + Json.MatType + "' ");
|
}
|
// 时间段
|
if (Json.BeginTime != DateTime.MinValue && Json.BeginTime != null && Json.BeginTime != DateTime.MaxValue)
|
{
|
sqlString.Append("and CreateTime >= '" + Convert.ToDateTime(Json.BeginTime) + "' ");
|
}
|
|
// 合格证判定
|
if (!string.IsNullOrEmpty(Json.Certificate))
|
{
|
if (Json.Certificate == "有")
|
{
|
sqlString.Append("and LEN(isnull(certificate,'')) > 0 ");
|
}
|
else
|
{
|
sqlString.Append("and LEN(isnull(certificate,'')) = 0 ");
|
}
|
}
|
|
if (Json.EndTime != DateTime.MinValue && Json.EndTime != null && Json.EndTime != DateTime.MaxValue)
|
{
|
sqlString.Append("and CreateTime <= '" + Convert.ToDateTime(Json.EndTime).ToShortDateString() + " 23:59:59.999" + "' ");
|
}
|
|
SqlParam[] para = new SqlParam[] { };
|
DataTable dt = DataFactory.SqlDataBase().GetPageList(sqlString.ToString(), para, "CreateTime", "DESC", ref page);
|
IList<DeliveryOutDetail> list = ModelConvertHelper<DeliveryOutDetail>.DataTableToModel(dt);
|
|
return list;
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
|
public DeliveryOutDetail GetCertificate(string ordNo, string matNo)
|
{
|
try
|
{
|
StringBuilder sqlString = new StringBuilder();
|
sqlString.Append("select *,HeGeZheng as Certificate from ErpInDetail where ordno='" + ordNo);
|
sqlString.Append("'and MatNo = '" + matNo + "';");
|
DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(sqlString);
|
|
IList<DeliveryOutDetail> list = ModelConvertHelper<DeliveryOutDetail>.DataTableToModel(dt);
|
return list[0];
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
|
public bool SetCertificates(DeliveryOutDetail model)
|
{
|
bool bl = false;
|
try
|
{
|
if (String.IsNullOrEmpty(model.MatNo) || string.IsNullOrEmpty(model.OrdNo))
|
{
|
return bl;
|
}
|
|
StringBuilder sqlString = new StringBuilder();
|
sqlString.Append("UPDATE ErpInDetail SET HeGeZheng = '" + model.Certificate + "',");
|
sqlString.Append("Demo='" + model.Demo + "',PalNo='补录合格证' ");
|
sqlString.Append("WHERE OrdNo = '" + model.OrdNo + "' AND MatNo='" + model.MatNo + "';");
|
|
int rowCount = DataFactory.SqlDataBase().ExecuteBySql(sqlString);
|
if (rowCount > 0)
|
{
|
bl = true;
|
}
|
|
return bl;
|
}
|
catch (Exception)
|
{
|
return bl;
|
}
|
}
|
}
|
}
|