Copy Code code as follows:
protected void Txtqty_textchanged (object sender, EventArgs e)
{
Checkform ();
}
Verify that the text information is legal and start the calculation if it is valid
protected void Checkform ()
{
Try
{
if (! Isnumberic (txtqty.text) && txtqty.text!= "")
{
Checkbool = false;
Response.Write ("<script>alert" number can only be a number, please enter digital information, thank you for your cooperation!) ') </script> ");
Txtqty.text = "";
Txtqty.focus ();
}
else if (Txtqty.text!= "")
{
Qty = Int. Parse (Txtqty.text);
}
if (! Isnumberic (txtvat.text) && txtvat.text!= "")
{
Response.Write ("<script>alert" is only a number, please enter digital information, thank you for your cooperation!) ') </script> ");
Checkbool = false;
Txtvat.text = "";
Txtvat.focus ();
}
else if (Txtvat.text!= "")
{
Vat = Double.Parse (Txtvat.text);
}
if (! Isnumberic (txtunitprice.text) && txtunitprice.text!= "")
{
Response.Write ("<script>alert" price can only be a number, please enter digital information, thank you for your cooperation!) ') </script> ");
Checkbool = false;
Txtunitprice.text = "";
Txtunitprice.focus ();
}
else if (Txtunitprice.text!= "")
{
UnitPrice = Double.Parse (Txtunitprice.text);
}
if (Checkbool = = True)
{
if (Vat!= 0 && exvatamount!= 0)
{
Amountvat = Exvatamount/(1-vat/100);
Txtamountvat.text = Amountvat.tostring ();
}
}
}
catch (Exception ex)
{
Console.WriteLine (ex. message);
}
}
<summary>
Name: Isnumberic
Function: To determine whether the input is a number
Parameters: String Otext: Source text
return value: BOOL true: Yes false: No
</summary>
public bool Isnumberic (string otext)
{
Try
{
Conversion from string to double, string to double, return true if successful, or false.
Double var1 = convert.todouble (Otext);
return true;
}
Catch
{
return false;
}
}
}