子单据体联动(二开)原创
金蝶云社区-HN_楊華
HN_楊華
7人赞赏了该文章 2,335次浏览 未经作者许可,禁止转载编辑于2020年08月04日 09:09:06

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

using Kingdee.BOS;
using Kingdee.BOS.Util;
using Kingdee.BOS.Core;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Core.Metadata.EntityElement;
using Kingdee.BOS.Orm.DataEntity;

namespace JDSample.FormPlugIn.DynamicForm
{
    /// <summary>
    /// 根据单据体行号获取子单据体数据集合
    /// </summary>
    /// <remarks>
    /// 背景说明:
    /// 需要在用户点击单据体单元格时(EntryCellFocued),获取子单据体数据集合;
    /// 通过this.Model.GetEntityData获取的单据体数据并不可靠。
    /// 需要通过参数中传入的行号,主动取单据体数据
    /// </remarks>
    [Description("根据单据体行号获取子单据体数据集合")]
    public class S150923GetSubEntityRowsEdit : AbstractDynamicFormPlugIn
    {
        /// <summary>
        /// 单据体单元格改变时触发此事件
        /// </summary>
        /// <param name="e"></param>
        public override void EntryCellFocued(EntryCellFocuedEventArgs e)
        {
            if (e.EntryKey.EqualsIgnoreCase("FEntity"))
            {// 点击单据体
                if (e.NewFieldKey.EqualsIgnoreCase("FQty"))
                {// 点击数量单元格
                    Entity entity = this.View.BillBusinessInfo.GetEntity("FEntity");
                    Entity subEntity = this.View.BillBusinessInfo.GetEntity("FSubEntity");

                    // 取单据体行集合
                    DynamicObjectCollection entityRows = entity.DynamicProperty.GetValue(this.Model.DataObject)
                                as DynamicObjectCollection;

                    // 取单据体当前行数据包
                    DynamicObject currRow = entityRows[e.NewRow];

                    // 取当前行的子单据体数据集合
                    DynamicObjectCollection subEntityRows = subEntity.DynamicProperty.GetValue(currRow)
                                as DynamicObjectCollection;

                    // TODO : 基于子单据体行数据集合,进行其他处理
                }
            }
        }
    }
}

赞 7