Пример #1
0
        public static List <Course> readCareerFinalCourses(Career career)
        {
            List <Course> courses       = new List <Course>();
            String        readJobsTable = "SELECT COURSEID FROM FinalCourse WHERE CAREERID ='" + career.id + "'";

            try
            {
                dbConnection.Open();
                sqlCommand = new SQLiteCommand(readJobsTable, dbConnection);
                dataReader = sqlCommand.ExecuteReader();

                while (dataReader.Read())
                {
                    String finalCourseId   = dataReader["COURSEID"].ToString();
                    String readFinalCourse = "SELECT * FROM Course WHERE ID = '" + finalCourseId + "'";

                    SQLiteCommand    sqlCommandTemp = new SQLiteCommand(readFinalCourse, dbConnection);
                    SQLiteDataReader dataReaderTemp = sqlCommandTemp.ExecuteReader();
                    Course           finalCourse    = null;
                    while (dataReaderTemp.Read())
                    {
                        finalCourse = new Course(dataReaderTemp["ID"].ToString(),
                                                 (int)dataReaderTemp["YR"],
                                                 (int)dataReaderTemp["SEM"],
                                                 dataReaderTemp["NAME"].ToString(),
                                                 dataReaderTemp["DESC"].ToString(),
                                                 (int)dataReaderTemp["POINTS"],
                                                 dataReaderTemp["ACADEMICORG"].ToString(),
                                                 dataReaderTemp["ACADEMICGROUP"].ToString(),
                                                 dataReaderTemp["COURSECOMP"].ToString(),
                                                 dataReaderTemp["GRADINGBASIS"].ToString(),
                                                 dataReaderTemp["TYPOFFERED"].ToString(),
                                                 dataReaderTemp["REMARKS"].ToString(),
                                                 dataReaderTemp["CAREERID"].ToString());
                    }
                    if (finalCourse != null)
                    {
                        Logger.Info("[DatabaseConnection::readCareerFinalCourses()] PreRequisite Course Information:");
                        Logger.Info("[DatabaseConnection::readCareerFinalCourses()]" + "\nID: " + finalCourse.id + "\nNAME: " + finalCourse.name + "\nDESC: " + finalCourse.description);
                        courses.Add(finalCourse);
                    }
                }
                dbConnection.Close();
            }
            catch (Exception e)
            {
                Logger.Error("DatabaseConnection::readCareerFinalCourses() " + e.Message);
            }

            return(courses);
        }
Пример #2
0
        public static void readCareers(List <Career> careers)
        {
            String readCareerTable = "SELECT * FROM Career";

            try
            {
                careers.Clear();
                dbConnection.Open();
                sqlCommand = new SQLiteCommand(readCareerTable, dbConnection);
                dataReader = sqlCommand.ExecuteReader();

                while (dataReader.Read())
                {
                    Career career = new Career(dataReader["ID"].ToString(), dataReader["NAME"].ToString(), dataReader["DESC"].ToString());
                    careers.Add(career);
                    Logger.Info("ID: " + career.id + " NAME: " + career.name + " DESC: " + career.description);
                }
                dbConnection.Close();
            }
            catch (Exception ex)
            {
                Logger.Error("DatabaseConnection::readCareers() " + ex.Message);
            }
        }
Пример #3
0
        /// <summary>
        /// Handles the career selection.
        /// </summary>
        private void careerTreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
        {
            TreeViewItem tvi = (TreeViewItem)e.NewValue;

            if (tvi != null)
            {
                tvi.IsExpanded = !tvi.IsExpanded;

                StackPanel itemHeader = (StackPanel)((TreeViewItem)((TreeView)sender).SelectedItem).Header;

                var careerLabel = itemHeader.Children.OfType<Label>().FirstOrDefault();

                foreach(var career in careers)
                {
                    if (career.name == careerLabel.Content.ToString())
                    {
                        selectedCareer = null;

                        // Set the final courses for this career
                        //
                        careerFinalCoursesGrid.Items.Clear();
                        List<Course> finalCoursesToTake = DatabaseConnection.readCareerFinalCourses(career);
                        foreach(Course course in finalCoursesToTake)
                        {
                            careerFinalCoursesGrid.Items.Add(new CareerInfoDataItem() { finalCourse = course.id + " - " + course.name });
                        }
                        // Workaround to fill the table
                        //
                        for (int i = 0; i < 5; i++)
                        {
                            careerFinalCoursesGrid.Items.Add(new CareerInfoDataItem() { finalCourse = "" });
                        }
                        //careerFinalCoursesGrid.Visibility = Visibility.Visible;

                        if (selectedCareer == null)
                        {
                            selectedCareer = new Career(career.id,
                                                    career.name,
                                                    career.description);
                        }
                        else
                        {
                            selectedCareer.id = career.id;
                            selectedCareer.name = career.name;
                            selectedCareer.description = career.description;
                        }

                        Logger.Info("selectedCareer.name: " + selectedCareer.name);
                        break;
                    }
                }
            }
        }
