11.4、表单插件,DataChanged,e.Row + switch,case,break原创
金蝶云社区-林荫大道cc身份
林荫大道cc
13人赞赏了该文章 6644次浏览 未经作者许可,禁止转载编辑于2020年07月02日 12:40:31
封面


11.3



上一节,使用if,这节使用 switch,case,break 代替if




1、注释上一节代码


            ////如果等于客户
            //if(e.Field.Key =="FCustId")
            //{
            //    this.View.Model.SetValue("FNote", "客户变化后赋值到备注");
            //    this.View.Model.SetValue("FNote1", "客户变化后赋值到备注1");
            //    //刷新
            //    this.View.UpdateView("FNote");
            //    this.View.UpdateView("FNote1");
            //    //赋值返回的是,基本资料FID内码
            //    //给A字段FCustIdNew,赋新值e.NewValue,更新前的值
            //    this.View.Model.SetValue("FCustIdNew",e.NewValue);
            //    //给B字段FCustIdOld,赋旧值e.OldValue,更新后的值
            //    this.View.Model.SetValue("FCustIdOld", e.OldValue);
            //    //刷新
            //    this.View.UpdateView("FCustIdNew");
            //    this.View.UpdateView("FCustIdOld");
            //}
            
            ////如果等于物料
            //if (e.Field.Key == "FMaterialId")
            //{
            //    //给项目名称,赋值
            //    //e.Row 区别是哪一行,+动态变化
            //    this.View.Model.SetValue("F_YDIE_ProjectName", "项目名称" +e.Row.ToString(), e.Row);
            //}




2、



            switch(e.Field.Key)
            {
                 //case 判断 客户
                 
                case "FCustId":
                    this.View.Model.SetValue("FNote", "客户变化后赋值到备注");
                    this.View.Model.SetValue("FNote1", "客户变化后赋值到备注1");
                    this.View.Model.SetValue("FCustIdNew", e.NewValue);
                    this.View.Model.SetValue("FCustIdOld", e.OldValue);
                    //结束
                    break;
                
                
                 //case 判断 物料   
                 
                case "FMaterialId":
                    this.View.Model.SetValue("F_YDIE_ProjectName","项目名称"+e.Row.ToString(),e.Row);
                    break;
            }



3、重新生成dll



4、跟上一节,一样的效果


image.png

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kingdee.BOS;
using Kingdee.BOS.Core.Bill.PlugIn;
//添加引用后,缩写函数
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using System.ComponentModel;

namespace Kingdee.Bos.Project.BillDataChanged.plugln
{
    [Description ("DataChanged值更新后触发")]
    [Kingdee.BOS.Util.HotUpdate]
    public class ClassName:AbstractBillPlugIn
    {
        // DataChanged事件
        //public override void DataChanged(BOS.Core.DynamicForm.PlugIn.Args.DataChangedEventArgs e)
        //{
        //    base.DataChanged(e);
        //}
        //添加引用后,缩写函数
        public override void DataChanged(DataChangedEventArgs e)
        {
         base.DataChanged(e);
            ////如果等于客户
            //if(e.Field.Key =="FCustId")
            //{
            //    this.View.Model.SetValue("FNote", "客户变化后赋值到备注");
            //    this.View.Model.SetValue("FNote1", "客户变化后赋值到备注1");
            //    //刷新
            //    this.View.UpdateView("FNote");
            //    this.View.UpdateView("FNote1");
            //    //赋值返回的是,基本资料FID内码
            //    //给A字段FCustIdNew,赋新值e.NewValue,更新前的值
            //    this.View.Model.SetValue("FCustIdNew",e.NewValue);
            //    //给B字段FCustIdOld,赋旧值e.OldValue,更新后的值
            //    this.View.Model.SetValue("FCustIdOld", e.OldValue);
            //    //刷新
            //    this.View.UpdateView("FCustIdNew");
            //    this.View.UpdateView("FCustIdOld");
            //}
            ////如果等于物料
            //if (e.Field.Key == "FMaterialId")
            //{
            //    //给项目名称,赋值
            //    //e.Row 区别是哪一行,+动态变化
            //    this.View.Model.SetValue("F_YDIE_ProjectName", "项目名称" +e.Row.ToString(), e.Row);
            //}
            
            
            switch(e.Field.Key)
            {
                    //case 判断 客户
                case "FCustId":
                    this.View.Model.SetValue("FNote", "客户变化后赋值到备注");
                    this.View.Model.SetValue("FNote1", "客户变化后赋值到备注1");
                    this.View.Model.SetValue("FCustIdNew", e.NewValue);
                    this.View.Model.SetValue("FCustIdOld", e.OldValue);
                    //结束
                    break;
                    
                case "FMaterialId":
                    this.View.Model.SetValue("F_YDIE_ProjectName","项目名称"+e.Row.ToString(),e.Row);
                    break;
            }
            
        }
    }
}


总目录链接

https://vip.kingdee.com/article/64993872014591232



赞 13