• 服务插件给单据字段赋值-简单示例


    需求场景:委外用料清单保存时,根据子项物料的物料属性,判断勾不勾选MRP计算。

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Kingdee.BOS.Core.DynamicForm.PlugIn;
    using Kingdee.BOS.Core.Validation;
    using Kingdee.BOS.Core;
    using Kingdee.BOS;
    using Kingdee.BOS.App.Data;
    using System.Data;
    using Kingdee.BOS.Orm.DataEntity;
    using Kingdee.BOS.Core.Metadata.FieldElement;
    using Kingdee.BOS.Orm.Metadata.DataEntity;
    using Kingdee.BOS.Util;
    using Kingdee.BOS.Contracts;
    using Kingdee.BOS.Core.Metadata;
    using Kingdee.BOS.Orm;
    using System.ComponentModel;
    using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
    using Kingdee.BOS.Core.DynamicForm;
    using System.Web;
    using System.IO;


    namespace MRPSelect
    {
        [Description("委外用料清单保存判断MRP")]
        public class SUBBOMMRP:AbstractOperationServicePlugIn
        {
            public override void OnPrepareOperationServiceOption(OnPrepareOperationServiceEventArgs e)
            {
                base.OnPrepareOperationServiceOption(e);
            }
            /// <summary>
            /// 数据加载前,确保需要的属性被加载
            /// </summary>
            /// <param name="e"></param>
            /// <remarks>
            /// 在列表上执行操作时,单据的字段并没有被完全加载。
            /// 如果操作插件用到了未被加载的字段,一定会中断;
            /// 本事件允许插件,强制要求加载某些字段,避免中断
            /// </remarks>
            public override void OnPreparePropertys(PreparePropertysEventArgs e)
            {
                // 如下代码行,指定字段xxxxx的Key,强制要求加载字段
                //e.FieldKeys.Add("FJSTORDERNO");
                //e.FieldKeys.Add("FSOURCETYPE");
                //e.FieldKeys.Add("FSetAccountType");
                //e.FieldKeys.Add("FDATE");
            }
            public override void OnAddValidators(AddValidatorsEventArgs e)
            {
                base.OnAddValidators(e);
                this.OperationResult.IsShowMessage = true;
            }
            public override void BeginOperationTransaction(BeginOperationTransactionArgs e)
            {
                base.BeginOperationTransaction(e);
                if (e.DataEntitys.Count() < 1)
                {
                    return;
                }
                string MatID = "";
                string Sql = "";
                DataSet ds = new DataSet();
                foreach (var item in e.DataEntitys)
                {
                        
                    DynamicObjectCollection PPBomEntry = item["PPBomEntry"] as DynamicObjectCollection;
                    if (PPBomEntry.Count > 0)
                    {
                        for (int i = 0; i < PPBomEntry.Count; i++)
                        {
                            MatID = PPBomEntry[i]["MaterialID_Id"].ToString();
                            Sql = "select FERPCLSID from t_BD_MaterialBase where FMATERIALID = '" + MatID + "' ";
                            ds = Kingdee.BOS.ServiceHelper.DBServiceHelper.ExecuteDataSet(this.Context, Sql);
                            if (ds.Tables[0].Rows.Count > 0)
                            {
                                if (ds.Tables[0].Rows[0]["FERPCLSID"].ToString() == "2" || ds.Tables[0].Rows[0]["FERPCLSID"].ToString() == "3")
                                {
                                    PPBomEntry[i]["IsMrpRun"] = 0;
                                }
                            }
                        }
                    }   
                }
            }
        }
    }

  • 相关阅读:
    js怎样生成json的数据
    JS中生成与解析JSON
    [转]js动态创建json类型
    handlebars模板库的资源
    一指流沙,倾覆了谁的年华?
    c# const与readonly 关键字的比较
    静态类和静态构造函数
    编写跨浏览器兼容的 CSS 代码的金科玉律
    mysql 分页sql
    EF报LINQ to Entities 不识别方法“Web_JZRepository.Models.copy_materials_details get_Item(Int32) ”,因此该方法无法转换为存储表达式。
  • 原文地址:https://www.cnblogs.com/zfangfang/p/12462819.html
Copyright © 2020-2023  润新知