StoreRequiList.xaml.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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.Clients;
  8. using InABox.Core;
  9. using Xamarin.Forms;
  10. using Xamarin.Forms.Xaml;
  11. using ZXing.PDF417.Internal;
  12. using static comal.timesheets.RequiItems;
  13. namespace comal.timesheets.StoreRequis
  14. {
  15. [XamlCompilation(XamlCompilationOptions.Compile)]
  16. public partial class StoreRequiList : ContentPage
  17. {
  18. List<RequiShell> requiShells = new List<RequiShell>();
  19. public StoreRequiList()
  20. {
  21. InitializeComponent();
  22. //LoadHoldingsCache();
  23. HoldingsLoaded = true;
  24. if (Device.RuntimePlatform.Equals(Device.iOS))
  25. {
  26. imageBtn0.Margin = new Thickness(0);
  27. imageBtn0.VerticalOptions = LayoutOptions.FillAndExpand;
  28. imageBtn0.HeightRequest = 160;
  29. takerequinow.Margin = new Thickness(0);
  30. takerequinow.VerticalOptions = LayoutOptions.FillAndExpand;
  31. takerequinow.HeightRequest = 160;
  32. storereqimg.Margin = new Thickness(0);
  33. storereqimg.HeightRequest = 120;
  34. }
  35. }
  36. protected override void OnAppearing()
  37. {
  38. LoadList();
  39. base.OnAppearing();
  40. }
  41. private async void LoadList()
  42. {
  43. await Task.Run(() =>
  44. {
  45. requiShells.Clear();
  46. CoreTable table = new Client<Requisition>().Query(
  47. new Filter<Requisition>(x => x.Filled).IsEqualTo(DateTime.MinValue),
  48. new Columns<Requisition>(
  49. x => x.ID, //0
  50. x => x.Number, //1
  51. x => x.Due, //2
  52. x => x.RequestedBy.Name, //3
  53. x => x.JobLink.JobNumber, //4
  54. x => x.JobLink.Name, //5
  55. x => x.Request //6
  56. ),
  57. new SortOrder<Requisition>(x => x.Due)
  58. );
  59. foreach (var row in table.Rows)
  60. {
  61. List<object> list = row.Values;
  62. if (list[0] == null) { list[0] = Guid.Empty; } //0
  63. if (list[1] == null) { list[1] = 0; } //1
  64. if (list[2] == null) { list[2] = DateTime.MinValue; } //2
  65. if (list[3] == null) { list[3] = ""; } //3
  66. if (list[4] == null) { list[4] = ""; } //4
  67. if (list[5] == null) { list[5] = ""; } //5
  68. if (list[6] == null) { list[6] = ""; } //6
  69. RequiShell requiShell = new RequiShell();
  70. requiShell.ID = Guid.Parse(list[0].ToString());
  71. requiShell.Number = "No. " + list[1].ToString();
  72. requiShell.Due = "Due " + DateTime.Parse(list[2].ToString()).ToString("dd MMM yy");
  73. requiShell.Contact = "Contact: " + list[3].ToString();
  74. requiShell.Job = "(" + list[4].ToString() + ") " + list[5].ToString();
  75. requiShell.Request = list[6].ToString();
  76. requiShells.Add(requiShell);
  77. }
  78. Device.BeginInvokeOnMainThread(() =>
  79. {
  80. requisListView.ItemsSource = null;
  81. requisListView.ItemsSource = requiShells;
  82. listLbl.Text = "List of Unfilled Requis (" + requiShells.Count + ")";
  83. });
  84. });
  85. }
  86. private void Requi_Clicked(object sender, EventArgs e)
  87. {
  88. RequiShell requiShell = requisListView.SelectedItem as RequiShell;
  89. StoreRequiScannerPage storeRequiScannerPage = new StoreRequiScannerPage(requiShell.ID);
  90. Navigation.PushAsync(storeRequiScannerPage);
  91. }
  92. private void TakeStockNow_Tapped(object sender, EventArgs e)
  93. {
  94. StoreRequiScannerPage page = new StoreRequiScannerPage(Guid.Empty);
  95. Navigation.PushAsync(page);
  96. }
  97. private void NewRequiRequest_Tapped(object sender, EventArgs e)
  98. {
  99. StoreRequiConfirmationPage storeRequiConfirmationPage = new StoreRequiConfirmationPage();
  100. Navigation.PushAsync(storeRequiConfirmationPage);
  101. }
  102. }
  103. public class RequiShell
  104. {
  105. public Guid ID { get; set; }
  106. public string Number { get; set; }
  107. public string Due { get; set; }
  108. public string Contact { get; set; }
  109. public string Job { get; set; }
  110. public string Request { get; set; }
  111. public RequiShell()
  112. {
  113. ID = Guid.Empty;
  114. Number = "";
  115. Due = "";
  116. Due = "";
  117. Job = "";
  118. Request = "";
  119. }
  120. }
  121. }