private static void LoadMarks() { string filePath = @"../../Data/students_marks.txt"; StreamReader reader = new StreamReader(filePath); using (reader) { string currentLine = reader.ReadLine(); while (currentLine != null) { string[] currentLineArray = currentLine.Split('#'); TypeOfMarks markType = new TypeOfMarks(); switch (currentLineArray[1]) { case "Current": markType = TypeOfMarks.Current; break; case "Term": markType = TypeOfMarks.Term; break; case "Annual": markType = TypeOfMarks.Annual; break; } // 3,50#Current#1111111111#10#A#Math - Sample record of mark Mark currMark = new Mark(decimal.Parse(currentLineArray[0]), markType, long.Parse(currentLineArray[2]), int.Parse(currentLineArray[3]), char.Parse(currentLineArray[4]), currentLineArray[5]); ESchoolDiaryData.Marks.Add(currMark); currentLine = reader.ReadLine(); } } }
// Use it in the forms public Mark(decimal markValue, TypeOfMarks markType, Student student, Subject subject) { this.MarkValue = markValue; this.MarkType = markType; this.StudentPin = student.Pin; this.SchClass = student.SchClass; this.SchSubClass = student.SchSubClass; this.SubjectName = subject.Name.ToString(); }
// Constructors // Using it for reading the data in students_marks.txt - Tisho // 3,50#Current#1111111111#10#A#Math - Sample record of mark public Mark(decimal markValue, TypeOfMarks markType, long studentPin, int studSchClass, char studSchSubClass, string subjectName) { this.MarkValue = markValue; this.MarkType = markType; this.StudentPin = studentPin; this.SchClass = studSchClass; this.SchSubClass = studSchSubClass; this.SubjectName = subjectName; }