Ejemplo n.º 1
0
        private void metroTile5_Click(object sender, EventArgs e)
        {
            Module_selection.state = true;
            Module_selection m = new Module_selection();

            m.lbl_stud_no.Text   = txt_no.Text;
            m.lbl_course_no.Text = txt_course_code.Text;
            m.Text            = "Edit selected modules";
            m.metroTile1.Text = "Update";
            m.Show();
            m.metroTile1.Click += HandleCustomEvent1;
        }
        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
                {
                }
            }
        }