private void AddNewTestProc() { if (SelectedSubject == null) { MessageBox.Show("No subject selected"); return; } if (TestModel.Score > TestModel.Total) { MessageBox.Show("Invalid score; score cannot be greater than total"); return; } TestModel.Base = GradingSystem.Base; TestModel.TestDate = DateTime.Now; SelectedSubject.Tests.Add(TestModel); CalculateFinalGrade(); string _textToSave = $"{TestModel.Score},{TestModel.Total},{TestModel.TestDate},{TestModel.Base},{TestModel.TestType.Name},{TestModel.GradingPeriod.Name}"; string testPath = Path.Combine(Directory.GetCurrentDirectory(), "Data", AssociatedPerson.Username, "Subject Data", SelectedSubject.Name + " Tests.txt"); File.AppendAllText(testPath, _textToSave + Environment.NewLine); AddNewTestWindow.Close(); SetGraph(); TestModel = new Test(); }
private void CancelAddTestProc() { AddNewTestWindow.Close(); }