using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace SneakersSkakunov { /// /// Логика взаимодействия для Sneaker.xaml /// public partial class Sneaker : Page { private void Revert(object sender, RoutedEventArgs e) { MainFrame.mframe.Navigate(new AdminPage()); } private void Addendum(object sender, RoutedEventArgs e) { MainFrame.mframe.Navigate(new Add()); } public Sneaker() { InitializeComponent(); Sniker DB = new Sniker(); SneakerList.ItemsSource = DB.Sneakers.ToList(); } public void brands(object sender, RoutedEventArgs e) { TextBlock brand = (TextBlock)sender; int index = Convert.ToInt32(brand.Uid); Sniker DB = new Sniker(); string a = DB.Brand.Where(x => x.id_Brand == index).Select(x => x.Label).First(); brand.Text = "Брэнд: " + a; } public void models(object sender, RoutedEventArgs e) { TextBlock model = (TextBlock)sender; int index = Convert.ToInt32(model.Uid); Sniker DB = new Sniker(); string b = DB.Sneakers.Where(x => x.id_Sneakers == index).Select(x => x.Model + " ").First(); model.Text = "Модель: " + b; } public void Colors(object sender, RoutedEventArgs e) { TextBlock color = (TextBlock)sender; int index = Convert.ToInt32(color.Uid); Sniker DB = new Sniker(); string c = DB.Sneakers.Where(x => x.id_Sneakers == index).Select(x => x.Colors + " ").First(); color.Text = "Цвет: " + c; } public void prices(object sender, RoutedEventArgs e) { TextBlock price = (TextBlock)sender; int index = Convert.ToInt32(price.Uid); Sniker DB = new Sniker(); string d = DB.Sneakers.Where(x => x.id_Sneakers == index).Select(x => x.Price + " ").First().ToString(); price.Text = "Цена: " + d + "р."; } public void Date(object sender, RoutedEventArgs e) { TextBlock data = (TextBlock)sender; int index = Convert.ToInt32(data.Uid); Sniker DB = new Sniker(); string d = DB.Cheque.Where(x => x.id_Cheque == index).Select(x => x.Date_of_formation + " ").First().ToString(); data.Text = "Дата: " + d; } private void Delete(object sender, RoutedEventArgs e) { Button tb = (Button)sender; int index = Convert.ToInt32(tb.Uid); Sniker DB = new Sniker(); Sneakers SneakerRemove = DB.Sneakers.FirstOrDefault(x => x.id_Sneakers == index); switch (MessageBox.Show("Удалить полис???", "SneakerInsurance", MessageBoxButton.YesNo, MessageBoxImage.Question)) { case MessageBoxResult.Yes: DB.Sneakers.Remove(SneakerRemove); MessageBox.Show("Полис удален"); DB.SaveChanges(); ClassS.Mfrm.Navigate(new Sneaker()); break; case MessageBoxResult.No: MessageBox.Show("Полис не удален"); break; } } } }