private static void ClearLists() { ImportCourses.ClearCourseList(); Halls.ClearHallList(); }
public static List <OngoingClass> GetHallAvailabilityReturnOngoingCourses() { //List of ALL Courses //var listOfCourses = Courses.SendList ; OLD CODE var listOfCourses = ImportCourses.ListOfCourses(); // return listOfCourses; //List of All Halls var listOfHalls = Halls.ListOfHalls(); var onGoingClass = OngoingClass.OngoingCourses; #region First randomize the List of Courses //This is Creation of a Random List of Courses List <ImportCourses> randomCourseList = new List <ImportCourses>(); //Call the Random Object Random random = new Random(); //varable Random index int randomIndex = 0; //loop while (listOfCourses.Count > 0) { randomIndex = random.Next(0, listOfCourses.Count); randomCourseList.Add(listOfCourses[randomIndex]); listOfCourses.RemoveAt(randomIndex); } #endregion #region Looping thru the Randomized Courses and Adding them to the Ongoing Courses //i have no idea why i wrote this, or what it does int checkHallAvailability = listOfHalls.FindIndex(i => i.Availability == true); //truthfully --- signed Ojo Emmanuel for (int i = 0; i < randomCourseList.Count; i++) { //loop thru a count of the random list foreach (var hall in listOfHalls) { //loop thru the available halls foreach (var course in randomCourseList) { if (course.Status.ToUpper() == "C") { course.Size = "BIG"; } else if (course.Status.ToUpper() == "E") { course.Size = "SMALL"; } else if (course.Status.ToUpper() == "R") { course.Size = "MEDIUM"; } else { course.Size = "unknown"; } //loop thru the list of courses if (hall.Availability == true && course.Size.ToUpper() == hall.Capacity.ToUpper()) { bool checkVal = onGoingClass.Exists(x => x.LectureCode == course.Name.ToUpper()); //var check = onGoingClass.Find(x => x.LectureCode == course.Name); //{ ////add the merged list to the ongoing class //onGoingClass.Add(new OngoingClass { LectureCode = course.Name.ToUpper(), Location = hall.Number }); //hall.Availability = false; //} if ((checkVal == true)) { onGoingClass.Remove(new OngoingClass { LectureCode = course.Name.ToUpper(), Location = hall.Number }); } else { onGoingClass.Add(new OngoingClass { LectureCode = course.Name.ToUpper(), Location = hall.Number }); hall.Availability = false; } } } foreach (var Ahall in listOfHalls) { Ahall.Availability = true; } } } #endregion return(onGoingClass); // return onGoingClass; }
//private void Btn_BrowseFileHall_Click(object sender, RoutedEventArgs e) //{ //} private void Btn_AddBrowseFile_Click(object sender, RoutedEventArgs e) { var status = cmb_FileCategory.SelectionBoxItem.ToString(); var txt = txtBox_FileName.Text; if (status == "" || txt == "") { MessageBox.Show("Select File and Choose File Category"); } else { if (status == "Halls") { var sendFileAndGetStatus = Halls.GetOleDbConnectionSucess(FileNameAndPath); if (sendFileAndGetStatus == null) { MessageBox.Show("Something Wrong With File"); } else { var halls = Halls.ListOfHalls(); if (halls == null) { MessageBox.Show("Table Name Error:\nEnsure Sheet Name is Renamed to File Name \nEnsure All Editing is Completed", "Warning"); } else { CountHall = halls.Count; list_availableHall.ItemsSource = halls; // list_availableCourses.ItemsSource = halls; } } } else { var sendFileAndGetStatus = ImportCourses.GetOleDbConnectionSucess(FileNameAndPath); if (sendFileAndGetStatus == null) { MessageBox.Show("Something Wrong With File"); } else { var courses = ImportCourses.ListOfCourses(); if (courses == null) { MessageBox.Show("Table Name Error \n Ensure Sheet Name is Renamed to File Name", "Warning"); } else { #region Displays Available Courses Count CountCourse = courses.Count; lbl_availableCourses.Content = $"Registered Courses ({CountCourse})"; #endregion list_availableCourses.ItemsSource = courses; } } } } if (CountCourse > 0 && CountHall > 0) { btn_GenerateTimeTable.IsEnabled = true; } }