如何控制单据头字段只反写一次
说明:
1. 单据反写规则的执行是按单据关联主实体数来执行的,主实体往往是单据体,所以在反写单据头执行了N次
2. 适应情况,反写规则为累加或累减模式,单据头字段反写单据头字段
反写插件代码:
using System; using System.Collections.Generic; using System.Linq; using System.ComponentModel; using Kingdee.BOS.Util; using Kingdee.BOS.Core.BusinessFlow.PlugIn; using Kingdee.BOS.Core.BusinessFlow.PlugIn.Args; using Kingdee.BOS.BusinessEntity.BusinessFlow; namespace Kingdee.BOS.TestPlugIn.Demo { [Description("限制单据头只反写一次")] [Kingdee.BOS.Util.HotUpdate] public class WriteBackHeadPlugIn : AbstractBusinessFlowServicePlugIn { //需要干预的反写规则 private bool _isNeedHandleRule = false; private bool _isFirstWriteBack = true; /// <summary> /// 反写前事件,每个反写规则走一次,得到需要干预反写规则 /// </summary> /// <param name="e"></param> public override void BeforeWriteBack(BeforeWriteBackEventArgs e) { this._isNeedHandleRule = false; this._isFirstWriteBack = true; var ruleName = e.Rule.Name.ToString(); if (ruleName.EqualsIgnoreCase("单据B反写单据A——单据头字段")) { this._isNeedHandleRule = true; } } /// <summary> /// /// 反写条目反写后事件,每一行都会走 /// /// </summary> /// /// <param name="e"></param> public override void AfterCommitAmount(AfterCommitAmountEventArgs e) { base.AfterCommitAmount(e); if (this._isNeedHandleRule) { //第一次反写不处理 if (this._isFirstWriteBack) { this._isFirstWriteBack = false; return; } //第二次操作时,把相应的反写数据扣减或加回去 if (this.OperationNumber.EqualsIgnoreCase("Save") || this.OperationNumber.EqualsIgnoreCase("Delete")|| (this.OperationNumber.EqualsIgnoreCase("Audit") || this.OperationNumber.EqualsIgnoreCase("UnAudit")) { var sField = e.SourceCommitField;//被反写字段 var currWBValue= (e.WriteBackSourceRow as WSRow<Id>).Val;//当前反写值 //反写后的值 var afterWBValue = Convert.ToDecimal(e.SourceDataObject[sField.PropertyName]); //累加模式,把反写值减掉 e.SourceDataObject[sField.PropertyName] = afterWBValue - currWBValue; //累减模式,把反写值加回去 //e.SourceDataObject[sField.PropertyName] = afterWBValue + currWBValue; } } } }
如何控制单据头字段只反写一次
说明: 1. 单据反写规则的执行是按单据关联主实体数来执行的,主实体往往是单据体,所以在反写单据头执行了N次 2. 适应情况,反写...
点击下载文档
上一篇:反写上游子单据体下一篇:【反写】--允许一次超额
本文2024-09-23 03:37:26发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-160035.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章