Hi,
I am looking to see if anyone has run into and possibly overcome this issue. What I am trying to do is mimic how Epicor allows you to search for something (like an employee) and when you click ok on the search, it populates the ID and the name. With that, Epicor also allows you to manually type in the employee ID and populates the name when you hit tab.
Individually, I found ways to do this. I am not a programmer by any means but using code snippets and the simple search wizard, I have been able to do each of the steps above. When I use the button click along with the after field change method, I get the following error. I have also put my code below as well. Any help would be much appreciated!
Error Details:
Application Error
Exception caught in: Infragistics4.Shared.v12.2
Error Detail
Message: Index was outside the bounds of the array.
Program: Infragistics4.Shared.v12.2.dll
Method: ValidateIndex
Client Stack Trace
at Infragistics.Shared.SparseArray.ValidateIndex(Int32 index)
at Infragistics.Shared.SparseArray.GetItem(Int32 index, ICreateItemCallback createItemCallback)
at Infragistics.Win.UltraWinGrid.RowsCollection.get_Item(Int32 index)
at Script.PopulatePartDesc(String PartNum)
at Script.UD02_AfterFieldChange(Object sender, DataColumnChangeEventArgs args)
at System.Data.DataColumnChangeEventHandler.Invoke(Object sender, DataColumnChangeEventArgs e)
at System.Data.DataTable.OnColumnChanged(DataColumnChangeEventArgs e)
at Ice.BO.UD02DataSet.UD02DataTable.OnColumnChanged(DataColumnChangeEventArgs e)
at System.Data.DataRow.set_Item(DataColumn column, Object value)
at Script.btnPart_Click(Object sender, EventArgs args)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at Infragistics.Win.Misc.UltraButtonBase.OnClick(EventArgs e)
at Ice.Lib.Framework.EpiButton.OnClick(EventArgs e)
at Infragistics.Win.Misc.UltraButton.OnMouseUp(MouseEventArgs e)
at Ice.Lib.Framework.EpiButton.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Script code
// **************************************************
// Custom code for UD02Form
// Created: 11/11/2020 10:50:10 AM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Ice.BO;
using Ice.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 **
// 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.UD02_Column.ColumnChanged += new DataColumnChangeEventHandler(this.UD02_AfterFieldChange);
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
this.btnPart.Click += new System.EventHandler(this.btnPart_Click);
// 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.btnPart.Click -= new System.EventHandler(this.btnPart_Click);
this.UD02_Column.ColumnChanged -= new DataColumnChangeEventHandler(this.UD02_AfterFieldChange);
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
private void btnPart_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
bool recSelected;
string whereClause = string.Empty;
System.Data.DataSet dsPartAdapter = Ice.UI.FormFunctions.SearchFunctions.listLookup(this.oTrans, "PartAdapter", out recSelected, true, whereClause);
if (recSelected)
{
System.Data.DataRow adapterRow = dsPartAdapter.Tables[0].Rows[0];
// Map Search Fields to Application Fields
EpiDataView edvUD02 = ((EpiDataView)(this.oTrans.EpiDataViews["UD02"]));
System.Data.DataRow edvUD02Row = edvUD02.CurrentDataRow;
if ((edvUD02Row != null))
{
edvUD02Row.BeginEdit();
edvUD02Row["PartNum_c"] = adapterRow["PartNum"];
edvUD02Row["PartDesc_c"] = adapterRow["PartDescription"];
edvUD02Row.EndEdit();
}
}
}
private void UD02_AfterFieldChange(object sender, DataColumnChangeEventArgs args)
{
MessageBox.Show("After field change fired");
// ** Argument Properties and Uses **
// args.Row["FieldName"]
// args.Column, args.ProposedValue, args.Row
// Add Event Handler Code
EpiDataView edvUD02 = ((EpiDataView)(this.oTrans.EpiDataViews["UD02"]));
System.Data.DataRow edvUD02Row = edvUD02.CurrentDataRow;
switch (args.Column.ColumnName)
{
case "PartNum_c":
var partNum = csm.GetNativeControlReference("076ead93-986c-47c9-a764-ccc23bbc0bab");
string partNumber = partNum.Text;
edvUD02Row["PartDesc_c"] = PopulatePartDesc(partNumber);
break;
}
}
private string PopulatePartDesc(string PartNum)
{
DynamicQueryAdapter dqa = new DynamicQueryAdapter(UD02Form);
dqa.BOConnect();
QueryExecutionDataSet qeds = dqa.GetQueryExecutionParametersByID("DmcBaqSignifEvent_PartInfo");
qeds.ExecutionParameter.Clear();
qeds.ExecutionParameter.AddExecutionParameterRow("PartNum",PartNum,"int",false,Guid.NewGuid(),"A");
dqa.ExecuteByID("DmcBaqSignifEvent_PartInfo", qeds);
BaqResults.DataSource = dqa.QueryResults.Tables["Results"];
string PartDesc = BaqResults.Rows[0].Cells["Part_PartDescription"].Text;
return PartDesc;
}
}
``