DigitalFormSubscriptionsGrid.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using Comal.Classes;
  2. using InABox.Core;
  3. using InABox.DynamicGrid;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace PRSDesktop
  10. {
  11. class DigitalFormSubscriptionsGrid : DynamicOneToManyGrid<Employee, EmployeeFormSubscription>
  12. {
  13. protected override void Init()
  14. {
  15. base.Init();
  16. HiddenColumns.Add(x => x.Form.ID);
  17. }
  18. protected override void DoAdd(bool OpenEditorOnDirectEdit = false)
  19. {
  20. var formIDs = Items.Select(x => x.Form.ID).ToArray();
  21. var dlg = new MultiSelectDialog<DigitalForm>(new Filter<DigitalForm>(x => x.ID).NotInList(formIDs), null, true);
  22. if (dlg.ShowDialog())
  23. {
  24. var items = dlg.Items(null);
  25. foreach(var item in items)
  26. {
  27. var newItem = CreateItem();
  28. newItem.Form.ID = item.ID;
  29. newItem.Form.Synchronise(item);
  30. SaveItem(newItem);
  31. }
  32. Refresh(false, true);
  33. }
  34. }
  35. }
  36. }