Programtically End Activity

I am trying to auto end all activities in the production tab of MES. I remember doing this before but having this same issue and can’t remember how to resolve it. here is my code. I get the error that the labordtl record has not changed then when it hits the change before the update I get can’t change an active transaction. Any help would be greatly appreciated.

foreach(Infragistics.Win.UltraWinGrid.UltraGridRow UGR in ProdGV.Rows)
{

		ProdGV.ActiveRow = UGR;
		
		LaborAdapter Ladap  = new LaborAdapter(this.MESMenu);
		Ladap.BOConnect();
		int iLaborHedSeq;
		int.TryParse(UGR.Cells[2].Text,out iLaborHedSeq);
		int iLaborDtlSeq;
		int.TryParse(UGR.Cells[3].Text,out iLaborDtlSeq);
		//int iLaborDtlSeq = UGR.Cells[3].Value;
		Boolean GDTL = Ladap.GetDetail(iLaborHedSeq, iLaborDtlSeq);
			
		Boolean EAWorked = Ladap.EndActivity();
		
		string msg;			
		Boolean setqty = Ladap.DefaultLaborQty(1,out msg);
		Ladap.LaborData.LaborDtl[0]["LaborQty"] = 1;
		Ladap.Update();
		
		Ladap.Dispose();
	}

I have a BPM that ends labor activity. I had to process the records in the following order:

  1. Get the record (Labor.GetDetail)
  2. Set LaborDtlRow.RowMod = “U”
  3. Call Labor.EndActivity method
  4. Call Labor.Update method

    image
    Looks like you just need to add step 2 after you get the detail record.
2 Likes

Wow. As soon as I read your steps It dawned on me. This is definitely not the first time this has happened to me. Thank you so much.

calling End Labor Activity BO method should has LaborDtl.Update included in it.