//[FUNCTION - CourseSelectionForm_Load]
        //Formats the labels on the courses selection form upon load
        private void CourseSelectionForm_Load(object sender, EventArgs e)
        {
            //Display correct intro label
            string fullTermName;

            if (userInfo.getTermInterest() == "FA")
            {
                fullTermName = "fall";
            }
            else if (userInfo.getTermInterest() == "SP")
            {
                fullTermName = "spring";
            }
            else
            {
                fullTermName = "January";
            }
            CourseSelectionLabel.Text = "Welcome " + userInfo.getFirstName() + ", please add your " + fullTermName + " course(s)... ";
            UpdateCreditAmount();

            //Table Setup
            selectedCourseTable = new DataTable();
            // - Set labels
            selectedCourseTable.Columns.Add("ID", typeof(string));
            selectedCourseTable.Columns.Add("Title", typeof(string));
            // - Set initial entry (doesn't count as course)
            selectedCourseTable.Rows.Add("N/A", "No Courses Added");
            // - Set formatting
            selectedCoursesGridView.DataSource = selectedCourseTable;
            selectedCoursesGridView.Columns["ID"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            selectedCoursesGridView.Columns["ID"].Width = 72;
            // - Preselect first row
            selectedRow           = selectedCoursesGridView.Rows[0];
            selectedTableRowIndex = 0;
        }
예제 #2
0
        //[FUNCTION - RemoveIrevSections]
        //Cleans up course data by removing irrevelant sections with missing times/days
        void RemoveIrevSections()
        {
            //Store the locations of sections to remove
            List <int> removeCourseIndexes  = new List <int>();
            List <int> removeSectionIndexes = new List <int>();

            //Detemine section need by iterating over all sections in all courses and marking their location in parallel lists above
            foreach (var course in courses)
            {
                foreach (var section in course.getSections())
                {
                    if (section.getMeetDays().Exists(s => s.Contains("NA")) || section.getStartTimes().Exists(s => s.Contains("NA")) ||
                        !section.getTerm().Contains(userData.getTermInterest()))
                    {
                        removeCourseIndexes.Add(courses.IndexOf(course));
                        removeSectionIndexes.Add(course.getSections().IndexOf(section));
                    }
                }
            }

            //Add unneeded courses to secondary list (some may have partial valid data) (revise to deep copy courses instead)
            foreach (var index in removeCourseIndexes)
            {
                unneededCourses.Add(courses[index]);
            }

            //Remove course entry from primary list
            int indexOffset = 0;

            if (removeCourseIndexes.Count() == 0)
            {
                return;
            }

            //Iterates over all section removal locations removing them from database
            int currentCourseIndex = removeCourseIndexes[0];

            for (int i = 0; i < removeCourseIndexes.Count(); i++)
            {
                if (currentCourseIndex != removeCourseIndexes[i])
                {
                    indexOffset        = 0;
                    currentCourseIndex = removeCourseIndexes[i];
                }
                Debug.WriteLine("Removing - Course: " + courses[removeCourseIndexes[i]].getCourseName() + " | Section: " + removeSectionIndexes[i]);
                courses[removeCourseIndexes[i]].getSections().RemoveAt(removeSectionIndexes[i] - indexOffset);
                indexOffset++;
            }

            RemoveEmptyCourses();
        }