ConsignmentEditDetailsView.xaml.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using InABox.Mobile;
  7. using Xamarin.Forms;
  8. using Xamarin.Forms.Xaml;
  9. namespace PRS.Mobile
  10. {
  11. [XamlCompilation(XamlCompilationOptions.Compile)]
  12. public partial class ConsignmentEditDetailsView
  13. {
  14. public ConsignmentEditDetailsView()
  15. {
  16. InitializeComponent();
  17. }
  18. public override void Refresh()
  19. {
  20. }
  21. private void SelectSupplier_Clicked(object sender, MobileButtonClickEventArgs args)
  22. {
  23. ShowPopup(() => SelectionView.Execute<SupplierShell>(
  24. (columns) =>
  25. {
  26. columns.Add(new MobileGridTextColumn<SupplierShell>()
  27. {
  28. Column = x => x.Name,
  29. Width = GridLength.Star,
  30. Caption = "Select Supplier",
  31. Alignment = TextAlignment.Start
  32. });
  33. },
  34. (refresh) => App.Data.Suppliers.Refresh(false),
  35. (suppliers) =>
  36. {
  37. ViewModel.Item.SupplierID = suppliers.FirstOrDefault()?.ID ?? Guid.Empty;
  38. ViewModel.Item.SupplierName = suppliers.FirstOrDefault()?.Name ?? string.Empty;
  39. DoChanged(nameof(ViewModel.Item), nameof(ConsignmentShell.SupplierName));
  40. DismissPopup();
  41. }));
  42. }
  43. private void SelectType_Clicked(object sender, MobileButtonClickEventArgs args)
  44. {
  45. ShowPopup(() => SelectionView.Execute<ConsignmentTypeShell>(
  46. (columns) =>
  47. {
  48. columns.Add(new MobileGridTextColumn<ConsignmentTypeShell>()
  49. {
  50. Column = x => x.Description,
  51. Width = GridLength.Star,
  52. Caption = "Select Type",
  53. Alignment = TextAlignment.Start
  54. });
  55. },
  56. (refresh) => App.Data.ConsignmentTypes.Refresh(false),
  57. (types) =>
  58. {
  59. ViewModel.Item.TypeID = types.FirstOrDefault()?.ID ?? Guid.Empty;
  60. ViewModel.Item.TypeDescription = types.FirstOrDefault()?.Description ?? string.Empty;
  61. DoChanged(nameof(ViewModel.Item), nameof(ConsignmentShell.TypeDescription));
  62. DismissPopup();
  63. }));
  64. }
  65. private void SelectETA_Clicked(object sender, MobileButtonClickEventArgs args)
  66. {
  67. ShowPopup(
  68. () =>
  69. {
  70. var selector = new MobileDateSelector();
  71. selector.Date = ViewModel.Item.EstimatedWarehouseArrival;
  72. selector.Changed += (o, changedArgs) =>
  73. {
  74. ViewModel.Item.EstimatedWarehouseArrival = changedArgs.Date;
  75. DismissPopup();
  76. };
  77. selector.Cancelled += (o, eventArgs) => DismissPopup();
  78. return selector;
  79. },
  80. new PopupManagerConfiguration()
  81. {
  82. Modal = true
  83. }
  84. );
  85. }
  86. private void Number_Changed(object sender, TextChangedEventArgs e)
  87. {
  88. DoChanged(nameof(ViewModel.Item), nameof(ConsignmentShell.Number));
  89. }
  90. private void Description_Changed(object sender, TextChangedEventArgs e)
  91. {
  92. DoChanged(nameof(ViewModel.Item), nameof(ConsignmentShell.Description));
  93. }
  94. private void SelectATA_Clicked(object sender, MobileButtonClickEventArgs args)
  95. {
  96. ShowPopup(
  97. () =>
  98. {
  99. var selector = new MobileDateSelector();
  100. selector.Date = ViewModel.Item.ActualWarehouseArrival;
  101. selector.Changed += (o, changedArgs) =>
  102. {
  103. ViewModel.Item.ActualWarehouseArrival = changedArgs.Date;
  104. DismissPopup();
  105. };
  106. selector.Cancelled += (o, eventArgs) => DismissPopup();
  107. return selector;
  108. },
  109. new PopupManagerConfiguration()
  110. {
  111. Modal = true
  112. }
  113. );
  114. }
  115. }
  116. }