RMA Process Update

I want to update the RMA record to close an RMA with a button click. I have the code below so far but am getting an error:

	private void CallRMAProcAdapterUpdateMethod()
	{
		try
		{
			var intRMA = Convert.ToInt32("2");   //Convert.ToInt32(tbCustomerCustNum.Text);
			// Declare and Initialize EpiDataView Variables
			// Declare and create an instance of the Adapter.
			RMAProcAdapter adapterRMAProc = new RMAProcAdapter(this.oTrans);
			adapterRMAProc.BOConnect();
			adapterRMAProc.GetByID(intRMA);
			{
			adapterRMAProc.RMAProcData.RMAProc[0].OpenRMA = false;   **//THIS LINE IS ERRORING!**
			}
			adapterRMAProc.Update();
			adapterRMAProc.Dispose();

		} catch (System.Exception ex)
		{
			ExceptionBox.Show(ex);
		}
	}

I have
extern alias Erp_Contracts_BO_RMAProc;

Right, you need to reference a data table within the RMAProcData data set

Not quite the same, but this will work:

public void TestMethodRMAProc()	
	{
		RMAProcAdapter adapterRMAProc = new RMAProcAdapter(this.oTrans);
		adapterRMAProc.BOConnect();
		if(adapterRMAProc.GetByID(2))
		{
			adapterRMAProc.RMAProcData.RMAHead[0].OpenRMA = false;
		}
		adapterRMAProc.Update();
		adapterRMAProc.Dispose();
	}

That works perfect. Now instead of hard coding the 2 for the ID how would I get ahold of the DataView already in the form?

	private void CallRMAProcAdapterUpdateMethod()
	{
			//var intRMA = Convert.ToInt32("2");   //Convert.ToInt32(tbCustomerCustNum.Text);
			// Declare and Initialize EpiDataView Variables
			// Declare and create an instance of the Adapter.
			RMAProcAdapter adapterRMAProc = new RMAProcAdapter(this.oTrans);
			adapterRMAProc.BOConnect();
			if(adapterRMAProc.GetByID(InvcHead.RMANum)); //if(adapterRMAProc.GetByID(2));
			{
			adapterRMAProc.RMAProcData.RMAHead[0].OpenRMA = false;
			}
			adapterRMAProc.Update();
			adapterRMAProc.Dispose();

		} 

You’ll want to get ahold of the rma num from the dataview (I’ve seen you do this before so I have faith you won’t need the code!) and then either create a variable from it and pass that variable into the method or you can directly pass the dataview value into the method

Ha, I just reread an old answer from you! I think I got it figured out…thanks for the confidence lol. These dataview things always stump me!

	private void CallRMAProcAdapterUpdateMethod()
	{
			EpiDataView edvInvcHead = (EpiDataView)oTrans.EpiDataViews["InvcHead"];
			var RMANum = edvInvcHead.dataView[edvInvcHead.Row]["RMANum"];
			// Declare and Initialize EpiDataView Variables
			// Declare and create an instance of the Adapter.
			RMAProcAdapter adapterRMAProc = new RMAProcAdapter(this.oTrans);
			adapterRMAProc.BOConnect();
			if(adapterRMAProc.GetByID(RMANum)); //if(adapterRMAProc.GetByID(2));
			{
			adapterRMAProc.RMAProcData.RMAHead[0].OpenRMA = false;
			}
			adapterRMAProc.Update();
			adapterRMAProc.Dispose();

		} 
1 Like

One thing to comment on…

This if statement is evaluating if the GetByID method returns true/false. Since you closed the statement with a semi-colon, this statement will always then execute the code inside the bracket below.

You’d be better served removing the semi-colon and letting the statement execute only if the GetByID method returns true.

2 Likes

is not better to call the close method from the RMA BO instead ? so all the BO logic will run and DB get validated.