MES FKV to show operation comment text

I’m trying to show the comment text for the selected operation LaborDtl grid in an EpiTextBox. I tried to create a FKV from LaborDtl to JobOper, but I can’t link it by the OprSeq…I don’t quite understand how the FKV determines which fields can be used to link the tables. Does anyone have any ideas?

If you aren’t trying to put it into the grid, would it just be easier to call a GetById and assign the value to the text box on row change?

I still haven’t figured out FKV’s yet myself, so this is how I would avoid them. :wink:

I’ve had success with FKVs in the past, but I am open to other methods. I can probably figure out GetById. It should probably be triggered by selecting a different job/assembly/operation in the labor grid, but not sure what form event would trigger that.

I’m assuming you are talking about the Main MES screen right? I haven’t done it before, but a quick look through the wizard would make me think that AfterRowChange on the LaborDtl view would work. You might have to try before or after and see what works.

image

I tried that one, but it error’d out due to some conflicting code…once I cleaned that up, it is now working. Now I just need to fill that text box. Thanks for the help so far!

1 Like

I’m getting an “object reference not set to an instance of an object” error with the following code:

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["JobOper"]));
	if(view.Row >= 0)
	{
		string comment = view.dataView[view.Row]["CommentText"].ToString();
		epiTextBoxC1.Text = comment;
	}
}

That view doesn’t have the comment text in it. That’s why you can’t just turn it on in the grid. You will have to load up an adapter that has the comment text in it, then do the get by ID. The JobEntry adapter probably has it, but there might be lighter weight one to get what you want.

Maybe someone can chime in with a good one to use. Search through the adapter list in object explorer and see if there is one that you can use.

When I get some time, I’ll dig around a bit, but I’m not the most knowledgeable in using adapters yet.

This has some good info on adapters.

This is where I learned how to use get by ID (not that long ago)

I am getting the error The type or namespace name 'JobEntryAdapter' could not be found (are you missing a using directive or an assembly reference?). I am loading Ice.Adapters, is there anywhere else I need to define this?

There are two places that you need to reference it. One is the using statement at the top of your code, the other is in the custom assembly reference. Do you have both of those?

Also, it may be ERP instead of ICE.

Do you have the BL tester available to use? You’ll want to use that to figure out what you need to call to find your operation comments. If you use GetByID(JobNum) I think it’s going to bring in the whole job, and if your jobs are large, be a big performance hit. See if you can find something that returns a smaller data set.

I added the ERP assembly, that got rid of that error. However, I’m not quite sure how to refer to CommentText.

So this is were I’ve reached the limit of my experience, as I have only done a GetByID with one value. If you use the GetByID(JobNum), you now have the whole job in the data set. You need to be able to look up the AsmSeq and OpSeq that is referenced in the grid.

Maybe @josecgomez or @Chris_Conn could help us with the last step on finding the right row in the data set?

I think you will want to use GetRows() instead, but I don’t know how to make the WhereClause for that one.

I’m looking at some of your code in the second link you gave me, and trying to adapt it to my needs. I am triggering the code on AfterRowChange, but I believe that is causing an issue with the switch function: 'Ice.Lib.Framework.EpiRowChangedArgs' does not contain a definition for 'Column' and no extension method 'Column' accepting a first argument of type 'Ice.Lib.Framework.EpiRowChangedArgs' could be found (are you missing a using directive or an assembly reference?)

You have to add both the adapter and contract dll for that BO. Also, you’ll probably want to add:
using Erp.BO;
using Erp.Contracts;

You’re not looking for a view change, so you won’t have a switch statement.

Just start with a message box and see if it fires when you want it to,

MessageBox.Show(“testing text here”);

Right now I’m getting a textbox that says “True”.

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();
	string JobNum = adapterJobOperSearch.GetByID("JobNum").ToString();
	MessageBox.Show(JobNum);
	adapterJobOperSearch.Dispose();
}

GetByID returns true if it finds a record.

I think what you want is to access the data from the record.

var row = adapterJobOperSearch.JobOperSearchData.JobOper.Rows[0];
string job = row[“JobNum”].ToString(); //etc

Is JobNum an actual job number in your system?

Also, for the message box you will need (JobNum.Value.ToString())

You will have to get the values that you need from your grid. I would start there. Assign the values to a variable then you can use the variable in your where clause. (that we still have to figure out). Those should be the one that we can use the Args for.

JobNum should be (I don’t have time to test this so you will have to verify and may have to tweak some things). See if you can get the Job number, assembly sequence and operation sequence because you will need those going forward. Display them in your message box to verify they are what you expect.

var JobNum =  args.CurrentRow["JobNum"].Value.ToString();

Oh yeah, that makes sense. There is another part of that thread that talks about how to reference something in the data set.

I can get the job, assembly, and operation from the LaborDtl dataview. If GetByID simply returns a boolean, then what would I use to reference? I’m looking through the thread and can’t find it.

What @Chris_Conn showed up above.

Get by ID returns a boolean, but it also loads the values into the adapter that you can reference.

The part I don’t know how to do is to get the specific row you want out of that data set. You are probably better off using GetRows() because that will only return the row you want. (I want to learn how to to that too)