From 4bc6892bd4d64fa8ec66a2a81c90776e9c16d956 Mon Sep 17 00:00:00 2001 From: TML <1448969505@qq.com> Date: Tue, 2 Mar 2021 16:15:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=8C=E7=BB=B4=E8=AE=A2=E5=8D=95=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E6=B7=BB=E5=8A=A0=EF=BC=8Ccontrol=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/SCP_PO_CONTROLLER.cs | 226 ++++++++++- SCP/SCP.csproj | 16 + SCP/Views/富维冲插件/SCP_PO_EXTEND.aspx | 206 ++++++++++ .../富维冲插件/SCP_PO_EXTEND.aspx.cs | 310 ++++++++++++++ .../SCP_PO_EXTEND.aspx.designer.cs | 377 ++++++++++++++++++ .../富维冲插件/SCP_PO_EXTEND_DETAIL.aspx | 43 ++ .../SCP_PO_EXTEND_DETAIL.aspx.cs | 35 ++ .../SCP_PO_EXTEND_DETAIL.aspx.designer.cs | 143 +++++++ 8 files changed, 1345 insertions(+), 11 deletions(-) create mode 100644 SCP/Views/富维冲插件/SCP_PO_EXTEND.aspx create mode 100644 SCP/Views/富维冲插件/SCP_PO_EXTEND.aspx.cs create mode 100644 SCP/Views/富维冲插件/SCP_PO_EXTEND.aspx.designer.cs create mode 100644 SCP/Views/富维冲插件/SCP_PO_EXTEND_DETAIL.aspx create mode 100644 SCP/Views/富维冲插件/SCP_PO_EXTEND_DETAIL.aspx.cs create mode 100644 SCP/Views/富维冲插件/SCP_PO_EXTEND_DETAIL.aspx.designer.cs diff --git a/Controller/SCP_PO_CONTROLLER.cs b/Controller/SCP_PO_CONTROLLER.cs index 4db65b5..f863109 100644 --- a/Controller/SCP_PO_CONTROLLER.cs +++ b/Controller/SCP_PO_CONTROLLER.cs @@ -729,6 +729,7 @@ namespace CK.SCP.Controller _ask.Site = site; _ask.ReceivedPort = "";//交货口 _ask.State = (int)AskState.New; + // _ask.State = (int)AskState.Release; _ask.Remark = _entity.备注; _ask.ModType = (int)p_modtype; _ask.ErpBillNum = _po.PoBillNum; @@ -883,7 +884,205 @@ namespace CK.SCP.Controller return _ret; } + public static ResultObject Save_EXCEL_PO_MOD1(List p_order_list, string site, string p_creator, DateTime p_time, string subsite, string p_chineseName, string p_buyerPhone,string CreateTime,string EN,string EndTime,string PartCode,string PoBillNum,string Remark, string Time,string VendId,string PoUnit) + { + ResultObject _ret = new ResultObject(); + try + { + + using (ScpEntities db = EntitiesFactory.CreateScpInstance()) + { + int _num = 1; + var _lst = p_order_list; + string _polist = ""; + var OrderList = _lst.GroupBy(p => PoBillNum).ToList(); + OrderList.ForEach((p) => + { + var list = p.ToList(); + if (list.Count>0) + { + TB_PO _po = new TB_PO(); + _po.GUID = Guid.NewGuid(); + _po.PoBillNum = SCP_BILLCODE_CONTROLLER.MakePoNum(_num); + _po.State = (int)PoState.Open; + _po.Site = site; + _po.SubSite = subsite; + _po.VendId = VendId; + _po.ErpBillNum = _po.PoBillNum; + _po.ModType = 2; + _po.Contacter = p_chineseName;// _entity.联系人; + _po.Buyer = p_chineseName;// _entity.联系人; + _po.BuyerPhone = p_buyerPhone; + _po.Site = site; + _po.Remark = Remark; + _po.IsDeleted = false; + _po.CreateTime = DateTime.Parse(CreateTime); + _po.CreateUser = p_creator; + _po.BeginTime = DateTime.Parse(EndTime); + _po.EndTime = DateTime.Parse(Time); + db.TB_PO.AddOrUpdate(_po); + TB_ASK _ask = new TB_ASK(); + _ask.AskBillNum = SCP_BILLCODE_CONTROLLER.MakeASKCodeByNum(_num); + _ask.GUID = Guid.NewGuid(); + _ask.PoBillNum = _po.PoBillNum; + _ask.VendId = VendId; + _ask.IsDeleted = false; + _ask.CreateTime = DateTime.Now; + _ask.CreateUser = p_creator; + _ask.Site = site; + _ask.ReceivedPort = "";//交货口 + _ask.State = (int)AskState.Release; + _ask.Remark = Remark; + _ask.ModType = 2; + _ask.ErpBillNum = _po.PoBillNum; + _ask.BeginTime = p_time; + _ask.EndTime = DateTime.Parse(EndTime); + _ask.Buyer = p_chineseName; + _ask.BuyerPhone = p_buyerPhone; + _ask.SubSite = subsite; + db.TB_ASK.Add(_ask); + int _number = 1; + list.ForEach((itm) => + { + TB_PO_DETAIL _PO_Detail = new TB_PO_DETAIL(); + _PO_Detail.GUID = Guid.NewGuid(); + _PO_Detail.PartCode = PartCode; + _PO_Detail.PoLine = _number; + _PO_Detail.PoBillNum = _po.PoBillNum; + _PO_Detail.State = (int)PoState.Open; + _PO_Detail.Site = site; + _PO_Detail.SubSite = subsite; + _PO_Detail.Currency = "CNY"; + _PO_Detail.PoUnit = PoUnit; + _PO_Detail.CreateTime = DateTime.Parse(CreateTime); + _PO_Detail.CreateUser = p_creator; + _PO_Detail.BeginTime = string.IsNullOrEmpty(CreateTime) ? DateTime.Now : DateTime.Parse(CreateTime); + _PO_Detail.EndTime = string.IsNullOrEmpty(EndTime) ? DateTime.Now.AddYears(30) : DateTime.Parse(EndTime); + _PO_Detail.PlanQty = decimal.Parse(EN); + _PO_Detail.IsDeleted = false; + _PO_Detail.LocUnit = PoUnit; + _PO_Detail.PoUnit = PoUnit; + _PO_Detail.UnConv = 1; + //_PO_Detail.Price = string.IsNullOrEmpty(itm.单价) ? 0 : decimal.Parse(itm.单价); + _PO_Detail.TempQty = decimal.Parse(EN); + TB_ASK_DETAIL _tDetail = new TB_ASK_DETAIL(); + _tDetail.Remark = Remark; + _tDetail.PoBillNum = _po.PoBillNum; + _tDetail.AskBillNum = _ask.AskBillNum; + _tDetail.PoLine = _number; + _tDetail.PoUnit = PoUnit; + _tDetail.CreateTime = DateTime.Now; + _tDetail.CreateUser = p_creator; + _tDetail.PartCode = PartCode; + _tDetail.ReceivedPort = ""; + _tDetail.BeginTime = p_time; + _tDetail.EndTime = Convert.ToDateTime(EndTime); + _tDetail.TempQty = 0; + _tDetail.AskQty = Decimal.Parse(EN); + _tDetail.IsDeleted = false; + _tDetail.LocUnit = PoUnit; + _tDetail.UnConv = 1; + _tDetail.State = (int)PoState.Open; + _tDetail.SubSite = subsite; + _tDetail.Site = site; + //_tDetail.Price = Decimal.Parse(itm.单价); + _tDetail.GUID = Guid.NewGuid(); + _tDetail.Currency = "CNY"; + db.TB_ASK_DETAIL.Add(_tDetail); + db.TB_PO_DETAIL.AddOrUpdate(_PO_Detail); + //_number++; + }); + } + else + { + _ret.MessageList.Add("订单信息输入有误"); + return; + } + + } + ); + + if (_ret.MessageList.Count == 0) + { + int state = db.SaveChanges(); + if (state != -1) + { + _ret.State = ReturnStatus.Succeed; + _ret.Result = true; + _ret.Message = _polist; + } + else + { + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + } + } + else + { + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + } + } + } + catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常 + { + var sb = new StringBuilder(); + + foreach (var error in dbEx.EntityValidationErrors.ToList()) + { + error.ValidationErrors.ToList().ForEach(i => + { + sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage); + }); + } + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.ErrorList.Add(dbEx); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_PO_MOD", sb.ToString()); + throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString()); + } + catch (OptimisticConcurrencyException ex)//并发冲突异常 + { + + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_PO_MOD", ex.ToString()); + throw new ScpException(ResultCode.Exception, "9999", ex.ToString()); + } + catch (ScpException ex) + { + + + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_PO_MOD", ex.ToString()); + + if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException)) + { + var inner = (UpdateException)ex.InnerException; + + + throw new ScpException(ResultCode.Exception, "0000", ex.ToString()); + } + else + { + if (ex.InnerException != null) throw ex.InnerException; + } + } + catch (Exception e) + { + _ret.State = ReturnStatus.Failed; + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_PO_MOD", e.Message); + _ret.Result = false; + _ret.ErrorList.Add(e); + throw e; + } + return _ret; + + } public static ResultObject Check_EXCEL_PO_MOD(List p_order_list, BillModType p_modtype, string site, string subsite) { ResultObject _ret = new ResultObject(); @@ -1176,6 +1375,11 @@ namespace CK.SCP.Controller } else { + var ls = db.TA_VENDER.SingleOrDefault(p => p.VendId == p_excel.供应商编号); + if (ls == null) + { + ErrorList.Add(string.Format("订单编号【{1}】零件名称【{0}】的供应商编号不存在", p_excel.零件号, p_excel.订单编号)); + } decimal a = decimal.Parse(p_excel.数量); if (a <= 0) { @@ -1197,17 +1401,17 @@ namespace CK.SCP.Controller ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】的订单截止日期必须大于等于2049年!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); } } - var checkcount = db.TB_PRICE.Where(p => p.PartCode == p_excel.零件号 && p.Site == site&& p.VendId == p_excel.供应商编号 && p.StartTime <= DateTime.Now && DateTime.Now <= p.EndTime).ToList(); - if (checkcount.Count == 0) - { - ErrorList.Add(string.Format("零件名称【{0}】供应编码【{1}】价格表没有维护信息!", p_excel.零件号, p_excel.供应商编号)); - } - else - { - p_excel.单价 = checkcount[0].Amt.ToString(); - p_excel.单位 = checkcount[0].Unit; - p_excel.币种 = checkcount[0].Curr; - } + //var checkcount = db.TB_PRICE.Where(p => p.PartCode == p_excel.零件号 && p.Site == site&& p.VendId == p_excel.供应商编号 && p.StartTime <= DateTime.Now && DateTime.Now <= p.EndTime).ToList(); + //if (checkcount.Count == 0) + //{ + // ErrorList.Add(string.Format("零件名称【{0}】供应编码【{1}】价格表没有维护信息!", p_excel.零件号, p_excel.供应商编号)); + //} + //else + //{ + // p_excel.单价 = checkcount[0].Amt.ToString(); + // p_excel.单位 = checkcount[0].Unit; + // p_excel.币种 = checkcount[0].Curr; + //} //if (!Regex.IsMatch(p_excel.税率, "^[0-9]{1,2}$")) //{ // ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】税率最大2位整数!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); diff --git a/SCP/SCP.csproj b/SCP/SCP.csproj index 3af78e8..d3441db 100644 --- a/SCP/SCP.csproj +++ b/SCP/SCP.csproj @@ -4537,6 +4537,8 @@ + + @@ -5847,6 +5849,20 @@ SCP_RECEIVE_DETAIL.aspx + + SCP_PO_EXTEND.aspx + ASPXCodeBehind + + + SCP_PO_EXTEND.aspx + + + SCP_PO_EXTEND_DETAIL.aspx + ASPXCodeBehind + + + SCP_PO_EXTEND_DETAIL.aspx + SCP_ASK.aspx ASPXCodeBehind diff --git a/SCP/Views/富维冲插件/SCP_PO_EXTEND.aspx b/SCP/Views/富维冲插件/SCP_PO_EXTEND.aspx new file mode 100644 index 0000000..1d0b440 --- /dev/null +++ b/SCP/Views/富维冲插件/SCP_PO_EXTEND.aspx @@ -0,0 +1,206 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SCP_PO_EXTEND.aspx.cs" Inherits="SCP.Views.富维冲插件.SCP_PO_EXTEND" %> + + + + + + + + <%-- + --%> + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +