ExecutorList.xaml.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using Esoft.Windows;
  2. using Microsoft.Office.Interop.Word;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Data;
  11. using System.Windows.Documents;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Navigation;
  16. using System.Windows.Shapes;
  17. namespace Esoft.Pages
  18. {
  19. /// <summary>
  20. /// Логика взаимодействия для ExecutorList.xaml
  21. /// </summary>
  22. public partial class ExecutorList : System.Windows.Controls.Page
  23. {
  24. private user6Entities _context = new user6Entities();
  25. //private List<string> listUsers = new List<string>();
  26. public ExecutorList()
  27. {
  28. InitializeComponent();
  29. //CmbExecutorSort.ItemsSource = user6Entities.GetContext().Executor.ToList();
  30. DGTasks.ItemsSource = user6Entities.GetContext().Task.ToList();
  31. //foreach (var user in _context.User.ToList())
  32. //{
  33. // listUsers.Add(user.getFamilia());
  34. //}
  35. //CmbExecutorSort.ItemsSource = listUsers;
  36. }
  37. private void BtnAdd_Click(object sender, RoutedEventArgs e)
  38. {
  39. NavigationService.Navigate(new AddExecutor());
  40. }
  41. private void BtnEdit_Click(object sender, RoutedEventArgs e)
  42. {
  43. NavigationService.Navigate(new AddExecutor());
  44. }
  45. private void BtnDelTask_Click(object sender, RoutedEventArgs e)
  46. {
  47. var taskIsForRemoving = DGTasks.SelectedItems.Cast<Task>().ToList();
  48. if (MessageBox.Show($"Вы точно хотите удалить иполнителя?",
  49. "Внимание", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
  50. {
  51. try
  52. {
  53. user6Entities.GetContext().Task.RemoveRange(taskIsForRemoving);
  54. user6Entities.GetContext().SaveChanges();
  55. MessageBox.Show("Данные удалены");
  56. DGTasks.ItemsSource = user6Entities.GetContext().Task.ToList();
  57. }
  58. catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); }
  59. }
  60. }
  61. }
  62. }