SiteManufacturingSetouts.xaml.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 SiteManufacturingSetouts : ContentView
  15. {
  16. private String _currentFilter;
  17. public SetoutModel Setouts { get; set; }
  18. public ManufacturingPacketModel Packets { get; set; }
  19. public SetoutDocumentModel Documents { get; set; }
  20. public Guid JobID { get; set; }
  21. public SiteManufacturingSetouts()
  22. {
  23. InitializeComponent();
  24. }
  25. public event EventHandler RefreshRequested;
  26. public void Refresh()
  27. {
  28. Setouts.Search(FilterShell);
  29. _items.ItemsSource ??= Setouts.Items;
  30. }
  31. private void _search_OnTextChanged(object sender, MobileSearchBarTextChangedArgs args)
  32. {
  33. _currentFilter = args.Text.ToUpper();
  34. Refresh();
  35. }
  36. private bool FilterShell(SetoutShell shell)
  37. {
  38. var bOK =
  39. String.IsNullOrWhiteSpace(_currentFilter)
  40. || shell.Number?.ToUpper().Contains(_currentFilter) == true
  41. || shell.Description?.ToUpper().Contains(_currentFilter) == true
  42. || shell.JobNumber?.ToUpper().Contains(_currentFilter) == true
  43. || shell.JobName?.ToUpper().Contains(_currentFilter) == true;
  44. return bOK;
  45. }
  46. private void ListView_Tapped(object sender, EventArgs e)
  47. {
  48. if ((sender as Frame)?.BindingContext is SetoutShell shell)
  49. {
  50. Documents.Search((doc) => doc.Entity.EntityLink.ID == shell.ID);
  51. var editor = new SiteManufacturingSetout(
  52. shell,
  53. Packets.Items.Where(x=>x.SetoutID == shell.ID).ToArray(),
  54. Documents
  55. );
  56. Navigation.PushAsync(editor);
  57. }
  58. }
  59. private void _items_OnRefreshRequested(object sender, MobileListRefreshEventArgs args)
  60. {
  61. RefreshRequested?.Invoke(this, EventArgs.Empty);
  62. }
  63. }
  64. }