Hi,
I have a secondary part number UD field in Part. When I read in the part record I need to grab the UD field and use it to look up the description and then stuff it into a text box with no binding.
My script below does it all except get the part number in the UD field to look up the secondary part.
I’ve used an EpiDataView in another event handler to do this, but it looks like the data view hasn’t been set up yet at this point. (?)
How might I grab a field from the part master here?
Thanks,
Joe
private void oTrans_adapter_AfterAdapterMethod(object sender, AfterAdapterMethodArgs args)
{
// ** Argument Properties and Uses **
// ** args.MethodName **
// ** Add Event Handler Code **
// ** Use MessageBox to find adapter method name
// EpiMessageBox.Show(args.MethodName)
MessageBox.Show("args.Methodsname " + args.MethodName);
switch (args.MethodName)
{
case "Update":
break;
case "GetByID":
MessageBox.Show("entering get by id");
EpiDataView edv = ((EpiDataView)(oTrans.EpiDataViews["Part"])); // GET DATA VIEW
if (edv == null) MessageBox.Show("null epidataview"); // IT'S NOT NULL
bool recSelected = false;
//string whereClause = "PartNum = '" + txtServicePartUsePart.Text + "'";
string whereClause = "PartNum = '" + edv.dataView[edv.Row]["ServicePartUsePart_c"] + "'"; // THIS LINE DOES A BAD THING (Is This a New Record?)
//string whereClause = "PartNum = '" + "021497" + "'"; This works just fine, but...
MessageBox.Show("whereClause" + whereClause);
DataSet dsPart = Ice.UI.FormFunctions.SearchFunctions.listLookup(oTrans, "PartAdapter", out recSelected, false, whereClause);
MessageBox.Show("after dataset");
if (recSelected)
{
MessageBox.Show("recSelected " + recSelected.ToString());
txtServicePartUsePartDesc.Text = Convert.ToString(dsPart.Tables[0].Rows[0]["PartDescription"]);
}
else
{
txtServicePartUsePartDesc.Text = "";
}
MessageBox.Show("exiting get by id");
break;
}
}