ConsignmentEditItemsView.xaml.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Comal.Classes;
  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 ConsignmentEditItemsView
  15. {
  16. public ConsignmentEditItemsView()
  17. {
  18. InitializeComponent();
  19. }
  20. public override void Refresh()
  21. {
  22. //throw new NotImplementedException();
  23. }
  24. private void _search_OnTextChanged(object sender, MobileSearchBarTextChangedArgs args)
  25. {
  26. //throw new NotImplementedException();
  27. //Refresh();
  28. }
  29. public void AddPOItems()
  30. {
  31. ShowPopup(() => SelectionView.Execute<PurchaseOrderShell>(
  32. (columns) =>
  33. {
  34. columns.Add(new MobileGridTextColumn<PurchaseOrderShell>()
  35. {
  36. Column = x => x.PONumber,
  37. Width = GridLength.Auto,
  38. Caption = "Number",
  39. Alignment = TextAlignment.Start
  40. });
  41. columns.Add(new MobileGridTextColumn<PurchaseOrderShell>()
  42. {
  43. Column = x => x.SupplierName,
  44. Width = GridLength.Star,
  45. Caption = "Select Purchase Order",
  46. Alignment = TextAlignment.Start
  47. });
  48. },
  49. (refresh) =>
  50. {
  51. var model = new PurchaseOrderModel(App.Data,
  52. () => new Filter<PurchaseOrder>(x => x.IssuedDate).IsNotEqualTo(DateTime.MinValue)
  53. .And(x=>x.ClosedDate).IsEqualTo(DateTime.MinValue)
  54. .And(x=>x.CancelledDate).IsEqualTo(DateTime.MinValue)
  55. .And(x=>x.Unreceived).IsNotEqualTo(FilterConstant.Null)) { FileName = "consigment_orders.index" };
  56. return model.Refresh(false);
  57. },
  58. (orders) =>
  59. {
  60. var model = new PurchaseOrderItemModel(App.Data,
  61. () => new Filter<PurchaseOrderItem>(x => x.PurchaseOrderLink.ID).IsEqualTo(orders.FirstOrDefault()?.ID ?? Guid.Empty));
  62. model.Refresh(false);
  63. foreach (var item in model.Items)
  64. {
  65. var newitem = ViewModel.Items.AddItem();
  66. newitem.Row.LoadValues(item.Row.Values);
  67. }
  68. Dispatcher.BeginInvokeOnMainThread(() =>
  69. {
  70. _itemsList.ItemsSource = null;
  71. _itemsList.ItemsSource = ViewModel.Items;
  72. });
  73. DismissPopup();
  74. }));
  75. }
  76. private void SelectPOItem_Clicked(object sender, EventArgs e)
  77. {
  78. if ((sender as MobileCard)?.BindingContext is PurchaseOrderItemShell item)
  79. {
  80. var page = new ConsignmentEditItem(item);
  81. Navigation.PushAsync(page);
  82. }
  83. }
  84. }
  85. }