Jeffrey,
Here’s a write-up I did on a customization of the Part form. One of the
components looks up a part description and displays it in a text field, but
does not store it.
See if it helps.
Joe
Notes:
Joe’s changes marked with //JDT in red.
These changes revolved around the entry and validation of a “Service Part”
part number and the lookup/display of a part description on entry of the
field and when reading in the part.
Also included is read-only security applied to controls of specified group
boxes for specified security groups.
// **************************************************
// Custom code for PartForm
// Created: 2/6/2016 5:19:57 PM
// **************************************************
extern alias Erp_Contracts_BO_Part;
extern alias Erp_Contracts_BO_PartPlantSearch;
extern alias Erp_Contracts_BO_PO;
extern alias Erp_Contracts_BO_PartOnHandWhse;
extern alias Erp_Contracts_BO_Vendor;
extern alias Erp_Contracts_BO_VendorPPSearch;
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using System.Drawing;
using Erp.Adapters;
using Erp.UI;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
public class Script
{
// ** Wizard Insert Location - Do Not Remove 'Begin/End
Wizard Added Module Level Variables’ Comments! **
// Begin Wizard Added Module Level Variables **
private EpiDataView edvPart;
private EpiBaseAdapter oTrans_adapter;
// 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.Part_Column.ColumnChanging += new
DataColumnChangeEventHandler(this.Part_BeforeFieldChange);
this.edvPart =
((EpiDataView)(this.oTrans.EpiDataViews[“Part”]));
this.edvPart.EpiViewNotification += new
EpiViewNotification(this.edvPart_EpiViewNotification);
this.oTrans_adapter =
((EpiBaseAdapter)(this.csm.TransAdaptersHT[“oTrans_adapter”]));
this.oTrans_adapter.AfterAdapterMethod +=
new AfterAdapterMethod(this.oTrans_adapter_AfterAdapterMethod);
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
this.chkMesQaVerification.AfterCheckStateChanged += new
Infragistics.Win.CheckEditor.AfterCheckStateChangedHandler(this.chkMesQaVerification_AfterCheckStateChanged);
this.cmbMesQaType.Leave += new
System.EventHandler(this.cmbMesQaType_Leave);
// 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.chkMesQaVerification.AfterCheckStateChanged -= new
Infragistics.Win.CheckEditor.AfterCheckStateChangedHandler(this.chkMesQaVerification_AfterCheckStateChanged);
this.cmbMesQaType.Leave -= new
System.EventHandler(this.cmbMesQaType_Leave);
this.Part_Column.ColumnChanging -= new
DataColumnChangeEventHandler(this.Part_BeforeFieldChange);
this.edvPart.EpiViewNotification -= new
EpiViewNotification(this.edvPart_EpiViewNotification);
this.edvPart = null;
this.oTrans_adapter.AfterAdapterMethod -=
new AfterAdapterMethod(this.oTrans_adapter_AfterAdapterMethod);
this.oTrans_adapter = null;
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
private void PartForm_Load(object sender, EventArgs args)
{
//JDT – This section looks up the user ID, reads the security groups and
security manager, and applies “read only” to controls belonging to two
group boxes if not security manager or in the right security group
Ice.Core.Session session =
(Ice.Core.Session)PartForm.Session;
bool recSelected = false;
string secGroup = "";
bool secManager = false;
string whereClause = "DcdUserID = '" +
session.UserID + “’”;
DataSet dsUser =
Ice.UI.FormFunctions.SearchFunctions.listLookup(oTrans, “UserFileAdapter”,
out recSelected, false, whereClause);
if (recSelected)
{
secGroup =
Convert.ToString(dsUser.Tables[0].Rows[0][“GroupList”]);
secManager
= Convert.ToBoolean(dsUser.Tables[0].Rows[0][“SecurityMgr”]);
}
if (!("~" + secGroup + "~").Contains("~" +
“ENGA01” + “~”) && !secManager)
{
foreach
(Control sPlate in grpSerialPlate.Controls)
{
sPlate.Enabled = false;
}
foreach
(Control sPlateImage in grpSPImages.Controls)
{
sPlateImage.Enabled = false;
}
}
}
private void
chkMesQaVerification_AfterCheckStateChanged(object sender, System.EventArgs
args)
{
// ** Place Event Handling Code Here **
if(this.chkMesQaVerification.Checked)
{
this.txtMesQaLabel.Enabled
= true;
this.cmbMesQaType.Enabled =
true;
this.txtMesQaOtherQaCode.Enabled = true;
this.txtMesQaOtherQaCode2.Enabled = true;
this.chkMesQaPartialMatch.Enabled = true;
setTxtMesQaOtherQaCodeEnable();
}
else
{
this.txtMesQaLabel.Enabled
= false;
this.cmbMesQaType.Enabled =
false;
this.txtMesQaOtherQaCode.Enabled = false;
this.txtMesQaOtherQaCode2.Enabled = false;
this.chkMesQaPartialMatch.Enabled = false;
}
}
private void cmbMesQaType_Leave(object sender,
System.EventArgs args)
{
// ** Place Event Handling Code Here **
setTxtMesQaOtherQaCodeEnable();
}
private void setTxtMesQaOtherQaCodeEnable()
{
if (cmbMesQaType.Text == "Other")
{
this.txtMesQaOtherQaCode.Enabled = true;
this.txtMesQaOtherQaCode2.Enabled = true;
}
else
{
this.txtMesQaOtherQaCode.Enabled = false;
this.txtMesQaOtherQaCode2.Enabled = false;
}
}
private void Part_BeforeFieldChange(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)
{
//JDT – This section displays a part description for a secondary part
number upon entry. Stores the description in a text box with no binding.
case "ServicePartUsePart_c":
EpiDataView edv = ((EpiDataView)(oTrans.EpiDataViews[“Part”]));
bool recSelected = false;
string whereClause = “PartNum = '” + txtServicePartUsePart.Text + “’”;
DataSet dsPart = Ice.UI.FormFunctions.SearchFunctions.listLookup(oTrans,
“PartAdapter”, out recSelected, false, whereClause);
if (recSelected)
{
txtServicePartUsePartDesc.Text =
Convert.ToString(dsPart.Tables[0].Rows[0][“PartDescription”]);
edv.Notify( new EpiNotifyArgs(oTrans, edv.Row, edv.Column) );
}
else if
(txtServicePartUsePart.Text == “”)
{
txtServicePartUsePartDesc.Text = “”;
}
else
{
MessageBox.Show("’" + txtServicePartUsePart.Text + “’” + " is not a valid
part number.");
txtServicePartUsePartDesc.Text = “”;
txtServicePartUsePart.Focus();
}
break;
}
}
private void edvPart_EpiViewNotification(EpiDataView view,
EpiNotifyArgs args)
{
// ** Argument Properties and Uses **
// view.dataView[args.Row]["FieldName"]
// args.Row, args.Column, args.Sender,
args.NotifyType
// NotifyType.Initialize,
NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView,
NotifyType.InitAndResetTreeNodes
if ((args.NotifyType ==
EpiTransaction.NotifyType.Initialize) && args.Row > -1)
{
//JDT – This section displays a part description for a secondary part
number upon part load
if
(String.IsNullOrEmpty(txtServicePartUsePart.Text))
{
txtServicePartUsePartDesc.Text = “”;
}
if(String.IsNullOrEmpty(txtServicePartUsePartDesc.Text) &&
!String.IsNullOrEmpty(txtServicePartUsePart.Text))
{
EpiDataView
edv = ((EpiDataView)(oTrans.EpiDataViews[“Part”]));
bool
recSelected = false;
string
whereClause = “PartNum = '” + txtServicePartUsePart.Text + “’”;
DataSet
dsPart = Ice.UI.FormFunctions.SearchFunctions.listLookup(oTrans,
“PartAdapter”, out recSelected, false, whereClause);
if
(recSelected)
{
txtServicePartUsePartDesc.Text =
Convert.ToString(dsPart.Tables[0].Rows[0][“PartDescription”]);
edv.Notify( new EpiNotifyArgs(oTrans, edv.Row, edv.Column) );
}
else
{
txtServicePartUsePartDesc.Text = “”;
}
}
}
if ((args.NotifyType ==
EpiTransaction.NotifyType.AddRow))
{
if ((args.Row > -1))
{
}
}
}
private void oTrans_adapter_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)
{
//JDT – This section clears the secondary part description upon clearing
form
case "ClearData":
txtServicePartUsePartDesc.Text = “”;
break;
}
}
}