Service plug-in to document field assignment - simple example

Demand Scenario: When outsourcing to save bills of materials, according to the material properties of the material child, judgment hook uncheck MRP calculations.

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;
the System.Web the using;
the using the System.IO;


namespace MRPSelect
{
    [the Description ( "Subcontract bill of materials stored Analyzing the MRP")]
    public class SUBBOMMRP: AbstractOperationServicePlugIn
    {
        public void OnPrepareOperationServiceOption the override (OnPrepareOperationServiceEventArgs E)
        {
            base.OnPrepareOperationServiceOption (E);
        }
        /// <Summary>
        before /// data loading, ensuring the necessary properties to be loaded
        /// </ Summary>
        /// <param name = "E"> </ param>
        /// <Remarks>
        // / when an operation, document field is not completely loaded on the list.
        /// If the operator uses a plug-in field is not loaded, will be interrupted;
        /// This event allows the plug-in, load some mandatory fields, to avoid disruption
        /// </ remarks>
        the override void OnPreparePropertys public (PreparePropertysEventArgs E)
        {
            // following lines, the specified field xxxxx Key, loading mandatory fields
            //e.FieldKeys.Add("FJSTORDERNO ");
            //e.FieldKeys.Add("FSOURCETYPE") ;
            //e.FieldKeys.Add("FSetAccountType ");
            //e.FieldKeys.Add("FDATE");
        }
        public void OnAddValidators the override (AddValidatorsEventArgs E)
        {
            base.OnAddValidators (E);
            this.OperationResult.IsShowMessage = to true;
        }
        public void BeginOperationTransaction the override (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;
                            }
                        }
                    }
                }   
            }
        }
    }
}

Guess you like

Origin www.cnblogs.com/zfangfang/p/12462819.html