二开:手工设置生产领料单的实发数量=申请数量(实发数量为0时)原创
金蝶云社区-Ottack
Ottack
6人赞赏了该文章 865次浏览 未经作者许可,禁止转载编辑于2020年03月19日 10:06:16

1、打开BOS设计器,在菜单集合下增加一个按钮,标识为tbButton,如下图:

image.png

2、二开表单插件,继承BaseControlEdit,重写BarItemClick,如下图:

image.png

image.png

3、二开后效果:

image.png

附二开代码:

using System;
using System.Data;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using Kingdee.BOS.Util;
using Kingdee.K3.MFG.PRD.Business.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using System.ComponentModel;
using Kingdee.BOS.Core.Metadata.EntityElement;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.K3.Core.MFG.EntityHelper;

namespace Kingdee.K3.MFG.PRD.EK.Business.PlugIn
{
    [Description("生产领料单-表单插件二开")]
    public class PickMtrlEdit_EK : BaseControlEdit
    {
        public override void BarItemClick(BarItemClickEventArgs e)
        {
            base.BarItemClick(e);
            if (e.BarItemKey == "tbButton")
            {
                EntryEntity entity = this.View.BusinessInfo.GetEntryEntity("FEntity");
                DynamicObjectCollection entityDatas = this.View.Model.GetEntityDataObject(entity);
                if (entityDatas.IsEmpty()) return;
                foreach (var entityData in entityDatas)
                {
                    decimal actualQty = entityData.GetDynamicValue<decimal>("ActualQty");
                    if (actualQty == 0)
                    {
                        decimal appQty = entityData.GetDynamicValue<decimal>("AppQty");
                        this.View.Model.SetValue("FActualQty", appQty, entityDatas.IndexOf(entityData));
                    }
                }
            }
        }
    }
}


赞 6