Beispiel #1
0
        /// <summary>
        /// Event listener for year selection changes from the UI.
        /// </summary>
        /// <param name="sender">Re-pass sender from original event handler.</param>
        /// <param name="e">Re-pass e from original event handler.</param>
        public void SelectedYearChanged(object sender, SelectionChangedEventArgs e)
        {
            //Currently getting ALL students. This will need to filter by school year.
            int year;

            try
            {
                ComboBoxItem cb = (ComboBoxItem)windowRef.comboYear.SelectedItem;
                year = Int32.Parse(cb.Content.ToString());
            }
            catch (Exception)
            {
                //This fails EVERY time right now (2011-2012 does not parse to int). We're not actually filtering based off year yet.
                //Also, since we had to update to school years (2011-2012 instead of just 2011), we'll need to
                //Split at the '-', and retrieve students who were "lastActive" during either year.
            }

            if (dbConn.Open())
            {
                DataTable info   = dbConn.oldQuery("StudentInfo", null, null);
                DataTable grades = dbConn.oldQuery("grades", null, null);
                DataTable stats  = dbConn.oldQuery("StudentStats", null, null);

                /* John's sql join fix
                 *      DataTable GetStudentsForYear = dbConn.executeQuery(null, 2010);
                 *
                 *      //studID = 34623462
                 *      //desiredItem = "c_5_dhc140";
                 *      //SelectStudentInfo(GetStudentsForYear, studID, desiredItem);
                 *
                 *      String testCollection = SelectStudentInfo(GetStudentsForYear, 23454984, "birthday");
                 *      MessageBox.Show(testCollection);
                 */


                dbConn.Close();

                /*
                 * Relying on all tables to return the same number of rows - FIXME!
                 */
                try
                {
                    for (int i = 0; i < info.Rows.Count; i++)
                    {
                        StudentList.Add(new Student(info.Rows[i], stats.Rows[i], grades.Rows[i]));
                    }
                }
                catch (Exception) { }

                StudentList.Sort(delegate(Student s1, Student s2) { return(s1.LastName.CompareTo(s2.LastName)); });
                windowRef.listStudents.ItemsSource       = StudentList;
                windowRef.listStudents.DisplayMemberPath = "DisplayString";
            }
        }
Beispiel #2
0
        public List <Course> GetCourses()
        {
            List <Course> courses = new List <Course>();

            dbConn = new DBController();

            DataTable grades = null;

            if (dbConn.Open())
            {
                grades = dbConn.GetSchema("Grades");
                dbConn.Close();
            }


            /*
             * if (grades != null)
             *  foreach (DataRow myField in grades.Rows)
             *      foreach (DataColumn myProperty in grades.Columns)
             *      {
             *          string title = myField[myProperty].ToString();
             *          if (myProperty.ColumnName == "ColumnName" && title.StartsWith(COURSE_PREFIX))
             *          {
             *              string dept = Regex.Replace(title, @"\d", "").Substring(COURSE_PREFIX.Length);
             *
             *              Regex numbers = new Regex("[0-9]+");
             *              int number = 0;
             *              try
             *              {
             *                  number = Int32.Parse(numbers.Match(title).Value);
             *              }
             *              catch (Exception e)
             *              {
             *                  MessageBox.Show("Error parsing Grade schema for course list: " + e.Message);
             *                  throw;
             *              }
             *
             *              courses.Add(new Course(dept, number, ""));
             *          }
             *      }*/
            return(courses);
        }
        public List<Course> GetCourses()
        {
            List<Course> courses = new List<Course>();
            dbConn = new DBController();

            DataTable grades = null;
            if (dbConn.Open())
            {
                grades = dbConn.GetSchema("Grades");
                dbConn.Close();
            }

            /*
            if (grades != null)
                foreach (DataRow myField in grades.Rows)
                    foreach (DataColumn myProperty in grades.Columns)
                    {
                        string title = myField[myProperty].ToString();
                        if (myProperty.ColumnName == "ColumnName" && title.StartsWith(COURSE_PREFIX))
                        {
                            string dept = Regex.Replace(title, @"\d", "").Substring(COURSE_PREFIX.Length);

                            Regex numbers = new Regex("[0-9]+");
                            int number = 0;
                            try
                            {
                                number = Int32.Parse(numbers.Match(title).Value);
                            }
                            catch (Exception e)
                            {
                                MessageBox.Show("Error parsing Grade schema for course list: " + e.Message);
                                throw;
                            }

                            courses.Add(new Course(dept, number, ""));
                        }
                    }*/
            return courses;
        }
Beispiel #4
0
        /// <summary>
        /// Event listener for year selection changes from the UI.
        /// </summary>
        /// <param name="sender">Re-pass sender from original event handler.</param>
        /// <param name="e">Re-pass e from original event handler.</param>
        public void SelectedYearChanged(object sender, SelectionChangedEventArgs e)
        {
            //Currently getting ALL students. This will need to filter by school year.
            int year;

            try
            {
                ComboBoxItem cb = (ComboBoxItem)windowRef.comboYear.SelectedItem;
                year = Int32.Parse(cb.Content.ToString());
            }
            catch (Exception)
            {
                //This fails EVERY time right now (2011-2012 does not parse to int). We're not actually filtering based off year yet.
                //Also, since we had to update to school years (2011-2012 instead of just 2011), we'll need to
                //Split at the '-', and retrieve students who were "lastActive" during either year.
            }

            if (dbConn.Open())
            {
                DataTable GetStudentsForYear = dbConn.executeQuery(null, 2010); //Year not being used yet

                dbConn.Close();

                try
                {
                    for (int i = 0; i < GetStudentsForYear.Rows.Count; i++)
                    {
                        StudentList.Add(new Student(GetStudentsForYear.Rows[i]));
                    }
                }
                catch (Exception) { }

                StudentList.Sort(delegate(Student s1, Student s2) { return(s1.LastName.CompareTo(s2.LastName)); });
                windowRef.listStudents.ItemsSource       = StudentList;
                windowRef.listStudents.DisplayMemberPath = "DisplayString";
            }
        }