Skip to content

Instantly share code, notes, and snippets.

@hasokeric
Created April 10, 2014 12:53
Show Gist options
  • Save hasokeric/10378963 to your computer and use it in GitHub Desktop.
Save hasokeric/10378963 to your computer and use it in GitHub Desktop.
Epicor - Checking Part Details in Order Entry
// **************************************************
// 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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment