private void txt_org_SelectedIndexChanged(object sender, EventArgs e)
 {
     string[] d = General_methods.get_organization_details_from_org_name(txt_org.Text);
     txt_Oadd.Text         = d[0];
     txt_office_tel_1.Text = d[1];
     txt_oemail.Text       = d[2];
     txt_fax.Text          = d[3];
 }
        public void redraw_controls(string data)
        {
            invisible();
            con.Open();
            SqlCommand    cmd = new SqlCommand("SELECT * FROM Stud_details WHERE stud_no='" + data + "' ", con);
            SqlDataReader dr  = cmd.ExecuteReader();

            dr.Read();
            if (dr.IsDBNull(23))
            {
                txt_no.Text                      = dr.GetValue(0).ToString();
                no                               = dr.GetValue(0).ToString();
                txt_fname.Text                   = dr.GetValue(1).ToString() + " " + dr.GetValue(2).ToString() + " " + dr.GetValue(3).ToString();
                txt_gender.Text                  = dr.GetValue(4).ToString();
                txt_nic.Text                     = dr.GetValue(5).ToString();
                txt_desig.Text                   = dr.GetValue(7).ToString();
                txt_address.Text                 = dr.GetValue(22).ToString() + " " + d.singleString("SELECT Address_string FROM Place_Details WHERE place_id='" + dr.GetValue(8).ToString() + "'");
                txt_resi_tel.Text                = dr.GetValue(10).ToString();
                txt_mobile.Text                  = dr.GetValue(9).ToString();
                txt_resi_email.Text              = dr.GetValue(11).ToString();
                contact_p_1_name.Text            = dr.GetValue(15).ToString();
                contact_p_1_no.Text              = dr.GetValue(16).ToString();
                contact_p_2_name.Text            = dr.GetValue(17).ToString();
                contact_p_2_no.Text              = dr.GetValue(18).ToString();
                txt_batchno.Text                 = dr.GetValue(21).ToString();
                txt_stud_name_with_initials.Text = dr.GetValue(24).ToString();
                txt_batch_name.Text              = General_methods.get_batch_name_from_batch_ne(dr.GetValue(21).ToString());
                txt_course_code.Text             = dr.GetValue(12).ToString();
                txt_course_name.Text             = General_methods.get_course_name_from_course_no(dr.GetValue(12).ToString());
                txt_typ.Text                     = General_methods.get_course_type_from_course_no(dr.GetValue(12).ToString());
                txt_medium.Text                  = dr.GetValue(13).ToString();
                txt_bday.Text                    = Convert.ToDateTime(dr.GetValue(14).ToString()).ToLongDateString();
                txt_age.Text                     = (DateTime.Today.Year - Convert.ToDateTime(txt_bday.Text).Year).ToString();
                txt_org_name.Text                = General_methods.find_organization_name_from_organization_no(dr.GetValue(6).ToString());
                string[] a = General_methods.get_organization_details_from_org_name(txt_org_name.Text);
                txt_oaddress.Text = a[0];
                txt_otel.Text     = a[1];
                txt_oemail.Text   = a[2];
                txt_fax.Text      = a[3];
                if (!dr.IsDBNull(20))
                {
                    General_methods.get_stud_pic(pictureBox1, dr.GetValue(0).ToString());
                }
                visible();
                con.Close();
                dr.Close();
                listBox1.Items.Clear();
                if (General_methods.get_course_type_from_course_no(txt_course_code.Text) == "Diploma")
                {
                    con.Open();
                    SqlCommand    cmd3 = new SqlCommand("SELECT module_no FROM Dip_stud_modules WHERE stud_no='" + txt_no.Text + "'", con);
                    SqlDataReader dr3  = cmd3.ExecuteReader();
                    while (dr3.Read())
                    {
                        listBox1.Items.Add(General_methods.get_module_name_from_module_no(dr3.GetValue(0).ToString()));
                    }
                    dr3.Close();
                    con.Close();
                }
                else
                {
                    groupBox5.Visible = false;
                }
            }
            else
            {
                SqlConnection con2 = new SqlConnection(Credentials.connection);
                SqlCommand    cmd2 = new SqlCommand("SELECT * FROM Stud_details WHERE stud_no='" + dr.GetValue(23).ToString() + "' ", con2);
                con2.Open();
                SqlDataReader dr2 = cmd2.ExecuteReader();
                dr2.Read();
                txt_no.Text                      = dr2.GetValue(0).ToString();
                no                               = dr2.GetValue(0).ToString();
                txt_fname.Text                   = dr2.GetValue(1).ToString() + " " + dr2.GetValue(2).ToString() + " " + dr2.GetValue(3).ToString();
                txt_gender.Text                  = dr2.GetValue(4).ToString();
                txt_nic.Text                     = dr2.GetValue(5).ToString();
                txt_desig.Text                   = dr2.GetValue(7).ToString();
                txt_address.Text                 = dr2.GetValue(22).ToString() + " " + dr.GetValue(22).ToString() + " " + d.singleString("SELECT Address_string FROM Place_Details WHERE place_id='" + dr2.GetValue(8).ToString() + "'");
                txt_resi_tel.Text                = dr2.GetValue(10).ToString();
                txt_mobile.Text                  = dr2.GetValue(9).ToString();
                txt_resi_email.Text              = dr2.GetValue(11).ToString();
                contact_p_1_name.Text            = dr2.GetValue(15).ToString();
                contact_p_1_no.Text              = dr2.GetValue(16).ToString();
                contact_p_2_name.Text            = dr2.GetValue(17).ToString();
                contact_p_2_no.Text              = dr2.GetValue(18).ToString();
                txt_batchno.Text                 = dr.GetValue(21).ToString();
                txt_stud_name_with_initials.Text = dr2.GetValue(24).ToString();
                txt_batch_name.Text              = General_methods.get_batch_name_from_batch_ne(dr.GetValue(21).ToString());
                txt_course_code.Text             = dr.GetValue(12).ToString();
                txt_course_name.Text             = General_methods.get_course_name_from_course_no(dr.GetValue(12).ToString());
                txt_typ.Text                     = General_methods.get_course_type_from_course_no(dr.GetValue(12).ToString());
                txt_medium.Text                  = dr.GetValue(13).ToString();
                txt_org_name.Text                = General_methods.find_organization_name_from_organization_no(dr2.GetValue(6).ToString());
                string[] a = General_methods.get_organization_details_from_org_name(txt_org_name.Text);
                txt_oaddress.Text = a[0];
                txt_otel.Text     = a[1];
                txt_oemail.Text   = a[2];
                txt_fax.Text      = a[3];
                visible();
                con.Close();
                con2.Close();
                dr.Close();
                dr2.Close();
                listBox1.Items.Clear();
                if (General_methods.get_course_type_from_course_no(txt_course_code.Text) == "Diploma")
                {
                    con.Open();
                    SqlCommand    cmd3 = new SqlCommand("SELECT module_no FROM Dip_stud_modules WHERE stud_no='" + txt_no.Text + "'", con);
                    SqlDataReader dr3  = cmd3.ExecuteReader();
                    while (dr3.Read())
                    {
                        listBox1.Items.Add(General_methods.get_module_name_from_module_no(dr3.GetValue(0).ToString()));
                    }
                    dr3.Close();
                    con.Close();
                }
                else
                {
                    groupBox5.Visible = false;
                }
            }
        }