private void cmb_name1_SelectedIndexChanged(object sender, EventArgs e) { if (cmb_type_2.SelectedIndex == 0) { cmb_module_2.DataSource = General_methods.fill_module_combobox(General_methods.get_course_no_from_course_name(cmb_name1.Text)); } else { cmb_module_2.Enabled = false; } }
public void edit_batch_no_and_name() { if (cmb_type.Text == "Diploma") { txt_batch_no.Text = "NILS/Dip/" + General_methods.get_course_no_from_course_name(cmb_name.Text) + "/" + cmb_medium.Text + "/" + cmb_year.Text + "/" + dat_startdate.Value.ToString("MMMM") + "/" + txt_batch_for_year.Text; txt_batch_name.Text = cmb_name.Text + "-" + cmb_medium.Text + "-" + cmb_year.Text + "-" + dat_startdate.Value.ToString("MMMM") + "-" + txt_batch_for_year.Text; } else if (cmb_type.Text == "Certificate") { txt_batch_no.Text = "NILS/Certif/" + General_methods.get_course_no_from_course_name(cmb_name.Text) + "/" + cmb_medium.Text + "/" + cmb_year.Text + "/" + dat_startdate.Value.ToString("MMMM") + "/" + txt_batch_for_year.Text; txt_batch_name.Text = cmb_name.Text + "-" + cmb_medium.Text + "-" + cmb_year.Text + "-" + dat_startdate.Value.ToString("MMMM") + "-" + txt_batch_for_year.Text; } }
private void cmb_name_SelectedIndexChanged(object sender, EventArgs e) { con.Open(); SqlCommand cmd = new SqlCommand("SELECT course_no FROM Course_details_master WHERE course_name='" + cmb_name.Text + "'", con); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); if (dr.HasRows) { txt_no.Text = dr.GetValue(0).ToString(); } else { /* dr.NextResult(); * dr.Read(); * if (dr.HasRows) * { * txt_no.Text = dr.GetValue(0).ToString(); * } * else * { * dr.NextResult(); * dr.Read(); * txt_no.Text = dr.GetValue(0).ToString(); * }*/ } if ((cmb_type.SelectedIndex == 0 || cmb_type.SelectedIndex == 1) == false) { txt_progtitle.Text = cmb_name.Text; } dr.Close(); if (cmb_type.SelectedIndex == 0) { cmb_module.DataSource = null; cmb_module.DataSource = General_methods.fill_module_combobox(General_methods.get_course_no_from_course_name(cmb_name.Text)); } con.Close(); }
private void metroTile4_Click(object sender, EventArgs e) { if (txt_mosule_wise_amount_after_discount.Text == "") { MessageBox.Show("Please calculate the final amount", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (txt_amount_paying_module_wise.Text == "") { MessageBox.Show("Paying amounts for modules have not been confirmed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (cmb_payment_mode.Text == "") { MessageBox.Show("Please select payment method", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (cmb_payment_mode.SelectedIndex == 2 && txt_chequeno.Text == "") { MessageBox.Show("Please enter the cheque number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { DialogResult dr = MessageBox.Show("You are about to save a payment. Press yes to confirm", "Notification", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { d.insert("INSERT INTO PaymentDetails(Gross_amount,Discount_percent,Net_amount,Date,Time,stud_no_org_no,program_no,Remark,Payment_mode) VALUES ('" + txt_amount_paying_module_wise.Text.Remove(txt_amount_paying_module_wise.Text.Length - 2, 2).ToString() + "','" + txt_mod_wise_discount.Text + "','" + txt_mosule_wise_amount_after_discount.Text.Remove(txt_mosule_wise_amount_after_discount.Text.Length - 2, 2).ToString() + "','" + General_methods.get_current_date() + "','" + General_methods.get_current_time() + "','" + txt_studno.Text + "','None','Module wise Payement for Diploma course','" + cmb_payment_mode.Text + "')"); int id = d.singleInt("SELECT MAX(Payment_No) FROM PaymentDetails"); for (int i = 0; i < checkedListBox1.Items.Count; i++) { if (checkedListBox1.CheckedItems.Contains(checkedListBox1.Items[i]) == true && a.Contains(i) == false) { d.update("UPDATE Dip_stud_modules SET payement_no='" + id + "' WHERE stud_no='" + txt_studno.Text + "' AND module_no='" + General_methods.get_module_no_from_module_name(checkedListBox1.Items[i].ToString(), General_methods.get_course_no_from_course_name(txt_course_name.Text)) + "'"); } else { } } if (cmb_payment_mode.SelectedIndex == 2) { d.insert("INSERT INTO Cheque_payments (Payment_no,Cheque_no) VALUES ('" + d.singleInt("SELECT MAX(Payment_No) FROM PaymentDetails") + "','" + txt_chequeno.Text + "')"); } MessageBox.Show("Details Saved Successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult a1 = MessageBox.Show("Generate Recipt?", "Notofication", MessageBoxButtons.OK, MessageBoxIcon.Information); //this label is used for event firing label1.Text = General_methods.Generate_RandomNumber(1, 678767).ToString(); ////////////// if (a1 == DialogResult.Yes) { } else { } } else { } } }
private void cmb_medium_TextChanged(object sender, EventArgs e) { if (cmb_medium.Text != "") { if (cmb_type.SelectedIndex == 0) { char a = 'p'; if (cmb_medium.Text == "English") { a = 'E'; } else if (cmb_medium.Text == "Sinhala") { a = 'S'; } else if (cmb_medium.Text == "Tamil") { a = 'T'; } con.Open(); SqlCommand cmd = new SqlCommand("SELECT stud_no FROM Stud_details WHERE course_no='" + General_methods.get_course_no_from_course_name(cmb_course_1.Text) + "'", con); SqlDataReader dr = cmd.ExecuteReader(); List <int> stud_nos = new List <int>(); while (dr.Read()) { stud_nos.Add(Convert.ToInt32(dr.GetValue(0).ToString().Split('/').GetValue(3))); } if (!stud_nos.Any()) { stud_nos.Add(0); } else { } con.Close(); string studno = "D/" + DateTime.Today.Year.ToString().Remove(0, 2) + "/" + d3.singleString("SELECT course_initials FROM Course_details_master WHERE course_no='" + General_methods.get_course_no_from_course_name(cmb_course_1.Text) + "'") + a + "/" + (stud_nos.Max() + 1).ToString(); txt_studno_1.Text = studno; } else if (cmb_type.SelectedIndex == 1) { char a = 'p'; if (cmb_medium.Text == "English") { a = 'E'; } else if (cmb_medium.Text == "Sinhala") { a = 'S'; } else if (cmb_medium.Text == "Tamil") { a = 'T'; } con.Open(); SqlCommand cmd = new SqlCommand("SELECT stud_no FROM Stud_details WHERE course_no='" + General_methods.get_course_no_from_course_name(cmb_course_1.Text) + "'", con); SqlDataReader dr = cmd.ExecuteReader(); List <int> stud_nos = new List <int>(); while (dr.Read()) { stud_nos.Add(Convert.ToInt32(dr.GetValue(0).ToString().Split('/').GetValue(3))); } if (!stud_nos.Any()) { stud_nos.Add(0); } else { } con.Close(); string studno = "C/" + DateTime.Today.Year.ToString().Remove(0, 2) + "/" + d3.singleString("SELECT course_initials FROM Course_details_master WHERE course_no='" + General_methods.get_course_no_from_course_name(cmb_course_1.Text) + "'") + a + "/" + (stud_nos.Max() + 1).ToString(); txt_studno_1.Text = studno; } } else { } }
private void cmb_course_1_SelectedIndexChanged(object sender, EventArgs e) { con.Open(); cmb_batch.Items.Clear(); SqlCommand cmd = new SqlCommand("SELECT Batch_name FROM Batches WHERE Course_no='" + General_methods.get_course_no_from_course_name(cmb_course_1.Text) + "' AND completed_state='0'", con); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { cmb_batch.Items.Add(dr.GetValue(0)); } con.Close(); cmb_medium.Text = ""; txt_studno_1.Text = ""; }
private void tile_confirm_Click(object sender, EventArgs e) { if (metroTile5.Text != "Change") { MessageBox.Show(this, "Students course details are not confirmed", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else if (metroTile2.Text != "Change") { MessageBox.Show(this, "Students personal details are not confirmed", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else if (metroTile3.Text != "Change") { MessageBox.Show(this, "Students contact details are not confirmed", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else if (metroTile4.Text != "Change") { MessageBox.Show(this, "Students Organization details are not confirmed", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else if (metroTile3.Text != "Change") { MessageBox.Show(this, "Students contact information is not confirmed", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else if (metroCheckBox3.Checked == false && metroCheckBox4.Checked == false && metroCheckBox5.Checked == false && metroCheckBox6.Checked == false && metroCheckBox7.Checked == false && metroCheckBox8.Checked == false && metroCheckBox9.Checked == false && metroCheckBox11.Checked == false) { MessageBox.Show(this, "Please select students advertisement mode", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else if (General_methods.check_if_id_exists(txt_nic.Text, General_methods.get_batch_no_from_batch_name(cmb_batch.Text)) == "false") { MessageBox.Show(this, "A student with the same NIC already exists in this batch", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { DialogResult d = MessageBox.Show(this, "You are about to add a new student. Click on Yes to add student", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question); string place_id = G_maps.get_place_id_from_place_name_2(txt_Radd.Text); string[] stats = G_maps.get_place_details_from_place_id(place_id); if (d3.singleInt("SELECT COUNT(*) FROM Place_Details WHERE place_id='" + place_id + "'") == 0) { d3.insert("INSERT INTO Place_Details (place_id,Address_string,Latitude,Longitude) VALUES ('" + place_id + "','" + stats[1] + "','" + stats[3] + "','" + stats[4] + "')"); } if (d == DialogResult.Yes) { if (state == false) { if (metroCheckBox10.Checked == false) { if (metroCheckBox1.Checked == true) { if (metroCheckBox12.Checked == false) { d3.insert("INSERT INTO Stud_details (stud_no,f_name,m_name,l_name,gender,NIC,organization_id,designation,address_R,mobile,tel_R_1,email_R,course_no,medium,Birthday,Contact_person_1_name,Contact_person_1_no,Contact_person_2_name,Contact_person_2_no,mode,batch_no,home_no,name_with_initials) VALUES ('" + txt_studno_1.Text + "','" + txt_firstname.Text + "','" + txt_middlename.Text + "','" + txt_lname.Text + "','" + gender + "','" + txt_nic.Text + "','" + General_methods.find_organization_no_from_organization_name(txt_org.Text) + "','" + txt_desig.Text + "','" + place_id + "','" + txt_mobile.Text + "','" + txt_residence_tel.Text + "','" + txt_resi_email.Text + "','" + General_methods.get_course_no_from_course_name(cmb_course_1.Text) + "','" + cmb_medium.Text + "','" + metroDateTime1.Value.GetDateTimeFormats().GetValue(5) + "','" + txt_contact_person_1_name.Text + "','" + txt_contacts_person_1_no.Text + "','" + txt_contact_person_2_name.Text + "','" + txt_contact_person_2_no.Text + "','" + mode + "','" + General_methods.get_batch_no_from_batch_name(cmb_batch.Text) + "','" + txt_homeno.Text + "','" + txt_name_with_initials.Text + "')"); } else { d3.insert("INSERT INTO Stud_details (stud_no,f_name,l_name,gender,NIC,organization_id,designation,address_R,mobile,tel_R_1,email_R,course_no,medium,Birthday,Contact_person_1_name,Contact_person_1_no,Contact_person_2_name,Contact_person_2_no,mode,batch_no,home_no,name_with_initials) VALUES ('" + txt_studno_1.Text + "','" + txt_firstname.Text + "','" + txt_lname.Text + "','" + gender + "','" + txt_nic.Text + "','" + General_methods.find_organization_no_from_organization_name(txt_org.Text) + "','" + txt_desig.Text + "','" + place_id + "','" + txt_mobile.Text + "','" + txt_residence_tel.Text + "','" + txt_resi_email.Text + "','" + General_methods.get_course_no_from_course_name(cmb_course_1.Text) + "','" + cmb_medium.Text + "','" + metroDateTime1.Value.GetDateTimeFormats().GetValue(5) + "','" + txt_contact_person_1_name.Text + "','" + txt_contacts_person_1_no.Text + "','" + txt_contact_person_2_name.Text + "','" + txt_contact_person_2_no.Text + "','" + mode + "','" + General_methods.get_batch_no_from_batch_name(cmb_batch.Text) + "','" + txt_homeno.Text + "','" + txt_name_with_initials.Text + "')"); } } else { if (metroCheckBox12.Checked == false) { d3.insert("INSERT INTO Stud_details (stud_no,f_name,m_name,l_name,gender,NIC,organization_id,designation,address_R,mobile,tel_R_1,email_R,course_no,medium,Birthday,Contact_person_1_name,Contact_person_1_no,Contact_person_2_name,Contact_person_2_no,mode,batch_no,home_no,name_with_initials) VALUES ('" + txt_studno_1.Text + "','" + txt_firstname.Text + "','" + txt_middlename.Text + "','" + txt_lname.Text + "','" + gender + "','" + txt_nic.Text + "','No company','" + txt_desig.Text + "','" + place_id + "','" + txt_mobile.Text + "','" + txt_residence_tel.Text + "','" + txt_resi_email.Text + "','" + General_methods.get_course_no_from_course_name(cmb_course_1.Text) + "','" + cmb_medium.Text + "','" + metroDateTime1.Value.GetDateTimeFormats().GetValue(5) + "','" + txt_contact_person_1_name.Text + "','" + txt_contacts_person_1_no.Text + "','" + txt_contact_person_2_name.Text + "','" + txt_contact_person_2_no.Text + "','" + mode + "','" + General_methods.get_batch_no_from_batch_name(cmb_batch.Text) + "'),'" + txt_homeno.Text + "','" + txt_name_with_initials.Text + "')"); } else { d3.insert("INSERT INTO Stud_details (stud_no,f_name,l_name,gender,NIC,organization_id,designation,address_R,mobile,tel_R_1,email_R,course_no,medium,Birthday,Contact_person_1_name,Contact_person_1_no,Contact_person_2_name,Contact_person_2_no,mode,batch_no,home_no,name_with_initials) VALUES ('" + txt_studno_1.Text + "','" + txt_firstname.Text + "','" + txt_lname.Text + "','" + gender + "','" + txt_nic.Text + "','No company','" + txt_desig.Text + "','" + place_id + "','" + txt_mobile.Text + "','" + txt_residence_tel.Text + "','" + txt_resi_email.Text + "','" + General_methods.get_course_no_from_course_name(cmb_course_1.Text) + "','" + cmb_medium.Text + "','" + metroDateTime1.Value.GetDateTimeFormats().GetValue(5) + "','" + txt_contact_person_1_name.Text + "','" + txt_contacts_person_1_no.Text + "','" + txt_contact_person_2_name.Text + "','" + txt_contact_person_2_no.Text + "','" + mode + "','" + General_methods.get_batch_no_from_batch_name(cmb_batch.Text) + "'),'" + txt_homeno.Text + "','" + txt_name_with_initials.Text + "')"); } } } else { if (metroCheckBox1.Checked == true) { if (metroCheckBox12.Checked == false) { d3.insert("INSERT INTO Stud_details (stud_no,f_name,m_name,l_name,gender,NIC,organization_id,designation,address_R,mobile,tel_R_1,email_R,course_no,medium,Birthday,Contact_person_1_name,Contact_person_1_no,Contact_person_2_name,Contact_person_2_no,mode,batch_no,home_no,name_with_initials) VALUES ('" + txt_studno_1.Text + "','" + txt_firstname.Text + "','" + txt_middlename.Text + "','" + txt_lname.Text + "','" + gender + "','" + txt_nic.Text + "','" + General_methods.find_organization_no_from_organization_name(txt_org.Text) + "','" + txt_desig.Text + "','" + place_id + "','" + txt_mobile.Text + "','" + txt_residence_tel.Text + "','" + txt_resi_email.Text + "','" + General_methods.get_course_no_from_course_name(cmb_course_1.Text) + "','" + cmb_medium.Text + "','" + metroDateTime1.Value.GetDateTimeFormats().GetValue(5) + "','" + txt_contact_person_1_name.Text + "','" + txt_contacts_person_1_no.Text + "','None','None','" + mode + "','" + General_methods.get_batch_no_from_batch_name(cmb_batch.Text) + "','" + txt_homeno.Text + "','" + txt_name_with_initials.Text + "')"); } else { d3.insert("INSERT INTO Stud_details (stud_no,f_name,l_name,gender,NIC,organization_id,designation,address_R,mobile,tel_R_1,email_R,course_no,medium,Birthday,Contact_person_1_name,Contact_person_1_no,Contact_person_2_name,Contact_person_2_no,mode,batch_no,home_no,name_with_initials) VALUES ('" + txt_studno_1.Text + "','" + txt_firstname.Text + "','" + txt_lname.Text + "','" + gender + "','" + txt_nic.Text + "','" + General_methods.find_organization_no_from_organization_name(txt_org.Text) + "','" + txt_desig.Text + "','" + place_id + "','" + txt_mobile.Text + "','" + txt_residence_tel.Text + "','" + txt_resi_email.Text + "','" + General_methods.get_course_no_from_course_name(cmb_course_1.Text) + "','" + cmb_medium.Text + "','" + metroDateTime1.Value.GetDateTimeFormats().GetValue(5) + "','" + txt_contact_person_1_name.Text + "','" + txt_contacts_person_1_no.Text + "','None','None','" + mode + "','" + General_methods.get_batch_no_from_batch_name(cmb_batch.Text) + "','" + txt_homeno.Text + "','" + txt_name_with_initials.Text + "')"); } } else { if (metroCheckBox12.Checked == false) { d3.insert("INSERT INTO Stud_details (stud_no,f_name,m_name,l_name,gender,NIC,organization_id,designation,address_R,mobile,tel_R_1,email_R,course_no,medium,Birthday,Contact_person_1_name,Contact_person_1_no,Contact_person_2_name,Contact_person_2_no,mode,batch_no,home_no,name_with_initials) VALUES ('" + txt_studno_1.Text + "','" + txt_firstname.Text + "','" + txt_middlename.Text + "','" + txt_lname.Text + "','" + gender + "','" + txt_nic.Text + "','No company','" + txt_desig.Text + "','" + place_id + "','" + txt_mobile.Text + "','" + txt_residence_tel.Text + "','" + txt_resi_email.Text + "','" + General_methods.get_course_no_from_course_name(cmb_course_1.Text) + "','" + cmb_medium.Text + "','" + metroDateTime1.Value.GetDateTimeFormats().GetValue(5) + "','" + txt_contact_person_1_name.Text + "','" + txt_contacts_person_1_no.Text + "','None','None','" + mode + "','" + General_methods.get_batch_no_from_batch_name(cmb_batch.Text) + "','" + txt_homeno.Text + "','" + txt_name_with_initials.Text + "')"); } else { d3.insert("INSERT INTO Stud_details (stud_no,f_name,l_name,gender,NIC,organization_id,designation,address_R,mobile,tel_R_1,email_R,course_no,medium,Birthday,Contact_person_1_name,Contact_person_1_no,Contact_person_2_name,Contact_person_2_no,mode,batch_no,home_no,name_with_initials) VALUES ('" + txt_studno_1.Text + "','" + txt_firstname.Text + "','" + txt_lname.Text + "','" + gender + "','" + txt_nic.Text + "','No company','" + txt_desig.Text + "','" + place_id + "','" + txt_mobile.Text + "','" + txt_residence_tel.Text + "','" + txt_resi_email.Text + "','" + General_methods.get_course_no_from_course_name(cmb_course_1.Text) + "','" + cmb_medium.Text + "','" + metroDateTime1.Value.GetDateTimeFormats().GetValue(5) + "','" + txt_contact_person_1_name.Text + "','" + txt_contacts_person_1_no.Text + "','None','None','" + mode + "','" + General_methods.get_batch_no_from_batch_name(cmb_batch.Text) + "','" + txt_homeno.Text + "','" + txt_name_with_initials.Text + "')"); } } } if (metroCheckBox2.Checked == false) { con.Open(); SqlCommand cmd = new SqlCommand("UPDATE Stud_details SET pic=(@imgdata) WHERE stud_no='" + txt_studno_1.Text + "'", con); cmd.Parameters.AddWithValue("@imgdata", SqlDbType.Image).Value = bimage; cmd.ExecuteNonQuery(); con.Close(); } else { } MessageBox.Show(this, "Successfully added new student", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { d3.insert("INSERT INTO Stud_details (stud_no,course_no,medium,batch_no,ref) VALUES ('" + txt_studno_1.Text + "','" + General_methods.get_course_no_from_course_name(cmb_course_1.Text) + "','" + cmb_medium.Text + "','" + General_methods.get_batch_no_from_batch_name(cmb_batch.Text) + "','" + ref_stud_no + "')"); state = false; MessageBox.Show(this, "Successfully added new student", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (type == "Diploma") { Module_selection.state = false; Module_selection m = new Module_selection(); m.lbl_stud_no.Text = txt_studno_1.Text; m.lbl_course_no.Text = General_methods.get_course_no_from_course_name(cmb_course_1.Text); m.Show(); } clear(); } else { } } }
private void cmb_name_SelectedIndexChanged(object sender, EventArgs e) { txt_fee.Text = d.singleString("SELECT course_fee FROM Course_details_master WHERE course_no='" + General_methods.get_course_no_from_course_name(cmb_name.Text) + "'"); txt_registration_fee_txt.Text = d.singleString("SELECT reg_fee FROM Course_details_master WHERE course_no='" + General_methods.get_course_no_from_course_name(cmb_name.Text) + "'"); cmb_medium.DataSource = General_methods.fill_course_mediums_combobox(General_methods.get_course_no_from_course_name(cmb_name.Text)); cmb_medium.SelectedIndex = 0; }
private void metroTile1_Click(object sender, EventArgs e) { if (cmb_year.Text == "") { MessageBox.Show(this, "Please select year of batch", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (cmb_type.Text == "") { MessageBox.Show(this, "Please select type of course", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (cmb_name.Text == "") { MessageBox.Show(this, "Please select course", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (cmb_medium.Text == "") { MessageBox.Show(this, "Please select medium", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (txt_fee.Text == "" || txt_fee.Text.Any(char.IsLetter)) { MessageBox.Show(this, "Please enter valid course fee", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (txt_registration_fee_txt.Text == "" || txt_registration_fee_txt.Text.Any(char.IsLetter)) { MessageBox.Show(this, "Please enter valid registration fee", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { d.insert("INSERT INTO Batches (Batch_no,Batch_name,Course_no,Medium,Year,start_date,completed_state,course_fee_for_batch,reg_fee_for_batch) VALUES ('" + txt_batch_no.Text + "','" + txt_batch_name.Text + "','" + General_methods.get_course_no_from_course_name(cmb_name.Text) + "','" + cmb_medium.Text + "','" + cmb_year.Text + "','" + dat_startdate.Value.ToString("MM/dd/yyyy") + "',0,'" + txt_fee.Text + "','" + txt_registration_fee_txt.Text + "')"); MessageBox.Show(this, "Successfully added new Batch", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); metroGrid1.DataSource = d.show("SELECT * FROM Batches"); } }
private void cmb_medium_SelectedIndexChanged(object sender, EventArgs e) { txt_batch_for_year.Text = (d.singleInt("SELECT COUNT(*) FROM Batches WHERE Course_no='" + General_methods.get_course_no_from_course_name(cmb_name.Text) + "' AND Year='" + cmb_year.Text + "' AND Medium='" + cmb_medium.Text + "'") + 1).ToString(); edit_batch_no_and_name(); }
private void stud_no_change() { Database d3 = new Database(); SqlConnection con = new SqlConnection(Credentials.connection); if (cmb_medium.Text != "") { if (batchno == txt_batch_no.Text) { txt_studno_1.Text = stud_no; } else { if (cmb_type.SelectedIndex == 0) { char a = 'p'; if (cmb_medium.Text == "English") { a = 'E'; } else if (cmb_medium.Text == "Sinhala") { a = 'S'; } else if (cmb_medium.Text == "Tamil") { a = 'T'; } con.Open(); SqlCommand cmd = new SqlCommand("SELECT stud_no FROM Stud_details WHERE course_no='" + General_methods.get_course_no_from_course_name(txt_course_namer.Text) + "'", con); SqlDataReader dr = cmd.ExecuteReader(); List <int> stud_nos = new List <int>(); while (dr.Read()) { stud_nos.Add(Convert.ToInt32(dr.GetValue(0).ToString().Split('/').GetValue(3))); } if (!stud_nos.Any()) { stud_nos.Add(0); } else { } con.Close(); if (General_methods.get_course_no_from_course_name(txt_course_namer.Text) == c_no) { string studno = "D/" + DateTime.Today.Year.ToString().Remove(0, 2) + "/" + d3.singleString("SELECT course_initials FROM Course_details_master WHERE course_no='" + General_methods.get_course_no_from_course_name(txt_course_namer.Text) + "'") + a + "/" + (stud_nos.Max()).ToString(); txt_studno_1.Text = studno; } else { string studno = "D/" + DateTime.Today.Year.ToString().Remove(0, 2) + "/" + d3.singleString("SELECT course_initials FROM Course_details_master WHERE course_no='" + General_methods.get_course_no_from_course_name(txt_course_namer.Text) + "'") + a + "/" + (stud_nos.Max() + 1).ToString(); txt_studno_1.Text = studno; } } else if (cmb_type.SelectedIndex == 1) { char a = 'p'; if (cmb_medium.Text == "English") { a = 'E'; } else if (cmb_medium.Text == "Sinhala") { a = 'S'; } else if (cmb_medium.Text == "Tamil") { a = 'T'; } con.Open(); SqlCommand cmd = new SqlCommand("SELECT stud_no FROM Stud_details WHERE course_no='" + General_methods.get_course_no_from_course_name(txt_course_namer.Text) + "'", con); SqlDataReader dr = cmd.ExecuteReader(); List <int> stud_nos = new List <int>(); while (dr.Read()) { stud_nos.Add(Convert.ToInt32(dr.GetValue(0).ToString().Split('/').GetValue(3))); } if (!stud_nos.Any()) { stud_nos.Add(0); } else { } con.Close(); if (General_methods.get_course_no_from_course_name(txt_course_namer.Text) == c_no) { string studno = "C/" + DateTime.Today.Year.ToString().Remove(0, 2) + "/" + d3.singleString("SELECT course_initials FROM Course_details_master WHERE course_no='" + General_methods.get_course_no_from_course_name(txt_course_namer.Text) + "'") + a + "/" + (stud_nos.Max()).ToString(); txt_studno_1.Text = studno; } else { string studno = "C/" + DateTime.Today.Year.ToString().Remove(0, 2) + "/" + d3.singleString("SELECT course_initials FROM Course_details_master WHERE course_no='" + General_methods.get_course_no_from_course_name(txt_course_namer.Text) + "'") + a + "/" + (stud_nos.Max() + 1).ToString(); txt_studno_1.Text = studno; } } } if (txt_batch_no.Text == batchno && stud_no == txt_studno_1.Text) { metroTile5.Enabled = false; } else { metroTile5.Enabled = true; } } else { } }
private void metroTile5_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("Edit students course details?", "Notification", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { Database d = new Database(); d.update("UPDATE Stud_details SET stud_no='" + txt_studno_1.Text + "',course_no='" + General_methods.get_course_no_from_course_name(txt_course_namer.Text) + "',batch_no='" + txt_batch_no.Text + "',medium='" + cmb_medium.Text + "' WHERE stud_no='" + stud_no + "' "); if (d.singleInt("SELECT COUNT(*) FROM Dip_stud_modules WHERE stud_no='" + stud_no + "'") == 1) { d.delete("DELETE FROM Dip_stud_modules WHERE stud_no='" + stud_no + "'"); } MessageBox.Show("Successfully Updates Record", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); if (cmb_type.SelectedIndex == 0) { /*Select_modules s = new Select_modules(); * s.lb_stud_no.Text = txt_studno_1.Text; * s.lb_course_no.Text = General_methods.get_course_no_from_course_name(txt_course_namer.Text); * s.lb_course_name.Text = txt_course_namer.Text; * s.metroTile1.Text = "Add"; * s.Show(); * s.metroTile1.Click += handler;*/ } else { label1.Text = ""; } } else { } }