I’m working on setting up a customization that basically executes an external BAQ what a Quantity is reported.
The goal is look at the quantity reported, and if that quantity is higher than the count that the BAQ returns, it should display a message box, and then clear the Current/Total values.
Here is a bit of the code:
private void ReportQty_AfterFieldChange(object sender, DataColumnChangeEventArgs args)
{
// ** Argument Properties and Uses **
// args.Row["FieldName"]
// args.Column, args.ProposedValue, args.Row
// Add Event Handler Code
Control txtResc = csm.GetNativeControlReference("fcda044e-f261-47b3-be39-49e88db77b2e");
Control nbrCurrent = csm.GetNativeControlReference("94e152f3-dbc7-4180-a2c5-ea03f8d12aa2");
Control nbrTotal = csm.GetNativeControlReference("c87c566a-db0d-4fe1-aa8d-0947764f2eb5");
string currentQty = nbrCurrent.Text;
if (currentQty != "0.00000000")
{
string RescID = txtResc.Text;
DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans);
dqa.BOConnect();
QueryExecutionDataSet qeds = dqa.GetQueryExecutionParametersByID("SHRINK1COUNT");
qeds.ExecutionParameter.Clear();
qeds.ExecutionParameter.AddExecutionParameterRow("MchParam", RescID, "nvarchar", false, Guid.NewGuid(),"A");
dqa.ExecuteByID("SHRINK1COUNT",qeds);
tbMDCQty.Text = dqa.QueryResults.Tables[0].Rows[0][0].ToString();
string MDCrtn = tbMDCQty.Text;
decimal mQty = decimal.Parse(MDCrtn);
decimal cQty = decimal.Parse(currentQty);
if (cQty mQty)
{
int cQty2 = decimal.ToInt32(cQty);
MessageBox.Show(String.Format("You reported a quantity of {0}, which is higher than the database returned {1}",cQty2,mQty));
nbrCurrent.Text = "0.00000000";
nbrTotal.Text = "0.00000000";
tbMDCQty.Text = "";
}
(That is not all of the code, but the portion I’m working with.)
It seems if I run this bit on an EpiButton click it clears:
Are your number boxes text? or Numeric editors? I think (and I could be wrong, I am not real experienced in coding) that you will need nbrCurrent.Text to be nbrCurrent.Value , because a text editor doesn’t use text.
It was picked up from some code I messed with months back when I was initially looking at referencing native controls in e10.
Trying to use this:
Control nbrCurrent = (EpiNumericEditor)csm.GetNativeControlReference(“94e152f3-dbc7-4180-a2c5-ea03f8d12aa2”);
Ends up with this:
(335) - ‘System.Windows.Forms.Control’ does not contain a definition for ‘Value’ and no extension method ‘Value’ accepting a first argument of type ‘System.Windows.Forms.Control’ could be found (are you missing a using directive or an assembly reference?)
So the field type you can find when you click on the control and look in the properties, it should tell you what type of editor it is, that should tell you what you need to put into your control to get a hold of it. See what those boxes are there, and you’ll know how to set them up.