I’m pretty close on this but there’s one last problem. I’ve added an BAQcombo to the Part form and populated it with a query that retrieves all the SalesCatID and Description fields from SalesCat. The SalesCatID is the value field that is bound to ShortChar01. The idea is that the sales category gets set for each part. So far, so good.
When a part is added to a sales order line, I want to select the Sales Category combobox entry based on the value from the part table. I have a BAQ that gets ShortChar01 from the part table filtered by part number. I then set the value of the Sales Category combobox to that value from the part table. The only problem is that the Sales Category combo on order entry doesn’t display the correct description until you drop down the combo. Once you drop it, it immediately selects the correct item.
Here’s my code (mostly appropriated from Jose’s YouTube)
private void OrderDtl_AfterFieldChange(object sender, DataColumnChangeEventArgs args)
{
// ** Argument Properties and Uses **
// args.Row["FieldName"]
// args.Column, args.ProposedValue, args.Row
// Add Event Handler Code
switch (args.Column.ColumnName)
{
case "PartNum":
Ice.Lib.Framework.EpiTextBox PartNumTextBox;
PartNumTextBox = (EpiTextBox)csm.GetNativeControlReference("b7505712-6225-4cce-90bb-c39ee8c9efae");
Ice.Lib.Framework.EpiCombo SalesTypeCombo;
SalesTypeCombo = (EpiCombo)csm.GetNativeControlReference("75f5323e-199c-44c1-bf11-d74945f5f8a1");
DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans);
dqa.BOConnect();
Ice.BO.QueryExecutionDataSet qeds = dqa.GetQueryExecutionParametersByID("OG_GetPartSalesType");
qeds.ExecutionParameter.Clear();
qeds.ExecutionParameter.AddExecutionParameterRow("PartNumber",PartNumTextBox.Text, "nvarchar",false,Guid.NewGuid(),"A");
dqa.ExecuteByID("OG_GetPartSalesType",qeds);
if (dqa.QueryResults.Tables["Results"].Rows.Count > 0)
{
DataRow resultrow = dqa.QueryResults.Tables["Results"].Rows[0];
edvOrderDtl.dataView[edvOrderDtl.Row]["SalesCatID"]=resultrow["Part_Shortchar01"];
edvOrderDtl.Notify(new EpiNotifyArgs(oTrans,edvOrderDtl.Row,edvOrderDtl.Column));
}
dqa.Dispose();
break;
}
}
}
Any pointers would be greatly appreciated.