public void set_items_to_items_list(string type, List <string> k) { if (type == "other") { k.Clear(); con.Open(); SqlCommand cmd = new SqlCommand("SELECT s.program_no,s.scheduled_date,c.Program_title,s.course_type,s.course_no FROM Session_details s INNER JOIN Short_program_details c ON s.program_no=c.Code WHERE s.course_type='Workshop' OR s.course_type='One-day' OR s.course_type='Two-day'OR s.course_type='Three-day' ", con); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { if (dr.GetValue(2).ToString() == "None") { k.Add(dr.GetValue(0).ToString() + " - " + dr.GetDateTime(1).ToString("dd/MM/yyy") + " - " + General_methods.get_course_name_from_course_no(dr.GetValue(4).ToString()) + " - " + dr.GetValue(3).ToString()); } else { k.Add(dr.GetValue(0).ToString() + " - " + dr.GetDateTime(1).ToString("dd/MM/yyy") + " - " + dr.GetValue(2).ToString() + " - " + dr.GetValue(3).ToString()); } } con.Close(); } else { k.Clear(); txt_enter_name.Items.Clear(); txt_enter_name.Text = ""; con.Open(); SqlCommand cmd = new SqlCommand("SELECT stud_no,f_name,m_name,l_name,NIC,ref,course_no FROM Stud_details", con); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { if (General_methods.get_course_type_from_course_no(dr.GetValue(6).ToString()) == type) { if (dr.IsDBNull(5)) { k.Add(dr.GetValue(0).ToString() + " - " + dr.GetValue(1).ToString() + " " + dr.GetValue(2).ToString() + " " + dr.GetValue(3).ToString() + " - " + dr.GetValue(4).ToString()); } else { SqlConnection con2 = new SqlConnection(Credentials.connection); SqlCommand cmd2 = new SqlCommand("SELECT f_name,m_name,l_name,NIC,course_no FROM Stud_details WHERE stud_no='" + dr.GetValue(5).ToString() + "'", con2); con2.Open(); SqlDataReader dr2 = cmd2.ExecuteReader(); dr2.Read(); k.Add(dr.GetValue(0).ToString() + " - " + dr2.GetValue(0).ToString() + " " + dr2.GetValue(1).ToString() + " " + dr2.GetValue(2).ToString() + " - " + dr2.GetValue(3).ToString()); dr2.Close(); con2.Close(); } } } con.Close(); } }
private void metroTile1_Click_1(object sender, EventArgs e) { Edit_students_courses.batchno = txt_batchno.Text; Edit_students_courses.stud_no = txt_no.Text; Edit_students_courses.c_no = txt_course_code.Text; p = new Edit_students_courses(); p.cmb_type.Text = General_methods.get_course_type_from_course_no(txt_course_code.Text); //p.cmb_batch.DataSource = General_methods.fill_batches_combobox(p.cmb_type.Text); //p.txt_studno_1.Text = txt_no.Text; p.cmb_batch.Text = txt_batch_name.Text; //p.metroTile5.Enabled = false; /*p.txt_batch_no.Text = General_methods.get_batch_no_from_batch_name(txt_batch_name.Text); * p.txt_course_namer.Text = General_methods.get_course_name_from_course_no(General_methods.get_course_no_of_batch_from_batch_no(p.txt_batch_no.Text)); * p.cmb_medium.Text = General_methods.get_medium_from_batch_no(p.txt_batch_no.Text); * p.txt_studno_1.Text = txt_no.Text;*/ p.Show(); p.metroTile5.Click += HandleCustomEvent2; p.label1.TextChanged += HandleCustomEvent2; }
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; } } }