V6Profile.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Collections.Generic;
  3. namespace Comal.Classes
  4. {
  5. public class V6Profile : V6BOMItem
  6. {
  7. public double Length { get; set; }
  8. public string Finish { get; set; }
  9. public override void ValidateQuery(string sql, List<string> errors)
  10. {
  11. base.ValidateQuery(sql, errors);
  12. ValidateField(sql, nameof(Length), errors);
  13. ValidateField(sql, nameof(Finish), errors);
  14. }
  15. public static String SQL =
  16. "SELECT \n" +
  17. $" e.extn_code as {nameof(Code)}, \n" +
  18. $" e.descr as {nameof(Description)}, \n" +
  19. $" f.fincol_code as {nameof(Finish)}, \n" +
  20. $" round(coalesce(bb.bar_length, 0.0) * 0.0254, 2) as {nameof(Length)}, \n" +
  21. $" sum(bp.piece_count) as {nameof(Quantity)}, \n" +
  22. $" round(bb.cost * coalesce(bb.bar_length, 0.0),2) as {nameof(Cost)} \n" +
  23. "FROM \n" +
  24. " bom_piece bp \n" +
  25. "left outer join \n" +
  26. " extn e on bp.extn_id = e.extn_id \n" +
  27. "left outer join \n" +
  28. " quote_item qi on qi.quote_item_id = bp.quote_item_id \n" +
  29. "left outer join \n" +
  30. " quote q on q.quote_id = qi.quote_id \n" +
  31. "left outer join \n" +
  32. " (Select bcp.bom_piece_id, MAX(bcp.bom_cutplan_id) as bom_cutplan_id from bom_cutplan_piece bcp group by bcp.bom_piece_id) bcp on bcp.bom_piece_id = bp.bom_piece_id \n" +
  33. "left outer join \n" +
  34. " bom_bar bb on bb.bom_cutplan_id = bcp.bom_cutplan_id \n" +
  35. "left outer join \n" +
  36. " fincol f on f.fincol_lib_id = bp.fincol_lib_id and f.fincol_id = bp.fincol_id \n" +
  37. "where \n" +
  38. " 1 = 1 \n" +
  39. "and \n" +
  40. " bb.bar_length is not null \n" +
  41. "group by \n" +
  42. " e.extn_code, \n" +
  43. " e.descr, \n" +
  44. " f.fincol_code, \n" +
  45. " bb.bar_length, \n" +
  46. " bb.cost";
  47. }
  48. }