V6Variation.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System.Collections.Generic;
  2. using InABox.Core;
  3. namespace PRSDesktop.Integrations.V6;
  4. public class V6Variation : V6Object
  5. {
  6. [CodeEditor(Visible = Visible.Default)]
  7. [EditorSequence(1)]
  8. [RequiredColumn]
  9. public string ID { get; set; }
  10. [TextBoxEditor(Visible=Visible.Default)]
  11. [EditorSequence(2)]
  12. [RequiredColumn]
  13. public string Description { get; set; }
  14. [CurrencyEditor]
  15. [EditorSequence(3)]
  16. public double SellPrice {get; set; }
  17. public override void ValidateQuery(string sql, List<string> errors)
  18. {
  19. ValidateField(sql,nameof(ID), errors);
  20. ValidateField(sql, nameof(Description), errors);
  21. }
  22. public string GetReference()
  23. {
  24. var result = $"V6:{ID}";
  25. return result;
  26. }
  27. public static bool ParseReference(string? reference, out string variation)
  28. {
  29. variation = "";
  30. if (reference?.StartsWith("V6:") != true)
  31. return false;
  32. var comps = reference.Split(':');
  33. if (comps.Length < 2)
  34. return false;
  35. if (comps.Length > 1)
  36. variation = comps[1];
  37. return true;
  38. }
  39. public static string SQL = $@"
  40. select
  41. q.QUOTE_NUM_SUFF as {nameof(ID)},
  42. q.QUOTE_TITLE as {nameof(Description)},
  43. q.nett_sell_price + q.nett_sell_prc_lab as {nameof(SellPrice)}
  44. from
  45. Quote q
  46. where
  47. 1=1
  48. and
  49. coalesce(q.QUOTE_NUM_SUFF,'') <> ''
  50. ";
  51. }