二开插件-单据转换携带子单据体

栏目:云星空知识作者:金蝶来源:金蝶云社区发布:2024-09-16浏览:1

二开插件-单据转换携带子单据体

``` /// <summary> /// 单据从源单到目标单已经转换完毕,输出最后的目标单数据包之前触发, /// 此时,目标单数据包已经构建完毕,不会再有变动了 /// </summary> /// <param name="e"></param> /// <remarks> /// 可以在此事件中,对目标单数据包进行最后的修订、补充 /// </remarks> public override void AfterConvert(AfterConvertEventArgs e) { base.AfterConvert(e); var headEntity = e.Result.FindByEntityKey("FBillHead"); foreach (var extendedDataEntity in headEntity) { //目标父单据体数据包 DynamicObjectCollection entryCollection = extendedDataEntity.DataEntity[tarEntityOrm] as DynamicObjectCollection; //源单单据体数据包 DynamicObjectCollection sourceObjCollection = sourceBill[srcEntityOrm] as DynamicObjectCollection; //目标单据体实体 Entity entity = e.TargetBusinessInfo.GetEntity(tarEntityId); //entryCollection.Clear(); int difCount = entryCollection.Count; if (sourceBill != null) { difCount -= sourceObjCollection.Count; } //从源单上获取每一条父单据体的子单据体集合,并赋值到目标单上对应的父单据体中 for (int i = 0; i < entryCollection.Count; i++) { var entityData = entryCollection[i]; int index = entryCollection.IndexOf(entityData); for (int k = 0; k < sourceObjCollection.Count; k++) { //获取源子单据体的数据包集合    DynamicObjectCollection sourceSubCollection = (sourceObjCollection[k] as DynamicObject)[srcSubEntityOrm] as DynamicObjectCollection; if (Convert.ToInt64(entityData["SrcEntryId"]) == Convert.ToInt64(sourceObjCollection[k]["Id"])) { #region // 目标子单据体的实体(标识) Entity FSubEntity = e.TargetBusinessInfo.GetEntity(tarSubEntityId1); DynamicObjectCollection subCollection = entityData[tarSubEntityOrm1] as DynamicObjectCollection; String[] SourceFeild = { "test1", "test2" }; String[] GoalFeild = { "test1", "test2" }; //创建一个目标单据体(包括父子单据体)            DynamicObjectCollection newRows = new DynamicObjectCollection(FSubEntity.DynamicObjectType, entityData); foreach (var sourceSubEntityData in sourceSubCollection) { //创建一个目标子单据体的数据包                        DynamicObject newRow = new DynamicObject(FSubEntity.DynamicObjectType); for (int m = 0; m < SourceFeild.Length; m++) { newRow[GoalFeild[m]] = sourceSubEntityData[SourceFeild[m]]; } newRows.Add(newRow); } if (subCollection == null) { subCollection = new DynamicObjectCollection(FSubEntity.DynamicObjectType, entityData); } else { subCollection.Clear(); } foreach (DynamicObject newRow in newRows) { subCollection.Add(newRow); } #endregion } } } } }

二开插件-单据转换携带子单据体

``` /// <summary> /// 单据从源单到目标单已经转换完毕,输出最后的目标单数据包之前触发, ...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息