LogikalProfile.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. using InABox.Core;
  2. using InABox.Integration.Logikal;
  3. using System;
  4. using System.Collections.Generic;
  5. namespace PRSDesktop.Integrations.Logikal
  6. {
  7. public class LogikalProfile : LogikalBOMItem, ILogikalProfile
  8. {
  9. public double Length { get; set; }
  10. public double PaintPerimeter { get; set; }
  11. public double AnodizePerimeter { get; set; }
  12. public double MillCost { get; set; }
  13. public string Group { get; set; }
  14. public string Supplier { get; set; }
  15. public string? Finish { get; set; }
  16. public override void ValidateQuery(string sql, List<string> errors)
  17. {
  18. base.ValidateQuery(sql, errors);
  19. ValidateField(sql, nameof(Length), errors);
  20. ValidateField(sql, nameof(Finish), errors);
  21. ValidateField(sql, nameof(Group), errors);
  22. ValidateField(sql, nameof(Supplier), errors);
  23. ValidateField(sql, nameof(PaintPerimeter), errors);
  24. ValidateField(sql, nameof(AnodizePerimeter), errors);
  25. ValidateField(sql, nameof(MillCost), errors);
  26. }
  27. public static String DesignSQL =
  28. $@"select
  29. p.[ArticleCode_BaseNumber] as [{nameof(Code)}],
  30. p.[description] as [{nameof(Description)}],
  31. p.[length_output] as [{nameof(Length)}],
  32. c.[PowderID] as [{nameof(Finish)}],
  33. p.Perimeter as [{nameof(AnodizePerimeter)}],
  34. p.[PerimeterBoundaryBox] as [{nameof(PaintPerimeter)}],
  35. p.[Amount] as [{nameof(Quantity)}],
  36. case p.[ArticleType] when 1 then 'Profiles' when 2 then 'Profiles' when 5 then 'Gasket' when 7 then 'Gasket' when 8 then 'Components' when 16 then 'Components' when 18 then 'Components' when 30 then 'Fills' else '???' end as [{nameof(Group)}],
  37. p.[Price] as [{nameof(Cost)}],
  38. (p.[PriceGross]-p.[PriceCoating]) as [{nameof(MillCost)}],
  39. coalesce(s.[CustomerNo],s.[ActiveTitle]) as [{nameof(Supplier)}]
  40. from
  41. profiles p
  42. left outer join
  43. colors c on p.[lk_colorid] = c.[colorid]
  44. join
  45. insertions i on p.[insertionid] = i.[insertionid]
  46. join
  47. elevations e on i.[elevationid] = e.[elevationid]
  48. left outer join
  49. suppliers s on p.[LK_SupplierID] = s.[SupplierID]";
  50. public static String BillOfMaterialsSQL =
  51. $@"select
  52. sum(p.[Amount]) as [{nameof(Quantity)}],
  53. case p.[ArticleType] when 2 then 'Profiles' when 5 then 'Gasket' when 8 then 'Components' when 30 then 'Fills' else '???' end as [{nameof(Group)}],
  54. coalesce(s.[CustomerNo],s.[ActiveTitle]) as [{nameof(Supplier)}],
  55. p.[ArticleCode_BaseNumber] as [{nameof(Code)}],
  56. p.[description] as [{nameof(Description)}],
  57. p.Perimeter as [{nameof(AnodizePerimeter)}],
  58. p.[PerimeterBoundaryBox] as [{nameof(PaintPerimeter)}],
  59. c.[ColorName] as [{nameof(Finish)}],
  60. p.[Length] as [{nameof(Length)}],
  61. (p.[PriceGross]-p.[PriceCoating])*p.[Length] as [{nameof(MillCost)}],
  62. p.[PriceGross]*p.[Length] as [{nameof(Cost)}]
  63. from
  64. profilebars p
  65. left outer join
  66. colors c on p.[lk_colorid] = c.[colorid]
  67. left outer join
  68. suppliers s on p.[SupplierID] = s.[SupplierID]
  69. group by
  70. p.[ArticleCode],
  71. p.[Description],
  72. p.[Length],
  73. c.[ColorName],
  74. p.[ArticleType],
  75. coalesce(s.[CustomerNo],s.[ActiveTitle]),
  76. (p.[PriceGross]-p.[PriceCoating])*p.[Length],
  77. p.[Perimeter],
  78. p.[PerimeterBoundaryBox],
  79. p.[PriceGross]*p.[Length]
  80. ";
  81. }
  82. /* BillOf Materials
  83. select
  84. sum(p.[Amount]) as [{nameof(Quantity)}],
  85. d.[DiscountGroup] as [{nameof(Group)}],
  86. coalesce(s.[CustomerNo],s.[ActiveTitle]) as [{nameof(Supplier)}],
  87. p.[ArticleCode] as [{nameof(Code)}],
  88. p.[description] as [{nameof(Description)}],
  89. p.Perimeter as [{nameof(AnodizePerimeter)}],
  90. p.[PerimeterBoundaryBox] as [{nameof(PaintPerimeter)}],
  91. c.[ColorName] as [{nameof(Finish)}],
  92. p.[Length] as [{nameof(Length)}],
  93. (p.[PriceGross]-p.[PriceCoating])*p.[Length] as [{nameof(MillCost)}],
  94. p.[PriceGross]*p.[Length] as [{nameof(Cost)}]
  95. from
  96. profilebars p
  97. left outer join
  98. colors c on p.[lk_colorid] = c.[colorid]
  99. join
  100. estimationdiscounts d on p.[LK_DiscountId] = d.[EstimationDiscountID]
  101. left outer join
  102. suppliers s on p.[SupplierID] = s.[SupplierID]
  103. group by
  104. p.[ArticleCode],
  105. p.[Description],
  106. p.[Length],
  107. c.[ColorName],
  108. d.[DiscountGroup],
  109. coalesce(s.[CustomerNo],s.[ActiveTitle]),
  110. (p.[PriceGross]-p.[PriceCoating])*p.[Length],
  111. p.[Perimeter],
  112. p.[PerimeterBoundaryBox],
  113. p.[PriceGross]*p.[Length]
  114. */
  115. /* Designs
  116. */
  117. }