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; } } }
public UC_payments() { InitializeComponent(); txt_mod_wise_discount.Text = "00"; txt_amount_paying_module_wise.Text = "0"; pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; DataGridViewTextBoxColumn module = new DataGridViewTextBoxColumn(); DataGridViewTextBoxColumn amount = new DataGridViewTextBoxColumn(); module.HeaderText = "Module Name"; amount.HeaderText = "Amount"; module.ReadOnly = true; metroGrid1.Columns.Add(module); metroGrid1.Columns.Add(amount); if ((d.singleInt("SELECT COUNT(*) FROM Dip_stud_modules WHERE stud_no='" + studno + "' AND payement_no=(SELECT TOP 1 payement_no FROM Dip_stud_modules WHERE stud_no='" + studno + "' AND payement_no!='NULL')") == d.singleInt("SELECT COUNT(*) FROM Dip_stud_modules WHERE stud_no='" + studno + "'")) && d.singleInt("SELECT COUNT(*) FROM Dip_stud_modules WHERE stud_no='" + studno + "'") != 0) { groupBox3.Enabled = false; metroRadioButton1.Checked = true; metroRadioButton2.Enabled = false; groupBox2.Enabled = false; groupBox2.Text = "Full payement already done"; } else { metroRadioButton2.Checked = true; if (d.singleInt("SELECT COUNT(*) FROM Dip_stud_modules WHERE stud_no='" + studno + "' AND payement_no IS NULL") != d.singleInt("SELECT COUNT(*) FROM Dip_stud_modules WHERE stud_no='" + studno + "' ")) { metroRadioButton1.Enabled = false; } con.Open(); SqlCommand cmd = new SqlCommand("SELECT module_no,payement_no FROM Dip_stud_modules WHERE stud_no='" + studno + "'", con); SqlDataReader dr = cmd.ExecuteReader(); int i = 0; while (dr.Read()) { checkedListBox1.Items.Add(General_methods.get_module_name_from_module_no(dr.GetValue(0).ToString()).ToString()); if (dr.IsDBNull(1)) { } else { checkedListBox1.SetItemChecked(i, true); a.Add(i); } i++; } con.Close(); dr.Close(); checkedListBox1.CheckOnClick = true; } con.Open(); SqlCommand cmd2 = new SqlCommand("SELECT reg_fee FROM Stud_details WHERE stud_no='" + studno + "'", con); SqlDataReader dr2 = cmd2.ExecuteReader(); dr2.Read(); if (!dr2.IsDBNull(0)) { groupBox4.Enabled = false; groupBox4.Text = "Registration fee payed"; } else { } dr2.Close(); con.Close(); con.Open(); metroGrid2.BorderStyle = BorderStyle.FixedSingle; SqlDataAdapter da = new SqlDataAdapter("SELECT Payment_No,Gross_amount,Discount_percent,Net_amount,Date,Time,Remark FROM PaymentDetails WHERE stud_no_org_no='" + studno + "'", con); DataTable dt = new DataTable(); da.Fill(dt); dt.Columns.Add("Modules included in payment"); con.Close(); SqlConnection con2 = new SqlConnection(Credentials.connection); con2.Open(); foreach (DataRow dr in dt.Rows) // search whole table { string modulename = null; SqlCommand cmd5 = new SqlCommand("SELECT module_no FROM Dip_stud_modules WHERE payement_no='" + dr["Payment_No"].ToString() + "'", con2); SqlDataReader dra = cmd5.ExecuteReader(); while (dra.Read()) { modulename = modulename + General_methods.get_module_name_from_module_no(dra.GetValue(0).ToString()) + " , "; } dr["Modules included in payment"] = modulename; dra.Close(); } metroGrid2.DataSource = dt; DataGridViewButtonColumn bt = new DataGridViewButtonColumn(); bt.Text = "Terminate Payment"; bt.FlatStyle = FlatStyle.Flat; bt.UseColumnTextForButtonValue = true; bt.Width = 150; metroGrid2.Columns.Add(bt); DataGridViewButtonColumn bt2 = new DataGridViewButtonColumn(); bt2.Text = "Generate Recipt"; bt2.FlatStyle = FlatStyle.Flat; bt2.UseColumnTextForButtonValue = true; bt2.Width = 150; metroGrid2.Columns.Add(bt2); metroGrid2.Columns[6].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; metroGrid2.Columns[7].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; metroGrid2.AllowUserToAddRows = false; con2.Close(); metroGrid2.Columns[4].DefaultCellStyle.Format = "dd/MM/yyyy"; }
private void Certifs_view_Load(object sender, EventArgs e) { Database d1 = new Database(); int count = d1.singleInt("SELECT COUNT(*) FROM Dip_module_details_2 WHERE Course_no='" + Student_profiles.cno + "'"); con.Open(); if (count > 7) { SqlCommand cmd = new SqlCommand("SELECT mod1,mod2,mod3,mod4,mod5,mod6,mod7,mod8 FROM Dip_stud_modules WHERE stud_no='" + Student_profiles.no + "' ", con); SqlDataReader r = cmd.ExecuteReader(); r.Read(); mod1_nam.Text = General_methods.get_module_name_from_module_no(r.GetValue(0).ToString()); mod2_nam.Text = General_methods.get_module_name_from_module_no(r.GetValue(1).ToString()); mod3_nam.Text = General_methods.get_module_name_from_module_no(r.GetValue(2).ToString()); mod4_nam.Text = General_methods.get_module_name_from_module_no(r.GetValue(3).ToString()); mod5_nam.Text = General_methods.get_module_name_from_module_no(r.GetValue(4).ToString()); mod6_nam.Text = General_methods.get_module_name_from_module_no(r.GetValue(5).ToString()); mod7_nam.Text = General_methods.get_module_name_from_module_no(r.GetValue(6).ToString()); mod8_nam.Text = General_methods.get_module_name_from_module_no(r.GetValue(7).ToString()); r.Close(); } else if (count > 6) { SqlCommand cmd = new SqlCommand("SELECT mod1,mod2,mod3,mod4,mod5,mod6,mod7 FROM Dip_stud_modules WHERE stud_no='" + Student_profiles.no + "' ", con); SqlDataReader r = cmd.ExecuteReader(); r.Read(); mod1_nam.Text = General_methods.get_module_name_from_module_no(r.GetValue(0).ToString()); mod2_nam.Text = General_methods.get_module_name_from_module_no(r.GetValue(1).ToString()); mod3_nam.Text = General_methods.get_module_name_from_module_no(r.GetValue(2).ToString()); mod4_nam.Text = General_methods.get_module_name_from_module_no(r.GetValue(3).ToString()); mod5_nam.Text = General_methods.get_module_name_from_module_no(r.GetValue(4).ToString()); mod6_nam.Text = General_methods.get_module_name_from_module_no(r.GetValue(5).ToString()); mod7_nam.Text = General_methods.get_module_name_from_module_no(r.GetValue(6).ToString()); mod8_nam.Text = ""; r.Close(); } else if (count > 5) { SqlCommand cmd = new SqlCommand("SELECT mod1,mod2,mod3,mod4,mod5,mod6 FROM Dip_stud_modules WHERE stud_no='" + Student_profiles.no + "' ", con); SqlDataReader r = cmd.ExecuteReader(); r.Read(); mod1_nam.Text = General_methods.get_module_name_from_module_no(r.GetValue(0).ToString()); mod2_nam.Text = General_methods.get_module_name_from_module_no(r.GetValue(1).ToString()); mod3_nam.Text = General_methods.get_module_name_from_module_no(r.GetValue(2).ToString()); mod4_nam.Text = General_methods.get_module_name_from_module_no(r.GetValue(3).ToString()); mod5_nam.Text = General_methods.get_module_name_from_module_no(r.GetValue(4).ToString()); mod6_nam.Text = General_methods.get_module_name_from_module_no(r.GetValue(5).ToString()); mod7_nam.Text = ""; mod8_nam.Text = ""; r.Close(); } else if (count > 4) { SqlCommand cmd = new SqlCommand("SELECT mod1,mod2,mod3,mod4,mod5 FROM Dip_stud_modules WHERE stud_no='" + Student_profiles.no + "' ", con); SqlDataReader r = cmd.ExecuteReader(); r.Read(); mod1_nam.Text = General_methods.get_module_name_from_module_no(r.GetValue(0).ToString()); mod2_nam.Text = General_methods.get_module_name_from_module_no(r.GetValue(1).ToString()); mod3_nam.Text = General_methods.get_module_name_from_module_no(r.GetValue(2).ToString()); mod4_nam.Text = General_methods.get_module_name_from_module_no(r.GetValue(3).ToString()); mod5_nam.Text = General_methods.get_module_name_from_module_no(r.GetValue(4).ToString()); mod6_nam.Text = ""; mod7_nam.Text = ""; mod8_nam.Text = ""; r.Close(); } SqlCommand cmd1 = new SqlCommand("SELECT mod1,mod2,mod3,mod4,mod5,mod6,mod7,mod8 FROM Dip_stud_certifs WHERE stud_no='" + Student_profiles.no + "'", con); SqlDataReader dr = cmd1.ExecuteReader(); dr.Read(); // MessageBox.Show(dr.GetValue(0).ToString()); if (count > 7) { mod1_stat.Text = set(dr.GetValue(0).ToString()); mod2_stat.Text = set(dr.GetValue(1).ToString()); mod3_stat.Text = set(dr.GetValue(2).ToString()); mod4_stat.Text = set(dr.GetValue(3).ToString()); mod5_stat.Text = set(dr.GetValue(4).ToString()); mod6_stat.Text = set(dr.GetValue(5).ToString()); mod7_stat.Text = set(dr.GetValue(6).ToString()); mod8_stat.Text = set(dr.GetValue(7).ToString()); } else if (count > 6) { mod1_stat.Text = set(dr.GetValue(0).ToString()); mod2_stat.Text = set(dr.GetValue(1).ToString()); mod3_stat.Text = set(dr.GetValue(2).ToString()); mod4_stat.Text = set(dr.GetValue(3).ToString()); mod5_stat.Text = set(dr.GetValue(4).ToString()); mod6_stat.Text = set(dr.GetValue(5).ToString()); mod7_stat.Text = set(dr.GetValue(6).ToString()); mod8_stat.Text = ""; } else if (count > 5) { mod1_stat.Text = set(dr.GetValue(0).ToString()); mod2_stat.Text = set(dr.GetValue(1).ToString()); mod3_stat.Text = set(dr.GetValue(2).ToString()); mod4_stat.Text = set(dr.GetValue(3).ToString()); mod5_stat.Text = set(dr.GetValue(4).ToString()); mod6_stat.Text = set(dr.GetValue(5).ToString()); mod7_stat.Text = ""; mod8_stat.Text = ""; } else if (count > 4) { mod1_stat.Text = set(dr.GetValue(0).ToString()); mod2_stat.Text = set(dr.GetValue(1).ToString()); mod3_stat.Text = set(dr.GetValue(2).ToString()); mod4_stat.Text = set(dr.GetValue(3).ToString()); mod5_stat.Text = set(dr.GetValue(4).ToString()); mod6_stat.Text = ""; mod7_stat.Text = ""; mod8_stat.Text = ""; } }