Hi Team
I am wanting to use the value in the EpiTextbox to change the status of a EpiShape. I used the code I used to change a Epishape using a EpiCheckBox but I’m not quite sure about the syntax/methods needed for using it with a EpiTextBox. The following code compiles but does not have the desired effect. It does not change to True when the condition is not met.
Any help would be much appreciated
> Blockquote
> public class Script
> {
> // ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
> // Begin Wizard Added Module Level Variables **
> public EpiShape sSuggShow;
> public EpiTextBox tbSuggField;
>
> // End Wizard Added Module Level Variables **
>
> // Add Custom Module Level Variables Here **
>
> public void InitializeCustomCode()
> {
>
> // ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
> // Begin Wizard Added Variable Initialization
> sSuggShow = (EpiShape)csm.GetNativeControlReference("43d9342a-3544-4ea3-af88-b205> b173eb51");
> tbSuggField = (EpiTextBox)csm.GetNativeControlReference("b52976bb-92cc-484d-a31->ed51e048e749");
> // End Wizard Added Variable Initialization
>
> // Begin Wizard Added Custom Method Calls
> sSuggShow.Enabled = false;
>
> var textbox = (EpiTextBox)csm.GetNativeControlReference("b52976bb-92cc-484d-a131-ed51e048e749");
> {
> if(tbSuggField.Text == "Suggestion")
> {
> sSuggShow.Enabled = false;
> sSuggShow.Status = StatusTypes.Stop;
> }
> else
> {
> sSuggShow.Enabled = true;
> sSuggShow.Status = StatusTypes.OK;
> }
> };
> }
>
> public void DestroyCustomCode()
> {
> // ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
> // Begin Wizard Added Object Disposal
>
> // End Wizard Added Object Disposal
>
> // Begin Custom Code Disposal
>
> // End Custom Code Disposal
> }
> }
InitailizeCustomCode only runs once when the form opens. I think you want this to change when the text value changes. However, if this text box has an EpiBinding, then use RowRules instead.
1 Like
That would be an ideal end state
To update you guys. I want to pull the value from a database field (in this case a UD field from the POHeader table) and check if it meets a criteria. I have set it as [tbSuggfield] in my code however only seem able to be able to return the name of the object “ICE.Framework…” etc. I want to return the contents of the field. Any help would be much appreciated
public class Script
{
// ** Wizard Insert Location - Do Not Remove ‘Begin/End Wizard Added Module Level Variables’ Comments! **
// Begin Wizard Added Module Level Variables **
public EpiShape sSuggShow;
public EpiTextBox tbSuggField;
public string SuggStat;
public string SuggYes;
public string SuggNo;
public string SuggFieldValue;
private EpiBaseAdapter oTrans_poAdapter;
// End Wizard Added Module Level Variables **
// Add Custom Module Level Variables Here **
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete ‘Begin/End Wizard Added Variable Initialization’ lines **
// Begin Wizard Added Variable Initialization
sSuggShow = (EpiShape)csm.GetNativeControlReference(“43d9342a-3544-4ea3-af88-b205b173eb51”);
tbSuggField = (EpiTextBox)csm.GetNativeControlReference(“b52976bb-92cc-484d-a131-ed51e048e749”);
SuggStat = “Suggestion”;
SuggYes = “Yes”;
SuggNo = “No”;
this.oTrans_poAdapter = ((EpiBaseAdapter)(this.csm.TransAdaptersHT[“oTrans_poAdapter”]));
this.oTrans_poAdapter.AfterAdapterMethod += new AfterAdapterMethod(this.oTrans_poAdapter_AfterAdapterMethod);
}
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
private void oTrans_poAdapter_AfterAdapterMethod(object sender, AfterAdapterMethodArgs args)
{
// ** Argument Properties and Uses **
// ** args.MethodName **
// ** Add Event Handler Code **
// ** Use MessageBox to find adapter method name
switch (args.MethodName)
{
case "GetByID":
SuggFieldValue = tbSuggField.ToString();
EpiMessageBox.Show("Start"); // Will remove later
EpiMessageBox.Show(SuggFieldValue + " " + SuggStat); // Will remove later
EpiMessageBox.Show(args.MethodName);
if(tbSuggField.Equals(SuggStat))
{
sSuggShow.Enabled = false;
EpiMessageBox.Show(SuggYes);
//sSuggShow.Status = StatusTypes.Stop;
}
else
{
sSuggShow.Enabled = true;
EpiMessageBox.Show(SuggNo);
//sSuggShow.Status = StatusTypes.OK;
}
EpiMessageBox.Show("Finish"); // Will remove later
break;
}
}
public void DestroyCustomCode()
{
// ** Wizard Insert Location - Do not delete ‘Begin/End Wizard Added Object Disposal’ lines **
// Begin Wizard Added Object Disposal
this.oTrans_poAdapter.AfterAdapterMethod -= new AfterAdapterMethod(this.oTrans_poAdapter_AfterAdapterMethod);
this.oTrans_poAdapter = null;
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
}
This is where I am up to now. Getting an index error.
private void oTrans_poAdapter_AfterAdapterMethod(object sender, AfterAdapterMethodArgs args)
{
// ** Argument Properties and Uses **
EpiDataView poHeaderView=(EpiDataView)(oTrans.EpiDataViews[“POHeader”]);
string GenType = poHeaderView.dataView[poHeaderView.Row][“PONum”].ToString(); //PoGenType_c
// ** args.MethodName **
// ** Add Event Handler Code **
// ** Use MessageBox to find adapter method name
switch (args.MethodName)
{
case "GetByID":
EpiMessageBox.Show("Start"); // Will remove later
EpiMessageBox.Show("T" + " | " + SuggStat); // Will remove later
EpiMessageBox.Show(args.MethodName);
if(SuggStat.Equals(SuggStat))
{
sSuggShow.Enabled = false;
EpiMessageBox.Show(SuggYes);
//sSuggShow.Status = StatusTypes.Stop;
}
else
{
sSuggShow.Enabled = true;
EpiMessageBox.Show(SuggNo);
//sSuggShow.Status = StatusTypes.OK;
}
EpiMessageBox.Show("Finish"); // Will remove later
break;
}
}
It is something to do with this line
string GenType = poHeaderView.dataView[poHeaderView.Row]["PONum"].ToString();
because when i remove it runs without error
For those who are interested. I got to the bottom of it by using the EpiViewNotification, not the AfterAdaptorMethod event. There is no data in the AfterAdaptor. Using EpiViewNotification triggering when initialized (not the default AddRow). Allows you to pull the data in and then do you if statements changes etc.
Hopefully this helps people in the future.
private void edvPOEntryForm_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
{
// ** Argument Properties and Uses **
// view.dataView[args.Row][“FieldName”]
// args.Row, args.Column, args.Sender, args.NotifyType
// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
if ((args.NotifyType == EpiTransaction.NotifyType.Initialize))
{
if ((args.Row > -1))
{
//EpiMessageBox.Show("Start"); // Will remove later
//EpiDataView POValue=(EpiDataView)(oTrans.EpiDataViews["POHeader"]);
//string GenType = POValue.dataView[POValue.Row]["PONum"].ToString(); //PoGenType_c
var myView = oTrans.Factory("POHeader");
if (myView.HasRow)
{
GenType = myView.CurrentDataRow["PoGenType_c"].ToString();
}
else
{
EpiMessageBox.Show("No Rows Found");
}
//EpiMessageBox.Show(myVar + " | " + SuggStat); // Will remove later
//EpiMessageBox.Show(args.Row);
sSuggShow.Enabled = false;
if(GenType.Equals(SuggStat))
{
sSuggShow.Enabled = false;
//EpiMessageBox.Show(SuggYes);
//sSuggShow.Status = StatusTypes.Stop;
}
else
{
sSuggShow.Enabled = true;
//EpiMessageBox.Show(SuggNo);
sSuggShow.Status = StatusTypes.Warning;
}
//EpiMessageBox.Show("Finish"); // Will remove later
}
}
}