Exemple #1
0
 public static int checkNullMetrotxt(MetroFramework.Controls.MetroTextBox txt)
 {
     if (txt.Text.Trim() == "")
     {
         MessageBox.Show("กรุณาระบุข้อมูลให้ครบถ้วน");
         txt.Focus();
         return 0;
     }
     return 1;
 }
 public static bool IsPresent(MetroFramework.Controls.MetroTextBox textBox, string name)
 {
     if (textBox.Text == "")
     {
         MessageBox.Show(name + " is a required field.", "Entry Error");
         textBox.Focus();
         return false;
     }
     return true;
 }
 public static bool IsWithinRange(MetroFramework.Controls.MetroTextBox textBox, string name,
     decimal min, decimal max)
 {
     decimal number = Convert.ToDecimal(textBox.Text);
     if (number < min || number > max)
     {
         MessageBox.Show(name + " must be between " + min
             + " and " + max + ".", "Entry Error");
         textBox.Focus();
         return false;
     }
     return true;
 }
 public static bool IsInt32(MetroFramework.Controls.MetroTextBox textBox, string name)
 {
     int number = 0;
     if (Int32.TryParse(textBox.Text, out number))
     {
         return true;
     }
     else
     {
         MessageBox.Show(name + " must be an integer.", "Entry Error");
         textBox.Focus();
         return false;
     }
 }
 public static bool IsDecimal(MetroFramework.Controls.MetroTextBox textBox, string name)
 {
     decimal number = 0m;
     if (Decimal.TryParse(textBox.Text, out number))
     {
         return true;
     }
     else
     {
         MessageBox.Show(name + " must be a decimal value.", "Entry Error");
         textBox.Focus();
         return false;
     }
 }