So I’m trying to be a good EpiCitizen, and update EDV rather than the textbox on screen. I have the following, but it doesn’t blank out the visible TextBox value or cause it to be saved.
So a bit more backround. It’s on the Part screen, and I want to prevent typing into the EpiTextBox and instead force a Search. The Search massively limits the list of available parts. This all works fine. But because the EpiTextBox is ReadOnly/Disabled - I have to have a separate button to perform the Clear of this field if it is no longer required on the Part record.
Just tweaked it slightly to match the wizard provided code:
private static void SearchOnPartAdapterShowDialog()
{
// Wizard Generated Search Method
// You will need to call this method from another method in custom code
// For example, [Form]_Load or [Button]_Click
bool recSelected;
string whereClause = "PartNum LIKE '%QA'";
System.Data.DataSet dsPartAdapter = Ice.UI.FormFunctions.SearchFunctions.listLookup(Script.oTrans, "PartAdapter", out recSelected, true, whereClause);
if (recSelected)
{
System.Data.DataRow adapterRow = dsPartAdapter.Tables[0].Rows[0];
// Map Search Fields to Application Fields
EpiDataView edvPart = ((EpiDataView)(Script.oTrans.EpiDataViews["Part"]));
System.Data.DataRow edvPartRow = edvPart.CurrentDataRow;
if ((edvPartRow != null))
{
edvPartRow.BeginEdit();
edvPartRow["SamplePartNum_c"] = adapterRow["PartNum"];
edvPartRow.EndEdit();
}
}
}
private static void btnLabSample_Click(object sender, System.EventArgs args)
{
SearchOnPartAdapterShowDialog();
}
private static void btnClearQASample_Click(object sender, System.EventArgs args)
{
EpiDataView edvPart = ((EpiDataView)(Script.oTrans.EpiDataViews["Part"]));
System.Data.DataRow edvPartRow = edvPart.CurrentDataRow;
if ((edvPartRow != null))
{
edvPartRow.BeginEdit();
edvPartRow["SamplePartNum_c"] = String.Empty;
edvPartRow.EndEdit();
}
}
I tried changing the method away from Static, but get this error:
Compiling Custom Code ...
----------errors and warnings------------
Error: CS0708 - line 245 (4267) - 'btnClearQASample_Click': cannot declare instance members in a static class
** Compile Failed. **
I don’t want to change the Class definition, because it’s the base Epicor form.