I am extremely new to C# and Epicor. The referred to code starts from case "CountryofOrigin_c"
The code referred to starts from - case “CountryofOrigin_c”:
I have a field called Country of Origin(COO) that has a drop list of the countries. If the user types in an invalid country I want the field to go blank. The user input of the country is captured by (cmbCountryOrg.Text).
Now, the cmbCountryOrg.Text=""; works temporarily but only if the message box is displayed after it. The field reverts back to the user input country after clicking OK on the message box. Secondly, it does not work if the message box was displayed before it. Thirdly, it doesn’t work at all without the message box.
private void OrderDtl_AfterFieldChange(object sender, DataColumnChangeEventArgs args)
{
MessageBox.Show("Testing AfterFieldChange");
switch (args.Column.ColumnName)
{
case "PartNum":if(!string.IsNullOrEmpty(Convert.ToString(args.Row["PartNum"])))
{
/*args.Row["HTSCode_c"]= string.Empty;
args.Row["CountryofOrigin_c"] =string.Empty;
txtHTSCodeDesc.Text = "";
*/
DataTable dt =GetBAQ("EL_PartData");
string RowFilter = "Part_PartNum ='" + Convert.ToString(args.Row["PartNum"]) + "'";
DataTable dtFilter = Filter(dt,RowFilter);
if(dtFilter.Rows.Count > 0)
{
args.Row.BeginEdit();
args.Row["HTSCode_c"]= dtFilter.Rows[0]["Part_CommodityCode"];
args.Row["CountryofOrigin_c"] =dtFilter.Rows[0]["Part_ISOrigCountry"];
args.Row.EndEdit();
}
}
else
{
args.Row["HTSCode_c"]= string.Empty;
args.Row["CountryofOrigin_c"] =string.Empty;
txtHTSCodeDesc.Text = "";
}
break;
case "CountryofOrigin_c": DataTable dt1 = GetBAQ("NML_COOList");
string RowFilter1 = "Country_Description ='" + Convert.ToString(cmbCountryOrg.Text) + "'";
MessageBox.Show("RowFltr",RowFilter1);
DataTable dtFilter1 = Filter(dt1,RowFilter1);
if (dtFilter1.Rows.Count==0)
{
MessageBox.Show("cmbCountryOrg.Text",cmbCountryOrg.Text);
cmbCountryOrg.Text="";
string message = "Enter a valid country name.";
MessageBox.Show(message);
}
break;
}
}