private void metroTile1_Click(object sender, EventArgs e) { if (txt_org.Text == "") { MessageBox.Show(this, "Please select company", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { DialogResult d1 = MessageBox.Show("Change organization details of Student?", "Notification", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (d1 == DialogResult.Yes) { Database d = new Database(); d.update("UPDATE Stud_details SET organization_id='" + General_methods.find_organization_no_from_organization_name(txt_org.Text) + "' WHERE stud_no='" + txt_stud_no.Text + "'"); MessageBox.Show("Record Updated successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); } else { } } }
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 metroTile1_Click(object sender, EventArgs e) { if (txt_name.Text == "") { MessageBox.Show(this, "Please enter participants name", "Missing Field", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (txt_email.Text == "") { MessageBox.Show(this, "Please enter participants email", "Missing Field", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (txt_phoneno.MaskCompleted == false) { MessageBox.Show(this, "Please enter participants phone no", "Missing Field", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (cmb_desigs.Text == "") { MessageBox.Show(this, "Please enter participants phone no", "Missing Field", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (General_methods.Quick_NIC_Validation(txt_NIC.Text) == "Invalid") { MessageBox.Show(this, "Please enter valid NIC", "Missing Field", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (cmb_org.Text == "") { MessageBox.Show(this, "Please select Organization of participant", "Missing Field", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (txt_destrict.Text == "") { MessageBox.Show(this, "Please select Address of participant", "Missing Field", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { DialogResult d2 = MessageBox.Show("Update details?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (d2 == DialogResult.Yes) { Database d = new Database(); d.update("UPDATE Short_program_participation SET address='" + txt_destrict.Text + "',designation='" + cmb_desigs.Text + "',Email='" + txt_email.Text + "',Name='" + txt_name.Text + "',NIC='" + txt_NIC.Text + "',Organization_id='" + General_methods.find_organization_no_from_organization_name(cmb_org.Text) + "',phone_no='" + txt_phoneno.Text + "' WHERE ref_no='" + lbl_no.Text + "'"); MessageBox.Show("Details Updated Successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); label1.Text = General_methods.Generate_RandomNumber(3, 678).ToString(); Close(); } } }
private void cmb_companies_SelectedIndexChanged(object sender, EventArgs e) { metroGrid1.DataSource = null; metroGrid1.Update(); metroGrid1.Columns.Clear(); a.Clear(); if (cmb_companies.Text != "") { checkedListBox1.Items.Clear(); txt_tot_amount_payable.Text = calc_amount_payable(cmb_companies.Text, 0).ToString() + "/="; con.Open(); SqlCommand cmd = new SqlCommand("SELECT Name,payment_no,ref_no FROM Short_program_participation WHERE program_code='" + progno + "' AND Organization_id='" + General_methods.find_organization_no_from_organization_name(cmb_companies.Text) + "'", con); SqlDataReader dr = cmd.ExecuteReader(); int c = 0; while (dr.Read()) { checkedListBox1.Items.Add(dr.GetValue(0).ToString() + "-" + dr.GetValue(2).ToString()); if (!dr.IsDBNull(1)) { checkedListBox1.SetItemChecked(c, true); a.Add(c); } c++; } con.Close(); metroGrid1.DataSource = d.show("SELECT Payment_No,Gross_amount,Discount_percent,Net_amount,Date,Time,Remark FROM PaymentDetails WHERE program_no='" + progno + "' AND stud_no_org_no='" + General_methods.find_organization_no_from_organization_name(cmb_companies.Text) + "'"); DataGridViewButtonColumn bt = new DataGridViewButtonColumn(); bt.Text = "Terminate Payment"; bt.FlatStyle = FlatStyle.Flat; bt.UseColumnTextForButtonValue = true; bt.Width = 150; metroGrid1.Columns.Add(bt); DataGridViewButtonColumn bt2 = new DataGridViewButtonColumn(); bt2.Text = "Generate Recipt"; bt2.FlatStyle = FlatStyle.Flat; bt2.UseColumnTextForButtonValue = true; bt2.Width = 150; metroGrid1.Columns.Add(bt2); DataGridViewButtonColumn bt3 = new DataGridViewButtonColumn(); bt3.Text = "View Payed Students"; bt3.FlatStyle = FlatStyle.Flat; bt3.UseColumnTextForButtonValue = true; bt3.Width = 150; metroGrid1.Columns.Add(bt3); metroGrid1.Columns[6].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; metroGrid1.AllowUserToAddRows = false; } }
public double calc_amount_payable(string orgname, double amount_paying) { con.Open(); double tot = d.singleInt("SELECT COUNT(*) FROM Short_program_participation WHERE Organization_id='" + General_methods.find_organization_no_from_organization_name(orgname) + "' AND program_code='" + progno + "'") * Convert.ToDouble(txt_priceperhead.Text.Remove(txt_priceperhead.Text.Length - 2, 2)); SqlCommand cmd = new SqlCommand("SELECT Gross_amount FROM PaymentDetails WHERE stud_no_org_no='" + General_methods.find_organization_no_from_organization_name(orgname) + "' AND program_no='" + progno + "'", con); SqlDataReader dr = cmd.ExecuteReader(); if (d.singleInt("SELECT COUNT(*) FROM PaymentDetails WHERE stud_no_org_no='" + General_methods.find_organization_no_from_organization_name(orgname) + "' AND program_no='" + progno + "'") != 0) { while (dr.Read()) { tot = tot - Convert.ToDouble(dr.GetValue(0).ToString()); } } con.Close(); return(tot - amount_paying); }
private void metroTile1_Click(object sender, EventArgs e) { string remark = "Payament for short programs / workshops (Company) -" + txt_remark.Text; if (txt_netamount.Text == "") { MessageBox.Show("Please calculate the final amount", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (txt_amount.Text == "") { MessageBox.Show("Participants have not been selected", "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.Text.Remove(txt_amount.Text.Length - 2, 2).ToString() + "','" + txt_discount.Text + "','" + txt_netamount.Text.Remove(txt_netamount.Text.Length - 2, 2).ToString() + "','" + General_methods.get_current_date() + "','" + General_methods.get_current_time() + "','" + General_methods.find_organization_no_from_organization_name(cmb_companies.Text) + "','" + txt_progno.Text + "','" + remark + "','" + 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 Short_program_participation SET payment_no='" + id + "' WHERE ref_no='" + checkedListBox1.Items[i].ToString().Split('-').GetValue(1) + "'"); } 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 { } } }