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!"; } }
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!"; } }