QuoteDesignItemGrid.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using System.Linq;
  3. using Comal.Classes;
  4. using InABox.Core;
  5. using InABox.DynamicGrid;
  6. namespace PRSDesktop
  7. {
  8. public class QuoteDesignItemGrid : DynamicManyToManyDataGrid<QuoteDesignItem, QuoteDesign>
  9. {
  10. public QuoteDesignItemGrid()
  11. {
  12. Options.AddRange(DynamicGridOption.RecordCount, DynamicGridOption.SelectColumns);
  13. HiddenColumns.Add(x => x.Design.ID);
  14. HiddenColumns.Add(x => x.Design.Quote.ID);
  15. }
  16. public Guid DesignID
  17. {
  18. get => ID;
  19. set
  20. {
  21. ID = value;
  22. Refresh(false, true);
  23. }
  24. }
  25. public Guid QuoteID { get; set; }
  26. protected override void Reload(Filters<QuoteDesignItem> criteria, Columns<QuoteDesignItem> columns, ref SortOrder<QuoteDesignItem> sort,
  27. Action<CoreTable, Exception> action)
  28. {
  29. criteria.Add(new Filter<QuoteDesignItem>(x => x.Design.ID).IsEqualTo(DesignID));
  30. base.Reload(criteria, columns, ref sort, action);
  31. }
  32. protected override QuoteDesignItem CreateItem()
  33. {
  34. var result = base.CreateItem();
  35. result.Design.ID = DesignID;
  36. result.Design.Quote.ID = QuoteID;
  37. return result;
  38. }
  39. protected override object GetFilter()
  40. {
  41. var ids = CurrentGuids();
  42. if (ids.Any())
  43. return new Filter<QuoteTakeoff>(x => x.Quote.ID).IsEqualTo(QuoteID).And(x => x.ID).NotInList(CurrentGuids());
  44. return new Filter<QuoteTakeoff>(x => x.Quote.ID).IsEqualTo(QuoteID);
  45. }
  46. }
  47. }