V6Labour.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. using System.Collections.Generic;
  3. namespace Comal.Classes
  4. {
  5. public class V6Labour : V6Object
  6. {
  7. public string Code { get; set; }
  8. public string Description { get; set; }
  9. public double Minutes { get; set; }
  10. public double Cost { get; set; }
  11. public override void ValidateQuery(string sql, List<string> errors)
  12. {
  13. ValidateField(sql,nameof(Code), errors);
  14. ValidateField(sql,nameof(Description), errors);
  15. ValidateField(sql, nameof(Minutes), errors);
  16. ValidateField(sql, nameof(Cost), errors);
  17. }
  18. public static String SQL =
  19. "select \n" +
  20. $" la.code as {nameof(Code)}, \n" +
  21. $" la.code as {nameof(Description)}, \n" +
  22. $" sum(bl.lab_time) as {nameof(Minutes)}, \n" +
  23. $" sum(bl.cost) as {nameof(Cost)} \n" +
  24. "from \n" +
  25. " bom_labour bl \n" +
  26. "left outer join \n" +
  27. " quote_item qi on qi.quote_item_id = bl.quote_item_id \n" +
  28. "left outer join \n" +
  29. " quote q on q.quote_id = qi.quote_id \n" +
  30. "left outer join \n" +
  31. " (select lab_area_lib_id, lab_area_id, case when descr LIKE '%Cutting%' then 'CUTTING' when descr LIKE '%Site%' OR descr LIKE '%fixings%' OR descr LIKE '%S/Glz%' then 'SITE' else 'FABRICATION' end as code from lab_area) la on la.lab_area_lib_id = bl.lab_area_lib_id and la.lab_area_id = bl.lab_area_id \n" +
  32. "where \n" +
  33. " 1=1 \n" +
  34. "group by \n" +
  35. " la.code";
  36. }
  37. }