EquipmentModule.xaml.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using System.Linq;
  3. using System.Threading.Tasks;
  4. using Comal.Classes;
  5. using InABox.Core;
  6. using Xamarin.Forms;
  7. using Xamarin.Forms.Xaml;
  8. using XF.Material.Forms.UI.Dialogs;
  9. namespace comal.timesheets
  10. {
  11. [XamlCompilation(XamlCompilationOptions.Compile)]
  12. public partial class EquipmentModule
  13. {
  14. public EquipmentModule ()
  15. {
  16. InitializeComponent ();
  17. }
  18. protected override void UpdateTransportStatus()
  19. {
  20. base.UpdateTransportStatus();
  21. LiveMaps.IsEnabled = App.Data.IsConnected();
  22. }
  23. private async void EquipmentScanner_Tapped(ModuleMenuItem sender, ModuleMenuItemTappedArgs args)
  24. {
  25. var scannerPage = new ScannerPage();
  26. scannerPage.ItemScanned = async (e) =>
  27. {
  28. if (!Guid.TryParse(e.Text, out Guid equipmentid))
  29. {
  30. await MaterialDialog.Instance.AlertAsync("Invalid Code", "Error");
  31. return;
  32. }
  33. var model = new EquipmentDetailModel(App.Data,
  34. () => new Filter<Equipment>(x => x.ID).IsEqualTo(equipmentid));
  35. using (await MaterialDialog.Instance.LoadingDialogAsync(message: "Checking Code"))
  36. model.Load();
  37. if (model.Item != null)
  38. Device.BeginInvokeOnMainThread(() => Navigation.PushAsync(new EquipmentDetailsPage(model)));
  39. else
  40. await MaterialDialog.Instance.AlertAsync("Code Not Found", "Error");
  41. };
  42. Navigation.PushAsync(scannerPage);
  43. }
  44. private void EquipmentList_Tapped(ModuleMenuItem sender, ModuleMenuItemTappedArgs args)
  45. {
  46. Navigation.PushAsync(new EquipmentList());
  47. }
  48. private void LiveMaps_Tapped(ModuleMenuItem sender, ModuleMenuItemTappedArgs args)
  49. {
  50. Navigation.PushAsync(new LiveMapsTwo());
  51. }
  52. }
  53. }