Hello everyone,
Let me preface this by saying I’m fairly new to both Epicor and .NET so please feel free to course correct if I’m going about this all wrong.
I am attempting to customize the DMR Processing Screen. Under the Reject > Detail screen, our users want the Reject Reason Drop down to be filtered based on a UD field called “Department” in order to make finding a specific reason code a little easier.
I have currently built the following in order to attempt to create this. I am using UD10 as a “master table” for all the departments and the reject reason codes they are linked to. I am only using 3 columns to do this: Key1, Character01 (for the department), and Character02 (for the reason code). Here are a couple of sample records for reference:
Key1: 100, Character01: “Igniters/Recips”, Character02: “Damaged”
Key1: 107, Character01: “Igniters/Recips”, Character02: “Crack: Counterbore”
Key1: 135, Character01: “Power Supplies”, Character02: “Transformer: Failure”
On the DMR Processing > Reject > Detail sheet, I have hidden the default “Reason” field and replaced it with two custom epiUltraCombo boxes: “Department” and “Reason”.
I populate the first field (Department) programmatically when the sheet loads with each unique department listed in the UD10 table. This works without issue.
What I would like to do is capture the “RowSelected” event when a user selects a department in the first dropdown (according to Infragistics - this should be an event I can utilize unless I’m misunderstanding the documentation: RowSelected Event (UltraCombo) - Infragistics Windows Forms™ Help), and use the selected department to populate the second dropdown (reason) with only the reason codes linked to the selected department. So using the sample data above, if a user selects “Igniters/Recips” as the department, “Damaged”, and “Crack: Counterbore” should be the only records that display in the dropdown.
In my code, I am attempting to call this click event like so:
private void ucboDepartment_RowSelected(object sender, Infragistics.Win.UltraWinGrid.RowSelectedEventArgs ev)
{
MessageBox.Show("Calling Row Selected event");
string connString = [MyConnectionString];
string whereClause = ucboDepartment.Value.ToString();
List<string> reasons = new List<string>();
DataSet ds = new DataSet();
DataTable dt = new DataTable("Departments");
DataRow dr = null;
try
{
dt.Columns.Add(new DataColumn("Reason",typeof(string)));
using (System.Data.SqlClient.SqlConnection cnn = new System.Data.SqlClient.SqlConnection(connString))
using (System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("Select distinct Character02 from Ice.UD10 where Character01 = '" + whereClause + "' order by Character02 asc", cnn))
{
cnn.Open();
using (System.Data.SqlClient.SqlDataReader rdr = cmd.ExecuteReader())
{
while (rdr.Read())
{
reasons.Add(rdr.GetString(0));
}
}
}
foreach (string item in reasons)
{
dr = dt.NewRow();
dr["Reason"] = item;
dt.Rows.Add(dr);
}
ds.Tables.Add(dt);
SearchOnUD10AdapterFillDropDownDepartmentReason(ref ds);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
private void SearchOnUD10AdapterFillDropDownDepartmentReason(ref DataSet ds)
{
this.ucboDepartment.ValueMember = "Reason";
this.ucboDepartment.DataSource = ds;
this.ucboDepartment.DisplayMember = "Reason";
string[] fields = new string[] {"Reason"};
this.ucboDepartment.SetColumnFilter(fields);
}
This code compiles with no issue within the script editor and I receive no runtime errors. However, the event never actually appears to be called as I never see the messagebox.
My question is two fold:
- While my syntax appears to be at least correct, what am I doing wrong that is causing the event not to fire?
- If there are any criticisms with how I’ve attempted to approach this, please feel free to share. I’m here to learn, and if there’s a better way to go about this I would very much love to be told.
Thanks everyone!