MES FKV to show operation comment text

I missed that! I will try it.

When the code runs, it says that there is no row at position 0.

private void LaborDtl_AfterRowChange(EpiRowChangedArgs args)
{
// ** Argument Properties and Uses **
// args.CurrentView.dataView[args.CurrentRow]["FieldName"]
// args.LastRow, args.CurrentRow, args.CurrentView
// Add Event Handler Code
JobOperSearchAdapter adapterJobOperSearch = new JobOperSearchAdapter(oTrans);
adapterJobOperSearch.BOConnect();
var row = adapterJobOperSearch.JobOperSearchData.JobOper.Rows[0];
string job1 = row["JobNum"].ToString();
MessageBox.Show(job1);
adapterJobOperSearch.Dispose();
}

You connected the adapter, but you still have to run a lookup of some sort. (like GetByID or something)

I guess I’m lost…if GetByID returns a boolean, that seems more like a verification to me, not something that would provide information that is required for Chris’ code to run.

GetByID populates the internal dataset of the adapter: adapterJobOperSearch.JobOperSearchData

If you just ask for the adapter to come back as a string, you get the boolean. If you reference the rows, like you have, you will get the rows.

Just add adapterJobOperSearch.GetByID(yourjobnumber); in front of your “var row” line.

1 Like

I am still getting the no row error.

private void LaborDtl_AfterRowChange(EpiRowChangedArgs args)
{
	// ** Argument Properties and Uses **
	// args.CurrentView.dataView[args.CurrentRow]["FieldName"]
	// args.LastRow, args.CurrentRow, args.CurrentView
	// Add Event Handler Code
	var view = ((EpiDataView)(this.oTrans.EpiDataViews["LaborDtl"]));
	string job = view.dataView[view.Row]["JobNum"].ToString();
	JobOperSearchAdapter adapterJobOperSearch = new JobOperSearchAdapter(oTrans);
	adapterJobOperSearch.BOConnect();
	adapterJobOperSearch.GetByID(job);
	var row = adapterJobOperSearch.JobOperSearchData.JobOper.Rows[0];
	string job1 = row["JobNum"].ToString();
	MessageBox.Show(job1);
	adapterJobOperSearch.Dispose();
}

First before you check the row, ensure the GetByID is returning true.

Second, make a BAQ against the JobOper table and query for that job# and ensure that there is in fact a JobOper there

I am getting a true value for GetByID(job), and the BAQ shows records for the job.

Ah, i believe this might be the issue… Looks like the GetByID for that adapter requires three params

image
which translates to:
image

So to use the GetByID on that particular adapter, you need something like:
adapter.GetByID(new object[]{“job”,assySeq, opSeq});

if you need something more flexible, you might consider a GetRows with a whereclause

Teach us how to use that master!!

This is exactly what I need, the only issue I’m having is converting AssemblySeq and OprSeq to integers. Example: int asm = view.dataView[view.Row]["AssemblySeq"].???

SearchOptions optsTrans = new SearchOptions(SearchMode.AutoSearch); 
optsTrans.PageSize = 100; //return this many (can call more later)
string whereTrans = string.Format("JobNum = '{0}'" , JobEdit.Text); 
optsTrans.NamedSearch.WhereClauses.Add("JobOper",whereTrans); 
var trans =myAdapter.GetRows(optsTrans,out more);


int asm = (int)view.dataView[view.Row][“AssemblySeq”];

It’s working! Thank you so much!

1 Like

I’m going to open this one up again…an issue I’ve noticed is that because it’s triggered by AfterRowChange, it won’t work if there is only one row (one job clocked in).

Maybe you could add another condition to handle when the first row is added. You could use EpiViewNotification event. Condition AddRow event and a RowCount = 1

I’ve grappled with this for a while now, looking at quite a few threads, and I’m not sure how to get the RowCount. It looks like it’s an attribute of the DataView, but not sure on the syntax.

view.dataView.Count

Hmmmm…the code is compiling, but it’s not triggering when I clock in to a job, and it’s not triggering if I login when there is a job already clocked in. Is there an event that fires when a row is clicked, even if it doesn’t change?

I ran a check on MESMenu_Load and the message box isn’t showing up.

var view = ((EpiDataView)(this.oTrans.EpiDataViews["LaborDtl"]));
if (view.dataView.Count == 1)
{
	MessageBox.Show("!!!");
}