12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- 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 Khaustov_ProbniyDE
- {
- /// <summary>
- /// Логика взаимодействия для Услуги.xaml
- /// </summary>
- public partial class Услуги : Page
- {
- public Услуги()
- {
- InitializeComponent();
- DGridУслуги.ItemsSource = Хаустов_ПробныйДЭEntities.GetContext().Service.ToList();
- }
- private void BtnEdit_Click(object sender, RoutedEventArgs e)
- {
- Switcher.MainFrame.Navigate(new AddEditPage((sender as Button).DataContext as Service));
- }
- private void BtnAdd_Click(object sender, RoutedEventArgs e)
- {
- Switcher.MainFrame.Navigate(new AddEditPage(null));
- }
- private void BtnDelete_Click(object sender, RoutedEventArgs e)
- {
- var ServiceForRemoving = DGridУслуги.SelectedItems.Cast<Service>().ToList();
- if (MessageBox.Show($"Вы точно хотите удалить следующие {ServiceForRemoving.Count()} элементов?", "Внимание", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
- {
- try
- {
- Хаустов_ПробныйДЭEntities.GetContext().Service.RemoveRange(ServiceForRemoving);
- Хаустов_ПробныйДЭEntities.GetContext().SaveChanges();
- MessageBox.Show("Данные удалены");
- DGridУслуги.ItemsSource = Хаустов_ПробныйДЭEntities.GetContext().Service.ToList();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message.ToString());
- }
- }
- }
- }
- }
|