Message Box with Input as a Number

I have a form prompt that pops up and the user can enter a line number in it. I want to use this as the Line # to input into a BO update. I am running into an issue with how to declare a number box instead of a text box. Below is my code and it is the line:
TextBox inputBox

I need this to be a number or return a number and not a text string.

//Order - Cancel/Close Order Line
private void CallSalesOrderAdapterUpdateMethodCancelLine()
	{
		try
		{
			Form prompt = new Form();
			prompt.StartPosition = FormStartPosition.CenterScreen;
			prompt.Width = 200;
			prompt.Height = 150;
			prompt.Text = "Order Line";
        	Label textLabel = new Label() { Left = 15, Width=50, Top=20, Text="Order Line" };
			//TextBox inputnumberBox = new NumberBox () { Left = 55, Top=20, Width=50, Height=23 };
        	**_TextBox inputBox = new TextBox () { Left = 55, Top=20, Width=50, Height=23 };_**
            Button confirmation = new Button() { Text = "OK", Left=40, Width=100, Top=60 };
            confirmation.Click += (sender, e) => 
				{ 
					if ((inputBox.Text == ""))
					{ 
					prompt.Close();
					}
					else
					{
						prompt.Close();
						}
				};
			  prompt.Controls.Add(confirmation);
          	prompt.Controls.Add(textLabel);
          	prompt.Controls.Add(inputBox);
			  prompt.AcceptButton = confirmation;
          	prompt.ShowDialog();
		
			var orderNum = (int) edvGS_Order_Detail_DataView.dataView[edvGS_Order_Detail_DataView.Row]["OrderHed_OrderNum"];
			**_var orderLine = (int) Convert.ToInt32(inputBox);_**
			SalesOrderAdapter adapterSalesOrder = new SalesOrderAdapter(this.oTrans);
			adapterSalesOrder.BOConnect();
			adapterSalesOrder.CloseOrderLine(orderNum, orderLine);
			adapterSalesOrder.Dispose();
		} 
			catch (System.Exception ex)
		{
			ExceptionBox.Show(ex);
		}
	}

Maybe try

var orderLine = (int) Convert.ToInt32(inputBox.Text);

or tryparse:

int result = 0;
if (Int32.TryParse(inputBox.Text,  out result))
{
    // you know that the parsing attempt
    // was successful ...make the update.

}

Edit: but personnaly, whenever I need a special form to popup, I go into Visual Studio and create the form test it and when all is fine, copy the form class into my customization at the end.

Pierre

BPMs have a Info Prompt that you can accomplish this without code.

2 Likes

Have you tried a BPM Form? The CallContextBPM variables are already declared and passed between the BPM and Form.

1 Like

Hi Pierre,
I have Visual Studio and have always wanted to do what you suggest. Is there a guide somewhere on how to do it?
Thanks
Adrian
@Hogardy

Well you make a form into VS test it and when ready, copy the contents of the cs files:
I attached a doc about a test I did

.Implement VS form into Epicor customization.doc (68 KB)

Hope it answers your request…

Pierre

3 Likes

Thanks very much Pierre. I will give it a try.
Adrian