电脑桌面
添加蚂蚁七词文库到电脑桌面
安装后可以在桌面快捷访问

业务流.二开案例.调整下游单据的link实体实现关联和反写

来源:金蝶云社区作者:金蝶2024-09-234

业务流.二开案例.调整下游单据的link实体实现关联和反写

【场景】调整下游单据的link实体实现关联和反写 【二开案例】 (0)定义下游单据的关联实体配置,用作id存储关联关系的存放表 ![image.webp](/download/010076a99dd78bbb4f62b9f9a072b3ecbe86.webp) (1)定义转换规则 转换规则是必须的,因为关联关系中需要记录转换规则id ![image.webp](/download/01001d3d6d18854b45e3bb2dce25ec5dab52.webp) (2)插件代码,实现调整link并重新保存实现关联和反写 ![image.webp](/download/010024a23d1a45ce4f30b62c23ca51b75b4f.webp) ```csharp using Kingdee.BOS.Core.Bill.PlugIn; using Kingdee.BOS.Core.DynamicForm.PlugIn.Args; using Kingdee.BOS.Core.Metadata; using Kingdee.BOS.Core.Metadata.EntityElement; using Kingdee.BOS.Core.Metadata.FieldElement; using Kingdee.BOS.Core.SqlBuilder; using Kingdee.BOS.Orm.DataEntity; using Kingdee.BOS.Util; using System; using System.Collections.Generic; namespace DynamicFormPlugIn.WriteBack { [Kingdee.BOS.Util.HotUpdate] public class FormSamplePlugIn_ChangeLink : AbstractBillPlugIn { public override void BarItemClick(BarItemClickEventArgs e) { if (!string.Equals(e.BarItemKey, "BHR_tbButton", StringComparison.OrdinalIgnoreCase)) { return; } ChangeLink(); } private readonly string EntityKey = "FEntity"; private readonly string FieldKey = "F_BHR_LinkInfo"; private void ChangeLink() { Entity entity = this.View.BillBusinessInfo.GetEntity(EntityKey); DynamicObjectCollection objColl = this.Model.GetEntityDataObject(entity); if (objColl == null) return; bool hasChange = false; foreach(var entityRowObj in objColl) { string linkInfo = ObjectUtils.Object2String(entityRowObj[FieldKey]); if (linkInfo.IsNullOrEmptyOrWhiteSpace()) continue; hasChange = true; string[] info = linkInfo.Split(','); string srcBillNo = info[0];//源单编号 int seq = ObjectUtils.Object2Int(info[1]);//分录序号行 ChangeRowLink(entityRowObj, srcBillNo, seq); entityRowObj[FieldKey] = string.Empty; } //将更新的link信息保存到数据库,并计算单据的反写值 if (hasChange) { //如果没有界面就调用BusinessDataServiceHelper.Save this.View.Model.Save(); this.View.ShowMessage("根据自定义信息重新关联完成"); } } private void ChangeRowLink(DynamicObject rowObj, string srcbillNo, int seq) { const string srcFormId = "kc0c27c005bcc4df9a8172dff6c36f5c4";//关联源单实体 const string srcEntityKey = "FEntity";//关联的源单实体 const string srcBillNoKey = "FBillNo"; FormMetadata metaData = Kingdee.BOS.ServiceHelper.MetaDataServiceHelper.Load(this.Context, srcFormId) as FormMetadata; if (metaData == null) return; Field field = metaData.BusinessInfo.GetField(srcBillNoKey); Entity srcEntity = metaData.BusinessInfo.GetEntity(srcEntityKey); if (field == null || srcEntity == null) return; string entityIdKey = string.Concat(srcEntity.Key, "_", srcEntity.EntryPkFieldName); string seqKey = string.Concat(srcEntity.Key, "_", srcEntity.SeqFieldKey); //<1>根据单据编号和序号,获取到需要关联的单据内码 和 分录内码 QueryBuilderParemeter query = new Query

业务流.二开案例.调整下游单据的link实体实现关联和反写

【场景】调整下游单据的link实体实现关联和反写【二开案例】(0)定义下游单据的关联实体配置,用作id存储关联关系的存放表![image.webp](/do...
点击下载文档文档为doc格式

声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。如若本站内容侵犯了原著者的合法权益,可联系本站删除。

已经是第一篇
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息
QQ群
  • 答案:my7c点击这里加入QQ群
支持邮箱
微信
  • 微信