AddEditPage.xaml.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. namespace bobrovTounApp
  16. {
  17. /// <summary>
  18. /// Логика взаимодействия для AddEditPage.xaml
  19. /// </summary>
  20. public partial class AddEditPage : Page
  21. {
  22. private Hotel _correntHotel = new Hotel();
  23. public AddEditPage()
  24. {
  25. InitializeComponent();
  26. DataContext = _correntHotel;
  27. StringBuilder errors = new StringBuilder();
  28. if (string.IsNullOrWhiteSpace(_correntHotel.name))
  29. errors.AppendLine("укажите название отеля");
  30. if (_correntHotel.countOfStars < 1 || _correntHotel.countOfStars > 5)
  31. errors.AppendLine("колличество звезд - число от 1 до 5");
  32. if (_correntHotel.Country == null)
  33. errors.AppendLine("выберите строку");
  34. if (errors.Length > 0)
  35. {
  36. MessageBox.Show(errors.ToString());
  37. return;
  38. }
  39. if (_correntHotel.id == 0) ;
  40. try
  41. {
  42. MessageBox.Show("Информация сохранена");
  43. }
  44. catch (Exception ex)
  45. {
  46. MessageBox.Show(ex.Message);
  47. }
  48. }
  49. private static void page_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
  50. {
  51. {
  52. }
  53. }
  54. }
  55. }