Beispiel #1
0
        //removes the course with the given id along with all courses with the same course code
        //returns true if successful
        public bool removeCourse(int courseID)
        {
            List <int> toBeRemoved = new List <int>();

            foreach (var course in schedule)
            {
                //deals with items that have an ID greater than the max for the database
                if (courseID < DB.getNumCourses() && DB.getCourseCode(courseID) == course.getCourseCode())
                {
                    toBeRemoved.Add(course.getCourseID());
                }
                else if (courseID == course.getCourseID())
                {
                    toBeRemoved.Add(course.getCourseID());
                }
            }
            bool result = false;

            foreach (var allIDs in toBeRemoved)
            {
                creditCount -= DB.getCredits(allIDs);

                m_Courses.RemoveAll(c => c.CourseID == allIDs);

                result = schedule.Remove(DB.getCourse(allIDs));
                updateConflictMarkers();
            }


            return(result);
        }
Beispiel #2
0
        // Constructor that uses a course id
        public Course(int courseID)
        {
            CourseInfo DB = CourseInfo.Create();

            this.courseID  = courseID;
            this.professor = DB.getProf(courseID);

            this.time = DB.getTime(courseID);
            this.day  = DB.getDay(courseID);

            this.building = DB.getBuilding(courseID);
            this.room     = DB.getRoom(courseID);

            this.courseDept = DB.getCourseDept(courseID);
            this.courseNum  = DB.getCourseNum(courseID);
            this.courseSect = DB.getCourseSect(courseID);
            this.courseCode = DB.getCourseCode(courseID);

            this.shortName = DB.getShortName(courseID);
            this.longName  = DB.getLongName(courseID);

            this.enrollment = DB.getEnrollment(courseID);
            this.capacity   = DB.getCapacity(courseID);

            this.credits = DB.getCredits(courseID);

            this.allInfo = DB.getAllInfo(courseID);
        }
Beispiel #3
0
        // displays an info box containing information about a course
        string getCalendarPopupString(int id)
        {
            // Gets all courses with same course code:
            List <int> ids = new List <int>();

            for (int i = 0; i < DB.getNumCourses(); i++)
            {
                if (DB.getCourseCode(i) == DB.getCourseCode(id))
                {
                    ids.Add(i);
                }
            }

            string val = DB.getCourseCode(ids[0]) + "\n";

            val += DB.getLongName(ids[0]) + "\n";
            val += "with " + DB.getProf(ids[0]).first + " " + DB.getProf(ids[0]).last + "\n\n";

            int credits = 0;

            foreach (int course_id in ids)
            {
                val     += DB.getCourse(course_id).getTimeString().Item1 + " to " + DB.getCourse(course_id).getTimeString().Item2;
                val     += " on " + getDays(DB.getCourse(course_id)) + " in " + DB.getBuilding(course_id) + " " + DB.getRoom(course_id) + "\n";
                credits += DB.getCredits(course_id);
            }

            val += "\n" + credits.ToString() + " total credits\n";
            val += DB.getEnrollment(ids[0]).ToString() + " seats taken out of " + DB.getCapacity(ids[0]).ToString() + "\n";
            return(val);
        }