OnClick Event on Update Field on OrderRel

Im looking to updating all open order releases to update the firm order relase checkbox either from true to false for every release on the order and this would be something that would be able to be run from my end users

here is my attempt at trying this. also I need the option if it already true make it false for all releases

private void btnUpdateRel_Click(object sender, System.EventArgs args)
{
	EpiDataView edvOrderRel = ((EpiDataView)(this.oTrans.EpiDataViews["OrderRel"]));
	// ** Place Event Handling Code Here **
	edvOrderRel.dataView[0].BeginEdit();
	edvOrderRel.dataView[edvOrderRel.Row]["OrderRel.FirmRelease"] = true;
	edvOrderRel.dataView[0].EndEdit();

	oTrans.Update();
}

You could make two separate buttons, one to “Set All” and the other to “Clear All”.

I’d shy away from one that toggles all.

Does this need to be line specific, or work across all lines?

The question is, are you going to simply flip every release to the opposite status, or should the first release drive the rest?

R1: Open -> Closed
R2: Closed -> Open
R3: Open -> Closed

R1: Open -> Closed
R2: Closed -> Closed
R3: Open -> Closed

1 Like

I would like to set all or clear all as needed.

Maybe something as simple as this would work. On click, do your logic to determine whether you want to release or unrelease, then call SetRels(myChoice);

void SetRels(bool Released)
{
      EpiDataView edvOrderRel = ((EpiDataView)(this.oTrans.EpiDataViews["OrderRel"]));
	// ** Place Event Handling Code Here **
       foreach(var row in edvOrderRel.dataView)
      {
             row["FirmRelease"] = Released;
       }
}

Chris - Just curious, but does the DataView hold records for all releases of the order, or just those of the current OrderLine?

yeah I think it only shows current line right now and that is current issue with my approach need to get the right process so I can do this for all order line releases

Maybe fetch the dataview for the OrderLine(s) first, and loop through that, with Chris’ code in side the OrderLine loop.

getting this error message

Error: CS0021 - line 155 (957) - Cannot apply indexing with [] to an expression of type ‘object’

void SetRels(bool Released)
{
	EpiDataView edvOrderRel = ((EpiDataView)(this.oTrans.EpiDataViews["OrderRel"]));
	EpiDataView edvOrderDtl = ((EpiDataView)(this.oTrans.EpiDataViews["OrderDtl"]));
		foreach(var rowLine in edvOrderDtl.dataView)
			{
			foreach(var row in edvOrderRel.dataView)
				{
					row["FirmRelease"] = Released;
				}
			}
}

foreach(DataRowView rowLine in edvOrderDtl.dataView)

Regarding Line → Rel, yes the Rel is set up as a subscriber to the line.

A few options (unsure if they are valid):
Try setting the edvOrderDtl.Tow = -1, maybe this will show all (probably it will show none)
Loop as you are trying

I would have guessed something more like

void SetRels(bool Released)
{
	
	EpiDataView edvOrderDtl = ((EpiDataView)(this.oTrans.EpiDataViews["OrderDtl"]));
		foreach(var rowLine in edvOrderDtl.dataView)
			{
			EpiDataView edvOrderRel = ((EpiDataView)(this.oTrans.EpiDataViews["OrderRel"]));
			foreach(var row in edvOrderRel.dataView)
				{
					row["FirmRelease"] = Released;
				}
			}
}

final question how do I add this to my button how do I call this method? it is one of those days lol

If you wanted to loop through all releases couldnt you just do:

 EpiDataView orderRel = (EpiDataView)(oTrans.EpiDataViews["OrderRel"]);
foreach (DataRow relLine in orderRel.dataView.Table.Rows)
{
//Do logic
}

And @Devin.Draeger , use the event wizard to auto generate the event code for your custom button. Then simply add YOUR METHOD NAME(); to the event

1 Like