private void txt_nic_TextChanged(object sender, EventArgs e)
        {
            string str = txt_nic.Text;

            formValidator3.Clear();
            if (!(str.Length == 0))
            {
                if ((str.Count(char.IsDigit) == 9) &&                          // only 9 digits
                    (str.EndsWith("X", StringComparison.OrdinalIgnoreCase) ||
                     str.EndsWith("V", StringComparison.OrdinalIgnoreCase)) && //a letter at the end 'x' or 'v'
                    (str[2] != '4' && str[2] != '9'))                          //3rd digit can not be equal to 4 or 9
                {
                    FormValidator.Clear();
                    FormValidator2.Clear();
                }
                else
                {
                    FormValidator2.Clear();
                    FormValidator.SetError(txt_nic, "please check your NIC Number");
                }
            }
            else
            {
                FormValidator2.SetError(txt_nic, "Please enter your nic number");
            }
        }
        private void txt_email_TextChanged(object sender, EventArgs e)
        {
            FormValidator.Clear();
            formValidator3.Clear();
            bool value;

            email = txt_email.Text;


            if (!(email.Length == 0))
            {
                value = emailIsValid(email);

                if (value == true)
                {
                    email = txt_email.Text;
                }
                else
                {
                    //show an error
                    FormValidator.SetError(txt_email, "Please check your email again");
                }
            }
            else
            {
                FormValidator.SetError(txt_email, "Please enter your email again");
            }
        }
 private void txt_question3_TextChanged(object sender, EventArgs e)
 {
     if (!(txt_question3.Text.Length == 0))
     {
         formValidator3.Clear();
         FormValidator.Clear();
         FormValidator2.Clear();
     }
 }
 private void txt_lastName_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (Char.IsControl(e.KeyChar) != true && Char.IsNumber(e.KeyChar) == true)
     {
         if (!(e.Handled == true))
         {
             FormValidator.SetError(txt_lastName, "Accepting only Charactors");
             e.Handled = true;
         }
     }
     else if (Char.IsControl(e.KeyChar) == true && Char.IsNumber(e.KeyChar) == false)
     {
         FormValidator.Clear();
     }
 }
 private void txt_contact_TextChanged(object sender, EventArgs e)
 {
     try
     {
         if (!(txt_contact.Text.Length == 0))
         {
             FormValidator.Clear();
             if (txt_contact.Text.Length > 10)
             {
                 txt_contact.BackColor = Color.IndianRed;
                 FormValidator.SetError(txt_contact, "Please check your contact Number");
             }
             else if (txt_contact.Text.Length < 7)
             {
                 txt_contact.BackColor = Color.IndianRed;
                 FormValidator.SetError(txt_contact, "Please check your contact Number");
             }
             else
             {
                 formValidator3.Clear();
                 FormValidator.Clear();
                 txt_contact.BackColor = Color.LightGreen;
             }
         }
         else if (txt_contact.Text.Length == 0)
         {
             FormValidator.SetError(txt_contact, "Please enter your contact Number");
         }
     }
     catch (FormatException)
     {
         FormValidator.SetError(txt_contact, "not allowed to enter charactors");
     }
     catch (OverflowException)
     {
         FormValidator.SetError(txt_contact, "Please check your contact Number");
     }
     catch (Exception)
     {
         FormValidator.SetError(txt_contact, "Please check your contact Number");
     }
 }
 private void txt_contact_TextChanged(object sender, EventArgs e)
 {
     if (txt_contact.Text.Length == 0)
     {
         txt_firstName.Clear();
         txt_lastName.Clear();
         txt_companyName.Clear();
         rrtxt_fullAddress.Clear();
         txt_contactNum.Clear();
         txt_nic.Clear();
         txt_email.Clear();
         txt_faxNum.Clear();
         txt_siteName.Clear();
         rtxt_comments.Clear();
         db.closeCon();
         FormValidator.Clear();
         FormValidator2.Clear();
         groupBox2.Enabled = false;
         groupBox3.Enabled = false;
     }
 }
示例#7
0
 private void btn_save_Click(object sender, EventArgs e)
 {
     if (!((txt_firstName.Text.Equals(null)) && (txt_lastName.Text.Equals(null)) && (txt_companyName.Text.Equals(null)) && (txt_line1.Text.Equals(null)) && (txt_line2.Text.Equals(null)) && (txt_contactNum.Text.Equals(null))))
     {
         string sql;
         sql = "Insert into supplier_table(supp_ID,supp_FirstName,supp_lastName,company_Name,company_Address,contactNumber,NIC,emailAddress,RegisteredDate,fax_Num,web_siteName,Comments)" +
               "Values('" + txt_suppID.Text + "','" + txt_firstName.Text + "','" + txt_lastName.Text + "','" + txt_companyName.Text + "','" + ((txt_line1.Text) + (txt_line2.Text) + (txt_city.Text)) + "','" + txt_contactNum.Text + "','" + txt_nic.Text + "','" + txt_email.Text + "','" + dtp_regDate.Value.ToString() + "','" + txt_faxNum.Text + "','" + txt_siteName.Text + "','" + rtxt_comments.Text + "')";
         int line = db.update_del_insert_Data(sql);
         db.closeCon();
         if (line == 1)
         {
             MessageBox.Show("Supplier successfully saved", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txt_firstName.Clear();
             txt_lastName.Clear();
             txt_companyName.Clear();
             txt_line1.Clear();
             txt_line2.Clear();
             txt_city.Clear();
             txt_contactNum.Clear();
             txt_nic.Clear();
             txt_email.Clear();
             txt_faxNum.Clear();
             txt_siteName.Clear();
             rtxt_comments.Clear();
             txt_suppID.Clear();
             FormValidator.Clear();
             FormValidator2.Clear();
             formValidator3.Clear();
             Error_empInfo.Clear();
         }
         else
         {
             MessageBox.Show("Supplier register process is failed.Please try again thank you", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("Please check the form and try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void txt_email_KeyPress(object sender, KeyPressEventArgs e)
 {
     FormValidator.Clear();
 }