V6Quote.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System.Collections.Generic;
  2. using InABox.Core;
  3. namespace Comal.Classes
  4. {
  5. public class V6Quote : V6Object
  6. {
  7. [NullEditor]
  8. public int ID { get; set; }
  9. [NullEditor]
  10. public int Revision { get; set; }
  11. [IntegerEditor(Width=80)]
  12. [Caption("Quote")]
  13. [EditorSequence(1)]
  14. public int Number { get; set; }
  15. [TextBoxEditor(Width=60)]
  16. [EditorSequence(2)]
  17. public string Variation { get; set; }
  18. [TextBoxEditor(Width = 100)]
  19. [EditorSequence(3)]
  20. public string ClientID { get; set; }
  21. [TextBoxEditor(Visible = Visible.Hidden)]
  22. [EditorSequence(4)]
  23. public string ClientName { get; set; }
  24. [TextBoxEditor]
  25. [EditorSequence(5)]
  26. public string Title { get; set; }
  27. [CurrencyEditor]
  28. [EditorSequence(6)]
  29. public double SellPrice {get; set; }
  30. public override void ValidateQuery(string sql, List<string> errors)
  31. {
  32. ValidateField(sql, nameof(ID), errors);
  33. ValidateField(sql, nameof(Revision), errors);
  34. ValidateField(sql, nameof(Number), errors);
  35. ValidateField(sql, nameof(Variation), errors);
  36. ValidateField(sql, nameof(ClientID), errors);
  37. ValidateField(sql, nameof(ClientName), errors);
  38. ValidateField(sql, nameof(Title), errors);
  39. ValidateField(sql, nameof(SellPrice), errors);
  40. }
  41. public static string SQL =
  42. "select distinct \n"
  43. + $" q.quote_id as {nameof(ID)}, \n "
  44. + $" q.quote_vers as {nameof(Revision)}, \n"
  45. + $" q.quote_num as {nameof(Number)}, \n"
  46. + $" q.quote_num_suff as {nameof(Variation)}, \n"
  47. + $" c.cust_code as {nameof(ClientID)}, \n"
  48. + $" c.cust_name as {nameof(ClientName)}, \n"
  49. + $" q.quote_title as {nameof(Title)}, \n"
  50. + $" q.nett_sell_price + q.nett_sell_prc_lab as {nameof(SellPrice)} \n"
  51. + "from quote q \n"
  52. + " left outer join customer c on q.cust_id = c.cust_id \n"
  53. + "where \n"
  54. + " q.quote_vers = (select max(quote_vers) from quote where quote_id = q.quote_id) \n"
  55. + "order by \n"
  56. + " q.quote_num, \n"
  57. + " q.quote_num_suff";
  58. }
  59. }