Using GetBySysRowID with Adapter in UI

Hey,

I’ve been able to firm a job by calling the JobEntry adapter, but I need to get the new job number.

When the code below runs I get a message when I look for JobNum after the update that the row has been removed from the data table , which makes sense.

When I try reading from the data table it complains some more about the enumerator being removed. That makes sense too.

So I had an idea that maybe the sysrow ID might survive the update and tried adding a GetBySysRowID. This seems to be supported in a BPM ‘Invoke BO Method’ box, but it’s giving me an error with the adapter:

----------errors and warnings------------

Error: CS1061 - line 502 (869) - ‘Erp.Adapters.JobEntryAdapter’ does not contain a definition for ‘GetBySysRowID’ and no extension method ‘GetBySysRowID’ accepting a first argument of type ‘Erp.Adapters.JobEntryAdapter’ could be found (are you missing a using directive or an assembly reference?)

The GetByID works, so I think the assembly reference is okay.

Have an idea?

Thanks,

Joe

	private void firmReleaseJob(string jobnum)
	{
		newJobNum = "";
		string sysRowID = "";

		// move this up to the start to save connect time
		JobEntryAdapter jobEntry = new JobEntryAdapter(oTrans);
		jobEntry.BOConnect();
		
		jobEntry.GetByID(jobnum);

		DataTable dt = jobEntry.JobEntryData.JobHead;

		foreach (DataRow row in dt.Rows)
		{
			sysRowID = row["SysRowID"].ToString(); // save the sysrow ID to get the new job num

			row["JobFirm"] = true;
			jobEntry.Update();
			//newJobNum = row["JobNum"].ToString(); // gets an error because the line has been removed
		}

		jobEntry.GetBySysRowID(sysRowID); // ** this is line 502 **

		DataTable dt = jobEntry.JobEntryData.JobHead;

		foreach (DataRow row in dt.Rows)
		{
MessageBox.Show("new job num " + row["JobNum"].ToString());
		}

		jobEntry.Dispose();
		EpiMessageBox.Show("Job Firmed " + jobnum + " > " + newJobNum);
	}
}

I am looking and see that there is no method GetBySysRowID in the JobEntry adapter, but it does exist on the BO itself. Could you try instantiating the BO service instead of the adapter and go that route?

Guess we’ll see. :slight_smile:

Thanks, Aaron.

Joe

Might need to keep your sysrowID as a guid too instead of a string; not sure how that behaves

That’s true. Thanks.

Are you 100% sure it doesn’t get returned after the first update? I think your problem is that the Update should be outside the foreach loop.

Jason,

I’m going to have to buy you dinner one of these days.

That was it. Thanks!

Joe

Working code:

	private void firmReleaseJob(string jobnum)
	{
		newJobNum = "";

		// moved this up to initialization to save connect time
		//JobEntryAdapter jobEntry = new JobEntryAdapter(oTrans);
		//jobEntry.BOConnect();
		
		jobEntry.GetByID(jobnum);

		DataTable dt = jobEntry.JobEntryData.JobHead;

		bool rowExists = false;

		// should be only one record if found
		foreach (DataRow row in dt.Rows)
		{
			row["JobFirm"] = true;
			row["RowMod"] = "U";

			rowExists = true;
		}

		if (rowExists) jobEntry.Update();

		foreach (DataRow row in dt.Rows)
		{
			newJobNum = row["JobNum"].ToString();
		}

		jobEntry.Dispose();
		EpiMessageBox.Show("Job Firmed " + jobnum + " > " + newJobNum);
	}