V6Elevation.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System.Collections.Generic;
  2. using InABox.Core;
  3. namespace PRSDesktop.Integrations.V6
  4. {
  5. public class V6Elevation : V6Object
  6. {
  7. [IntegerEditor(Visible=Visible.Hidden)]
  8. [EditorSequence(1)]
  9. [RequiredColumn]
  10. public int ID { get; set; }
  11. [TextBoxEditor(Visible=Visible.Default)]
  12. [EditorSequence(2)]
  13. public string Description { get; set; }
  14. [IntegerEditor(Visible=Visible.Default)]
  15. [EditorSequence(3)]
  16. public int Quantity { get; set; }
  17. [IntegerEditor(Visible=Visible.Default)]
  18. [EditorSequence(4)]
  19. public int Drawings { get; set; }
  20. public override void ValidateQuery(string sql, List<string> errors)
  21. {
  22. ValidateField(sql, nameof(Description), errors);
  23. ValidateField(sql, nameof(Quantity), errors);
  24. ValidateField(sql, nameof(Drawings), errors);
  25. }
  26. public static string SQL = $@"
  27. select
  28. qi.quote_item_id as {nameof(ID)},
  29. qi.descr as {nameof(Description)},
  30. qi.quantity as {nameof(Quantity)},
  31. qid.drawings as {nameof(Drawings)}
  32. from
  33. Quote_item qi
  34. join
  35. (select quote_item_id, count(*) as Drawings from quote_item_drawings group by quote_item_id) qid on qid.quote_item_id = qi.quote_item_id
  36. join
  37. quote q on qi.quote_id = q.quote_id and qi.quote_vers_start <= q.quote_vers and qi.quote_vers_stop >= q.quote_vers
  38. where
  39. 1=1
  40. and
  41. qi.quote_vers_start <= q.quote_vers and qi.quote_vers_stop >= q.quote_vers";
  42. }
  43. }