Sneaker.xaml.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 SneakersSkakunov
  16. {
  17. /// <summary>
  18. /// Логика взаимодействия для Sneaker.xaml
  19. /// </summary>
  20. public partial class Sneaker : Page
  21. {
  22. private void Revert(object sender, RoutedEventArgs e)
  23. {
  24. MainFrame.mframe.Navigate(new AdminPage());
  25. }
  26. private void Addendum(object sender, RoutedEventArgs e)
  27. {
  28. MainFrame.mframe.Navigate(new Add());
  29. }
  30. public Sneaker()
  31. {
  32. InitializeComponent();
  33. Sniker DB = new Sniker();
  34. SneakerList.ItemsSource = DB.Sneakers.ToList();
  35. }
  36. public void brands(object sender, RoutedEventArgs e)
  37. {
  38. TextBlock brand = (TextBlock)sender;
  39. int index = Convert.ToInt32(brand.Uid);
  40. Sniker DB = new Sniker();
  41. string a = DB.Brand.Where(x => x.id_Brand == index).Select(x => x.Label).First();
  42. brand.Text = "Брэнд: " + a;
  43. }
  44. public void models(object sender, RoutedEventArgs e)
  45. {
  46. TextBlock model = (TextBlock)sender;
  47. int index = Convert.ToInt32(model.Uid);
  48. Sniker DB = new Sniker();
  49. string b = DB.Sneakers.Where(x => x.id_Sneakers == index).Select(x => x.Model + " ").First();
  50. model.Text = "Модель: " + b;
  51. }
  52. public void Colors(object sender, RoutedEventArgs e)
  53. {
  54. TextBlock color = (TextBlock)sender;
  55. int index = Convert.ToInt32(color.Uid);
  56. Sniker DB = new Sniker();
  57. string c = DB.Sneakers.Where(x => x.id_Sneakers == index).Select(x => x.Colors + " ").First();
  58. color.Text = "Цвет: " + c;
  59. }
  60. public void prices(object sender, RoutedEventArgs e)
  61. {
  62. TextBlock price = (TextBlock)sender;
  63. int index = Convert.ToInt32(price.Uid);
  64. Sniker DB = new Sniker();
  65. string d = DB.Sneakers.Where(x => x.id_Sneakers == index).Select(x => x.Price + " ").First().ToString();
  66. price.Text = "Цена: " + d + "р.";
  67. }
  68. public void Date(object sender, RoutedEventArgs e)
  69. {
  70. TextBlock data = (TextBlock)sender;
  71. int index = Convert.ToInt32(data.Uid);
  72. Sniker DB = new Sniker();
  73. string d = DB.Cheque.Where(x => x.id_Cheque == index).Select(x => x.Date_of_formation + " ").First().ToString();
  74. data.Text = "Дата: " + d;
  75. }
  76. private void Delete(object sender, RoutedEventArgs e)
  77. {
  78. Button tb = (Button)sender;
  79. int index = Convert.ToInt32(tb.Uid);
  80. Sniker DB = new Sniker();
  81. Sneakers SneakerRemove = DB.Sneakers.FirstOrDefault(x => x.id_Sneakers == index);
  82. switch (MessageBox.Show("Удалить полис???", "SneakerInsurance", MessageBoxButton.YesNo, MessageBoxImage.Question))
  83. {
  84. case MessageBoxResult.Yes:
  85. DB.Sneakers.Remove(SneakerRemove);
  86. MessageBox.Show("Полис удален");
  87. DB.SaveChanges();
  88. ClassS.Mfrm.Navigate(new Sneaker());
  89. break;
  90. case MessageBoxResult.No:
  91. MessageBox.Show("Полис не удален");
  92. break;
  93. }
  94. }
  95. }
  96. }