QuoteTakeoffs.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 QuoteTakeoffs : DynamicDataGrid<QuoteTakeoff>, IQuotePage, IDataModelSource
  9. {
  10. public Guid ParentID { get; set; }
  11. public QuoteTakeoffs()
  12. {
  13. Options.AddRange(
  14. DynamicGridOption.RecordCount,
  15. DynamicGridOption.AddRows,
  16. DynamicGridOption.EditRows,
  17. DynamicGridOption.DeleteRows,
  18. DynamicGridOption.SelectColumns,
  19. DynamicGridOption.MultiSelect
  20. );
  21. }
  22. public event DataModelUpdateEvent OnUpdateDataModel;
  23. public string SectionName => "Quote Takeoffs";
  24. public DataModel DataModel(Selection selection)
  25. {
  26. var ids = ExtractValues(x => x.ID, selection).ToArray();
  27. return new BaseDataModel<QuoteTakeoff>(new Filter<QuoteTakeoff>(x => x.ID).InList(ids));
  28. }
  29. protected override void Reload(Filters<QuoteTakeoff> criteria, Columns<QuoteTakeoff> columns, ref SortOrder<QuoteTakeoff> sort,
  30. Action<CoreTable, Exception> action)
  31. {
  32. criteria.Add(new Filter<QuoteTakeoff>(x => x.Quote.ID).IsEqualTo(ParentID));
  33. base.Reload(criteria, columns, ref sort, action);
  34. }
  35. protected override QuoteTakeoff CreateItem()
  36. {
  37. var result = base.CreateItem();
  38. result.Quote.ID = ParentID;
  39. return result;
  40. }
  41. }
  42. }