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_question3_TextChanged(object sender, EventArgs e)
 {
     if (!(txt_question3.Text.Length == 0))
     {
         formValidator3.Clear();
         FormValidator.Clear();
         FormValidator2.Clear();
     }
 }
 private void txt_mobile_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && (e.KeyChar != '.'))
     {
         e.Handled = true;
         FormValidator2.SetError(txt_mobile, "Please check your contact Number");
     }
     else
     {
         this.FormValidator2.Clear();
     }
 }
Beispiel #4
0
 private void txt_faxNum_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && (e.KeyChar != '.'))
     {
         e.Handled = true;
         FormValidator2.SetError(txt_faxNum, "please check your fax number again");
     }
     else
     {
         this.FormValidator2.Clear();
     }
 }
 private void txt_companuName_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (Char.IsControl(e.KeyChar) != true && Char.IsNumber(e.KeyChar) == true)
     {
         if (!(e.Handled == true))
         {
             FormValidator2.SetError(txt_cmpnyName, "Accepting only Charactors");
             e.Handled = true;
         }
     }
     else if (Char.IsControl(e.KeyChar) == true && Char.IsNumber(e.KeyChar) == false)
     {
         FormValidator2.Clear();
     }
 }
 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;
     }
 }
Beispiel #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);
     }
 }