DeliveryModule.xaml.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using Comal.Classes;
  6. using InABox.Configuration;
  7. using InABox.Core;
  8. using InABox.Mobile;
  9. using Syncfusion.OfficeChart.Implementation;
  10. using Xamarin.Forms;
  11. using Xamarin.Forms.Xaml;
  12. using XF.Material.Forms;
  13. using XF.Material.Forms.UI;
  14. using XF.Material.Forms.UI.Dialogs;
  15. namespace PRS.Mobile
  16. {
  17. [XamlCompilation(XamlCompilationOptions.Compile)]
  18. public partial class DeliveryModule
  19. {
  20. private DeliveryItemBarcodeModel _deliveryitems;
  21. private Task _cache;
  22. public DeliveryModule()
  23. {
  24. InitializeComponent();
  25. _deliveryitems = new DeliveryItemBarcodeModel(App.Data, null);
  26. _cache = Task.Run(() => _deliveryitems.Refresh(false));
  27. }
  28. private void DeliveryScanner_OnTapped(MobileModuleItem sender, ModuleMenuItemTappedArgs args)
  29. {
  30. var scannerPage = new ScannerPage();
  31. scannerPage.ItemScanned = async (e) =>
  32. {
  33. Device.BeginInvokeOnMainThread(() =>
  34. {
  35. ProgressVisible = true;
  36. _cache.Wait();
  37. var barcode = _deliveryitems.FirstOrDefault(x => String.Equals(x.Barcode, e.Text));
  38. if (barcode != null)
  39. Navigation.PushAsync(new FrameDetailsPage(barcode.ID));
  40. else
  41. DisplayAlert("ERROR", "Barcode not found!", "OK");
  42. ProgressVisible = false;
  43. });
  44. };
  45. Navigation.PushAsync(scannerPage);
  46. }
  47. private void DeliveryList_OnTapped(MobileModuleItem sender, ModuleMenuItemTappedArgs args)
  48. {
  49. Navigation.PushAsync(new DeliveryList());
  50. }
  51. }
  52. }