1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace ROGOZ.Pages
- {
- /// <summary>
- /// Логика взаимодействия для TaskList.xaml
- /// </summary>
- public partial class TaskList : Page
- {
- public TaskList()
- {
- InitializeComponent();
- DGTasks.ItemsSource = user1Entities.GetContext().Task.ToList();
- }
- private void BtnAdd_Click(object sender, RoutedEventArgs e)
- {
- NavigationService.Navigate(new AddEditPage(null));
- }
- private void BtnEdit_Click(object sender, RoutedEventArgs e)
- {
- NavigationService.Navigate(new AddEditPage((sender as Button).DataContext as Task));
- }
- private void BtnDelTask_Click(object sender, RoutedEventArgs e)
- {
- var taskIsForRemoving = DGTasks.SelectedItems.Cast<Task>().ToList();
- if (MessageBox.Show($"Вы точно хотите удалить {taskIsForRemoving.Count()} задач?",
- "Внимание",MessageBoxButton.YesNo, MessageBoxImage.Question)==MessageBoxResult.Yes)
- {
- try
- {
- user1Entities.GetContext().Task.RemoveRange(taskIsForRemoving);
- user1Entities.GetContext().SaveChanges();
- MessageBox.Show("Данные удалены");
- DGTasks.ItemsSource = user1Entities.GetContext().Task.ToList();
- }
- catch (Exception ex) {MessageBox.Show(ex.Message.ToString());}
- }
- }
- }
- }
|