diff --git a/Gatedge.K3.Pilot.PlugIn/BOSPlugIn/AR_SalesVATInvoice/ServicePlugIn/AfterSave.cs b/Gatedge.K3.Pilot.PlugIn/BOSPlugIn/AR_SalesVATInvoice/ServicePlugIn/AfterSave.cs deleted file mode 100644 index 5bdf242..0000000 --- a/Gatedge.K3.Pilot.PlugIn/BOSPlugIn/AR_SalesVATInvoice/ServicePlugIn/AfterSave.cs +++ /dev/null @@ -1,94 +0,0 @@ -using Kingdee.BOS; -using Kingdee.BOS.Core.DynamicForm.PlugIn; -using Kingdee.BOS.Core.DynamicForm.PlugIn.Args; -using Kingdee.BOS.Log; -using Kingdee.BOS.Orm; -using Kingdee.BOS.Orm.DataEntity; -using Kingdee.BOS.ServiceHelper; -using Kingdee.BOS.Util; -using System; -using System.ComponentModel; -using System.Dynamic; - -namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.AR_SalesVATInvoice.ServicePlugIn -{ - [HotUpdate, Description("销售增值税专用发票_保存后事件")] - public class AfterSave : AbstractOperationServicePlugIn - { - public override void OnPreparePropertys(PreparePropertysEventArgs e) - { - base.OnPreparePropertys(e); - // 根据日志中的实际实体属性名来添加 - e.FieldKeys.Add("FIDD"); - e.FieldKeys.Add("FSEQQ"); - e.FieldKeys.Add("SRCBILLTYPEID"); // 实体属性名(没有F前缀) - e.FieldKeys.Add("SRCBILLNO"); // 实体属性名(没有F前缀) - e.FieldKeys.Add("SEQ"); - e.FieldKeys.Add("BILLNO"); // 单据编号(主表字段) - } - - - public override void EndOperationTransaction(EndOperationTransactionArgs e) - { - base.EndOperationTransaction(e); - foreach (var dataEntity in e.DataEntitys) - { - var billObj = dataEntity as DynamicObject; - if (billObj == null) - continue; - - // 获取单据体 - var entrys = billObj["SALESICENTRY"] as DynamicObjectCollection; - if (entrys == null || entrys.Count == 0) - continue; - - foreach (var entry in entrys) - { - // 使用 Id 获取主键值 - var entryId = Convert.ToInt64(entry.GetPrimaryKeyValue()); - var fidd = entry["FIDD"]; - var fiddValue = fidd == null ? 0 : Convert.ToInt64(fidd); - - if (fiddValue > 0) - { - // FIDD > 0 时,判断是否需要回写 - var srcBillNo = entry["SRCBILLNO"]?.ToString() ?? ""; - - // 判断条件:FIDD != 当前行ID 且 源单编号为空 - if (fiddValue != entryId && string.IsNullOrWhiteSpace(srcBillNo)) - { - // 从当前单据主表获取单据编号(实体属性名:BILLNO) - var billNo = billObj["BILLNO"]?.ToString() ?? ""; - // 固定源单类型为"销售增值税专用发票" - var srcBillType = "IV_SALESIC"; - - // 回写当前单据体:源单类型、源单编号 - // 这里使用数据库字段名(带F前缀) - var updateSql = $@"/*dialect*/ -UPDATE T_IV_SALESICENTRY -SET FSRCBILLTYPEID = '{srcBillType.Replace("'", "''")}', - FSRCBILLNO = '{billNo.Replace("'", "''")}' -WHERE FENTRYID = {entryId}"; - Logger.Error("销售增值税专用发票", updateSql, new Exception()); - Logger.Error("销售增值税专用发票", "78", new Exception()); - DBServiceHelper.Execute(this.Context, updateSql); - } - } - else - { - // FIDD <= 0 时,把当前行FID赋值给FIDD,同时把FSEQ赋值给FSEQQ - var seq = entry["SEQ"]?.ToString() ?? "0"; - var updateSql = $@"/*dialect*/ -UPDATE T_IV_SALESICENTRY -SET FIDD = {entryId}, - FSEQQ = '{seq.Replace("'", "''")}' -WHERE FENTRYID = {entryId}"; - Logger.Error("销售增值税专用发票", updateSql, new Exception()); - Logger.Error("销售增值税专用发票", "78", new Exception()); - DBServiceHelper.Execute(this.Context, updateSql); - } - } - } - } - } -} \ No newline at end of file diff --git a/Gatedge.K3.Pilot.PlugIn/Gatedge.K3.Pilot.PlugIn.csproj b/Gatedge.K3.Pilot.PlugIn/Gatedge.K3.Pilot.PlugIn.csproj index cc432a0..e21859f 100644 --- a/Gatedge.K3.Pilot.PlugIn/Gatedge.K3.Pilot.PlugIn.csproj +++ b/Gatedge.K3.Pilot.PlugIn/Gatedge.K3.Pilot.PlugIn.csproj @@ -89,7 +89,6 @@ - @@ -106,6 +105,7 @@ +