private void txt_org_Click(object sender, EventArgs e)
 {
     txt_org.DataSource = General_methods.fill_companys_combobx();
     txt_org.Text       = "";
 }
 private void metroTile1_Click(object sender, EventArgs e)
 {
     if (txt_nic_already_exists.Text == "")
     {
         MessageBox.Show(this, "Please enter NIC to search", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if ((txt_nic_already_exists.Text.Length == 12 || txt_nic_already_exists.Text.Length == 10) == false)
     {
         MessageBox.Show(this, "Invalid NIC entered. Please enter valid NIC number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (txt_nic_already_exists.Text.Length == 12 && txt_nic_already_exists.Text.Any(char.IsLetter) == true)
     {
         MessageBox.Show(this, "Invalid NIC entered. Please enter valid NIC number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (txt_nic_already_exists.Text.Length == 10 && (txt_nic_already_exists.Text.Last() != 'V' || txt_nic_already_exists.Text.Last() != 'X' || txt_nic_already_exists.Text.Last() != 'v' || txt_nic_already_exists.Text.Last() != 'x'))
     {
         MessageBox.Show(this, "Invalid NIC entered. Please enter valid NIC number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (d3.singleInt("SELECT COUNT(*) FROM Stud_details WHERE NIC ='" + txt_nic_already_exists.Text + "'") == 0)
     {
         MessageBox.Show(this, "A student with this NIC is not recorded in the system", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         state = true;
         txt_org.DataSource = General_methods.fill_companys_combobx();
         DialogResult d = MessageBox.Show(this, "Student with NIC " + txt_nic_already_exists.Text + " Found in system. Load Details of student?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (d == DialogResult.Yes)
         {
             SqlConnection con2 = new SqlConnection(Credentials.connection);
             con2.Open();
             SqlCommand    cmd = new SqlCommand("SELECT * FROM Stud_details WHERE NIC='" + txt_nic_already_exists.Text + "'", con2);
             SqlDataReader dr  = cmd.ExecuteReader();
             dr.Read();
             ref_stud_no         = dr.GetValue(0).ToString();
             txt_firstname.Text  = dr.GetValue(1).ToString();
             txt_middlename.Text = dr.GetValue(2).ToString();
             txt_lname.Text      = dr.GetValue(3).ToString();
             if (dr.GetValue(4).ToString() == "male")
             {
                 metroRadioButton6.Checked = true;
             }
             else
             {
                 metroRadioButton5.Checked = true;
             }
             txt_nic.Text                   = dr.GetValue(5).ToString();
             txt_org.Text                   = General_methods.find_organization_name_from_organization_no(dr.GetValue(6).ToString());
             txt_desig.Text                 = dr.GetValue(7).ToString();
             txt_Radd.Text                  = dr.GetValue(8).ToString();
             txt_mobile.Text                = dr.GetValue(9).ToString();
             txt_residence_tel.Text         = dr.GetValue(10).ToString();
             txt_resi_email.Text            = dr.GetValue(11).ToString();
             metroDateTime1.Value           = Convert.ToDateTime(dr.GetValue(14));
             txt_contact_person_1_name.Text = dr.GetValue(15).ToString();
             txt_contacts_person_1_no.Text  = dr.GetValue(16).ToString();
             txt_contact_person_2_name.Text = dr.GetValue(17).ToString();
             txt_contact_person_2_no.Text   = dr.GetValue(18).ToString();
             txt_homeno.Text                = dr.GetValue(22).ToString();
             General_methods.get_stud_pic(pictureBox1, dr.GetValue(0).ToString());
             foreach (Control c in groupBox5.Controls)
             {
                 if (c is CheckBox && c.Text == dr.GetValue(19).ToString())
                 {
                     CheckBox v = (CheckBox)c;
                     v.Checked = true;
                 }
             }
             dr.Close();
             con2.Close();
         }
         else
         {
         }
     }
 }
 private void Edit_workplace_info_Load(object sender, EventArgs e)
 {
     txt_org.DataSource = General_methods.fill_companys_combobx();
 }