EditShipment.xaml.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.Linq;
  3. using System.Windows;
  4. using Comal.Classes;
  5. using InABox.Clients;
  6. using InABox.Core;
  7. using InABox.Wpf;
  8. namespace PRSDesktop.Shipping
  9. {
  10. /// <summary>
  11. /// Interaction logic for EditShipment.xaml
  12. /// </summary>
  13. public partial class EditShipment : ThemableWindow
  14. {
  15. private readonly Shipment Shipment;
  16. public EditShipment(Shipment shipment)
  17. {
  18. InitializeComponent();
  19. Shipment = shipment;
  20. Code.Text = string.IsNullOrWhiteSpace(Shipment.Code) ? "" : Shipment.Code;
  21. Description.Text = string.IsNullOrWhiteSpace(Shipment.Description) ? "" : Shipment.Description;
  22. RackType.Text = string.IsNullOrWhiteSpace(Shipment.Type) ? "" : Shipment.Type;
  23. var trackers = new Client<GPSTracker>().Load(null, new SortOrder<GPSTracker>(x => x.Description));
  24. Tracker.ItemsSource = trackers.Select(x => new { x.ID, Name = string.Format("{0} ({1})", x.Description, x.DeviceID) }).ToList();
  25. Tracker.DisplayMemberPath = "Name";
  26. Tracker.SelectedValuePath = "ID";
  27. Tracker.SelectedValue = Shipment.TrackerLink.ID;
  28. Barcode.Text = Shipment.BarCode;
  29. }
  30. private void OKButton_Click(object sender, RoutedEventArgs e)
  31. {
  32. Shipment.Code = Code.Text;
  33. Shipment.Description = Description.Text;
  34. Shipment.Type = RackType.Text;
  35. Shipment.TrackerLink.ID = Tracker.SelectedValue != null ? (Guid)Tracker.SelectedValue : Guid.Empty;
  36. DialogResult = true;
  37. Close();
  38. }
  39. private void CancelButton_Click(object sender, RoutedEventArgs e)
  40. {
  41. DialogResult = false;
  42. Close();
  43. }
  44. }
  45. }