DMR Processing Customization - Capturing Combo Box Click Events in C#

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:

  1. While my syntax appears to be at least correct, what am I doing wrong that is causing the event not to fire?
  2. 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!

Did you use the even wizard to create the event?

I’m guessing not, as the format of your function doesn’t match that of one generated by the Event wizard

Yours:

private void ucboDepartment_RowSelected(object sender, Infragistics.Win.UltraWinGrid.RowSelectedEventArgs ev){
...
}

Event Wiz generated:

private void epiUltraComboC1_RowSelected(object sender, Infragistics.Win.UltraWinGrid.RowSelectedEventArgs args){
...
}

Notice that the Event generated one uses the variable args as the parameter. While the variable name doesn’t matter, it shows that you might be missing the initializing call (like the following)

this.epiUltraComboC1.RowSelected += new Infragistics.Win.UltraWinGrid.RowSelectedEventHandler(this.epiUltraComboC1_RowSelected);

Do you have that in the InitializeCustomCode() section?

And there’s a similar one in the DestroyCustomCode() section too.

These two (in Init..() and Destroy...() are created by the event wizard.

1 Like

You. Are. The. Literal. BEST! I did NOT use the wizard to generate the code so that’s exactly it. I haven’t tested this yet, but I’m assuming this will resolve the issue. I’ll keep you updated.

What you want can be done with no code.

  • Make 2 BAQ’s “UD10a” and “UD10b”

    • UD10a displays just the Char01 field, of all rows, Grouped By Char01
    • UD10b displays Key1 and Char02 fields, all the rows. (we’ll come back and add the filter later)
  • On your form, add two baqCombo’s

    • For the Category combo

      • bind it to a DMR field (add a UD one if necessary) Say we use ShortChar01.
      • set the control’s BAQ Properties like:
        • DynamicQueryID: UD10a
        • Display Member: UD10_Character01
        • ValueMember: UD10_Character01
    • For the Category combo

      • bind it to the DMR field (add another UD one if necessary)
      • set the control’s BAQ Properties like:
        • DynamicQueryID: UD10b
        • Display Member: UD10_Character02
        • ValueMember: UD10_Key1
  • Go back into BAQ UD10b, and add a table criteria of where
    Character01 = [EpiBinding:table_and_field_you_bound_the_control_for_UD10a_to]

For example: [EpiBinding:OrderHed.UserChar4]

That’s it. When the baqCombo for BAQ UD10a changes value, the combo for UD10b will automatically update.

3 Likes

Sorry for the delay - you hit the nail on the head. Because I hadn’t used the wizard, I wasn’t initializing the event properly. Thank you so much for taking the time to give such helpful responses! I will likely end up using the BAQ solution you posted as that seems more maintainable than the code side. Thank you, thank you, THANK YOU!

If I may, where did you find the syntax for [EpiBinding:Orderhed.UserChar4]? I’m not seeing that in the customization guide or the C# programmers guide.

It is in the ICE tools

Search for “Add the BAQ Markup”

1 Like

Can’t thank you enough Calvin!