TransportEditWindow.xaml.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. using System.Linq;
  2. using System.Windows;
  3. namespace Kusach.Windows
  4. {
  5. /// <summary>
  6. /// Логика взаимодействия для TransportEditWindow.xaml
  7. /// </summary>
  8. public partial class TransportEditWindow : Window
  9. {
  10. int transportId;
  11. public TransportEditWindow(int id)
  12. {
  13. InitializeComponent();
  14. transportId = id;
  15. NameOfTransportBox.Text = Functions.GetNameOfTransport(transportId);
  16. NumberPlateBox.Text = Functions.GetNumberPlate(transportId);
  17. }
  18. private void BackButton_Click(object sender, RoutedEventArgs e)
  19. {
  20. this.Close();
  21. }
  22. private void SaveTransportButton_Click(object sender, RoutedEventArgs e)
  23. {
  24. Transport transport = cnt.db.Transport.Where(item => item.IdTransport == transportId).FirstOrDefault();
  25. transport.NameOfTransport = NameOfTransportBox.Text;
  26. transport.NumberPlate = NumberPlateBox.Text;
  27. cnt.db.SaveChanges();
  28. this.Close();
  29. }
  30. }
  31. }