C# syntax help within E10 customization layer

OK, time to throw in the towel and seek out help from those with a whole lot more C# knowledge than I. I’m almost there but can’t get that last step solved. I’m trying to invoke a quick search within a customization layer to return two values to fill two fields (std only supports one). I’ve got everything but the final step to fill the fields in the edv which will then display on the UI panel when complete. I’ve tried various permutations on this.oTrans and whatever examples I could find which seemed to be germane but to no avail. The std dataview is “POHeader”. Here’s the code I’ve got:

private void DIIbtnVendorID_Click(object sender, System.EventArgs args)
{
	// ** Place Event Handling Code Here **
	object selected = ProcessCaller.InvokeAdapterMethod(oTrans.EpiBaseForm,"QuickSearchAdapter", "ShowQuickSearchForm", new object[]
	{oTrans.EpiBaseForm, "QS_PPointActive", false, new DataTable()});
	
	if (selected != null)
	{
		string Supplier = selected.ToString().Split(';')[0];
		string PurPoint = selected.ToString().Split(';')[1];
		//  What now here??????
		EpiMessageBox.Show("it works!! " + Supplier + "  " + PurPoint);
	}
}

THANKS! to those gurus out there who know C# better than lowly me. (lol)

var edvPoHeader = oTrans.Factory("POHeader");
if(edvPoHeader.Row >=0)
{
     edvPoHeader.dataView[edvPoHeader.Row].BeginEdit();
     edvPoHeader.dataView[edvPoHeader.Row]["Field1"]=Supplier;
     edvPoHeader.dataView[edvPoHeader.Row]["Field2"]=PurPoint;
     edvPoHeader.dataView[edvPoHeader.Row].EndEdit();

}

Thanks for the quick response Jose. Almost there. Compiles if I remove the Begin and EndEdit but doesn’t populate the data fields because the “if” conditional failed (message added inside the braces to trace what’s up and didn’t show). Not sure where the “Factory” came from - haven’t seen that one before now.

What is the error message when you try to compile with beginedit and endedit in?

ok, I got it to work!!! I just tweaked it a tad and now it all works. Here’s what I have:

private void DIIbtnVendorID_Click(object sender, System.EventArgs args)
{
	// ** Place Event Handling Code Here **
	object selected = ProcessCaller.InvokeAdapterMethod(oTrans.EpiBaseForm,"QuickSearchAdapter", "ShowQuickSearchForm", new object[]
	{oTrans.EpiBaseForm, "QS_PPointActive", false, new DataTable()});
	
	if (selected != null)
	{
		string Supplier = selected.ToString().Split(';')[0];
		string PurPoint = selected.ToString().Split(';')[1];

		var edvPoHeader = ((EpiDataView)(this.oTrans.EpiDataViews["POHeader"]));
		if(edvPoHeader.Row >= 0)
		{
		    edvPoHeader.dataView[edvPoHeader.Row]["VendorVendorID"] = Supplier;
		    edvPoHeader.dataView[edvPoHeader.Row]["PurPoint"] = PurPoint;
			//EpiMessageBox.Show("Should fill!! " + Supplier + "  " + PurPoint);
		}
		
		//EpiMessageBox.Show("it works!! " + Supplier + "  " + PurPoint);
	}
}

}

1 Like