/// <summary> /// Used when adding new students through the form window. /// Method will append current students data file to include new student's /// necessary information to read and write to when future updates are made. /// </summary> /// <param name="student">student object to add to existing students data file</param> public void AddStudentToFile(Student student) { TempStudentObjectList.Add(student); using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"../../Write-Read/Students.txt", true)) { file.WriteLine(student.ToStringAddNewStudent()); } }
/// <summary> /// Will populate a list of integers containing the indicies of specific class section student object's position in TempStudentObjectList. /// Will be used to reference specific objects when populating listboxes and writing data to file. /// Goal is to "skip over" the student objects who are NOT in the class section but still maintaining their integrity to write all students to file during updates. /// </summary> /// <param name="classSection"></param> public void DetermineActiveStudents(string classSection) { List <int> tempIndicies = new List <int>(); int count = TempStudentObjectList.Count(); for (int i = 0; i < count; ++i) { if (TempStudentObjectList[i].SectionID == CurrentClassID) { tempIndicies.Add(i); } } ActiveRosterLength = tempIndicies.Count();//stores number of students who belong to currentclassID. ActiveStudentObjectIndices = tempIndicies; }