Example #1
0
        // displays the course information for the selected course
        private void showCourseInfo(String myCourse)
        {
            lstBoxReplacements.Items.Clear();                 //since new selection has been made, the replacement courses box is cleared in case it wasn't empty
            DataTable result = GraduationPlanningSystem.db.find(myCourse, "course");

            DataRow[] rows     = result.Select();
            Object[]  rowArray = rows[0].ItemArray;
            txtBoxCourseTitle.Text  = (String)rowArray[1];
            txtBoxUID.Text          = (String)rowArray[0];
            txtBoxCourseNumber.Text = (String)rowArray[2];
            txtBoxDepartment.Text   = (String)rowArray[4];
            txtBoxHours.Text        = (String)(rowArray[3].ToString());
            txtBoxSemester.Text     = (String)rowArray[9];


            //empties the prereq/coreq/precoreq boxes
            lstBoxPrereqs.DataSource   = null;
            lstBoxCoreqs.DataSource    = null;
            lstBoxPreCoreqs.DataSource = null;
            lstBoxPrereqs.Items.Clear();
            lstBoxCoreqs.Items.Clear();
            lstBoxPreCoreqs.Items.Clear();


            //the information needed for prereqs/coreqs/precoreqs must be parsed from the database
            String entry = (String)rowArray[5];

            if (entry.Equals(""))
            {
                lstBoxPrereqs.Items.Add("No prereqs");
            }
            else
            {
                List <String> preReqs = ParseGPS.parseReqs(entry);
                lstBoxPrereqs.DataSource = preReqs;
            }

            entry = (String)rowArray[6];
            if (entry.Equals(""))
            {
                lstBoxCoreqs.Items.Add("No coreqs");
            }
            else
            {
                List <String> coReqs = ParseGPS.parseReqs(entry);
                lstBoxCoreqs.DataSource = coReqs;
            }

            entry = (String)rowArray[7];
            if (entry.Equals(""))
            {
                lstBoxPreCoreqs.Items.Add("No pre/coreqs");
            }
            else
            {
                List <String> preCoReqs = ParseGPS.parseReqs(entry);
                lstBoxPreCoreqs.DataSource = preCoReqs;
            }
        }
        /// <summary>
        /// Populates a list of courses based on major
        /// </summary>
        /// <param name="major"></param>
        /// <returns></returns>
        private List <Course> GetCoursesFromDB(string major)
        {
            List <Course> result = new List <Course>();
            DataTable     table  = GraduationPlanningSystem.db.find(major, "major");

            foreach (DataRow row in table.Select())
            {
                Course course = new Course((String)row[1], Course.AcademicStatus.NotYetTaken);

                course.Hours = (Int64)row[3];
                String entry = (String)row[5];         //gets list of reqs and parses them into nodes for a list
                if (entry.Equals(""))
                {
                    course.CoReq = null;
                }
                else
                {
                    course.CoReq = ParseGPS.parseReqs(entry);
                }

                entry = (String)row[6];
                if (entry.Equals(""))
                {
                    course.Prereq = null;
                }
                else
                {
                    course.Prereq = ParseGPS.parseReqs(entry);
                }

                entry = (String)row[7];
                if (entry.Equals(""))
                {
                    course.PrereqOrCoreq = null;
                }
                else
                {
                    course.PrereqOrCoreq = ParseGPS.parseReqs(entry);
                }
                result.Add(course);
            }
            return(result);
        }