You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
using ICSSoft.ERPWMS.Entity; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace ICSSoft.ERPWMS.SQL { public class ReplyPOArrivalDate { public static Result Update(List<ReplyPOArrivalDateEntity> entityList) { Result res = new Result(); try { string jsonstr = JsonConvert.SerializeObject(entityList); Log.WriteLogFile(jsonstr, "回复预计到货日期日志"); StringBuilder sb = new StringBuilder();//接口返回Message
foreach (ReplyPOArrivalDateEntity entity in entityList) { try { if (string.IsNullOrWhiteSpace(entity.POCode)) { throw new Exception("存在订单号为空!"); }
if (entity.Sequence == null) { throw new Exception("订单行号为空!"); }
if (entity.SubSequence == null) { throw new Exception("SRM拆行为空!"); }
if (entity.Quantity == null) { throw new Exception("预计到货数量为空!"); }
if (string.IsNullOrWhiteSpace(entity.dReplyArriveDate)) { throw new Exception("预计到货日期为空!"); }
if (string.IsNullOrWhiteSpace(entity.WorkPoint)) { throw new Exception("站点参数为空!"); } string WorkPoint = ICSHelper.GetConnectStringTest(entity.WorkPoint);
if (WorkPoint == "NotExit") { throw new Exception("站点编码不存在!"); } //验证采购订单是否存在
string sqlCheck = "Select cPOID from {0}.dbo.PO_Pomain where cPOID ='{1}'"; sqlCheck = string.Format(sqlCheck, WorkPoint, entity.POCode); DataTable dtCheck = ICSHelper.GetDataTableERP(sqlCheck); if (dtCheck.Rows.Count<1) { //验证委外订单是否存在
sqlCheck = "Select cCode From {0}.dbo.OM_MOMain Where cCode='{1}'"; sqlCheck = String.Format(sqlCheck,WorkPoint, entity.POCode); dtCheck = ICSHelper.GetDataTableERP(sqlCheck); if (dtCheck!=null&&dtCheck.Rows.Count>0) { //验证委外订单明细是否存在
string sqldetail = "Select MODetailsID from {0}.dbo.OM_MODetails where MOID =(Select MOID from {0}.dbo.OM_MOMain where cCode ='{1}') and ivouchrowno ='{2}'"; sqldetail = string.Format(sqldetail, WorkPoint, entity.POCode, entity.Sequence); DataTable dtDetail = ICSHelper.GetDataTableERP(sqldetail); if (dtDetail != null && dtDetail.Rows.Count > 0) { string Total = entity.SubSequence.ToString() + ":" + entity.Quantity.ToString() + "-[" + entity.dReplyArriveDate + "]"; string sql = @"Update {0}.dbo.OM_MODetails Set cdefine28 ='{1}' Where MODetailsID='{2}'"; sql = string.Format(sql, WorkPoint, Total, dtDetail.Rows[0]["MODetailsID"].ToString()); Log.WriteLogFile(sql, "回复预计到货日期SQL日志"); if (ICSHelper.ExecuteSqlERP(sql) < 1) { throw new Exception("更新委外订单预计到货日期失败!"); } } else { throw new Exception("委外订单明细不存在!"); } } else { throw new Exception("订单号不存在!"); } } else { //验证采购订单明细是否存在
string sqldetail = "Select ID from {0}.dbo.PO_Podetails where POID =(Select poid from {0}.dbo.PO_Pomain where cpoid ='{1}') and ivouchrowno ='{2}'"; sqldetail = string.Format(sqldetail, WorkPoint, entity.POCode, entity.Sequence); DataTable dtDetail = ICSHelper.GetDataTableERP(sqldetail); if (dtDetail != null && dtDetail.Rows.Count > 0) { string Total = entity.SubSequence.ToString() + ":" + entity.Quantity.ToString() + "-[" + entity.dReplyArriveDate + "]"; string sql = @"Update {0}.dbo.PO_Podetails Set cdefine28 ='{1}' Where ID='{2}'"; sql = string.Format(sql, WorkPoint, Total, dtDetail.Rows[0]["ID"].ToString()); Log.WriteLogFile(sql, "回复预计到货日期SQL日志"); if (ICSHelper.ExecuteSqlERP(sql) < 1) { throw new Exception("更新采购订单预计到货日期失败!"); } } else { throw new Exception("采购订单明细不存在!"); } } } catch (Exception ex) { sb.Append("执行报错,订单号为:" + entity.POCode + ",报错信息:" + ex.Message + "!!!"); continue; }
}
if (sb.Length > 0) { res.IsSuccess = false; res.Message = sb.ToString(); } else { res.IsSuccess = true; res.Message = "执行成功!"; } return res; } catch (Exception ex) { res.IsSuccess = false; res.Message = ex.Message; return res; } } } }
|