ManufacturingPacketEditDetailsView.xaml.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using Comal.Classes;
  6. using InABox.Clients;
  7. using InABox.Core;
  8. using InABox.Mobile;
  9. using Xamarin.Forms;
  10. using Xamarin.Forms.Xaml;
  11. namespace PRS.Mobile
  12. {
  13. [XamlCompilation(XamlCompilationOptions.Compile)]
  14. public partial class ManufacturingPacketEditDetailsView
  15. {
  16. public ManufacturingPacketEditDetailsView()
  17. {
  18. InitializeComponent();
  19. }
  20. public override void Refresh()
  21. {
  22. LoadIssues();
  23. LoadStages();
  24. LoadOrders();
  25. }
  26. private void LoadOrders()
  27. {
  28. var poitem = ViewModel.OrderItems.FirstOrDefault();
  29. ETAFrame.IsVisible = poitem != null;
  30. if (poitem != null)
  31. {
  32. if (!poitem.ReceivedDate.IsEmpty())
  33. ETALbl.Text = $"Item received from {poitem.SupplierName} on {poitem.ReceivedDate:dd MMM yy}";
  34. else if (!poitem.EstimatedWarehouseArrival.IsEmpty())
  35. ETALbl.Text =
  36. $"Item on order from {poitem.SupplierName} (ETA: {poitem.EstimatedWarehouseArrival:dd MMM yy})";
  37. else
  38. ETALbl.Text = $"Item on order from {poitem.SupplierName} (unknown ETA)";
  39. }
  40. }
  41. private void LoadStages()
  42. {
  43. _stages.Columns
  44. .BeginUpdate()
  45. .Clear()
  46. .Add(new MobileGridTextColumn<ManufacturingPacketStageShell>()
  47. {
  48. Column = x => x.ManufacturingSectionLinkName, Width = GridLength.Star, Caption = "Section Name"
  49. })
  50. .Add(new MobileGridDateColumn<ManufacturingPacketStageShell>()
  51. { Column = x => x.Started, Width = GridLength.Auto })
  52. .Add(new MobileGridDateColumn<ManufacturingPacketStageShell>()
  53. { Column = x => x.Completed, Width = GridLength.Auto })
  54. .Add(new MobileGridDoubleColumn<ManufacturingPacketStageShell>()
  55. { Column = x => x.PercentageComplete, Width = GridLength.Auto, Caption = "%" })
  56. .EndUpdate();
  57. _stages.ItemsSource = ViewModel.Stages.Items;
  58. }
  59. private void LoadIssues()
  60. {
  61. IssuesFrame.IsVisible = !String.IsNullOrWhiteSpace(ViewModel.Item.Issues);
  62. IssuesLbl.Text = ViewModel.Item.Issues;
  63. IssuesTitle.IsVisible = IssuesFrame.IsVisible;
  64. }
  65. }
  66. }