Пример #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtStudentNumber.Text == "Student Number" || string.IsNullOrEmpty(txtStudentNumber.Text))
            {
                MessageBox.Show("Please indicate the student number.", "Add Student", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtStudentNumber.Text = "";
                txtStudentNumber.Focus();
                return;
            }
            else
            {
                if (txtFirstName.Text == "First Name" || string.IsNullOrEmpty(txtFirstName.Text))
                {
                    MessageBox.Show("Please indicate the first name.", "Add Student", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtFirstName.Text = "";
                    txtFirstName.Focus();
                    return;
                }
                else
                {
                    if (txtLastName.Text == "Last Name" || string.IsNullOrEmpty(txtLastName.Text))
                    {
                        MessageBox.Show("Please indicate the last name.", "Add Student", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtLastName.Text = "";
                        txtLastName.Focus();
                        return;
                    }
                    else
                    {
                        if (txtLastName.Text == "Last Name" || string.IsNullOrEmpty(txtLastName.Text))
                        {
                            MessageBox.Show("Please indicate the last name.", "Add Student", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            txtLastName.Text = "";
                            txtLastName.Focus();
                            return;
                        }
                        else
                        {
                            if (cbCourse.SelectedIndex == 0 || cbCourse.SelectedIndex == -1)
                            {
                                MessageBox.Show("Please indicate the course.", "Add Student", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                cbCourse.Focus();
                                return;
                            }
                            else
                            {
                                if (cbYearLevel.SelectedIndex == 0 || cbYearLevel.SelectedIndex == -1)
                                {
                                    MessageBox.Show("Please indicate the year level.", "Add Student", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    cbYearLevel.Focus();
                                    return;
                                }
                                else
                                {
                                    if (cbStatus.SelectedIndex == 0 || cbStatus.SelectedIndex == -1)
                                    {
                                        MessageBox.Show("Please indicate the status.", "Add Student", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                        cbStatus.Focus();
                                        return;
                                    }
                                    else
                                    {
                                        string student_number  = txtStudentNumber.Text;
                                        string first_name      = txtFirstName.Text;
                                        string middle_name     = (txtMiddleName.Text == "Middle Name") ? string.Empty : txtMiddleName.Text;
                                        string last_name       = txtLastName.Text;
                                        string contact_number  = (txtContactNumber.Text == "Contact Number") ? string.Empty : txtContactNumber.Text;
                                        string email           = (txtEmail.Text == "Email") ? string.Empty : txtEmail.Text;
                                        int    course_id       = Convert.ToInt32(cbCourse.SelectedValue);
                                        string year_level      = cbYearLevel.Text;
                                        string status          = cbStatus.Text;
                                        Byte[] profile_picture = classes.Configuration.ConvertScreenCaptureToByte(pbPreview.Image);

                                        personal_information = new classes.PersonalInformation();
                                        if (personal_information.insert_personal_information(first_name, middle_name, last_name, contact_number, email, profile_picture))
                                        {
                                            student = new classes.Student();
                                            if (student.insert_student(student_number, course_id, year_level, status))
                                            {
                                                account = new classes.Accounts();
                                                if (account.insert_account(student_number, "Student"))
                                                {
                                                    MessageBox.Show((first_name + " " + last_name).ToUpper() + " has been added!", "Add Student", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                                    includes.uc.frmDashboard.admin.mu.ucManageStudent.instance.display_student_data();
                                                    this.Close();
                                                }
                                                else
                                                {
                                                    return;
                                                }
                                            }
                                            else
                                            {
                                                return;
                                            }
                                        }
                                        else
                                        {
                                            return;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        public void display_student_data()
        {
            stdnt = new classes.Student();

            string search = cbSearchBy.Text;

            switch (search)
            {
            case "Student Number":
                student_table = stdnt.select_student_table("a.student_number", txtSearch.Text);
                break;

            case "Full Name":
                student_table = stdnt.select_student_table("b.first_name", txtSearch.Text);
                break;

            case "Contact Number":
                student_table = stdnt.select_student_table("b.contact_number", txtSearch.Text);
                break;

            case "Email":
                student_table = stdnt.select_student_table("b.email", txtSearch.Text);
                break;

            case "Course":
                student_table = stdnt.select_student_table("c.course_name", txtSearch.Text);
                break;

            case "Year Level":
                student_table = stdnt.select_student_table("a.year_level", txtSearch.Text);
                break;

            case "Status":
                student_table = stdnt.select_student_table("a.status", txtSearch.Text);
                break;

            case "--Search by--":
                student_table = stdnt.select_student_table();
                break;

            default:
                student_table = stdnt.select_student_table();
                break;
            }

            dgvManageStudent.DataSource          = student_table;
            dgvManageStudent.AutoGenerateColumns = false;

            if (dgvManageStudent.Columns.Contains("action") && dgvManageStudent.Columns["action"].Visible)
            {
            }
            else
            {
                DataGridViewButtonColumn button = new DataGridViewButtonColumn();
                {
                    button.Name       = "action";
                    button.HeaderText = "Action";
                    button.Text       = "Update Student";
                    button.UseColumnTextForButtonValue = true;
                    this.dgvManageStudent.Columns.Add(button);
                }
            }
        }