ChangeData.xaml.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. using BuzuevaDemo.Classes;
  16. namespace BuzuevaDemo.Pages
  17. {
  18. /// <summary>
  19. /// Логика взаимодействия для ChangeData.xaml
  20. /// </summary>
  21. public partial class ChangeData : Page
  22. {
  23. public int ind, id = 0;
  24. string newimg;
  25. ViewModel view = new ViewModel();
  26. public Agent agent;
  27. public string[] type = new string[6];
  28. public Agent buffer;
  29. public ChangeData(Agent idagent)
  30. {
  31. InitializeComponent();
  32. DataContext = idagent;
  33. agent = idagent;
  34. buffer = idagent;
  35. DataContext = buffer;
  36. typeag.ItemsSource = DataBase.BaseModel.AgentType.Where(x => x.ID > 0).ToList();
  37. typeag.SelectedValue = "ID";
  38. typeag.DisplayMemberPath = "Title";
  39. typeag.SelectedIndex = (int)buffer.AgentTypeID - 1;
  40. }
  41. private void Perezapis(object sender, RoutedEventArgs e)
  42. {
  43. try
  44. {
  45. agent.Title = Title.Text;
  46. agent.TitleType = typeag.Text;
  47. agent.Priority = Convert.ToInt32(Priority.Text);
  48. agent.Address = Address.Text;
  49. agent.INN = INN.Text;
  50. agent.KPP = KPP.Text;
  51. agent.Logo = newimg;
  52. agent.DirectorName = DirectorName.Text;
  53. agent.Phone = Phone.Text;
  54. agent.Email = Email.Text;
  55. DataBase.BaseModel.SaveChanges();
  56. view.agent = view.ListAgent();
  57. MessageBox.Show("Данные успешно обновлены");
  58. }
  59. catch
  60. {
  61. MessageBox.Show("Произошла ошибка слхранения", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
  62. }
  63. }
  64. private void NewImage(object sender, RoutedEventArgs e)
  65. {
  66. }
  67. }
  68. }