JobEmployeePanel.xaml.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Windows.Controls;
  5. using Comal.Classes;
  6. using System.ComponentModel;
  7. using InABox.Core;
  8. using InABox.Wpf;
  9. namespace PRSDesktop
  10. {
  11. /// <summary>
  12. /// Interaction logic for JobEmployeePanel.xaml
  13. /// </summary>
  14. public partial class JobEmployeePanel : UserControl, IPanel<JobEmployee>, IMasterDetailControl<Job>
  15. {
  16. public JobEmployeePanel()
  17. {
  18. InitializeComponent();
  19. Employees.OnChanged += (o,e) => Qualifications.Refresh(false, true);
  20. }
  21. public Job? Master
  22. {
  23. get => Employees.Master;
  24. set
  25. {
  26. Employees.Master = value;
  27. Qualifications.Master = value;
  28. }
  29. }
  30. public bool IsReady { get; set; }
  31. public event DataModelUpdateEvent? OnUpdateDataModel;
  32. public void CreateToolbarButtons(IPanelHost host)
  33. {
  34. }
  35. public string SectionName => "Job Employees";
  36. public DataModel DataModel(Selection selection)
  37. {
  38. var ids = Employees.ExtractValues(x => x.ID, selection).ToArray();
  39. return new JobEmployeeDataModel(new Filter<JobEmployee>(x => x.ID).InList(ids));
  40. }
  41. public void Heartbeat(TimeSpan time)
  42. {
  43. }
  44. public void Refresh()
  45. {
  46. Qualifications.Refresh(false, true);
  47. Employees.Refresh(false, true);
  48. }
  49. public Dictionary<string, object[]> Selected()
  50. {
  51. return new Dictionary<string, object[]>
  52. { { typeof(JobEmployee).EntityName(), Employees.SelectedRows } };
  53. }
  54. public void Setup()
  55. {
  56. Employees.Refresh(true, false);
  57. Qualifications.Refresh(true, false);
  58. }
  59. public void Shutdown(CancelEventArgs? cancel)
  60. {
  61. }
  62. }
  63. }