using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using BLL;
|
using Common;
|
using Model;
|
|
namespace BLL
|
{
|
public class DALPalletBind : IDALPalletBind
|
{
|
public IList<PalBind> GetList(PalBindList ajaxPbl, ref PageInfo page)
|
{
|
try
|
{
|
StringBuilder strSql = new StringBuilder();
|
List<SqlParam> para = new List<SqlParam>();
|
strSql.Append("Select Palno,OrdNo,Statu,StatuName," +
|
"LocationCode from View_IPalletBind where DepartGuid = @DepartGuid ");
|
|
para.Add(new SqlParam("@DepartGuid", ajaxPbl.DepartGuid));
|
if (!string.IsNullOrEmpty(ajaxPbl.OrdNo))
|
{
|
strSql.Append(" and OrdNo like '%' + @OrdNo + '%' ");
|
para.Add(new SqlParam("@OrdNo", ajaxPbl.OrdNo));
|
}
|
if (!string.IsNullOrEmpty(ajaxPbl.Palno))
|
{
|
strSql.Append(" and Palno like '%' + @Palno + '%' ");
|
para.Add(new SqlParam("@Palno", ajaxPbl.Palno));
|
}
|
if (!string.IsNullOrEmpty(ajaxPbl.Statu))
|
{
|
strSql.Append(" and Statu = @Statu ");
|
para.Add(new SqlParam("@Statu", ajaxPbl.Statu));
|
}
|
if (ajaxPbl.BeginTime != DateTime.MinValue && ajaxPbl.BeginTime != null && ajaxPbl.BeginTime != DateTime.MaxValue)
|
{
|
strSql.Append(" and CreateTime >= @CreateTime1 ");
|
para.Add(new SqlParam("@CreateTime1", Convert.ToDateTime(ajaxPbl.BeginTime).ToShortDateString()));
|
}
|
if (ajaxPbl.EndTime != DateTime.MinValue && ajaxPbl.EndTime != null && ajaxPbl.EndTime != DateTime.MaxValue)
|
{
|
strSql.Append("and CreateTime <= @CreateTime2 ");
|
para.Add(new SqlParam("@CreateTime2", Convert.ToDateTime(ajaxPbl.EndTime).ToShortDateString() + " 23:59:59.999"));
|
}
|
strSql.Append(" Group By Palno,OrdNo,Statu,StatuName,LocationCode ");
|
|
SqlParam[] param = null;
|
if (para != null)
|
{
|
param = para.ToArray();
|
}
|
|
DataTable dt = DataFactory.SqlDataBase().GetPageList(strSql.ToString(), param, "OrdNo", "desc", ref page);
|
return ModelConvertHelper<PalBind>.DataTableToModel(dt);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
public bool GetPalletBind(PalBind palBind, ref IList<PalBind> lst)
|
{
|
try
|
{
|
IList<PalletBind> ls = new List<PalletBind>();
|
StringBuilder strSql = new StringBuilder();
|
strSql.Append("Select * from View_IPalletBind ");
|
strSql.Append("where Palno = @Palno and OrdNo = @OrdNo ");
|
strSql.Append("and DepartGuid = @DepartGuid ");
|
|
SqlParam[] para = new SqlParam[]
|
{
|
new SqlParam("@Palno", palBind.Palno),
|
new SqlParam("@OrdNo", palBind.OrdNo),
|
new SqlParam("@DepartGuid", palBind.DepartGuid)
|
};
|
|
IDataReader dt = DataFactory.SqlDataBase().GetDataReaderBySQL(strSql, para);
|
lst = ModelConvertHelper<PalBind>.DataReaderToModel(dt);
|
|
return true;
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
public PalBind GetInNoDetail(PalBind models, List<PalBind> lists)
|
{
|
try
|
{
|
StringBuilder strSql = new StringBuilder();
|
strSql.Append("select OrdNo,MatNo,LingNo,cast(CurQuant as int) as CurQuant,sum(cast(MatCount as int)) as MatCount,MatGuid ");
|
strSql.Append("from View_GetMatNum where matno = '" + models.MatNo + $"' AND DepartGuid='{models.DepartGuid}' ");
|
if (!string.IsNullOrEmpty(models.OrdNo))
|
{
|
strSql.Append(" and OrdNo = '" + models.OrdNo + "' ");
|
}
|
strSql.Append("group by OrdNo,MatNo,CurQuant,LingNo,MatGuid order by OrdNo;");
|
DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(strSql);
|
|
PalBind pallet = new PalBind();
|
foreach (DataRow row in dt.Rows)
|
{
|
if (row["CurQuant"].ToString() == row["MatCount"].ToString())
|
{
|
continue;
|
}
|
|
string ordNo = row["OrdNo"].ToString();
|
pallet.OrdNo = ordNo;
|
pallet.CurQuant = row["CurQuant"].ToString();
|
pallet.MatNo = models.MatNo;
|
pallet.LingNo = row["LingNo"].ToString();
|
int matNoNb = int.Parse(row["CurQuant"].ToString()) - int.Parse(row["MatCount"].ToString());
|
pallet.MatCount = matNoNb.ToString();
|
pallet.MatGuid = row["MatGuid"].ToString();
|
|
// liudl 此处逻辑待确认
|
if (lists != null)
|
{
|
foreach (PalBind palBind in lists)
|
{
|
if (palBind.OrdNo == ordNo && palBind.MatNo == models.MatNo)
|
{
|
matNoNb = matNoNb + int.Parse(palBind.MatCount);
|
//matNoNb = matNoNb - int.Parse(palBind.MatCount);
|
if (matNoNb > 0)
|
{
|
pallet.MatCount = matNoNb.ToString();
|
break;
|
}
|
else
|
{
|
pallet.MatGuid = "";
|
pallet.LingNo = "";
|
pallet.CurQuant = "";
|
pallet.OrdNo = "";
|
pallet.MatCount = "";
|
matNoNb = 0;
|
break;
|
}
|
}
|
}
|
}
|
|
if (matNoNb > 0)
|
{
|
break;
|
}
|
}
|
|
return pallet;
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
public bool GetErpinByMatNo(PalBind models, ref IList<PalBind> lstPd)
|
{
|
bool ret = false;
|
//try
|
//{
|
// IList<PalletBind> ls = new List<PalletBind>();
|
// StringBuilder strSql = new StringBuilder();
|
// if (string.IsNullOrEmpty(models.OrdNo))
|
// {
|
// strSql.Append("Select OrdNo, LingNo, TuNo, PageNo, CurQuant As MatCount from View_ErpInMatDetail where ");
|
// strSql.Append("MatNo = '" + models.MatNo + "' and Statu != 'ER03'");
|
// DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(strSql);
|
// if (dt.Rows.Count > 0)
|
// {
|
|
// for (int i = 0; i < dt.Rows.Count; i++)
|
// {
|
// //循环根据物料单号查询数量是否已经组盘完成,完成则查询此物料的下一个单号
|
// StringBuilder strhql = new StringBuilder();
|
// strhql.Append("select sum(cast(MatCount as int)) as MatCount ,OrdNo from IPalletBind where IsDel=0 and OrdNo='" + dt.Rows[i]["OrdNo"].ToString() + "' and MatNo ='" + models.MatNo + "' group by OrdNo");
|
// DataTable dd = DataFactory.SqlDataBase().GetDataTableBySQL(strhql);
|
// if (dd.Rows.Count > 0)
|
// {
|
// if (dt.Rows[i]["MatCount"].ToInt() > dd.Rows[0]["MatCount"].ToInt())
|
// {
|
// lstPd = ModelConvertHelper<PalletBind>.DataTableToModel(dt);
|
// break;
|
// }
|
// else
|
// {
|
|
// dt.Rows.RemoveAt(i);
|
// i--;
|
|
// }
|
// }
|
// else
|
// {
|
// lstPd = ModelConvertHelper<PalletBind>.DataTableToModel(dt);
|
// break;
|
// }
|
// }
|
// dt.AcceptChanges();
|
// }
|
|
// lstPd = ModelConvertHelper<PalletBind>.DataTableToModel(dt);
|
// }
|
// else
|
// {
|
// strSql.Append("Select OrdNo, LingNo, TuNo, PageNo, CurQuant As MatCount from View_ErpInMatDetail where ");
|
// strSql.Append("MatNo = @MatNo and Statu != @Statu and OrdNo = @OrdNo");
|
// SqlParam[] para = new SqlParam[]
|
// {
|
// new SqlParam("@MatNo", models.MatNo),
|
// new SqlParam("@Statu", "ER03"),
|
// new SqlParam("@OrdNo", models.OrdNo),
|
// };
|
// IDataReader dt = DataFactory.SqlDataBase().GetDataReaderBySQL(strSql, para);
|
// lstPd = ModelConvertHelper<PalletBind>.DataReaderToModel(dt);
|
// }
|
|
// ret = true;
|
//}
|
//catch
|
//{
|
// ret = false;
|
// throw new NotImplementedException();
|
//}
|
return true;
|
}
|
|
/// <summary>
|
/// 验证物料绑定数量是否超过入库数量
|
/// </summary>
|
/// <param name="OrdNo"></param>
|
/// <param name="MatNo">物料编码guid</param>
|
/// <param name="CurCount"></param>
|
/// <param name="BindCount"></param>
|
/// <param name="remainCount"></param>
|
/// <param name="PalletNo"></param>
|
/// <returns></returns>
|
public bool GetRemainBindCount(string OrdNo, string MatNo, ref int CurCount, ref int BindCount, ref int remainCount, string PalletNo)
|
{
|
bool bR = false;
|
try
|
{
|
//获取该物料在入库单中数量
|
StringBuilder sqlSelOrdCount = new StringBuilder();
|
sqlSelOrdCount.Append("select CurQuant from ErpinDetail where OrdNo = @OrdNo and MatNo = @MatNo");
|
SqlParam[] para = new SqlParam[]
|
{
|
new SqlParam("@OrdNo", OrdNo),
|
new SqlParam("@MatNo", MatNo),
|
};
|
IDataReader dt = DataFactory.SqlDataBase().GetDataReaderBySQL(sqlSelOrdCount, para);
|
OrdMatCount omc = ModelConvertHelper<OrdMatCount>.ReaderToModel(dt);
|
if (omc == null)
|
return false;
|
CurCount = int.Parse(omc.CurQuant);
|
|
//获取该物料已经绑定数量
|
StringBuilder sqlBindCount = new StringBuilder();
|
sqlBindCount.Append("select MatCount from IPalletBind where OrdNo = @OrdNo and MatGuid = @MatNo and IsDel = 0 and Palno != @PalletNo");
|
SqlParam[] para1 = new SqlParam[]
|
{
|
new SqlParam("@OrdNo", OrdNo),
|
new SqlParam("@MatNo", MatNo),
|
new SqlParam("@PalletNo", PalletNo),
|
};
|
IDataReader dt1 = DataFactory.SqlDataBase().GetDataReaderBySQL(sqlBindCount, para1);
|
IList<PalBind> lstCount = new List<PalBind>();
|
lstCount = ModelConvertHelper<PalBind>.DataReaderToModel(dt1);
|
for (int i = 0; i < lstCount.Count; i++)
|
{
|
BindCount += int.Parse(lstCount[i].MatCount);
|
|
}
|
//获取当前绑定数量(修改绑定时考虑)
|
remainCount = CurCount - BindCount;
|
|
}
|
catch (Exception ex)
|
{
|
bR = false;
|
throw ex;
|
}
|
return bR;
|
}
|
|
public bool Add(PalBind model, List<PalBind> lst)
|
{
|
bool result = false;
|
try
|
{
|
if (lst.Count > 0)
|
{
|
return false;
|
}
|
|
int _ret = DataFactory.SqlDataBase().DeleteData("IPalletBind", "Palno", lst[0].Palno);
|
if (_ret < 0)
|
{
|
return false;
|
}
|
StringBuilder strSqlTime = new StringBuilder();
|
strSqlTime.Append("SELECT GETDATE() as time");
|
var dtTime = DataFactory.SqlDataBase().GetDataTableBySQL(strSqlTime);
|
model.CreateTime = DateTime.Parse(dtTime.Rows[0][0].ToString());
|
List<SqlParam> para = new List<SqlParam>();
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append(" Insert into IPalletBind (PalletNo,MatNo,MatCount,GoodsPos,Statu,LingNo,TuNo,PageNo,CreateUser,CreateTime,Demo,Addre,IsDel,OrdNo) values ");
|
for (int i = 0; i < lst.Count; i++)
|
{
|
string Statu = "1";
|
if (lst[i].LocationCode != null)
|
{
|
if (lst[i].LocationCode.Length > 10) // 指定货位单据状态为正在执行
|
{
|
Statu = "2";
|
|
DAL.DAL_Pub pub = new DAL.DAL_Pub();
|
StringBuilder sqlStr = new StringBuilder();
|
sqlStr.Append("select count(*) from WH_CMD where palno = '" + lst[i].Palno + "'");
|
sqlStr.Append(" and CMDStatu = '2' and IsDel = '0';");
|
DataTable whdt = DataFactory.SqlDataBase().GetDataTableBySQL(sqlStr);
|
if (whdt.Rows[0][0].ToString() == "0")
|
{
|
// 生成指令
|
sqlStr.Clear();
|
sqlStr.Append("INSERT INTO WH_CMD(TaskID,Palno,Height,CMDType,OldAddre,CMDStatu,CreateUser,IsDel)");
|
sqlStr.Append("VALUES ('" + lst[i].OrdNo + "','" + lst[i].Palno + "','200','in','");
|
sqlStr.Append(lst[i].LocationCode + "','2','" + model.CreatUser + "','0');");
|
DataFactory.SqlDataBase().ExecuteBySql(sqlStr);
|
|
// 更改库位状态
|
pub.UpdateLocationState(lst[i].Palno, "03");
|
}
|
|
// 更改入库单状态
|
sqlStr.Clear();
|
sqlStr.Append("Update Erp_in set Statu = '02' where Ordno='" + lst[i].OrdNo + "';");
|
DataFactory.SqlDataBase().ExecuteBySql(sqlStr);
|
}
|
}
|
|
strSql.Append("(@PalletNo" + i + ",");
|
para.Add(new SqlParam("@PalletNo" + i, lst[i].Palno));
|
strSql.Append("@MatNo" + i + ",");
|
para.Add(new SqlParam("@MatNo" + i, lst[i].MatNo));
|
strSql.Append("@MatCount" + i + ",");
|
para.Add(new SqlParam("@MatCount" + i, lst[i].MatCount));
|
strSql.Append("@Statu" + i + ",");
|
para.Add(new SqlParam("@Statu" + i, Statu));
|
strSql.Append("@LingNo" + i + ",");
|
para.Add(new SqlParam("@LingNo" + i, lst[i].LingNo));
|
strSql.Append("@CreateUser" + i + ",");
|
para.Add(new SqlParam("@CreateUser" + i, model.CreatUser));
|
strSql.Append("@CreateTime" + i + ",");
|
para.Add(new SqlParam("@CreateTime" + i, model.CreateTime));
|
strSql.Append("@Demo" + i + ",");
|
para.Add(new SqlParam("@Demo" + i, model.Demo));
|
strSql.Append("@Addre" + i + ",");
|
para.Add(new SqlParam("@Addre" + i, lst[i].LocationCode));
|
strSql.Append("@IsDel" + i + ",");
|
para.Add(new SqlParam("@IsDel" + i, 0));
|
strSql.Append("@OrdNo" + i + "),");
|
para.Add(new SqlParam("@OrdNo" + i, lst[i].OrdNo));
|
}
|
|
SqlParam[] param = null;
|
if (para != null)
|
{
|
strSql.Remove(strSql.Length - 1, 1);
|
param = para.ToArray();
|
}
|
|
int dt = DataFactory.SqlDataBase().ExecuteBySql(strSql, param);
|
|
if (dt > -1) result = true;
|
|
return result;
|
}
|
catch
|
{
|
return result;
|
}
|
}
|
|
public bool UpdateErpinStatus(string OrderNo, string Statu)
|
{
|
try
|
{
|
bool bl = false;
|
StringBuilder strSQL = new StringBuilder();
|
Hashtable ht = new Hashtable();
|
|
ht["Statu"] = "'" + Statu + "'";
|
int ret = DataFactory.SqlDataBase().UpdateByHashtable("Erp_in", "Ordno", "'" + OrderNo + "'", ht);
|
if (ret > 0)
|
{
|
bl = true;
|
}
|
|
return bl;
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
public string SetPalBinds(string uesrCode, string departGuid, List<PalBind> palBinds)
|
{
|
try
|
{
|
string strMessage = "";
|
int rowCount = 0;
|
//StringBuilder strSqlTime = new StringBuilder();
|
//strSqlTime.Append("SELECT GETDATE() as time");
|
//var dtTime = DataFactory.SqlDataBase().GetDataTableBySQL(strSqlTime);
|
//var creatTime = DateTime.Parse(dtTime.Rows[0][0].ToString());
|
foreach (PalBind pal in palBinds)
|
{
|
StringBuilder sqlString = new StringBuilder();
|
if (string.IsNullOrEmpty(pal.Guid))
|
{
|
// 新增编码绑定信息
|
Hashtable htitems = new Hashtable();
|
htitems.Add("OrdNo", "'" + pal.OrdNo + "'");
|
htitems.Add("Palno", "'" + pal.Palno + "'");
|
htitems.Add("MatGuid", "'" + pal.MatGuid + "'");
|
htitems.Add("MatNo", "'" + pal.MatNo + "'");
|
htitems.Add("MatCount", "'" + pal.MatCount + "'");
|
htitems.Add("LocationCode", "'" + pal.LocationCode + "'");
|
htitems.Add("Statu", "'01'");
|
htitems.Add("Demo", "'" + pal.Demo + "'");
|
htitems.Add("DepartGuid", "'" + departGuid + "'");
|
htitems.Add("CreateUser", "'" + uesrCode + "'");
|
htitems.Add("CreateTime", "GETDATE()");
|
int num = DataFactory.SqlDataBase().InsertByHashtableNullParam("IPalletBind", htitems);
|
|
if (pal.LocationCode != null && pal.LocationCode != "")
|
{
|
Hashtable ht = new Hashtable();
|
|
ht["TurnoverDemand"] = "'03'";
|
int ret = DataFactory.SqlDataBase().UpdateByHashtable("DepotsLocation", "LocationCode", "'" + pal.LocationCode + "'", ht);
|
}
|
|
if (num > 0)
|
{
|
rowCount += num;
|
}
|
else
|
{
|
strMessage += pal.MatNo + "物料绑定失败!";
|
}
|
}
|
else
|
{
|
|
StringBuilder stringBuilder = new StringBuilder();
|
stringBuilder.Append("select * from IPalletBind where IsDel = 0 and Statu = '01' and palno = '"+pal.Palno+"'");
|
DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(stringBuilder);
|
foreach (DataRow dr in dt.Rows)
|
{
|
Hashtable htitems2 = new Hashtable();
|
if (dr["OrdNo"].ToString() != pal.OrdNo)
|
{
|
htitems2.Clear();
|
htitems2.Add("LocationCode", "'" + pal.LocationCode + "'");
|
string guid2 = "'" + dr["Guid"].ToString() + "'";
|
|
int num2 = DataFactory.SqlDataBase().UpdateByHashtable("IPalletBind", "Guid", guid2, htitems2);
|
|
if (num2 > 0)
|
{
|
// 修改入库单状态
|
this.UpdateErpinStatus(dr["OrdNo"].ToString(), "02");
|
}
|
}
|
|
if (dr["OrdNo"].ToString() == pal.OrdNo)
|
{
|
if (pal.LocationCode != null && pal.LocationCode != "")
|
{
|
Hashtable ht = new Hashtable();
|
|
ht["TurnoverDemand"] = "'03'";
|
int ret = DataFactory.SqlDataBase()
|
.UpdateByHashtable("DepotsLocation", "LocationCode", "'" + pal.LocationCode + "'", ht);
|
|
|
}
|
else
|
{
|
Hashtable ht = new Hashtable();
|
|
ht["TurnoverDemand"] = "'01'";
|
int ret = DataFactory.SqlDataBase()
|
.UpdateByHashtable("DepotsLocation", "LocationCode", "'" + dr["LocationCode"].ToString() + "'", ht);
|
}
|
}
|
}
|
// 维护编码绑定信息
|
Hashtable htitems = new Hashtable();
|
htitems.Add("OrdNo", "'" + pal.OrdNo + "'");
|
htitems.Add("Palno", "'" + pal.Palno + "'");
|
htitems.Add("MatGuid", "'" + pal.MatGuid + "'");
|
htitems.Add("MatNo", "'" + pal.MatNo + "'");
|
htitems.Add("MatCount", "'" + pal.MatCount + "'");
|
htitems.Add("LocationCode", "'" + pal.LocationCode + "'");
|
htitems.Add("Demo", "'" + pal.Demo + "'");
|
htitems.Add("DepartGuid", "'" + departGuid + "'");
|
htitems.Add("UpdateTime", "getdate()");
|
htitems.Add("UpdateUser", "'" + uesrCode + "'");
|
string guid = "'" + pal.Guid + "'";
|
|
int num = DataFactory.SqlDataBase().UpdateByHashtable("IPalletBind", nameof(pal.Guid), guid, htitems);
|
|
if (num > 0)
|
{
|
rowCount += num;
|
}
|
else
|
{
|
strMessage += pal.MatNo + "物料编辑失败!";
|
}
|
}
|
if (rowCount > 0)
|
{
|
// 修改入库单状态
|
this.UpdateErpinStatus(pal.OrdNo, "02");
|
}
|
}
|
return strMessage;
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
public string DelPalBind(string userCode, string palno, string ordNo, string LocationCode)
|
{
|
try
|
{
|
string strMessage = "";
|
// 验证组盘单状态
|
StringBuilder stringBuilder = new StringBuilder();
|
stringBuilder.Append("select isnull(max(statu),'-1') as statu from View_IPalletBind ");
|
stringBuilder.Append("where Palno = '" + palno + "' and OrdNo = '" + ordNo + "';");
|
DataRow row = DataFactory.SqlDataBase().GetDataRowBySQL(stringBuilder);
|
if (row["statu"].ToString() != "01")
|
{
|
strMessage = "单据状态变更,删除失败!";
|
}
|
else
|
{
|
stringBuilder.Clear();
|
stringBuilder.Append("Update IPalletBind set IsDel = '1',UpdateUser ='" + userCode + "',UpdateTime = getDate() ");
|
stringBuilder.Append("where isDel = '0' and statu = '01' and Palno = '" + palno + "' and OrdNo = '" + ordNo + "';");
|
int rowCount = DataFactory.SqlDataBase().ExecuteBySql(stringBuilder);
|
if (rowCount > 0)
|
{
|
stringBuilder.Clear();
|
stringBuilder.Append("select count(*) from IPalletBind where isdel = '0' and OrdNo = '" + ordNo + "';");
|
DataRow rows = DataFactory.SqlDataBase().GetDataRowBySQL(stringBuilder);
|
if (rows != null && rows[0].ToString() == "0")
|
{
|
this.UpdateErpinStatus(ordNo, "01");
|
}
|
|
stringBuilder.Clear();
|
stringBuilder.Append("select * from IPalletBind where IsDel = 0 and Statu = '01' and palno = '" + palno + "'");
|
DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(stringBuilder);
|
if (dt.Rows.Count <= 0)
|
{
|
Hashtable ht = new Hashtable();
|
|
ht["TurnoverDemand"] = "'01'";
|
int ret = DataFactory.SqlDataBase()
|
.UpdateByHashtable("DepotsLocation", "LocationCode", "'" + LocationCode + "'", ht);
|
}
|
}
|
else
|
{
|
strMessage = "单据状态变更,删除失败!";
|
}
|
}
|
|
return strMessage;
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
public void DelPalBindDetail(string userCode, string guid, string ordNo)
|
{
|
try
|
{
|
StringBuilder stringBuilder = new StringBuilder();
|
stringBuilder.Append("Update IPalletBind set IsDel = '1',UpdateUser ='" + userCode + "',UpdateTime = getDate() ");
|
stringBuilder.Append("where isDel = '0' and guid = '" + guid + "';");
|
int rowCount = DataFactory.SqlDataBase().ExecuteBySql(stringBuilder);
|
if (rowCount > 0)
|
{
|
stringBuilder.Clear();
|
stringBuilder.Append("select count(*) from IPalletBind where isdel = '0' and OrdNo = '" + ordNo + "';");
|
DataRow rows = DataFactory.SqlDataBase().GetDataRowBySQL(stringBuilder);
|
if (rows != null && rows[0].ToString() == "0")
|
{
|
this.UpdateErpinStatus(ordNo, "01");
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
|
|
|
|
|
|
|
|
public bool GetPalletBind(string PalletNo, ref IList<PalletBind> lst)
|
{
|
bool ret = false;
|
try
|
{
|
IList<PalletBind> ls = new List<PalletBind>();
|
StringBuilder strSql = new StringBuilder();
|
strSql.Append("Select * from View_IPalletBindDetail where ");
|
strSql.Append("PalletNo = @PalletNo");
|
|
SqlParam[] para = new SqlParam[]
|
{
|
new SqlParam("@PalletNo", PalletNo),
|
};
|
|
IDataReader dt = DataFactory.SqlDataBase().GetDataReaderBySQL(strSql, para);
|
|
lst = ModelConvertHelper<PalletBind>.DataReaderToModel(dt);
|
|
ret = true;
|
}
|
catch
|
{
|
ret = false;
|
throw new NotImplementedException();
|
}
|
return ret;
|
}
|
|
public bool GetOrderMatByMatNoAndOrd(string OrdNo, string MatNo, ref ErpInDetail eid)
|
{
|
bool br = true;
|
try
|
{
|
StringBuilder strSQL = new StringBuilder();
|
|
strSQL.Append("select OrdNo, MatNo, MatName, CurQuant, LingNo, TuNo, PageNo, Demo from View_ErpInDetail where ");
|
if (!string.IsNullOrEmpty(OrdNo))
|
{
|
strSQL.Append("OrdNo = '");
|
strSQL.Append(OrdNo);
|
strSQL.Append("' and MatNo = '");
|
strSQL.Append(MatNo);
|
strSQL.Append("'");
|
}
|
else
|
{
|
strSQL.Append(" MatNo = '");
|
strSQL.Append(MatNo);
|
strSQL.Append("'");
|
}
|
|
|
IDataReader dt = DataFactory.SqlDataBase().GetDataReaderBySQL(strSQL);
|
if (dt != null)
|
{
|
List<ErpInDetail> ls = new List<ErpInDetail>();
|
ls = (List<ErpInDetail>)ModelConvertHelper<ErpInDetail>.DataReaderToModel(dt);
|
eid = ls[0];
|
br = true;
|
}
|
}
|
catch (Exception ex)
|
{
|
br = false;
|
}
|
return br;
|
}
|
|
public bool IsPalletUsing(string PalletNo)
|
{
|
bool br = false;
|
StringBuilder strSQL = new StringBuilder();
|
|
// 判断组盘中是否存在 组盘是否已使用
|
//strSQL.Append("select 1 from IPalletBind where Palno = '");
|
//strSQL.Append(PalletNo);
|
//strSQL.Append("' and IsDel = 0 and Statu <> '03'");
|
|
//DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(strSQL);
|
//if (dt != null && dt.Rows.Count > 0)
|
//{
|
// br = true;
|
//}
|
|
strSQL.Clear();
|
strSQL.Append("select 1 from IPalletEmptyIn where Palno = '");
|
strSQL.Append(PalletNo);
|
strSQL.Append("' and IsDel = 0 and Statu <> '03' and Statu <> '01'");
|
|
DataTable dt2 = DataFactory.SqlDataBase().GetDataTableBySQL(strSQL);
|
if (dt2 != null && dt2.Rows.Count > 0)
|
{
|
br = true;
|
}
|
|
// 判断库中是否存在 是否已使用
|
strSQL.Clear();
|
strSQL.Append("select TurnoverDemand from DepotsLocation where LocationCode in (");
|
strSQL.Append("select LocationCode from log_Store where Palno = '" + PalletNo + "' AND IsDel=0)");
|
DataTable dtt = DataFactory.SqlDataBase().GetDataTableBySQL(strSQL);
|
if (dtt != null && dtt.Rows.Count > 0)
|
{
|
string tDemand = dtt.Rows[0][0].ToString();
|
if (tDemand == "02" || tDemand == "04")
|
{
|
br = true;
|
}
|
}
|
|
return br;
|
}
|
|
//private bool UpdatePalletBind(string PalletNo)
|
//{
|
// return true;
|
//}
|
|
//private bool UpdateLogStore(string PalletNo)
|
//{
|
// return true;
|
//}
|
|
//private bool UpdateLogDetail(string PalletNo)
|
//{
|
// return true;
|
//}
|
|
public bool UpdateErpinByPalletNo(IList<ErpIn> lst)
|
{
|
bool r = true;
|
|
try
|
{
|
for (int i = 0; i < lst.Count; i++)
|
{
|
StringBuilder strSQL = new StringBuilder();
|
|
strSQL.Append("select * from IPalletBind where OrdNo = '");
|
strSQL.Append(lst[i].OrdNo);
|
strSQL.Append("' and IsDel = 0");
|
|
DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(strSQL);
|
if (dt != null)
|
{
|
if (dt.Rows.Count == 0)
|
UpdateErpinStatus(lst[i].OrdNo, "01");
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
return false;
|
}
|
return r;
|
}
|
|
public bool GetPalletBindStatus(string PalletNo, string status)
|
{
|
bool r = false;
|
|
StringBuilder strSQL = new StringBuilder();
|
|
strSQL.Append("select * from View_IPalletBind where PalletNo = '");
|
strSQL.Append(PalletNo);
|
strSQL.Append("' and Statu = '");
|
strSQL.Append(status);
|
strSQL.Append("'");
|
|
|
DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(strSQL);
|
if (dt == null)
|
{
|
return false;
|
}
|
if (dt.Rows.Count > 0)
|
{
|
return true;
|
}
|
else
|
{
|
return false;
|
}
|
}
|
|
//public bool GetIPalletEmptyInCount(string Palno)
|
//{
|
// try
|
// {
|
// IList<PalletBind> ls = new List<PalletBind>();
|
// StringBuilder strSql = new StringBuilder();
|
// strSql.Append("select * from IPalletBind ");
|
// strSql.Append("where Palno = @Palno and OrdNo = @OrdNo ");
|
// strSql.Append("and DepartGuid = @DepartGuid ");
|
|
// SqlParam[] para = new SqlParam[]
|
// {
|
// new SqlParam("@Palno", palBind.Palno),
|
// new SqlParam("@OrdNo", palBind.OrdNo),
|
// new SqlParam("@DepartGuid", palBind.DepartGuid)
|
// };
|
|
// IDataReader dt = DataFactory.SqlDataBase().GetDataReaderBySQL(strSql, para);
|
// lst = ModelConvertHelper<PalBind>.DataReaderToModel(dt);
|
|
// return true;
|
// }
|
// catch (Exception ex)
|
// {
|
// throw ex;
|
// }
|
//}
|
}
|
}
|