コード例 #1
0
        private void DeleteSubject(object sender, ExecutedRoutedEventArgs e)
        {
            Subject selectedSubject = SubjectList.SelectedItem as Subject;

            if (selectedSubject == null)
            {
                return;
            }

            var result =
                MessageBox.Show(
                    "Are you sure you want delete subject \"" + selectedSubject.Name +
                    "\" ?\n All related tasks and TimeTable items will be deleted.", "Confirm", MessageBoxButton.YesNo);

            if (result == MessageBoxResult.No)
            {
                return;
            }

            _subjectRepository.DeleteSubjectById(selectedSubject.SubjectId);
            _displayedSubjects.Remove(selectedSubject);
            SubjectList.Items.Refresh();
            AwailableSubjects.Items.Refresh();
            InitTaskGrid(false);
            InitSubjectControl();
        }