CopyCode The Code is as follows: protected void txtqty_textchanged (Object sender, eventargs E)
{
Checkform ();
}
// Check whether the text information is valid. If the text information is valid, the calculation starts.
Protected void checkform ()
{
Try
{
If (! Isnumberic (txtqty. Text) & txtqty. Text! = "")
{
Checkbool = false;
Response. Write ("<SCRIPT> alert (the number can only be numbers. Please enter the number 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 ('tax amount can only be a number. Please enter the number 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 the number 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: determines whether the input is a number.
/// Parameter: String otext: Source Text
/// Return value: bool true: false: No
/// </Summary>
Public bool isnumberic (string otext)
{
Try
{
// Conversion from string to double-precision value. If the string is converted to double, true is returned. Otherwise, false is returned.
Double var1 = convert. todouble (otext );
Return true;
}
Catch
{
Return false;
}
}
}