PgChange.xaml.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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.Shapes;
  14. namespace ProbnikDemo
  15. {
  16. /// <summary>
  17. /// Логика взаимодействия для PgChange.xaml
  18. /// </summary>
  19. public partial class PgChange : Window
  20. {
  21. Agent agent1 = new Agent();
  22. public PgChange(Agent agent)
  23. {
  24. InitializeComponent();
  25. agent1 = agent;
  26. ComboType.ItemsSource = BaseConnect.BaseModel.AgentType.Where(x => x.ID > 0).ToList();
  27. ComboType.SelectedValuePath = "ID";
  28. ComboType.DisplayMemberPath = "Title";
  29. DataContext = agent;
  30. }
  31. private void BtnDel_Click(object sender, RoutedEventArgs e)
  32. {
  33. try
  34. {
  35. BaseConnect.BaseModel.Agent.Remove(agent1);
  36. BaseConnect.BaseModel.SaveChanges();
  37. LoadPages.SwitchPages.Navigate(new PgListAgent());
  38. }
  39. catch
  40. {
  41. MessageBox.Show("Ошибка");
  42. }
  43. }
  44. private void BtnImg_Click(object sender, RoutedEventArgs e)
  45. {
  46. }
  47. }
  48. }