public admEnrolledStd(course crs) { InitializeComponent(); label.Text += crs.crsID; DataTable table = new DataTable(); table.Columns.Add("First Name"); table.Columns.Add("Last Name"); table.Columns.Add("Advisor"); foreach (student std in crs.getStudents()) { table.Rows.Add(std.fname, std.lname, std.advisor); } stdLst.DataSource = table; }
// Change the database public void removeCrs(string crsID, string filepath, ref userDatabase usrDB) { // Remove the course from the offering course removedCrs = getCourse(crsID); crsLst.Remove(removedCrs); // Remove the course from students' schedule List <student> enrolledStdLst = removedCrs.getStudents(); foreach (student std in enrolledStdLst) { std.dropCrsFromNext(removedCrs); } // Remove the course from faculties' schedule faculty fac = usrDB.getFaculty(removedCrs.instructor); fac.removeCrsFromNext(removedCrs); ////Updates the coursedb.in file to remove the removed course from it //string[] courseLines = File.ReadAllLines(filepath); //string[] newCourseLinesArr; //List<string> newCourseLines = new List<string>(); //foreach (string courseString in courseLines) //{ // string courseID = courseString.Substring(0, 10).Trim(); // //string courseID = courseString.Substring(4, 10); // if (courseID == removedCrs.crsID.Trim()) // continue; // Skip the iteration if the course is being deleted // else // newCourseLines.Add(courseString); // newCourseLinesArr = newCourseLines.ToArray(); // File.WriteAllLines(filepath, newCourseLinesArr); //} }