判断单据或分录是否下推而来
一、说明
通过判断关联数据包是否存在来确定是否下推而来
判断整张单据是否下推而来,只要判断存在任何一个关联数据包即可
判断分录是否下推而来,需要判断此分录下的关联数据包是否存在
二、判断代码类
使用了两种判断方式,一种调用封装好的接口,一种直接判断关联数据包
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Kingdee.BOS.Core.Metadata; using Kingdee.BOS.Core.Metadata.EntityElement; using Kingdee.BOS.Core.DependencyRules; using Kingdee.BOS.ServiceHelper; using Kingdee.BOS.Orm.DataEntity; using Kingdee.BOS.Util; namespace Kingdee.BOS.TestPlugIn.Common { public class BillLinkUtil { /// <summary> /// 单据是否下推而来 /// </summary> /// <param name="ctx"></param> /// <param name="bInfo"></param> /// <param name="dynObj">整单数据包</param> /// <returns></returns> public bool BillIsDraw(Context ctx,BusinessInfo bInfo, DynamicObject dynObj) { var linkEntity = bInfo.GetForm().LinkSet.LinkEntitys[0]; var parentEntity = bInfo.GetEntity(linkEntity.ParentEntityKey); DynamicObject parentObj = null;//关联主实体数据包 //关联主实体是单据头,绝大部分关联主实体为单据体,少部分为单据头 if (parentEntity is HeadEntity) { parentObj = dynObj; } else { var entryDynObjs = parentEntity.DynamicProperty.GetValue(dynObj) as DynamicObjectCollection; parentObj = entryDynObjs[0]; } var isLink = this.IsLink(linkEntity, parentObj); //或通过调用接口判断 var isLink2 = this.IsLinkByInterface(ctx,bInfo, parentEntity, parentObj); return isLink; } /// <summary> /// 判断每行是否下推而来 /// </summary> /// <param name="ctx"></param> /// <param name="bInfo"></param> /// <param name="dynObj"></param> public void EntryIsDraw(Context ctx, BusinessInfo bInfo, DynamicObject dynObj) { var linkEntity = bInfo.GetForm().LinkSet.LinkEntitys[0]; var parentEntity = bInfo.GetEntity(linkEntity.ParentEntityKey); var entryDynObjs = parentEntity.DynamicProperty.GetValue(dynObj) as DynamicObjectCollection; //判断每行分录是否下推而来 foreach (var entryObj in entryDynObjs) { var isLink = this.IsLink(linkEntity, entryObj); //或通过调用接口判断 var isLink2 = this.IsLinkByInterface(ctx,bInfo, parentEntity, entryObj); } } /// <summary> /// 调用接口判断是否关联 /// </summary> /// <param name="ctx"></param> /// <param name="bInfo"></param> /// <param name="parentEntity">关联主实体</param> /// <param name="parentObj">关联主实体对应的主数据包</param> /// <returns></returns> public bool IsLinkByInterface(Context ctx, BusinessInfo bInfo, Entity parentEntity, DynamicObject parentObj) { var dynamicRow = new BOSDynamicRow(parentObj, parentEntity.Key, bInfo); var isDraw = ConvertServiceHelper.IsDraw(ctx, bInfo, dynamicRow); return isDraw; } /// <summary> /// 是否关联 /// </summary> /// <param name="linkEntity"></param> /// <param name="parentObj">关联主实体对应的主数据包</param> /// <returns></returns> private bool IsLink(LinkEntity linkEntity, DynamicObject parentObj) { var linkDynObjs = parentObj[linkEntity.Key] as DynamicObjectCollection; if (linkDynObjs != null && linkDynObjs.Count > 0) { var sId = Convert.ToString(linkDynObjs[0]["SId"]); if (!(sId.IsNullOrEmptyOrWhiteSpace() || sId == "0")) { return true; } } return false; } } }
三、插件中调用代码
表单插件调用代码
BillLinkUtil linkUtil = new BillLinkUtil(); linkUtil.BillIsDraw(this.Context,this.View.BillBusinessInfo, this.Model.DataObject); linkUtil.EntryIsDraw(this.Context, this.View.BillBusinessInfo, this.Model.DataObject);
2. 操作插件调用代码
BillLinkUtil linkUtil = new BillLinkUtil(); linkUtil.BillIsDraw(this.Context,this.BusinessInfo, e.DataEntitys[0]); linkUtil.EntryIsDraw(this.Context,this.BusinessInfo, e.DataEntitys[0])
判断单据或分录是否下推而来
一、说明通过判断关联数据包是否存在来确定是否下推而来判断整张单据是否下推而来,只要判断存在任何一个关联数据包即可判断分录是否下推而...
点击下载文档
本文2024-09-23 03:37:42发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-160056.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章