// Read the files and returns our courses data public static Courses ReadCurrentCourseFiles() { Courses courseData = new Courses(); // Current Course data // Reads through each fileSet in each folder foreach (string[] fileSet in files) { // Instantiate new course Course newCourse = new Course(); // Finds the course information folder for (int i = 0; i < fileSet.Length; ++i) { // Fills all the information about the course if (fileSet[i].Contains("COURSEINFO")) { // Opens the excel Excel excel = new Excel(Path.GetFullPath(fileSet[i])); // Open the general information sheet excel.OpenSheet("General"); // Gets the data newCourse.Name = excel.ReadCell(1, 2); newCourse.Credits = Convert.ToInt16(excel.ReadCell(2, 2)); newCourse.FinalWeight = Convert.ToInt16(excel.ReadCell(3, 2)); // Read cutoffs List <int> cutOffs = new List <int>(); for (int j = 0; j < 4; ++j) { cutOffs.Add(Convert.ToInt16(excel.ReadCell(2 + j, 5))); } newCourse.PercCutoff = cutOffs; // Read and add categories List <Category> currCats = new List <Category>(); for (int j = 2; excel.ReadCell(j, 7).Equals(EndOfData) == false; j++) { Category currCat = new Category(); currCat.Name = excel.ReadCell(j, 7); currCat.Weight = Convert.ToInt16(excel.ReadCell(j, 8)); // Adds it to the vector currCats.Add(currCat); } // Adds the cats to the course newCourse.Catagories = currCats; // Adds grade history information excel.OpenSheet("GradeHistory"); for (int j = 2; excel.ReadCell(j, 1).Equals(EndOfData) == false; j++) { newCourse.AddGradeHist(Convert.ToDouble(excel.ReadCell(j, 2))); } // Search for each sheets in the category vector foreach (Category catagory in newCourse.Catagories) { // Opens the sheet excel.OpenSheet(catagory.Name); // Assignments expected catagory.ExpAssignments = Convert.ToInt16(excel.ReadCell(3, 2)); // Grade information for (int k = 3; excel.ReadCell(k, 4).Equals(EndOfData) == false; k++) { // Makes a new grade Grade currGrade = new Grade(); // Adds the data currGrade.Name = excel.ReadCell(k, 4); currGrade.PointsEarned = Convert.ToInt16(excel.ReadCell(k, 5)); currGrade.PointsTotal = Convert.ToInt16(excel.ReadCell(k, 6)); // Adds the grade to the category catagory.Grades.Add(currGrade); } } // Close the excel excel.Close(); } } // Adds the new course courseData.CreateCourse(newCourse); } return(courseData); }
static string newData; // New data static void Main(string[] args) { // Sets up the file system FileSystem.Setup(); // Reads data from the files and stores it courses = FileSystem.ReadCurrentCourseFiles(); competedCourses = FileSystem.ReadCompletedCourseFiles(); // Sets up the screens SetUp(); // Loops until the end of the program while (endProg == false) { Console.Clear(); // Screens with set choices switch (currScreen) { // Branching screens // Branching screens that lead to other screens case Screens.MainScreen: currColor = ConsoleColor.DarkMagenta; currScreen = (Screens)MainScreen.RunScreen(); returnScreen = Screens.MainScreen; break; case Screens.Editcourses: currColor = ConsoleColor.DarkRed; currScreen = (Screens)EditCoursesScreen.RunScreen(); returnScreen = Screens.Editcourses; break; case Screens.GradeManagement: currColor = ConsoleColor.DarkGreen; GradeManagementScreen.Title = "Grade Management Screen for " + courses.GetCourse(courseIndex).Name; currScreen = (Screens)GradeManagementScreen.RunScreen(); returnScreen = Screens.GradeManagement; break; case Screens.GpaManager: currColor = ConsoleColor.DarkBlue; currScreen = (Screens)GpaManagerScreen.RunScreen(); returnScreen = Screens.GpaManager; break; } // Checks if we need to pick a course, category, or grade // current courses if (currScreen == Screens.ViewCourse || currScreen == Screens.DeleteCourse || currScreen == Screens.GradeManagement || currScreen == Screens.AddOldCompletedCourse || currScreen == Screens.InputExpectedAssignments) { nextScreen = currScreen; // Runs the screen, updates the screen before hand currColor = ConsoleColor.DarkYellow; UpdateCourseScreen(); Console.Clear(); courseIndex = (int)PickCourseScreen.RunScreen(); // Checks to see if the user picked a course or wanted to exit (return to prev screen) if (courseIndex >= 0) { currScreen = nextScreen; } else { currScreen = returnScreen; } } // category if (currScreen == Screens.AddNewGrade || currScreen == Screens.DeleteGrade || currScreen == Screens.InputExpectedAssignments) { nextScreen = currScreen; // Runs the screen, updates the screen before hand currColor = ConsoleColor.DarkYellow; UpdateCatagoryScreen(); Console.Clear(); catagoryIndex = (int)PickCatagoryScreen.RunScreen(); // Checks to see if the user picked a course or wanted to exit (return to prev screen) if (catagoryIndex >= 0) { currScreen = nextScreen; } else { currScreen = returnScreen; } } // grade if (currScreen == Screens.DeleteGrade) { nextScreen = currScreen; // Runs the screen, updates the screen before hand currColor = ConsoleColor.DarkYellow; UpdateGradeScreen(); Console.Clear(); gradeIndex = (int)PickGradeScreen.RunScreen(); // Checks to see if the user picked a course or wanted to exit (return to prev screen) if (gradeIndex >= 0) { currScreen = nextScreen; } else { currScreen = returnScreen; } } Console.Clear(); // Secondary screens (Without branches) (WILL HAVE A RETURNSCREEN) switch (currScreen) { case Screens.ExitProg: // Ends prog endProg = true; break; case Screens.AddNewCourse: // Creates new course Course newCourse = courses.AddNewCourse(false); // Updates the file system FileSystem.CreateCourseFiles(newCourse); // Tells the user the course has been created Console.WriteLine(Environment.NewLine + "Course created!"); Program.PrintPressAnyKeyToContinue(); currScreen = returnScreen; break; case Screens.ViewCourse: // Runs the viewCourseInfo just for that course courses.GetCourse(courseIndex).ViewCourseInfo(); currScreen = returnScreen; break; case Screens.ViewGradeInfo: // Runs the viewGradeInfo just for that course courses.GetCourse(courseIndex).ViewGradeInfo(); currScreen = returnScreen; break; case Screens.AddNewGrade: // Creates a new grade Grade newGrade = courses.GetCourse(courseIndex).GetCatagory(catagoryIndex).AddNewGrade(); // Updates the file system FileSystem.UpdateGradeFiles(courses.GetCourse(courseIndex), catagoryIndex, newGrade); FileSystem.UpdateGradeHist(courses.GetCourse(courseIndex).GetPercGrade(), courses.GetCourse(courseIndex)); courses.GetCourse(courseIndex).AddGradeHist(courses.GetCourse(courseIndex).GetPercGrade()); // Tells the user the grade has been created Console.SetCursorPosition(2, 12); Console.WriteLine("Grade created!"); Console.SetCursorPosition(2, Program.WindowHeight - 1); Program.PrintPressAnyKeyToContinue(); currScreen = returnScreen; break; case Screens.DeleteCourse: // Asks the user if we want to delete this course bool needDelete = courses.DeleteCourse(courseIndex); // If so, delete course if (needDelete) { FileSystem.DeleteCourseFiles(courses.GetCourse(courseIndex)); // Removes the course from the courses vector courses.RemoveCourse(courseIndex); } currScreen = returnScreen; break; case Screens.DeleteGrade: // Gets the course that we need to delete needDelete = courses.GetCourse(courseIndex).GetCatagory(catagoryIndex).DeleteGrade(gradeIndex); // Checks if the user wants to delete the grade if (needDelete) { FileSystem.DeleteGradeInfo(courses.GetCourse(courseIndex), catagoryIndex, gradeIndex); FileSystem.UpdateGradeHist(courses.GetCourse(courseIndex).GetPercGrade(), courses.GetCourse(courseIndex)); courses.GetCourse(courseIndex).AddGradeHist(courses.GetCourse(courseIndex).GetPercGrade()); // Tells the user the course has been deleted Console.SetCursorPosition(2, 5); Console.WriteLine("Grade Deleted!"); Console.SetCursorPosition(2, Program.WindowHeight - 1); Program.PrintPressAnyKeyToContinue(); } currScreen = returnScreen; break; case Screens.ViewCompletedCourses: competedCourses.ViewCompetedCourses(); currScreen = returnScreen; break; case Screens.AddNewCompletedCourse: newCourse = competedCourses.AddNewCourse(true); FileSystem.UpdateCompletedCourseFiles(newCourse); currScreen = returnScreen; break; case Screens.ProjectGPA: courses.ProjectGpa(competedCourses.GetGradePointsEarned(), competedCourses.GetGradePointsTotal()); currScreen = returnScreen; break; case Screens.WhatDoINeedOnFinal: courses.ViewFinalNeeds(); currScreen = returnScreen; break; case Screens.AddOldCompletedCourse: newCourse = courses.AddOldCompletedCourse(courseIndex); competedCourses.CreateCourse(newCourse); // Deletes the old course in files, updates the files for completed course FileSystem.DeleteCourseFiles(newCourse); FileSystem.UpdateCompletedCourseFiles(newCourse); currScreen = returnScreen; break; case Screens.InputExpectedAssignments: // Save old data oldData = Convert.ToString(courses.GetCourse(courseIndex).GetCatagory(catagoryIndex).ExpAssignments); newData = Convert.ToString(courses.GetCourse(courseIndex).GetCatagory(catagoryIndex).InputExpAssignments()); FileSystem.UpdateExpAssignmentInfo(newData, courses.GetCourse(courseIndex), catagoryIndex); currScreen = returnScreen; break; case Screens.ViewGradeHist: courses.GetCourse(courseIndex).ViewGradeHist(); currScreen = returnScreen; break; } } }