Beispiel #1
0
        public Form1()
        {
            Schedule schedule = new Schedule();

            List<Course> requiredCourses = sqlQuery.getAllCoursesFromTable("required_classes");
            List<Course> socialScienceCourses = sqlQuery.getAllCoursesFromTable("icd_sse");
            List<Course> performingArtsCourses = sqlQuery.getAllCoursesFromTable("icd_vpae");
            List<Course> scienceCourses = sqlQuery.getAllCoursesFromTable("science_classes");
            InitializeComponent();

            addSemester((SemesterEnum)0, (YearEnum)0);
            addSemester((SemesterEnum)1, (YearEnum)0);

            addSemester((SemesterEnum)0, (YearEnum)1);
            addSemester((SemesterEnum)1, (YearEnum)1);

            addSemester((SemesterEnum)0, (YearEnum)2);
            addSemester((SemesterEnum)1, (YearEnum)2);

            addSemester((SemesterEnum)0, (YearEnum)3);
            addSemester((SemesterEnum)1, (YearEnum)3);

            foreach(Control ctrl in this.Controls)
            {
                if (ctrl is ListBox)
                {
                    ctrl.MouseDown += new MouseEventHandler(listBox_MouseDown);
                    ctrl.DragOver += new DragEventHandler(listBox_DragOver);
                    ctrl.DragEnter += new DragEventHandler(listBox_DragEnter);
                    ctrl.DragDrop += new DragEventHandler(listBox_DragDrop);
                }
            }

            foreach (Course c in requiredCourses)
            {
                requiredCoursesBox.Items.Add(c);

            }

            foreach (Course c in socialScienceCourses)
            {
                socialScienceBox.Items.Add(c);
            }

            foreach (Course c in performingArtsCourses)
            {
                performingArtsBox.Items.Add(c);
            }

            foreach (Course c in scienceCourses)
            {
                scienceBox.Items.Add(c);
            }
        }
 public static bool ValidPreReqs(Schedule input)
 {
     bool validPreReqs = true;
     List<Semester> semesters = input.getSemesters();
     List<Course> coursesInSchedual = new List<Course>();
     //Build class list
     foreach (Semester semester in semesters)
     {
         foreach (Course course in semester.semesterBox.Items)
         {
             Course tempCourse = course;
             tempCourse.semesterTaken = semester.getID();
             tempCourse.yearTaken = semester.getYear();
             coursesInSchedual.Add(tempCourse);
         }
     }
     //Check for pre-reqs
     foreach (Course course in coursesInSchedual)
     {
         List<Course> preReqs = course.getPreRequisites();
         foreach (Course preReq in preReqs)
         {
             //check if pre-req has been taken
             Course tempClass =
                 coursesInSchedual.SingleOrDefault(
                     c => c.Department == preReq.Department && c.CourseNum == preReq.CourseNum);
             if (tempClass == null)
             {
                 return false;
             }
             //Check if taken in right year
             else if (tempClass.yearTaken > course.yearTaken)
             {
                 return false;
             }
             else if (tempClass.yearTaken == course.yearTaken && tempClass.semesterTaken >= course.semesterTaken)
             {
                 return false;
             }
         }
     }
     return true;
 }