Exemplo n.º 1
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            string course_designation = txtSearchCourseDesisgnation.Text;

            if (course_designation != "")
            {
                Course course = MaintainCourseDetailsController.searchCourse
                                    (course_designation, cbbSemesterSelector.SelectedValue.ToString());

                // if found
                if (course.course_id != null)
                {
                    txtCourseID.Text           = course.course_id;
                    txtTitle.Text              = course.title;
                    txtCourseDesignation.Text  = course.course_designation;
                    cbbInstructorSelector.Text = course.instructor;
                    txtDepartment.Text         = course.department;
                    txtNumCredit.Text          = course.credit_hours.ToString();
                    txtPreReqCourse.Text       =
                        MaintainCourseDetailsController.getCourseDesignationFromId(course.prereq_course);
                    txtCourseDescription.Text = course.description;
                    txtMaxCap.Text            = course.capacity.ToString();
                    txtEnrolledStudent.Text   = course.enrolled_student.ToString();
                    lblStatusBar.Text         = "Course found. Modify or Delete?";
                }
                else
                {
                    resetAllTextbox();
                    lblStatusBar.Text = "No Course found";
                }
            }
        }
Exemplo n.º 2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (lblStatusBar.Text != "Course found. Modify or Delete?")
            {
                return;
            }
            if (cbbSemesterSelector.SelectedValue.ToString() != GLOBALS.current_semester)
            {
                MessageBox.Show("You cannot delete courses from old semesters!");
                return;
            }

            // Ask for confirmation
            DialogResult dialog_result = MessageBox.Show("Do you want to delete this course?", "Confirmation", MessageBoxButtons.YesNo);

            if (dialog_result == DialogResult.No)
            {
                return;
            }

            if (MaintainCourseDetailsController.deleteCourse(txtCourseID.Text))
            {
                lblStatusBar.Text = "Delete Success!";
                resetAllTextbox();
            }
            else
            {
                lblStatusBar.Text = "Delete Fails!";
            }
        }
Exemplo n.º 3
0
        // update Department textbox when Instructor selection changed
        private void cbbInstructorSelector_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!cbbInstructorSelector_SelectedIndexChanged_enable)
            {
                return;
            }

            txtDepartment.Text = MaintainCourseDetailsController.getDepartmentFromFacultyID(
                cbbInstructorSelector.SelectedValue.ToString());
        }
Exemplo n.º 4
0
        private void btnModify_Click(object sender, EventArgs e)
        {
            // check for required fields
            if (txtTitle.Text == "" || txtCourseDesignation.Text == "")
            {
                lblStatusBar.Text = "Modify fails!";
                return;
            }

            if (lblStatusBar.Text != "Course found. Modify or Delete?" &&
                lblStatusBar.Text != "Modify Success!" &&
                lblStatusBar.Text != "Modify fails!")
            {
                return;
            }



            // check if pre-req course is valid
            if (txtPreReqCourse.Text != "")
            {
                if (!MaintainCourseDetailsController.checkPreReqCourseValid(txtPreReqCourse.Text))
                {
                    lblStatusBar.Text = "Modify fails!";
                    MessageBox.Show("Invalid Pre-requisite Course");
                    return;
                }
            }
            if (!validateAllTextbox())
            {
                lblStatusBar.Text = "Modify fails!";
                return;
            }
            // Ask for confirmation
            DialogResult dialog_result = MessageBox.Show("Do you want to modify this course?", "Confirmation", MessageBoxButtons.YesNo);

            if (dialog_result == DialogResult.No)
            {
                return;
            }

            string faculty_id    = cbbInstructorSelector.SelectedValue.ToString();
            string department_id = MaintainCourseDetailsController.getDepartmentIdFromFacultyID(faculty_id);

            if (MaintainCourseDetailsController.modifyCourse(
                    txtCourseID.Text,
                    txtTitle.Text,
                    txtCourseDesignation.Text,
                    faculty_id,
                    department_id,
                    txtNumCredit.Text,
                    txtCourseDescription.Text,
                    txtPreReqCourse.Text,
                    txtMaxCap.Text,
                    txtEnrolledStudent.Text,
                    cbbSemesterSelector.SelectedValue.ToString()
                    ))
            {
                lblStatusBar.Text = "Modify Success!";
            }
            else
            {
                lblStatusBar.Text = "Modify fails!";
            }
        }
Exemplo n.º 5
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            // check for required fields
            if (txtTitle.Text == "" || txtCourseDesignation.Text == "")
            {
                lblStatusBar.Text = "Title and Course Designation is required";
                return;
            }

            if (txtDepartment.Text == "")
            {
                lblStatusBar.Text = "You have to select instructor and department!";
                return;
            }

            if (!validateAllTextbox())
            {
                lblStatusBar.Text = "Add fails!";
                return;
            }

            // Ask for confirmation
            DialogResult dialog_result = MessageBox.Show("Do you want to add this course (to current semester)?", "Confirmation", MessageBoxButtons.YesNo);

            if (dialog_result == DialogResult.No)
            {
                return;
            }

            // check if the course_designation is already in the database
            if (MaintainCourseDetailsController.checkDuplicateCourseDesignation(txtCourseDesignation.Text))
            {
                lblStatusBar.Text = "You cannot add same course designation!";
                return;
            }

            // check if pre-req course is valid
            if (txtPreReqCourse.Text != "")
            {
                if (!MaintainCourseDetailsController.checkPreReqCourseValid(txtPreReqCourse.Text))
                {
                    lblStatusBar.Text = "Invalid Pre-requisite course";
                    return;
                }
            }



            string faculty_id    = cbbInstructorSelector.SelectedValue.ToString();
            string department_id = MaintainCourseDetailsController.getDepartmentIdFromFacultyID(faculty_id);

            if (MaintainCourseDetailsController.addCourse(
                    txtTitle.Text,
                    txtCourseDesignation.Text,
                    faculty_id,
                    department_id,
                    txtNumCredit.Text,
                    txtCourseDescription.Text,
                    txtPreReqCourse.Text,
                    txtMaxCap.Text,
                    txtEnrolledStudent.Text
                    ))
            {
                txtEnrolledStudent.Text = "0";
                lblStatusBar.Text       = "Add Success!";
            }
            else
            {
                lblStatusBar.Text = "Add fails!";
            }
        }