static public void Write() { CoursesFile.Write(); Users_SubjectsFile.WriteData(); Subjects_UsersFile.WriteSubjects(); UsersFile.WriteinFile(); }
static void Read() { if (data != null) { return; } data = new ArrayList <Student>(); if (!File.Exists("User.txt")) { return; } FileStream fs = new FileStream("User.txt", FileMode.Open); StreamReader sr = new StreamReader(fs); string[] Records, Fields; Records = sr.ReadToEnd().Split('#'); sr.Close(); for (int i = 0; i < Records.Length; i++) { Fields = Records[i].Split('@'); if (Fields.Length == 1) { continue; } data.Append(new Student() { ID = int.Parse(Fields[0]), Name = Fields[1], Password = Fields[2], AcademicYear = Fields[3], RegisteredCourses = Users_SubjectsFile.GetSubjects(int.Parse(Fields[0])), }); } sr.Close(); }
static public void DeleteCourse(Course c) { for (int i = 0; i < Data.Count; i++) { if (Data[i] == c) { Subjects_UsersFile.DeleteCourse(c); Users_SubjectsFile.DeleteCourse(c); Data.DeleteAt(i); return; } } }
static public bool DeleteStudent(Student s) { for (int i = 0; i < Data.Count; i++) { if (Data[i] == s) { Users_SubjectsFile.DeleteStudent(s); Subjects_UsersFile.DeleteStudent(s); Data.DeleteAt(i); return(true); } } return(false); }
static public void AddStudent(Student s) { Data.Append(s); Users_SubjectsFile.RegisterStudent(s); }