BaseGLCodeLookupGenerator.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using InABox.Clients;
  3. using InABox.Core;
  4. namespace Comal.Classes
  5. {
  6. public abstract class BaseGLCodeLookupGenerator : LookupGenerator<object>
  7. {
  8. protected BaseGLCodeLookupGenerator(object[] items) : base(items)
  9. {
  10. AddColumn("Code", typeof(string));
  11. AddColumn("Description", typeof(string));
  12. }
  13. protected abstract Filter<GLCode> CreateFilter();
  14. protected override void DoGenerateLookups()
  15. {
  16. Clear();
  17. var codes = new Client<GLCode>().Query(
  18. Filters<GLCode>.Combine(CreateFilter(), new Filter<GLCode>(x=>x.Hidden).IsEqualTo(false)),
  19. new Columns<GLCode>(x=>x.ID, x => x.Code, x => x.Description),
  20. new SortOrder<GLCode>(x => x.Code)
  21. );
  22. foreach (var row in codes.Rows)
  23. AddValue(
  24. row.Get<GLCode, Guid>(x => x.ID),
  25. string.Format("{0}: {1}", row.Get<GLCode, string>(x => x.Code),
  26. row.Get<GLCode, string>(x => x.Description)),
  27. row.Get<GLCode, string>(x => x.Code),
  28. row.Get<GLCode, string>(x => x.Description)
  29. );
  30. }
  31. }
  32. }