コード例 #1
0
        protected void btnSchedule_Click(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();

            if (listOfCourses.Count == 4)
            {
                Section            sec   = new Section();
                Queries.SqlQueries query = new Queries.SqlQueries();
                query.SetCommand("Select * FROM Schedule WHERE CourseNumber = @CourseNumber1 OR CourseNumber = @CourseNumber2 OR CourseNumber = @CourseNumber3 Or CourseNumber = @CourseNumber4 ");
                query.AddParameters("@CourseNumber1", listOfCourses[0]);
                query.AddParameters("@CourseNumber2", listOfCourses[1]);
                query.AddParameters("@CourseNumber3", listOfCourses[2]);
                query.AddParameters("@CourseNumber4", listOfCourses[3]);
                query.Connect();
                dt = query.RunSelectQuery();
                query.Disconnect();
            }
            else
            {
                Response.Write("Must have four courses selected");
            }

            foreach (DataRow row in dt.Rows)
            {
                Section sec = new Section();

                sec.sectionNumber = row["SectionNumber"].ToString();
                sec.days          = row["Days"].ToString();
                sec.startTime     = int.Parse(row["StartTime"].ToString());
                sec.endTime       = int.Parse(row["EndTime"].ToString());
                sec.courseNumber  = row["CourseNumber"].ToString();
                sec.CRN           = row["CRN"].ToString();

                if (sec.courseNumber == listOfCourses[0])
                {
                    selectedCourseOne.Add(sec);
                }
                else if (sec.courseNumber == listOfCourses[1])
                {
                    selectedCourseTwo.Add(sec);
                }
                else if (sec.courseNumber == listOfCourses[2])
                {
                    selectedCourseThree.Add(sec);
                }
                else if (sec.courseNumber == listOfCourses[3])
                {
                    selectedCourseFour.Add(sec);
                }
                else
                {
                    Response.Write("nope");
                }
            }

            search();
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Queries.SqlQueries query = new Queries.SqlQueries();
                query.SetCommand("Select DISTINCT [CourseNumber] FROM Schedule");
                query.Connect();
                DataTable dt = query.RunSelectQuery();
                query.Disconnect();

                foreach (DataRow row in dt.Rows)
                {
                    ListItem courseItem = new ListItem();
                    courseItem.Text = row["CourseNumber"].ToString();
                    ddlCourseNumbers.Items.Add(courseItem);
                }
            }
            if (Session["listOfCourses"] == null)
            {
                Session["listOfCourses"] = new List <string>();
            }
            listOfCourses = (List <string>)Session["listOfCourses"];
        }