private void metroTile1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txt_fname.Text) || txt_fname.Text.Any(char.IsDigit)) { MessageBox.Show(this, "Please enter correct First name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (string.IsNullOrEmpty(txt_mname.Text) || txt_mname.Text.Any(char.IsDigit)) { MessageBox.Show(this, "Please enter correct Middle name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (string.IsNullOrEmpty(txt_lname.Text) || txt_lname.Text.Any(char.IsDigit)) { MessageBox.Show(this, "Please enter correct Last name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (General_methods.NIC_validation(txt_nic.Text, metroDateTime1.Value, gen) == "invalid") { MessageBox.Show(this, "Some Details do not match the NIC number entered. Please check NIC, birthdate and gender selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (txt_nic.Text != prev_nic && General_methods.check_if_id_exists(txt_nic.Text, batch) == "false") { MessageBox.Show(this, "A student with the same NIC already exists in this batch", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (metroRadioButton1.Checked == false && metroRadioButton2.Checked == false) { MessageBox.Show(this, "Please select gender", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (txt_desig.Text == "") { MetroMessageBox.Show(this, "Please enter designation", "error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { DialogResult d1 = MessageBox.Show(this, "Edit Details?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (d1 == DialogResult.Yes) { Database d = new Database(); d.update("UPDATE Stud_details SET f_name='" + txt_fname.Text + "', m_name='" + txt_mname.Text + "',l_name='" + txt_lname.Text + "',NIC='" + txt_nic.Text + "',Birthday='" + metroDateTime1.Value.ToString() + "',gender='" + gen + "',designation='" + txt_desig.Text + "' WHERE stud_no='" + txt_studno.Text + "'"); MessageBox.Show(this, "Successfully updated record", "done", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); 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 metroTile2_Click(object sender, EventArgs e) { if (metroTile2.Text == "Ok") { if (string.IsNullOrEmpty(txt_firstname.Text) || txt_firstname.Text.Any(char.IsDigit)) { MessageBox.Show(this, "Please enter correct First name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (metroCheckBox12.Checked == false && (string.IsNullOrEmpty(txt_middlename.Text) || txt_middlename.Text.Any(char.IsDigit))) { MessageBox.Show(this, "Please enter correct middle name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (string.IsNullOrEmpty(txt_name_with_initials.Text) || txt_name_with_initials.Text.Any(char.IsDigit)) { MessageBox.Show(this, "Please enter name with initials", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (string.IsNullOrEmpty(txt_lname.Text) || txt_lname.Text.Any(char.IsDigit)) { MessageBox.Show(this, "Please enter correct Last name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (metroRadioButton6.Checked == false && metroRadioButton5.Checked == false) { MessageBox.Show(this, "Please select gender", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (metroCheckBox2.Checked == false && pictureBox1.Image == null) { MessageBox.Show(this, "Please upload image of student", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (General_methods.NIC_validation(txt_nic.Text, metroDateTime1.Value, gender) == "invalid") { MessageBox.Show(this, "Some Details do not match the NIC number entered. Please check NIC, birthdate and gender selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (cmb_batch.Text != "" && 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 { txt_firstname.Enabled = false; txt_lname.Enabled = false; txt_middlename.Enabled = false; metroRadioButton5.Enabled = false; metroRadioButton6.Enabled = false; pictureBox1.Enabled = false; metroCheckBox2.Enabled = false; txt_nic.Enabled = false; linkLabel1.Enabled = false; metroTile2.Text = "Change"; metroTile2.AutoSize = true; metroDateTime1.Enabled = false; txt_name_with_initials.Enabled = false; } } else { //metroTile2.Text = "Change"; txt_firstname.Enabled = true; txt_lname.Enabled = true; txt_middlename.Enabled = true; txt_nic.Enabled = true; metroRadioButton5.Enabled = true; metroRadioButton6.Enabled = true; pictureBox1.Enabled = true; metroCheckBox2.Enabled = true; linkLabel1.Enabled = true; metroTile2.Text = "Ok"; metroDateTime1.Enabled = true; txt_name_with_initials.Enabled = true; } }