public void EditComponent() { var window = new AddGradingComponentWindow(); GradingComponent uneditedGradingComponent = new GradingComponent(); uneditedGradingComponent.ActivityTotalItems = SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.ActivityTotalItems; uneditedGradingComponent.ActivityTotalScorePercentage = SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.ActivityTotalScorePercentage; uneditedGradingComponent.ActivityTotalScoreRaw = SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.ActivityTotalScoreRaw; uneditedGradingComponent.Base = SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.Base; uneditedGradingComponent.ConvertedGrade = SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.ConvertedGrade; uneditedGradingComponent.FinalGrade = SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.FinalGrade; uneditedGradingComponent.GradingType = SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.GradingType; uneditedGradingComponent.ListActivities = SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.ListActivities; uneditedGradingComponent.Name = SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.Name; uneditedGradingComponent.PercentEffectOnTotalGrade = SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.PercentEffectOnTotalGrade; window.DataContext = SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent; var result = window.ShowDialog(); if (result == true) { ViewModelLocator.StartMenuViewModel.GetGradingComponentsPercentTotal(); if (SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.GradingComponentsPercentTotal > 100) { MessageBox.Show("Grading components percentage total will exceed 100%! Please recheck your components' percentage values.", "Error", MessageBoxButton.OK, MessageBoxImage.Warning); SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.ActivityTotalItems = uneditedGradingComponent.ActivityTotalItems; SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.ActivityTotalScorePercentage = uneditedGradingComponent.ActivityTotalScorePercentage; SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.ActivityTotalScoreRaw = uneditedGradingComponent.ActivityTotalScoreRaw; SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.Base = uneditedGradingComponent.Base; SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.ConvertedGrade = uneditedGradingComponent.ConvertedGrade; SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.FinalGrade = uneditedGradingComponent.FinalGrade; SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.GradingType = uneditedGradingComponent.GradingType; SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.ListActivities = uneditedGradingComponent.ListActivities; SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.Name = uneditedGradingComponent.Name; SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.PercentEffectOnTotalGrade = uneditedGradingComponent.PercentEffectOnTotalGrade; } } if (result == false) { SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.ActivityTotalItems = uneditedGradingComponent.ActivityTotalItems; SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.ActivityTotalScorePercentage = uneditedGradingComponent.ActivityTotalScorePercentage; SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.ActivityTotalScoreRaw = uneditedGradingComponent.ActivityTotalScoreRaw; SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.Base = uneditedGradingComponent.Base; SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.ConvertedGrade = uneditedGradingComponent.ConvertedGrade; SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.FinalGrade = uneditedGradingComponent.FinalGrade; SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.GradingType = uneditedGradingComponent.GradingType; SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.ListActivities = uneditedGradingComponent.ListActivities; SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.Name = uneditedGradingComponent.Name; SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.SelectedGradingComponent.PercentEffectOnTotalGrade = uneditedGradingComponent.PercentEffectOnTotalGrade; } }
public void AddNewComponent() { var window = new AddGradingComponentWindow(); GradingComponent newGradingComponent = new GradingComponent(); window.DataContext = newGradingComponent; var result = window.ShowDialog(); if (result == true) { SelectedUser.SelectedSemester.SelectedClass.SelectedGradingPeriod.ListGradingComponents.Add(newGradingComponent); } }