diff --git a/Pilot_KD_Parino/Pilot_KD_Parino.csproj b/Pilot_KD_Parino/Pilot_KD_Parino.csproj index da1d79e..fecf1ee 100644 --- a/Pilot_KD_Parino/Pilot_KD_Parino.csproj +++ b/Pilot_KD_Parino/Pilot_KD_Parino.csproj @@ -47,9 +47,9 @@ ..\..\..\派诺-裴豪\派诺功能\代码\Pilot_KD_Parino (2)\Pilot_KD_Parino\Pilot_KD_Parino\bin\Debug\BouncyCastle.Crypto.dll - + False - ..\..\..\派诺-裴豪\派诺功能\代码\Pilot_KD_Parino (2)\Pilot_KD_Parino\Pilot_KD_Parino\bin\Debug\Castle.Core.dll + bin\Debug\Castle.Core.dll False diff --git a/Pilot_KD_Parino/Sal_Order/SalDeliveryNoticeAudit.cs b/Pilot_KD_Parino/Sal_Order/SalDeliveryNoticeAudit.cs index 65bc24d..59257cd 100644 --- a/Pilot_KD_Parino/Sal_Order/SalDeliveryNoticeAudit.cs +++ b/Pilot_KD_Parino/Sal_Order/SalDeliveryNoticeAudit.cs @@ -1,4 +1,5 @@ -using Kingdee.BOS; +using Castle.Core.Internal; +using Kingdee.BOS; using Kingdee.BOS.App; using Kingdee.BOS.Contracts; using Kingdee.BOS.Core.DynamicForm; @@ -16,6 +17,7 @@ using Kingdee.BOS.ServiceHelper; using Kingdee.BOS.Util; using Pilot_KD_Parino.Common; using System; +using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Linq; @@ -28,6 +30,8 @@ namespace Pilot_KD_Parino.Sal_Order string ADDRESS = ""; string date = ""; string fid = "0"; + DynamicObject sheet = null; + public override void AfterExecuteOperationTransaction(AfterExecuteOperationTransaction e) { //throw new KDBusinessException("", "至少进来了"); @@ -35,10 +39,10 @@ namespace Pilot_KD_Parino.Sal_Order foreach (var rows in e.SelectedRows) { var Billobj = rows.DataEntity; - - //var sdsas = JsonHelper.ToJson(Billobj); - //Logger.Error("目标单据数据集合", sdsas, new Exception()); - + sheet = Billobj; + var sdsas = JsonHelper.ToJson(Billobj); + Logger.Error("目标单据数据集合", sdsas, new Exception()); + string id = Convert.ToString(Billobj["Id"]); fid = id; string addressSql = $@"/*dialect*/SELECT F_Shippingaddress, FDate FROM dbo.T_SAL_DELIVERYNOTICE WHERE fid={id}"; @@ -138,7 +142,7 @@ namespace Pilot_KD_Parino.Sal_Order } } - private IOperationResult Invoke(string source, string target, string tempFid, string sargetBillTypeId, ref int stockId) + private IOperationResult Invoke(string source, string target, string tempFid, string sargetBillTypeId,ref int stockId) { try { @@ -186,9 +190,58 @@ namespace Pilot_KD_Parino.Sal_Order if (date != "") { string addressSql = $@"/*dialect*/update T_SAL_DELIVERYNOTICE set FDate='{date}' WHERE fid={stocks3["Id"]}"; - + DBServiceHelper.ExecuteDynamicObject(this.Context, addressSql); } + + var itemList = sheet["SAL_DELIVERYNOTICEENTRY"] as DynamicObjectCollection; + var newItemlist = stocks3["SAL_DELIVERYNOTICEENTRY"] as DynamicObjectCollection; + Dictionary MaterialCode = new Dictionary(); + foreach (var item in itemList) + { + var Material = item["MaterialID"] as DynamicObject; + if (Material != null) + { + string code2 = (Material["Number"].ToString()); + decimal qty = decimal.Parse(item["Qty"].ToString()); + if (!MaterialCode.ContainsKey(code2)) + { + MaterialCode.Add(code2, qty); + } + else + MaterialCode[code2] = MaterialCode[code2] + qty; + } + } + + List deleteItem = new List(); + foreach (var item in newItemlist) + { + var Material = item["MaterialID"] as DynamicObject; + if (Material != null) + { + string code2 = (Material["Number"].ToString()); + decimal qty = decimal.Parse(item["Qty"].ToString()); + if (MaterialCode.ContainsKey(code2)) + { + if (MaterialCode[code2] != qty) + { + item["Qty"] = MaterialCode[code2]; + } + } + else + { + deleteItem.Add(item); + } + } + } + if (deleteItem.Count > 0) + { + deleteItem.ForEach(t => + { + newItemlist.Remove(t); + }); + saveResult = ServiceHelper.GetService().Save(this.Context, destFormMetadata.BusinessInfo, destObjs, OperateOption.Create()); + } } ////合并保存操作结果 diff --git a/Pilot_KD_Parino/bin/Debug/Castle.Core.dll b/Pilot_KD_Parino/bin/Debug/Castle.Core.dll index 24f4b2f..dfff9a5 100644 Binary files a/Pilot_KD_Parino/bin/Debug/Castle.Core.dll and b/Pilot_KD_Parino/bin/Debug/Castle.Core.dll differ