AddExecutor.xaml.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.SqlClient;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Shapes;
  15. namespace Esoft.Windows
  16. {
  17. public partial class AddExecutor : Page
  18. {
  19. private user6Entities _context = new user6Entities();
  20. private Task _currentTask = null;
  21. public AddExecutor()
  22. {
  23. InitializeComponent();
  24. // Здесь можно задать контекст данных, если необходимо
  25. }
  26. private void BtnCancel_Click(object sender, RoutedEventArgs e)
  27. {
  28. // Логика отмены, например, закрыть окно
  29. NavigationService?.GoBack();
  30. }
  31. private void BtnSave_Click(object sender, RoutedEventArgs e)
  32. {
  33. // Логика сохранения данных
  34. // Например, валидация и сохранение объекта User
  35. if (ValidateInputs())
  36. {
  37. // Сохранение данных
  38. MessageBox.Show("Исполнитель сохранен.");
  39. }
  40. else
  41. {
  42. MessageBox.Show("Пожалуйста, заполните все обязательные поля.");
  43. var context = user6Entities.GetContext();
  44. context.SaveChanges();
  45. NavigationService.GoBack();
  46. }
  47. }
  48. private bool ValidateInputs()
  49. {
  50. // Ваша логика валидации
  51. return !string.IsNullOrWhiteSpace(FirstName.Text);
  52. }
  53. }
  54. }