I am having some issues, and can’t figure out how to get it to work. I have a customization that only pulls in certain documents from the part and rev when using the get details feature in Job Entry. It works great, and does what I need it to, but in order to see the changes, I have to clear the form, then reload the job. I know that oTrans.Refresh is what I need, but it causes an “Object reference not set to an instance of an object” error. Here is my code:
private void oTrans_partSearchAdapter_AfterAdapterMethod(object sender, AfterAdapterMethodArgs args)
{
if (args.MethodName == "PartIsSalesKit")
{
try
{
JobEntryAdapter adapterJobEntry = new JobEntryAdapter(this.oTrans);
adapterJobEntry.BOConnect();
adapterJobEntry.GetByID("test");
int i = 0;
int x = adapterJobEntry.JobEntryData.JobHeadAttch.Rows.Count;
EpiDataView edvPA = new EpiDataView();
edvPA.dataView = new DataView(adapterJobEntry.JobEntryData.JobHeadAttch);
while(i < (x))
{
if (Convert.ToString(edvPA.dataView[i]["DocTypeID"]) == "DRAW" || Convert.ToString(edvPA.dataView[i]["DocTypeID"]) == "BALLOON")
{
i = i+1;
}
else
{
DataRow dr = adapterJobEntry.JobEntryData.JobHeadAttch.Rows[i];
dr.BeginEdit();
adapterJobEntry.Delete(dr);
dr.EndEdit();
adapterJobEntry.Update();
oTrans.Update();
oTrans.Refresh();
i = 0;
x = adapterJobEntry.JobEntryData.JobHeadAttch.Rows.Count;
}
}
adapterJobEntry.Dispose();
} catch (System.Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
Any ideas on how to get this to work?