using BLL.DAL;
|
using Common;
|
using Model;
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.IO;
|
using System.Net;
|
using System.Text;
|
|
namespace BLL
|
{
|
public class DALErpOut : IDALErpOut
|
{
|
public IList<ErpOut> GetList(AjaxErpOutList Json, ref PageInfo page)
|
{
|
try
|
{
|
StringBuilder strSql = new StringBuilder();
|
strSql.Append("Select DISTINCT Guid,OrdNo,Statu,AccessCode,AccessName,CompletionTime,CreateUser,CreateTime,");
|
strSql.Append("UpdateUser,UpdateTime,Demo from view_ErpOut where OrdType = 1 ");
|
|
List<SqlParam> para = new List<SqlParam>();
|
if (!string.IsNullOrEmpty(Json.OrdNo))
|
{
|
strSql.Append("and OrdNo like '%' + @OrdNo + '%' ");
|
para.Add(new SqlParam("@OrdNo", Json.OrdNo));
|
}
|
if (!string.IsNullOrEmpty(Json.Statu))
|
{
|
strSql.Append("and StatuCode = @Statu ");
|
para.Add(new SqlParam("@Statu", Json.Statu));
|
}
|
if (!string.IsNullOrEmpty(Json.AccessCode))
|
{
|
strSql.Append("and AccessCode = @AccessCode ");
|
para.Add(new SqlParam("@AccessCode", Json.AccessCode));
|
}
|
if (!string.IsNullOrEmpty(Json.BatchNo))
|
{
|
strSql.Append("and BatchNo like '%' + @BatchNo + '%' ");
|
para.Add(new SqlParam("@BatchNo", Json.BatchNo));
|
}
|
if (!string.IsNullOrEmpty(Json.BatchDemo))
|
{
|
strSql.Append("and BatchDemo like '%' + @BatchDemo + '%' ");
|
para.Add(new SqlParam("@BatchDemo", Json.BatchDemo));
|
}
|
if (!string.IsNullOrEmpty(Json.DepartGuid)) // 部门
|
{
|
strSql.Append("and DepartGuid = @DepartGuid ");
|
para.Add(new SqlParam("@DepartGuid", Json.DepartGuid));
|
}
|
// 根据物料属性检索入库单
|
if (!string.IsNullOrEmpty(Json.MatNo))
|
{
|
strSql.Append("and MatCode like '%' + @MatNo + '%' ");
|
para.Add(new SqlParam("@MatNo", Json.MatNo));
|
}
|
if (!string.IsNullOrEmpty(Json.MatName))
|
{
|
strSql.Append("and MatName like '%' + @MatName + '%' ");
|
para.Add(new SqlParam("@MatName", Json.MatName));
|
}
|
if (!string.IsNullOrEmpty(Json.LingNo))
|
{
|
strSql.Append("and LingNo like '%' + @LingNo + '%' ");
|
para.Add(new SqlParam("@LingNo", Json.LingNo));
|
}
|
if (!string.IsNullOrEmpty(Json.TuNo))
|
{
|
strSql.Append("and TuNo like '%' + @TuNo + '%' ");
|
para.Add(new SqlParam("@TuNo", Json.TuNo));
|
}
|
if (Json.BeginTime != DateTime.MinValue && Json.BeginTime != null && Json.BeginTime != DateTime.MaxValue)
|
{
|
strSql.Append("and CreateTime >= @CreateTime1 ");
|
para.Add(new SqlParam("@CreateTime1", Convert.ToDateTime(Json.BeginTime).ToShortDateString()));
|
}
|
if (Json.EndTime != DateTime.MinValue && Json.EndTime != null && Json.EndTime != DateTime.MaxValue)
|
{
|
strSql.Append("and CreateTime <= @CreateTime2 ");
|
para.Add(new SqlParam("@CreateTime2", Convert.ToDateTime(Json.EndTime).ToShortDateString() + " 23:59:59.999"));
|
}
|
|
SqlParam[] param = null;
|
if (para != null)
|
{
|
param = para.ToArray();
|
}
|
|
DataTable dt = DataFactory.SqlDataBase().GetPageList(strSql.ToString(), param, "CreateTime", "desc", ref page);
|
return ModelConvertHelper<ErpOut>.DataTableToModel(dt);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
public SelMatList GetLogStore(string storeGuid)
|
{
|
try
|
{
|
StringBuilder strSql = new StringBuilder();
|
strSql.Append("Select * from View_SelMatStore where storeGuid = '" + storeGuid + "';");
|
IDataReader dt = DataFactory.SqlDataBase().GetDataReaderBySQL(strSql);
|
|
return ModelConvertHelper<SelMatList>.ReaderToModel(dt);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
public bool IsCheckMatNum(string storeGuid, string curQuant, string guid)
|
{
|
try
|
{
|
bool bl = false;
|
if (int.Parse(curQuant) <= 0)
|
{// 出库数量不可小于等于0
|
return false;
|
}
|
|
StringBuilder strSql = new StringBuilder();
|
if (!string.IsNullOrEmpty(guid))
|
{
|
strSql.Append($"select (Quant - (CQuant-(select cast(CurQuant as int) from ErpOutDetail where Guid = '{guid}')) - " + curQuant + ") as num ");
|
strSql.Append("from View_SelMatStore where storeGuid = '" + storeGuid + "'; ");
|
}
|
else
|
{
|
strSql.Append("Select (Quant - CQuant -" + curQuant + ") as num from View_SelMatStore where storeGuid = '" + storeGuid + "';");
|
}
|
|
DataRow row = DataFactory.SqlDataBase().GetDataRowBySQL(strSql);
|
if (int.Parse(row["num"].ToString()) >= 0)
|
{
|
bl = true;
|
}
|
|
return bl;
|
}
|
catch (Exception ex)
|
{
|
return false;
|
throw ex;
|
}
|
}
|
|
public void DelOrdDetail(string guid, string storeGuid)
|
{
|
try
|
{
|
if (!string.IsNullOrEmpty(guid))
|
{
|
StringBuilder sqlString = new StringBuilder();
|
sqlString.Append("update log_Store set CQuant = CQuant-(select CAST(isnull(CurQuant,'0') as int) ");
|
sqlString.Append("from ErpOutDetail where IsDel = 0 and Guid = '" + guid + "') where Guid = '" + storeGuid + "'");
|
int rowCount = DataFactory.SqlDataBase().ExecuteBySql(sqlString);
|
if (rowCount > 0)
|
{
|
DataFactory.SqlDataBase().DeleteData("ErpOutDetail", "Guid", guid);
|
}
|
}
|
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
private string GetOrdNo()
|
{
|
try
|
{
|
string ordNo = "";
|
Hashtable ht1 = new Hashtable();
|
ht1.Add("sCode", "ODNO");
|
ht1.Add("OUT_sResult", "");
|
|
Hashtable rs = new Hashtable();
|
if (DataFactory.SqlDataBase().ExecuteByProcReturn("GetSerialNo", ht1, ref rs) != 0)
|
{
|
ordNo = rs["OUT_sResult"].ToString();
|
}
|
|
return ordNo;
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
public bool Add(ErpOut model, List<ErpOutDetail> Mats)
|
{
|
bool bl = false;
|
try
|
{
|
// 获取出库单号
|
string ordNo = GetOrdNo();
|
if (ordNo != "")
|
{
|
model.OrdNo = ordNo;
|
|
// 保存入库表
|
Hashtable ht = new Hashtable();
|
ht.Add("OrdNo", "'" + model.OrdNo + "'");
|
ht.Add("Statu", "'" + model.Statu + "'");
|
ht.Add("OrdType", "'" + "1" + "'");
|
ht.Add("DepartGuid", "'" + model.DepartGuid + "'");
|
ht.Add("AccessCode", "'" + model.AccessCode + "'");
|
ht.Add("Demo", "'" + model.Demo + "'");
|
ht.Add("CreateUser", "'" + model.CreateUser + "'");
|
|
int rowCount = DataFactory.SqlDataBase().InsertByHashtableNullParam("Erp_Out", ht);
|
if (rowCount == 1)
|
{
|
// 保存入库明细表
|
foreach (ErpOutDetail detail in Mats)
|
{
|
Hashtable htitems = new Hashtable();
|
htitems.Add("OrdNo", "'" + model.OrdNo + "'");
|
htitems.Add("MatNo", "'" + detail.MatGuid + "'");
|
htitems.Add("DepartGuid", "'" + model.DepartGuid + "'");
|
htitems.Add("StoreGuid", "'" + detail.StoreGuid + "'");
|
htitems.Add("CurQuant", "'" + detail.CurQuant + "'");
|
htitems.Add("LingNo", "'" + detail.LingNo + "'");
|
htitems.Add("TuNo", "'" + detail.TuNo + "'");
|
htitems.Add("PageNo", "'" + detail.PageNo + "'");
|
htitems.Add("Certificate", "'" + detail.Certificate + "'");
|
htitems.Add("BatchNo", "'" + detail.BatchNo + "'");
|
htitems.Add("BatchDemo", "'" + detail.BatchDemo + "'");
|
htitems.Add("Demo", "'" + detail.DetailDemo + "'");
|
htitems.Add("PickerUser", "'" + detail.PickerUser + "'");
|
htitems.Add("CreateUser", "'" + model.CreateUser + "'");
|
DataFactory.SqlDataBase().InsertByHashtableNullParam("ErpOutDetail", htitems);
|
}
|
bl = true;
|
}
|
else
|
{
|
bl = false;
|
}
|
}
|
|
return bl;
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
public bool Update(ErpOut model, List<ErpOutDetail> Mats)
|
{
|
bool result = false;
|
try
|
{
|
// 保存入库单
|
Hashtable ht = new Hashtable();
|
ht.Add("AccessCode", "'" + model.AccessCode + "'");
|
ht.Add("Demo", "'" + model.Demo + "'");
|
ht.Add("UpdateTime", "getdate()");
|
ht.Add("UpdateUser", "'" + model.CreateUser + "'");
|
string OrdNo = "'" + model.OrdNo + "'";
|
int rowCount = DataFactory.SqlDataBase().UpdateByHashtable("Erp_Out", nameof(model.OrdNo), OrdNo, ht);
|
|
// 保存入库单明细
|
if (rowCount == 1)
|
{
|
foreach (ErpOutDetail detail in Mats)
|
{
|
Hashtable htitems = new Hashtable();
|
if (string.IsNullOrEmpty(detail.Guid))
|
{
|
htitems.Add("OrdNo", "'" + model.OrdNo + "'");
|
htitems.Add("MatNo", "'" + detail.MatGuid + "'");
|
htitems.Add("DepartGuid", "'" + model.DepartGuid + "'");
|
htitems.Add("StoreGuid", "'" + detail.StoreGuid + "'");
|
htitems.Add("CurQuant", "'" + detail.CurQuant + "'");
|
htitems.Add("LingNo", "'" + detail.LingNo + "'");
|
htitems.Add("TuNo", "'" + detail.TuNo + "'");
|
htitems.Add("PageNo", "'" + detail.PageNo + "'");
|
htitems.Add("Certificate", "'" + detail.Certificate + "'");
|
htitems.Add("BatchNo", "'" + detail.BatchNo + "'");
|
htitems.Add("BatchDemo", "'" + detail.BatchDemo + "'");
|
htitems.Add("Demo", "'" + detail.DetailDemo + "'");
|
htitems.Add("PickerUser", "'" + detail.PickerUser + "'");
|
htitems.Add("CreateUser", "'" + model.CreateUser + "'");
|
DataFactory.SqlDataBase().InsertByHashtableNullParam("ErpOutDetail", htitems);
|
}
|
else
|
{
|
|
htitems.Add("MatNo", "'" + detail.MatGuid + "'");
|
htitems.Add("DepartGuid", "'" + model.DepartGuid + "'");
|
htitems.Add("StoreGuid", "'" + detail.StoreGuid + "'");
|
htitems.Add("CurQuant", "'" + detail.CurQuant + "'");
|
htitems.Add("LingNo", "'" + detail.LingNo + "'");
|
htitems.Add("TuNo", "'" + detail.TuNo + "'");
|
htitems.Add("PageNo", "'" + detail.PageNo + "'");
|
htitems.Add("Certificate", "'" + detail.Certificate + "'");
|
htitems.Add("BatchNo", "'" + detail.BatchNo + "'");
|
htitems.Add("BatchDemo", "'" + detail.BatchDemo + "'");
|
htitems.Add("Demo", "'" + detail.DetailDemo + "'");
|
htitems.Add("PickerUser", "'" + detail.PickerUser + "'");
|
htitems.Add("UpdateTime", "getdate()");
|
htitems.Add("UpdateUser", "'" + detail.CreateUser + "'");
|
string guid = "'" + detail.Guid + "'";
|
DataFactory.SqlDataBase().UpdateByHashtable("ErpOutDetail", nameof(model.Guid), guid, htitems);
|
}
|
}
|
result = true;
|
}
|
|
return result;
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
public bool BatchDelete(string[] OrdNo)
|
{
|
bool result = false;
|
try
|
{
|
Hashtable ht = new Hashtable();
|
ht["Statu"] = "01";
|
|
int dt = DataFactory.SqlDataBase().IsExist("Erp_Out", "OrdNo", OrdNo, ht);
|
if (dt >= OrdNo.Length)
|
{
|
int _ret = DataFactory.SqlDataBase().BatchDeleteData("Erp_Out", "OrdNo", OrdNo);
|
if (_ret >= OrdNo.Length)
|
{
|
int dt1 = DataFactory.SqlDataBase().IsExist("ErpOutDetail", "OrdNo", OrdNo);
|
if (dt1 > 0)
|
{
|
//删除出库单数据更改货位状态为合格
|
StringBuilder hql = new StringBuilder();
|
hql.Append("select * from View_ErpOutDetail where OrdNo='" + OrdNo[0] + "' and Statu='01' ");
|
DataTable dep = DataFactory.SqlDataBase().GetDataTableBySQL(hql);
|
if (dep.Rows.Count > 0)
|
{
|
for (int i = 0; i < dep.Rows.Count; i++)
|
{
|
StringBuilder Sql = new StringBuilder();
|
Sql.Append("update DepotsLocation set TurnoverDemand='02' where LocationCode='" + dep.Rows[i]["LocationCode"].ToString() + "'");
|
DataFactory.SqlDataBase().ExecuteBySql(Sql);
|
}
|
}
|
|
int _ret1 = DataFactory.SqlDataBase().BatchDeleteData("ErpOutDetail", "OrdNo", OrdNo);
|
if (_ret1 >= dt1) result = true;
|
}
|
}
|
}
|
|
return result;
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
/// 编辑物料时查询该物料库存数量
|
/// </summary>
|
/// <param name="matNo"></param>
|
/// <param name="palno"></param>
|
/// <returns></returns>
|
public string GetLogStore(string matNo, string palno, string Certificate)
|
{
|
try
|
{
|
StringBuilder strSql = new StringBuilder();
|
strSql.Append("Select Quant from log_Store where Palno = '" + palno + "'");
|
if (matNo != "" && matNo != null)
|
{//lijiangang修改:增加合格证Certificate条件
|
strSql.Append(" and MatNo = '" + matNo + "'");
|
strSql.Append(" and Certificate = '" + Certificate + "'");
|
}
|
DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(strSql);
|
return dt.Rows[0]["Quant"].ToString();
|
}
|
catch (Exception)
|
{
|
StringBuilder strSql = new StringBuilder();
|
strSql.Append("Select Quant from log_Store where Palno = '" + palno + "'");
|
if (matNo != "" && matNo != null)
|
{//lijiangang修改:增加合格证Certificate条件
|
strSql.Append(" and MatNo = '" + matNo + "'");
|
strSql.Append(" and Certificate is null");
|
}
|
DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(strSql);
|
return dt.Rows[0]["Quant"].ToString();
|
}
|
|
}
|
|
/// <summary>
|
/// 填写数量保存时判断库存是否足够
|
/// </summary>
|
/// <param name="Json"></param>
|
/// <param name="page"></param>
|
/// <returns></returns>
|
public IList<ErpMat> GetErpOutCurQuant(ErpMat Json)
|
{
|
try
|
{
|
IList<ErpMat> list = new List<ErpMat>();
|
StringBuilder strSql = new StringBuilder();
|
List<SqlParam> para = new List<SqlParam>();
|
//lijiangang修改:增加合格证Certificate条件
|
strSql.Append("Select OrdNo,CurQuant from ErpOutDetail where OrdNo in (Select OrdNo from Erp_Out where (Statu !='ER03' and statu != 'ER04') and IsDel !=1) and Palno='" + Json.Palno + "' and Certificate='" + Json.Certificate + "' ");
|
if (Json.MatNo != "" && Json.MatNo != null)
|
{
|
strSql.Append(" and MatNo='" + Json.MatNo + "'");
|
}
|
|
strSql.Append(" group by OrdNo,CurQuant ");
|
SqlParam[] param = null;
|
if (para != null)
|
param = para.ToArray();
|
|
DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(strSql);
|
list = ModelConvertHelper<ErpMat>.DataTableToModel(dt);
|
|
return list;
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
|
}
|
/// <summary>
|
/// 填写托盘数量保存时判断库存是否足够
|
/// </summary>
|
/// <param name="Json"></param>
|
/// <param name="page"></param>
|
/// <returns></returns>
|
public IList<ErpMat> GetPalletOutCurQuant(ErpMat Json)
|
{
|
try
|
{
|
IList<ErpMat> list = new List<ErpMat>();
|
StringBuilder strSql = new StringBuilder();
|
List<SqlParam> para = new List<SqlParam>();
|
//lijiangang修改:增加合格证Certificate条件
|
strSql.Append("Select OrdNo,CurQuant from ErpOutDetail where OrdNo in (Select OrdNo from Erp_Out where (Statu !='ER03' and statu != 'ER04') and IsDel !=1) and Palno='" + Json.Palno + "'");
|
if (Json.MatNo != "" && Json.MatNo != null)
|
{
|
strSql.Append(" and MatNo='" + Json.MatNo + "'");
|
}
|
|
strSql.Append(" group by OrdNo,CurQuant ");
|
SqlParam[] param = null;
|
if (para != null)
|
param = para.ToArray();
|
|
DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(strSql);
|
list = ModelConvertHelper<ErpMat>.DataTableToModel(dt);
|
|
return list;
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
|
}
|
public ErpOut GetModel(string OrdNo)
|
{
|
try
|
{
|
|
ErpOut us = null;
|
StringBuilder strSql = new StringBuilder();
|
strSql.Append(" Select * from View_ErpOut where ");
|
strSql.Append("OrdNo = @OrdNo ");
|
//strSql.Append("and IsDel != 1");
|
SqlParam[] para = new SqlParam[]
|
{
|
new SqlParam("@OrdNo", OrdNo),
|
};
|
|
IDataReader dt = DataFactory.SqlDataBase().GetDataReaderBySQL(strSql, para);
|
|
us = ModelConvertHelper<ErpOut>.ReaderToModel(dt);
|
|
return us;
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
public ErpOut GetModel(string OrdNo, ref IList<StorePalno> erpMats)
|
{
|
try
|
{
|
|
|
ErpOut us = null;
|
StringBuilder strSql = new StringBuilder();
|
strSql.Append(" Select * from View_ErpOut where ");
|
strSql.Append("OrdNo = @OrdNo ");
|
//strSql.Append("and IsDel != 1");
|
SqlParam[] para = new SqlParam[]
|
{
|
new SqlParam("@OrdNo", OrdNo),
|
};
|
|
IDataReader dt = DataFactory.SqlDataBase().GetDataReaderBySQL(strSql, para);
|
|
us = ModelConvertHelper<ErpOut>.ReaderToModel(dt);
|
|
IDALErpOutDetail erpInDetail = new DALErpOutDetail();
|
erpMats = erpInDetail.GetList(OrdNo);
|
|
|
return us;
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
public bool UpdateAudit(string[] OrdNo, string AuditFlag, string User)
|
{
|
bool result = false;
|
try
|
{
|
Hashtable ht = new Hashtable();
|
|
ht["AuditFlag"] = "'" + AuditFlag + "'";
|
//ht["Statu"] = "'ER04'";
|
ht["AuditUser"] = "'" + User + "'";
|
ht["AuditTime"] = "getdate()";
|
|
|
int _ret = DataFactory.SqlDataBase().UpdateByHashtableA("Erp_Out", nameof(OrdNo), OrdNo, ht);
|
if (_ret == 1) result = true;
|
|
return result;
|
|
}
|
catch
|
{
|
return result;
|
}
|
}
|
public bool UpdateClose(string[] OrdNo, string Statu)
|
{
|
bool result = false;
|
try
|
{
|
Hashtable ht = new Hashtable();
|
ht["Statu"] = "'" + Statu + "'";
|
ht["COMDAT"] = "getDate()";
|
int dt = DataFactory.SqlDataBase().IsExist("Erp_Out", "OrdNo", OrdNo);
|
if (dt >= OrdNo.Length)
|
{
|
int _ret = DataFactory.SqlDataBase().UpdateByHashtable("Erp_Out", "OrdNo", OrdNo, ht);
|
if (_ret >= OrdNo.Length) result = true;
|
}
|
return result;
|
|
}
|
catch
|
{
|
return result;
|
}
|
}
|
public bool IsExist(string name, string value)
|
{
|
bool result = false;
|
try
|
{
|
string[] para = new string[] { value };
|
int dt = DataFactory.SqlDataBase().IsExist("Erp_Out", name, para);
|
if (dt > 0) result = true;
|
return result;
|
}
|
catch
|
{
|
return result;
|
}
|
|
}
|
public DataTable GetDataTable(string[] strWhere)
|
{
|
DataTable dt = null;
|
try
|
{
|
int index = 0;
|
string str = "@RoleNum" + index;
|
SqlParam[] param = new SqlParam[strWhere.Length];
|
StringBuilder sql = new StringBuilder();
|
sql.Append("Select RoleNum as 角色编号, RoleName as 角色名,CreatUser as 创建人,CreatTime as 创建时间,UpdateUser as 更新人,UpdateTime as 更新时间,Demo as 备注 FROM View_GetRoles where RoleNum in (");
|
|
for (int i = 0; i < param.Length - 1; i++)
|
{
|
string obj2 = strWhere[i];
|
str = "@RoleNum" + index;
|
sql.Append(str).Append(",");
|
param[index] = new SqlParam(str, obj2);
|
index++;
|
}
|
str = "@RoleNum" + index;
|
sql.Append(str);
|
param[index] = new SqlParam(str, strWhere[index]);
|
sql.Append(")");
|
|
dt = DataFactory.SqlDataBase().GetDataTableBySQL(sql, param, "");
|
|
return dt;
|
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
|
}
|
|
/// <summary>
|
/// 出库逻辑判断下发指令
|
/// </summary>
|
/// <param name="OrdNo"></param>
|
/// <returns></returns>
|
public bool Out(string[] OrdNo, string accessCode, string CreateUser)
|
{
|
try
|
{
|
int _ret = 0;
|
|
DALWMSApi dalWMSApi = new DALWMSApi();
|
foreach (var itemNo in OrdNo)
|
{
|
// C口不允许出A3类型托盘
|
if (accessCode == "03")
|
{
|
StringBuilder sqlString = new StringBuilder();
|
sqlString.Append($"select count(guid) from View_ErpOutDetail where ordno='{itemNo}' and Palno like 'A3%';");
|
DataTable dtt = DataFactory.SqlDataBase().GetDataTableBySQL(sqlString);
|
if (dtt.Rows[0][0].ToString() != "0")
|
{
|
throw new Exception("此单包含A3类型的托盘,不允许出往C口!");
|
}
|
}
|
|
StringBuilder strSql = new StringBuilder();
|
strSql.Append($@"
|
SELECT LocationCode,
|
Palno
|
FROM View_ErpOutDetail
|
WHERE OrdNo = '{itemNo}' and Statu='01'
|
GROUP BY LocationCode,
|
Palno;
|
");
|
DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(strSql);
|
if (dt.Rows.Count <= 0)
|
{
|
continue;
|
}
|
foreach (DataRow dataRow in dt.Rows)
|
{
|
string locationCode = dataRow["LocationCode"].ToString();
|
string palNo = dataRow["Palno"].ToString();
|
strSql.Clear();
|
strSql.Append($"SELECT TurnoverDemand FROM dbo.DepotsLocation WHERE LocationCode='{locationCode}' AND IsDel=0");
|
var dtDL = DataFactory.SqlDataBase().GetDataTableBySQL(strSql);
|
if (dtDL != null && dtDL.Rows.Count >= 0)
|
{
|
string turnoverDemand = dtDL.Rows[0]["TurnoverDemand"].ToString();
|
switch (turnoverDemand)
|
{
|
case "02":
|
{
|
//TODO开发接口部分.
|
dalWMSApi.Send(palNo, locationCode, accessCode);
|
// 待出库
|
strSql.Clear();
|
strSql.Append($@"
|
UPDATE dbo.DepotsLocation
|
SET TurnoverDemand = '04',
|
UpdateTime = GETDATE(),
|
UpdateUser = '{CreateUser}'
|
WHERE LocationCode = '{locationCode}';");
|
|
_ret = DataFactory.SqlDataBase().ExecuteBySql(strSql);
|
if (_ret <= 0)
|
{
|
return false;
|
}
|
|
break;
|
}
|
case "03":
|
{
|
DALWMSApi api = new DALWMSApi();
|
var result = api.OutStorage(palNo, locationCode);
|
if (result.Code != "01")
|
{
|
return false;
|
}
|
break;
|
}
|
case "04":
|
dalWMSApi.Send1(palNo, locationCode, accessCode);
|
; break;
|
default:
|
break;
|
}
|
//下发完指令更改单号状态为正在执行
|
strSql.Clear();
|
strSql.Append($"UPDATE Erp_Out SET Statu='02' WHERE Ordno='{itemNo}' AND Statu='01'");
|
DataFactory.SqlDataBase().ExecuteBySql(strSql);
|
}
|
}
|
return true;
|
}
|
return true;
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
|
#region 出库指令重新开发
|
/*
|
bool result = false;
|
try
|
{
|
DAL_Pub dAL_Pub = new DAL_Pub();
|
StringBuilder strSql = new StringBuilder();
|
// 获取同一个出库单下外库位托盘码
|
strSql.Append("select Addre,palno from ErpOutDetail where OrdNo ='" + OrdNo[0] + "' ");
|
strSql.Append("and (Addre like '%-002%' or Addre like '%-003%') Group by Palno,Addre");
|
DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(strSql);
|
if (dt.Rows.Count > 0)
|
{
|
foreach (DataRow row in dt.Rows)
|
{
|
Hashtable ht = new Hashtable();
|
ht["TaskID"] = "'" + OrdNo[0] + "'";
|
ht["CMDType"] = "'out'";
|
ht["Palno"] = "'" + row["Palno"].ToString() + "'";
|
ht["OldAddre"] = "'" + row["Addre"].ToString() + "'";
|
ht["CMDStatu"] = "0";
|
ht["CreateUser"] = "'" + CreateUser + "'";
|
int dd = DataFactory.SqlDataBase().InsertByHashtableNullParam("WH_CMD", ht);
|
}
|
}
|
|
// 获取同一个出库单下内库位托盘码
|
strSql.Clear();
|
strSql.Append("select Addre,palno from ErpOutDetail where OrdNo ='" + OrdNo[0] + "' ");
|
strSql.Append("and (Addre like '%-001%' or Addre like '%-004%') Group by Palno,Addre");
|
DataTable dtt = DataFactory.SqlDataBase().GetDataTableBySQL(strSql);
|
if (dtt.Rows.Count > 0)
|
{
|
foreach (DataRow row in dtt.Rows)
|
{
|
// 获取对应的外库位状态
|
string addreW = row["Addre"].ToString(); // 当前内库位对应的外库位
|
addreW = addreW.Replace("-001", "-002");
|
addreW = addreW.Replace("-004", "-003");
|
StringBuilder sqlString = new StringBuilder();
|
sqlString.Append("Select Addre,Palno,DepotsLocation.Height from log_Store ");
|
sqlString.Append("left join DepotsLocation on log_Store.Addre = DepotsLocation.LocationCode ");
|
sqlString.Append("where Addre = '" + addreW + "' and DepotsLocation.TurnoverDemand = '02' ");
|
sqlString.Append("group by Addre,Palno,DepotsLocation.Height;");
|
DataTable dttw = DataFactory.SqlDataBase().GetDataTableBySQL(sqlString);
|
if (dttw.Rows.Count > 0) // 判断对应的外库位是否存在托盘
|
{
|
if (dttw.Rows.Count > 1)
|
{
|
// 如果出现一个库位地址存在多个托盘情况不允许下指令,删除已下指令等待处理好后在重新执行。
|
sqlString.Clear();
|
sqlString.Append("delete from WH_CMD where TaskID = '" + OrdNo[0] + "' and isdel = '0';");
|
DataFactory.SqlDataBase().ExecuteBySql(sqlString);
|
return false;
|
}
|
// 判断指令表里是否有关于该托盘出库或移出指令指令
|
sqlString.Clear();
|
sqlString.Append("select COUNT(*) as Num from WH_CMD ");
|
sqlString.Append("where OldAddre = '" + addreW + "' ");
|
sqlString.Append("and CMDType in ('out','move') and IsDel = 0; ");
|
DataTable dt1 = DataFactory.SqlDataBase().GetDataTableBySQL(sqlString);
|
if (dt1.Rows[0][0].ToString() == "0")
|
{
|
string moveaddre = ""; // 移库的目标库位
|
string oriPos = dttw.Rows[0]["Addre"].ToString();
|
int height = dttw.Rows[0]["Height"].ToInt();
|
DAL_Pub pub = new DAL_Pub();
|
int move = pub.GetEmptyPos(ref moveaddre, height, oriPos);
|
|
Hashtable ht1 = new Hashtable();
|
|
ht1["CMDType"] = "'move'";
|
ht1["Palno"] = "'" + dttw.Rows[0]["Palno"].ToString() + "'";
|
ht1["OldAddre"] = "'" + dttw.Rows[0]["Addre"].ToString() + "'";
|
ht1["NowAddre"] = "'" + moveaddre + "'";
|
ht1["CMDStatu"] = "0";
|
ht1["CreateUser"] = "'" + CreateUser + "'";
|
int moveadd = DataFactory.SqlDataBase().InsertByHashtableNullParam("WH_CMD", ht1);
|
}
|
}
|
else
|
{
|
// 判断指令表里是否有关于该托盘入库指令
|
sqlString.Clear();
|
sqlString.Append("select Palno,COUNT(*) as Num from WH_CMD ");
|
sqlString.Append(" where ((CMDType = 'in' and OldAddre='" + addreW + "') ");
|
sqlString.Append("or (CMDType='move' and NowAddre = '" + addreW + "')) and IsDel = 0 group by Palno; ");
|
DataTable dt1 = DataFactory.SqlDataBase().GetDataTableBySQL(sqlString);
|
if (dt1.Rows.Count > 0)
|
{
|
string moveaddre = ""; // 移库的目标库位
|
string oriPos = dttw.Rows[0]["Addre"].ToString();
|
int height = dttw.Rows[0]["Height"].ToInt();
|
DAL_Pub pub = new DAL_Pub();
|
int move = pub.GetEmptyPos(ref moveaddre, height, oriPos);
|
|
Hashtable ht1 = new Hashtable();
|
|
ht1["CMDType"] = "'move'";
|
ht1["Palno"] = "'" + dt1.Rows[0]["Palno"].ToString() + "'";
|
ht1["OldAddre"] = "'" + dttw.Rows[0]["Addre"].ToString() + "'";
|
ht1["NowAddre"] = "'" + moveaddre + "'";
|
ht1["CMDStatu"] = "0";
|
ht1["CreateUser"] = "'" + CreateUser + "'";
|
int moveadd = DataFactory.SqlDataBase().InsertByHashtableNullParam("WH_CMD", ht1);
|
}
|
}
|
|
|
Hashtable ht = new Hashtable();
|
ht["TaskID"] = "'" + OrdNo[0] + "'";
|
ht["CMDType"] = "'out'";
|
ht["Palno"] = "'" + row["Palno"].ToString() + "'";
|
ht["OldAddre"] = "'" + row["Addre"].ToString() + "'";
|
ht["CMDStatu"] = "0";
|
ht["CreateUser"] = "'" + CreateUser + "'";
|
int dd = DataFactory.SqlDataBase().InsertByHashtableNullParam("WH_CMD", ht);
|
}
|
}
|
|
//下发完指令更改单号状态为正在执行
|
Hashtable htup = new Hashtable();
|
htup["Statu"] = "'02'";
|
string Ordno = "'Ordno'";
|
string OrdNo1 = "'" + OrdNo[0] + "'";
|
|
int _ret = DataFactory.SqlDataBase().UpdateByHashtable("Erp_Out", nameof(Ordno), OrdNo1, htup);
|
|
#region liudl 注释 出库单内包含对应的内外库位程序出错
|
////获取单号下货位
|
//strSql.Append("Select Addre,Palno from ErpOutDetail where OrdNo ='"+OrdNo[0]+ "' Group by Palno,Addre");
|
//DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(strSql);
|
|
//for (int i = 0; i < dt.Rows.Count; i++)
|
//{
|
|
// //判断货位是里层还是外层
|
// if (dt.Rows[i]["Addre"].ToString().IndexOf("-001")>=0|| dt.Rows[i]["Addre"].ToString().IndexOf("-004") >= 0)
|
// {
|
// string pai1="";
|
// string pai2="";
|
// //是里层判断外层是否是空货位,不是则先移库
|
// if (dt.Rows[i]["Addre"].ToString().IndexOf("-001") >= 0)
|
// {
|
// pai1 = "-001";
|
// pai2 = "-002";
|
// }
|
// else
|
// {
|
// pai1 = "-004";
|
// pai2 = "-003";
|
// }
|
// //判断外层是否是空货位
|
// StringBuilder seladdre = new StringBuilder();
|
// seladdre.Append("Select Addre,Palno,DepotsLocation.Height from log_Store left join DepotsLocation on DepotsLocation.LocationCode =log_Store.Addre where Addre ='" + dt.Rows[i]["Addre"].ToString().Replace(pai1,pai2) + "'");
|
// DataTable dd = DataFactory.SqlDataBase().GetDataTableBySQL(seladdre);
|
// if (dd.Rows.Count>0)
|
// {
|
// string moveaddre = "";
|
// string oriPos = dd.Rows[i]["Addre"].ToString();
|
// int height = dd.Rows[0]["Height"].ToInt();
|
// DAL_Pub pub = new DAL_Pub();
|
// int move = pub.GetEmptyPos(ref moveaddre, height, oriPos);
|
// //外层有托盘则先移库再出库
|
// if (moveaddre.IndexOf("-001") >= 0 || moveaddre.IndexOf("-004") >= 0)
|
// {
|
// string ad1 = "";
|
// string ad2 = "";
|
// if (moveaddre.IndexOf("-001") >= 0)
|
// {
|
// ad1 = "-001";
|
// ad2 = "-002";
|
// }
|
// else
|
// {
|
// ad1 = "-004";
|
// ad2 = "-003";
|
// }
|
// //判断空货位外层是否是空位,是直接移库,不是外层托盘移向里层再移库
|
// StringBuilder sql = new StringBuilder();
|
// sql.Append("Select LocationCode,log_Store.Palno from DepotsLocation left join log_Store on DepotsLocation.LocationCode = log_Store.Addre where LocationCode ='" + moveaddre.Replace(ad1, ad2) + "' and TurnoverDemand='01' ");
|
|
// DataTable ad = DataFactory.SqlDataBase().GetDataTableBySQL(sql);
|
// if (ad.Rows.Count > 0)
|
// {
|
// Hashtable ht = new Hashtable();
|
// ht["CMDType"] = "'move'";
|
// ht["Palno"] = "'" + ad.Rows[0]["Palno"].ToString() + "'";
|
// ht["OldAddre"] = "'" + ad.Rows[0]["LocationCode"].ToString() + "'";
|
// ht["NowAddre"] = "'"+moveaddre+"'";
|
// ht["CMDStatu"] = "0";
|
// ht["CreateUser"] = "'" + CreateUser + "'";
|
// int moveadd = DataFactory.SqlDataBase().InsertByHashtableNullParam("WH_CMD", ht);
|
|
// Hashtable ht1 = new Hashtable();
|
// ht1["CMDType"] = "'move'";
|
// ht1["Palno"] = "'" + dd.Rows[0]["Palno"].ToString() + "'";
|
// ht1["OldAddre"] = "'" + dd.Rows[0]["Addre"].ToString() + "'";
|
// ht1["NowAddre"] = "'"+ad.Rows[0]["LocationCode"].ToString()+"'";
|
// ht1["CMDStatu"] = "0";
|
// ht1["CreateUser"] = "'" + CreateUser + "'";
|
// int moveadd1 = DataFactory.SqlDataBase().InsertByHashtableNullParam("WH_CMD", ht1);
|
// }
|
// else
|
// {
|
// Hashtable ht = new Hashtable();
|
// ht["CMDType"] = "'move'";
|
// ht["Palno"] = "'" + dd.Rows[0]["Palno"].ToString() + "'";
|
// ht["OldAddre"] = "'" + dd.Rows[0]["Addre"].ToString() + "'";
|
// ht["NowAddre"] = "'"+moveaddre+"'";
|
// ht["CMDStatu"] = "0";
|
// ht["CreateUser"] = "'" + CreateUser + "'";
|
// int moveadd = DataFactory.SqlDataBase().InsertByHashtableNullParam("WH_CMD", ht);
|
// }
|
// }
|
// else {
|
// Hashtable ht = new Hashtable();
|
// ht["CMDType"] = "'move'";
|
// ht["Palno"] = "'" + dd.Rows[i]["Palno"].ToString() + "'";
|
// ht["OldAddre"] = "'" + dd.Rows[i]["Addre"].ToString() + "'";
|
// ht["NowAddre"] = "'"+moveaddre+"'";
|
// ht["CMDStatu"] = "0";
|
// ht["CreateUser"] = "'" + CreateUser + "'";
|
// int moveadd = DataFactory.SqlDataBase().InsertByHashtableNullParam("WH_CMD", ht);
|
// }
|
// Hashtable hy = new Hashtable();
|
// hy["TaskID"] = "'" + OrdNo[0] + "'";
|
// hy["CMDType"] = "'out'";
|
// hy["Palno"] = "'" + dt.Rows[i]["Palno"].ToString() + "'";
|
// hy["OldAddre"] = "'" + dt.Rows[i]["Addre"].ToString() + "'";
|
// hy["CMDStatu"] = "0";
|
// hy["CreateUser"] = "'" + CreateUser + "'";
|
// int outadd = DataFactory.SqlDataBase().InsertByHashtableNullParam("WH_CMD", hy);
|
|
// } else
|
// {
|
// //外层没有托盘直接出库
|
// Hashtable ht = new Hashtable();
|
// ht["TaskID"] = "'" + OrdNo[0] + "'";
|
// ht["CMDType"] = "'out'";
|
// ht["Palno"] = "'" + dt.Rows[i]["Palno"].ToString() + "'";
|
// ht["OldAddre"] = "'" + dt.Rows[i]["Addre"].ToString() + "'";
|
// ht["CMDStatu"] = "0";
|
// ht["CreateUser"] = "'" + CreateUser + "'";
|
// int outadd = DataFactory.SqlDataBase().InsertByHashtableNullParam("WH_CMD", ht);
|
|
// }
|
|
// }//是外层则直接出库下发指令
|
// else
|
// {
|
// Hashtable ht = new Hashtable();
|
// ht["TaskID"] = "'" + OrdNo[0] + "'";
|
// ht["CMDType"] = "'out'";
|
// ht["Palno"] = "'"+dt.Rows[i]["Palno"].ToString()+"'";
|
// ht["OldAddre"] = "'" + dt.Rows[i]["Addre"].ToString() + "'";
|
// ht["CMDStatu"] = "0";
|
// ht["CreateUser"] = "'" + CreateUser + "'";
|
// int dd = DataFactory.SqlDataBase().InsertByHashtableNullParam("WH_CMD",ht);
|
// }
|
|
// //下发完指令更改单号状态为正在执行
|
// Hashtable htup = new Hashtable();
|
// htup["Statu"] = "'ER02'";
|
// string Ordno = "'Ordno'";
|
// string OrdNo1 = "'" + OrdNo[0] + "'";
|
|
// int _ret = DataFactory.SqlDataBase().UpdateByHashtable("Erp_Out", nameof(Ordno), OrdNo1, htup);
|
//}
|
#endregion
|
return true;
|
}
|
catch
|
{
|
return result;
|
}*/
|
#endregion
|
}
|
|
public DataSet GetPrintData(string OrdNo)
|
{
|
DataSet ds = new DataSet(); ;
|
try
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
strSql.Append(" Select * from View_ErpOut where ");
|
strSql.Append("OrdNo = @OrdNo ");
|
|
SqlParam[] para = new SqlParam[]
|
{
|
new SqlParam("@OrdNo", OrdNo),
|
};
|
|
DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(strSql, para, "Table1");
|
if (dt != null) ds.Tables.Add(dt);
|
|
strSql.Clear();
|
para = null;
|
strSql.Append($"SELECT * FROM [dbo].[View_ErpOutDetail] WHERE OrdNo='{OrdNo}'");
|
DataTable dt2 = DataFactory.SqlDataBase().GetDataTableBySQL(strSql, para, "Table2");
|
if (dt2 != null) ds.Tables.Add(dt2);
|
|
//DALErpOutDetail purDetail = new DALErpOutDetail();
|
//DataTable dts = purDetail.GetPrintData(OrdNo);
|
//if (dts != null) ds.Tables.Add(dts);
|
|
return ds;
|
}
|
catch
|
{
|
return null;
|
}
|
}
|
///<summary>
|
///将DataTable中数据写入数据库中
|
///
|
/// </summary>
|
public static string ImportExcel(DataTable dt, string CreateUser)
|
{
|
int ret = 0;
|
if (dt == null || dt.Rows.Count == 0)
|
{
|
return "Excel无内容";
|
}
|
|
//获取要插入列的名字(为动态,由Excel列数决定)
|
string colNames = "";
|
|
//循环获取列名并与数据库字段名修改一致
|
for (int i = 0; i < dt.Columns.Count; i++)
|
{
|
if (dt.Columns[i].ColumnName.Equals("单号") || dt.Columns[i].ColumnName.Equals("生产令号") || dt.Columns[i].ColumnName.Equals("物料编码") ||
|
dt.Columns[i].ColumnName.Equals("发货数量") || dt.Columns[i].ColumnName.Equals("领料人") ||
|
dt.Columns[i].ColumnName.Equals("合格证") || dt.Columns[i].ColumnName.Equals("备注"))
|
{
|
if (dt.Columns[i].ColumnName.Equals("单号"))
|
{
|
dt.Columns[i].ColumnName = "OrdNo";
|
}
|
if (dt.Columns[i].ColumnName.Equals("生产令号"))
|
{
|
dt.Columns[i].ColumnName = "Ling_No";
|
}
|
if (dt.Columns[i].ColumnName.Equals("物料编码"))
|
{
|
dt.Columns[i].ColumnName = "MatNo";
|
}
|
|
if (dt.Columns[i].ColumnName.Equals("发货数量"))
|
{
|
dt.Columns[i].ColumnName = "CurQuant";
|
}
|
if (dt.Columns[i].ColumnName.Equals("合格证"))
|
{
|
dt.Columns[i].ColumnName = "Certificate";
|
}
|
if (dt.Columns[i].ColumnName.Equals("备注"))
|
{
|
dt.Columns[i].ColumnName = "Demo";
|
}
|
if (dt.Columns[i].ColumnName.Equals("领料人"))
|
{
|
dt.Columns[i].ColumnName = "Lever";
|
}
|
|
}
|
else
|
{
|
//删除多余的列
|
dt.Columns.Remove(dt.Columns[i]);
|
i--;
|
}
|
|
}
|
int ordno = 0;
|
//判断出库单单号是否已经存在
|
for (int i = 0; i < dt.Rows.Count; i++)
|
{
|
StringBuilder hql = new StringBuilder();
|
hql.Append("select * from Erp_Out where Ordno = '" + dt.Rows[i]["OrdNo"].ToString() + "'");
|
DataTable dd = DataFactory.SqlDataBase().GetDataTableBySQL(hql);
|
if (dd.Rows.Count > 0)
|
{
|
ordno = 1;
|
}
|
}
|
if (ordno == 1)
|
{
|
return "已有出库单号存在,请核实后重新导入";
|
}
|
int number = 0;
|
int count = 0;
|
string MatNoName = "";
|
string QuantName = "";
|
|
//第一个循环,遍历每一行
|
for (int i = 0; i < dt.Rows.Count; i++)
|
{
|
|
int sum = 0;
|
StringBuilder hql = new StringBuilder();
|
hql.Append("select Quant,MatNo,Addre,Palno,Tu_No,Ye_No from log_Store where MatNo = '" + dt.Rows[i]["MatNo"].ToString() + "' and Ling_No='" + dt.Rows[i]["Ling_No"].ToString() + "'");
|
//if (dt.Rows[i]["Certificate"].ToString() != "")
|
//{
|
// hql.Append(" and Certificate='" + dt.Rows[i]["Certificate"].ToString() + "'");
|
//}
|
|
DataTable dd = DataFactory.SqlDataBase().GetDataTableBySQL(hql);
|
//库存是否有此物料
|
if (dd.Rows.Count > 0)
|
{
|
//库存该物料数量总和
|
for (int e = 0; e < dd.Rows.Count; e++)
|
{
|
count += dd.Rows[e]["Quant"].ToInt();
|
}
|
//库存该物料数量是否足够出库数量
|
if (count > dt.Rows[i]["CurQuant"].ToInt())
|
{
|
for (int q = 0; q < dd.Rows.Count; q++)
|
{
|
//如果有一条库存数量满足生成出库单则跳出循环
|
if (dd.Rows[q]["Quant"].ToInt() >= dt.Rows[i]["CurQuant"].ToInt())
|
{
|
StringBuilder sqls = new StringBuilder();
|
sqls.Append("insert into ErpOutDetail(OrdNo,MatNo,Palno,Addre,CurQuant,Demo,Lever,Ling_No,Tu_No,Ye_No,Certificate) " +
|
"values('" + dt.Rows[i]["OrdNo"].ToString() + "','" + dt.Rows[i]["MatNo"].ToString() + "','" + dd.Rows[q]["Palno"].ToString() + "','" + dd.Rows[q]["Addre"].ToString() + "'," +
|
"'" + dt.Rows[i]["CurQuant"].ToString() + "','" + dt.Rows[i]["Demo"].ToString() + "','" + dt.Rows[i]["Lever"].ToString() + "','" + dt.Rows[i]["Ling_No"].ToString() + "'," +
|
"'" + dd.Rows[q]["Tu_No"].ToString() + "','" + dd.Rows[q]["Ye_No"].ToString() + "','" + dt.Rows[i]["Certificate"].ToString() + "')");
|
ret = DataFactory.SqlDataBase().ExecuteBySql(sqls);
|
sum = 1;
|
|
break;
|
}
|
}
|
//库存单个托盘不满足出库数量则相加生成出库单
|
if (sum == 0)
|
{
|
for (int q = 0; q < dd.Rows.Count; q++)
|
{
|
//库存每个托盘不满足物料出库的数量相加
|
number += dd.Rows[q]["Quant"].ToInt();
|
StringBuilder sqls = new StringBuilder();
|
sqls.Append("insert into ErpOutDetail(OrdNo,MatNo,Palno,Addre,CurQuant,Demo,Lever,Ling_No,Tu_No,Ye_No,Certificate) " +
|
"values('" + dt.Rows[i]["OrdNo"].ToString() + "','" + dt.Rows[i]["MatNo"].ToString() + "','" + dd.Rows[q]["Palno"].ToString() + "','" + dd.Rows[q]["Addre"].ToString() + "'," +
|
"'" + dt.Rows[i]["CurQuant"].ToString() + "','" + dt.Rows[i]["Demo"].ToString() + "','" + dt.Rows[i]["Lever"].ToString() + "','" + dt.Rows[i]["Ling_No"].ToString() + "'" +
|
"'" + dd.Rows[q]["Tu_No"].ToString() + "','" + dd.Rows[q]["Ye_No"].ToString() + "','" + dt.Rows[i]["Certificate"].ToString() + "')");
|
ret = DataFactory.SqlDataBase().ExecuteBySql(sqls);
|
sum = 1;
|
//库存满足生成出库单
|
if (number >= dt.Rows[i]["Quant"].ToInt())
|
{
|
break;
|
}
|
}
|
}
|
}
|
else
|
{
|
//库存数量不够则提示
|
QuantName += dt.Rows[i]["MatNo"].ToString() + ',';
|
}
|
}
|
else
|
{
|
//库存无此物料则提示
|
MatNoName += dt.Rows[i]["MatNo"].ToString() + ',';
|
}
|
if (sum == 1)
|
{
|
StringBuilder sql = new StringBuilder();
|
sql.Append("select Ordno from Erp_Out where Ordno='" + dt.Rows[i]["Ordno"].ToString() + "'");
|
DataTable outordon = DataFactory.SqlDataBase().GetDataTableBySQL(sql);
|
if (outordon.Rows.Count <= 0)
|
{
|
sql.Clear();
|
sql.Append("insert into Erp_Out(Ordno,CreateTime,CreateUser,IsDel,Statu,OrdType) values('" + dt.Rows[i]["Ordno"].ToString() + "'," +
|
"GETDATE(),'" + CreateUser + "',0,'01','1')");
|
ret = DataFactory.SqlDataBase().ExecuteBySql(sql);
|
}
|
|
}
|
|
}
|
try
|
{
|
|
if (MatNoName != "" && QuantName != "")
|
{
|
return "该物料" + MatNoName + "库存无法找到。该物料" + QuantName + "库存数量不足。其余物料导入成功!";
|
}
|
if (MatNoName != "")
|
{
|
return "该物料" + MatNoName + "库存无法找到。其余物料导入成功!";
|
}
|
if (QuantName != "")
|
{
|
return "该物料" + QuantName + "库存数量不足。其余物料导入成功!";
|
}
|
}
|
catch (Exception e)
|
{
|
return "导入失败,请检查匹配";
|
}
|
|
return "导入成功";
|
throw new NotImplementedException();
|
}
|
}
|
}
|