DigitalFormSubscriptionsGrid.cs 1.1 KB

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