AddingEditingService.xaml.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using LearnPodg.DataBase;
  2. using System.Linq;
  3. using System.Windows;
  4. using System.Windows.Controls;
  5. using System.Windows.Media.Imaging;
  6. namespace LearnPodg
  7. {
  8. /// <summary>
  9. /// Логика взаимодействия для AddingEditingService.xaml
  10. /// </summary>
  11. public partial class AddingEditingService : UserControl
  12. {
  13. public AddingEditingService()
  14. {
  15. InitializeComponent();
  16. UCLabel.Text = "Добавление сервиса";
  17. GBID.Visibility = Visibility.Collapsed;
  18. }
  19. public AddingEditingService(int serviceID)
  20. {
  21. InitializeComponent();
  22. UCLabel.Text = "Редактирование сервиса";
  23. GBID.Visibility = Visibility.Visible;
  24. Service service;
  25. using (Entities db = new Entities()) service = db.Service.Where(a => a.ID == serviceID).First();
  26. TBTitle.Text = service.Title;
  27. TBDiscription.Text = service.Description;
  28. TBCost.Text = service.Cost.ToString();
  29. TBDiscount.Text = service.Discount.ToString();
  30. TBDurationInSecond.Text = service.DurationInSeconds.ToString();
  31. TBID.Text = service.ID.ToString();
  32. BitmapImage bitmapImage = new BitmapImage();
  33. bitmapImage.BeginInit();
  34. bitmapImage.UriSource = new System.Uri(service.Image.Trim(), System.UriKind.RelativeOrAbsolute);
  35. bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
  36. bitmapImage.EndInit();
  37. ServiceImage.Source = bitmapImage;
  38. }
  39. private void Button_Click(object sender, RoutedEventArgs e)
  40. {
  41. MainWindow.contentControl.Content = new ServicesList();
  42. }
  43. }
  44. }