protected void btnSubmit_Click(object sender, EventArgs e) { if (RadioButton1.Checked) { FullTimeStudent ftStudent = new FullTimeStudent(txtName.Text); studentType.Add(ftStudent); // Add the student to list foreach (ListItem chosenCourse in CheckBoxList.Items) { // if a course is selected do the following if (chosenCourse.Selected) { try { // Add each selected course to the student's enrolled courses foreach (Course course in Helper.GetCourses()) { if (course.ToString() == chosenCourse.Text) { ftStudent.addCourse(course); } } } catch (Exception ex) { // Display error message if courses exceed 8 hours lblError.Text = ex.Message; // Continue with rest of code if there is no error return; } } // End of btn selection } // End of foreach // Display confirmation page for full-time student displayConfirmationPage(ftStudent); } // End of condition else if (RadioButton2.Checked) { PartTimeStudent ptStudent = new PartTimeStudent(txtName.Text); studentType.Add(ptStudent); foreach (ListItem chosenCourse in CheckBoxList.Items) { if (chosenCourse.Selected) { try { foreach (Course course in Helper.GetCourses()) { if (course.ToString() == chosenCourse.Text) { ptStudent.addCourse(course); } } } catch (Exception ex) { lblError.Text = ex.Message; return; } } // end of btn selection } // end of foreach // Display confirmation page for part-time student displayConfirmationPage(ptStudent); } // end of condition else if (RadioButton3.Checked) { CoopStudent cpStudent = new CoopStudent(txtName.Text); studentType.Add(cpStudent); foreach (ListItem chosenCourse in CheckBoxList.Items) { if (chosenCourse.Selected) { try { foreach (Course course in Helper.GetCourses()) { if (course.ToString() == chosenCourse.Text) { cpStudent.addCourse(course); } } } catch (Exception ex) { lblError.Text = ex.Message; return; } } // end of btn selection } // End of foreach // Display confirmation page for co-op student displayConfirmationPage(cpStudent); } // End of condition } // End of btn submit method