Пример #4
0
        public static void readCareers(List<Career> careers)
        {
            String readCareerTable = "SELECT * FROM Career";

            try
            {
                careers.Clear();
                dbConnection.Open();
                sqlCommand = new SQLiteCommand(readCareerTable, dbConnection);
                dataReader = sqlCommand.ExecuteReader();

                while (dataReader.Read())
                {
                    Career career = new Career(dataReader["ID"].ToString(), dataReader["NAME"].ToString(), dataReader["DESC"].ToString());
                    careers.Add(career);
                    Logger.Info("ID: " + career.id + " NAME: " + career.name + " DESC: " + career.description);
                }
                dbConnection.Close();
            }
            catch(Exception ex)
            {
                Logger.Error("DatabaseConnection::readCareers() " + ex.Message);
            }
        }
Пример #5
0
        public static List<String> readCareerJobs(Career career)
        {
            List<String> jobs = new List<string>();
            String readJobsTable = "SELECT NAME FROM Job WHERE CAREERID ='" + career.id + "'";

            try
            {
                dbConnection.Open();
                sqlCommand = new SQLiteCommand(readJobsTable, dbConnection);
                dataReader = sqlCommand.ExecuteReader();

                while (dataReader.Read())
                {
                    String job = dataReader["NAME"].ToString();
                    jobs.Add(job);
                    Logger.Debug("DatabaseConnection::readCareerJobs() career = " + career.id + " job = " + job);
                }
                dbConnection.Close();
            }
            catch(Exception e)
            {
                Logger.Error("DatabaseConnection::readCareerJobs() " +  e.Message);
            }

            return jobs;
        }
Пример #6
0
        public static List<Course> readCareerFinalCourses(Career career)
        {
            List<Course> courses = new List<Course>();
            String readJobsTable = "SELECT COURSEID FROM FinalCourse WHERE CAREERID ='" + career.id + "'";

            try
            {
                dbConnection.Open();
                sqlCommand = new SQLiteCommand(readJobsTable, dbConnection);
                dataReader = sqlCommand.ExecuteReader();

                while (dataReader.Read())
                {
                    String finalCourseId = dataReader["COURSEID"].ToString();
                    String readFinalCourse = "SELECT * FROM Course WHERE ID = '" + finalCourseId + "'";

                    SQLiteCommand sqlCommandTemp = new SQLiteCommand(readFinalCourse, dbConnection);
                    SQLiteDataReader dataReaderTemp = sqlCommandTemp.ExecuteReader();
                    Course finalCourse = null;
                    while (dataReaderTemp.Read())
                    {
                        finalCourse = new Course(dataReaderTemp["ID"].ToString(),
                                (int)dataReaderTemp["YR"],
                                (int)dataReaderTemp["SEM"],
                                dataReaderTemp["NAME"].ToString(),
                                dataReaderTemp["DESC"].ToString(),
                                (int)dataReaderTemp["POINTS"],
                                dataReaderTemp["ACADEMICORG"].ToString(),
                                dataReaderTemp["ACADEMICGROUP"].ToString(),
                                dataReaderTemp["COURSECOMP"].ToString(),
                                dataReaderTemp["GRADINGBASIS"].ToString(),
                                dataReaderTemp["TYPOFFERED"].ToString(),
                                dataReaderTemp["REMARKS"].ToString(),
                                dataReaderTemp["CAREERID"].ToString());
                    }
                    if (finalCourse != null)
                    {
                        Logger.Info("[DatabaseConnection::readCareerFinalCourses()] PreRequisite Course Information:");
                        Logger.Info("[DatabaseConnection::readCareerFinalCourses()]" + "\nID: " + finalCourse.id + "\nNAME: " + finalCourse.name + "\nDESC: " + finalCourse.description);
                        courses.Add(finalCourse);
                    }
                }
                dbConnection.Close();
            }
            catch (Exception e)
            {
                Logger.Error("DatabaseConnection::readCareerFinalCourses() " + e.Message);
            }

            return courses;
        }