LogikalComponent.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using InABox.Integration.Logikal;
  2. using System;
  3. using System.Collections.Generic;
  4. namespace PRSDesktop.Integrations.Logikal
  5. {
  6. public class LogikalComponent : LogikalBOMItem, ILogikalComponent
  7. {
  8. public string Group { get; set; }
  9. public double PackSize { get; set; }
  10. public string Supplier { get; set; }
  11. public override void ValidateQuery(string sql, List<string> errors)
  12. {
  13. base.ValidateQuery(sql, errors);
  14. ValidateField(sql, nameof(PackSize), errors);
  15. ValidateField(sql, nameof(Group), errors);
  16. ValidateField(sql, nameof(Supplier), errors);
  17. }
  18. public static String SQL =
  19. $@"select
  20. a.[ArticleCode_BaseNumber] as [{nameof(Code)}],
  21. a.[description] as [{nameof(Description)}],
  22. a.[pusize] as [{nameof(PackSize)}],
  23. case a.[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)}],
  24. coalesce(s.[CustomerNo],s.[ActiveTitle]) as [{nameof(Supplier)}],
  25. sum(a.[units]/a.[pusize]) as [{nameof(Quantity)}],
  26. a.[Price]*a.[pusize] as [{nameof(Cost)}]
  27. from
  28. articles a
  29. join
  30. insertions i on a.[insertionid] = i.[insertionid]
  31. join
  32. elevations e on i.[elevationid] = e.[elevationid]
  33. left outer join
  34. suppliers s on a.[LK_SupplierID] = s.[SupplierID]
  35. where
  36. a.[ArticleType] not in (5,7)
  37. group by
  38. a.[ArticleCode_BaseNumber],
  39. a.[description],
  40. a.[Price],
  41. a.[ArticleType],
  42. coalesce(s.[CustomerNo],s.[ActiveTitle])";
  43. }
  44. /*
  45. select
  46. a.[ArticleCode_BaseNumber] as [{nameof(Code)}],
  47. a.[description] as [{nameof(Description)}],
  48. a.[pusize] as [{nameof(PackSize)}],
  49. d.[DiscountGroup] as [{nameof(Group)}],
  50. coalesce(s.[CustomerNo],s.[ActiveTitle]) as [{nameof(Supplier)}],
  51. sum(a.[units]/a.[pusize]) as [{nameof(Quantity)}],
  52. a.[Price]*a.[pusize] as [{nameof(Cost)}]
  53. from
  54. articles a
  55. join
  56. insertions i on a.[insertionid] = i.[insertionid]
  57. join
  58. elevations e on i.[elevationid] = e.[elevationid]
  59. join
  60. estimationdiscounts d on a.[LK_DiscountID] = d.[EstimationDiscountID]
  61. left outer join
  62. suppliers s on a.[LK_SupplierID] = s.[SupplierID]
  63. where
  64. a.[ArticleType] not in (5,7)
  65. group by
  66. a.[ArticleCode_BaseNumber],
  67. a.[description],
  68. a.[Price],
  69. d.[DiscountGroup],
  70. coalesce(s.[CustomerNo],s.[ActiveTitle])
  71. */
  72. }