csharp Epicor - 在订单输入中检查零件详细信息

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp Epicor - 在订单输入中检查零件详细信息相关的知识,希望对你有一定的参考价值。

// **************************************************
// Custom code for SalesOrderForm
// Created: 4/9/2014 7:29:23 AM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Epicor.Mfg.BO;
using Epicor.Mfg.UI;
using Epicor.Mfg.UI.Adapters;
using Epicor.Mfg.UI.Customization;
using Epicor.Mfg.UI.ExtendedProps;
using Epicor.Mfg.UI.FormFunctions;
using Epicor.Mfg.UI.FrameWork;
using Epicor.Mfg.UI.Searches;

public class Script
{
	// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
	// Begin Wizard Added Module Level Variables **

	private EpiBaseAdapter oTrans_ordAdapter;
	// End Wizard Added Module Level Variables **

	// Add Custom Module Level Variables Here **

	public void InitializeCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization

		this.oTrans_ordAdapter = ((EpiBaseAdapter)(this.csm.TransAdaptersHT["oTrans_ordAdapter"]));
		this.oTrans_ordAdapter.AfterAdapterMethod += new AfterAdapterMethod(this.oTrans_ordAdapter_AfterAdapterMethod);
		this.OrderDtl_Column.ColumnChanged += new DataColumnChangeEventHandler(this.OrderDtl_AfterFieldChange);
		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls

		// End Wizard Added Custom Method Calls
	}

	public void DestroyCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
		// Begin Wizard Added Object Disposal

		this.oTrans_ordAdapter.AfterAdapterMethod -= new AfterAdapterMethod(this.oTrans_ordAdapter_AfterAdapterMethod);
		this.oTrans_ordAdapter = null;
		this.OrderDtl_Column.ColumnChanged -= new DataColumnChangeEventHandler(this.OrderDtl_AfterFieldChange);
		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
	}

	private void oTrans_ordAdapter_AfterAdapterMethod(object sender, AfterAdapterMethodArgs args)
	{
		// ** Argument Properties and Uses **
		// ** args.MethodName **
		// ** Add Event Handler Code **

		// ** Use MessageBox to find adapter method name
		// EpiMessageBox.Show(args.MethodName)
		switch (args.MethodName)
		{
			// Maybe do something in here i dont recall when this event is fired
			case "ChangePartNumMaster":
				break;
		}

	}

	private void OrderDtl_AfterFieldChange(object sender, DataColumnChangeEventArgs args)
	{
		// ** Argument Properties and Uses **
		// args.Row["FieldName"]
		// args.Column, args.ProposedValue, args.Row
		// Add Event Handler Code
		switch (args.Column.ColumnName)
		{
			case "PartNum":
				// Call our Function
				System.Data.DataRow partRow = GetPartAdapterDataRow( args.ProposedValue.ToString() );

				if (Convert.ToBoolean(partRow["BuyToOrder"]) == true)
				{
					MessageBox.Show("Buy To Order is TRUE!");
				}

				if (Convert.ToBoolean(partRow["DropShip"]) == true)
				{
					// TODO: Do Something here
				}
				break;
		}
	}

	private DataRow GetPartAdapterDataRow(string partNum)
	{
		System.Data.DataRow dsPartAdapter = null;

		if (partNum != "")
		{
			// Connect to the ResourceGroup Adapter
			PartAdapter partAdapter = new PartAdapter(this.oTrans);
			partAdapter.BOConnect();

			// In the PartAdapter GetByID takes the PartNum as string
			if (partAdapter.GetByID(partNum))
			{
				// The values we want are located in
				// PartPlant.BuyToOrder
				// PartPlant.DropShip

				// Make sure we have some results
				if (partAdapter.PartData.PartPlant.Rows.Count > 0)
				{
					// Return the Row
					return partAdapter.PartData.PartPlant.Rows[0];
				}
			}

			// Cleanup
			partAdapter.Dispose();
		}

		return dsPartAdapter;
	}
}

以上是关于csharp Epicor - 在订单输入中检查零件详细信息的主要内容,如果未能解决你的问题,请参考以下文章

csharp Epicor 10.1 - 获得价值或0

csharp Epicor UD Entry KeyField

csharp 的Epicor-WCF-j.cs

csharp 创建Epicor BO Instace WCF

csharp Epicor 10.1从代码调用BAQ

csharp Epicor:从午夜到实际时间转换秒数