EmployeePanel.xaml.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Windows.Controls;
  5. using Comal.Classes;
  6. using InABox.Core;
  7. namespace PRSDesktop
  8. {
  9. /// <summary>
  10. /// Interaction logic for EmployeePanel.xaml
  11. /// </summary>
  12. public partial class EmployeePanel : UserControl, IPanel<Employee>
  13. {
  14. public EmployeePanel()
  15. {
  16. InitializeComponent();
  17. }
  18. public bool IsReady { get; set; }
  19. public event DataModelUpdateEvent OnUpdateDataModel;
  20. public Dictionary<string, object[]> Selected()
  21. {
  22. return new Dictionary<string, object[]> { { typeof(Employee).EntityName(), Employees.SelectedRows } };
  23. }
  24. public void Setup()
  25. {
  26. Employees.Refresh(true, false);
  27. }
  28. public void Shutdown()
  29. {
  30. }
  31. public void CreateToolbarButtons(IPanelHost host)
  32. {
  33. }
  34. public void Refresh()
  35. {
  36. Employees.Refresh(false, true);
  37. }
  38. public string SectionName => "Employees";
  39. public DataModel DataModel(Selection selection)
  40. {
  41. var ids = Employees.ExtractValues(x => x.ID, selection).ToArray();
  42. return new AutoDataModel<Employee>(new Filter<Employee>(x => x.ID).InList(ids));
  43. }
  44. public void Heartbeat(TimeSpan time)
  45. {
  46. }
  47. public Dictionary<Type, CoreTable> DataEnvironment()
  48. {
  49. var env = new Dictionary<Type, CoreTable>();
  50. env[typeof(Job)] = Employees.Data;
  51. return env;
  52. }
  53. }
  54. }