private void fillCourseDropDownList() { QueryController courseListQueryController = new QueryController(); courseListQueryController.createDatabaseCommand("Select distinct CourseNumber from Schedule"); courseListQueryController.connectToDatabase(); SqlDataReader reader = courseListQueryController.getDatabaseCommand().ExecuteReader(); while (reader.Read()) { addCourseNumberFrom(reader); } reader.Close(); courseListQueryController.disconnectFromDatabase(); }
private void fillCourseSessionVariables() { string course = "course" + Session["numberOfAddedCourses"].ToString(); QueryController qc = new QueryController(); qc.createDatabaseCommand("Select * from Schedule where CourseNumber=@cn"); qc.addQueryParameter("@cn", courseNumberDropDownList.SelectedValue.ToString()); Session[course] = courseNumberDropDownList.SelectedValue.ToString(); Session[course + "crns"] = ""; Session[course + "courseNumbers"] = ""; Session[course + "sections"] = ""; Session[course + "days"] = ""; Session[course + "startTimes"] = ""; Session[course + "endTimes"] = ""; qc.connectToDatabase(); SqlDataReader reader = qc.getDatabaseCommand().ExecuteReader(); while (reader.Read()) { Session[course + "crns"] = Session[course + "crns"] + reader["CRN"].ToString() + ","; Session[course + "courseNumbers"] = Session[course + "courseNumbers"] + reader["CourseNumber"].ToString() + ","; Session[course + "sectionNumbers"] = Session[course + "sectionNumbers"] + reader["SectionNumber"].ToString() + ","; Session[course + "days"] = Session[course + "days"] + reader["Days"].ToString() + ","; Session[course + "startTimes"] = Session[course + "startTimes"] + reader["StartTime"].ToString() + ","; Session[course + "endTimes"] = Session[course + "endTimes"] + reader["EndTime"].ToString() + ","; } reader.Close(); qc.disconnectFromDatabase(); Session["numberOfAddedCourses"] = Int32.Parse(Session["numberOfAddedCourses"].ToString()) + 1; addToSelectedCoursesLabel(course); coursesRemainingLabel.Text = (5 - Int32.Parse(Session["numberOfAddedCourses"].ToString())).ToString(); if (coursesRemainingLabel.Text.Equals("0")) { scheduleCoursesButton.Enabled = true; addCourseButton.Enabled = false; } }