private void Add_Click(object sender, RoutedEventArgs e) { var dialog = new LessonAddEditDialog(); dialog.Title = "Добавить занятие"; if (dialog.ShowDialog() == true) { var lesson = new Lesson { Day = dialog.Day, Start = dialog.Time }; db.Lessons.Add(lesson); UpdateGrid(); } }
private void Edit_Click(object sender, RoutedEventArgs e) { if (Data.SelectedItem == null || Data.SelectedItem as Lesson == null) { return; } var lesson = Data.SelectedItem as Lesson; var dialog = new LessonAddEditDialog(); dialog.Title = "Редактировать занятие"; dialog.Day = lesson.Day; dialog.Time = lesson.Start; if (dialog.ShowDialog() == true) { lesson.Day = dialog.Day; lesson.Start = dialog.Time; UpdateGrid(); } }