V6Quote.cs 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. [MemoEditor(Visible = Visible.Hidden)]
  28. [EditorSequence(6)]
  29. public string Street { get; set; }
  30. [TextBoxEditor]
  31. [EditorSequence(7)]
  32. public string City { get; set; }
  33. [TextBoxEditor]
  34. [EditorSequence(8)]
  35. public string State { get; set; }
  36. [TextBoxEditor]
  37. [EditorSequence(9)]
  38. public string PostCode { get; set; }
  39. [CurrencyEditor]
  40. [EditorSequence(10)]
  41. public double SellPrice {get; set; }
  42. public override void ValidateQuery(string sql, List<string> errors)
  43. {
  44. ValidateField(sql, nameof(ID), errors);
  45. ValidateField(sql, nameof(Revision), errors);
  46. ValidateField(sql, nameof(Number), errors);
  47. ValidateField(sql, nameof(Variation), errors);
  48. ValidateField(sql, nameof(ClientID), errors);
  49. ValidateField(sql, nameof(ClientName), errors);
  50. ValidateField(sql, nameof(Title), errors);
  51. ValidateField(sql, nameof(Street), errors);
  52. ValidateField(sql, nameof(City), errors);
  53. ValidateField(sql, nameof(State), errors);
  54. ValidateField(sql, nameof(PostCode), errors);
  55. ValidateField(sql, nameof(SellPrice), errors);
  56. }
  57. public static string SQL =
  58. "select distinct \n"
  59. + $" q.quote_id as {nameof(ID)}, \n "
  60. + $" q.quote_vers as {nameof(Revision)}, \n"
  61. + $" q.quote_num as {nameof(Number)}, \n"
  62. + $" q.quote_num_suff as {nameof(Variation)}, \n"
  63. + $" c.cust_code as {nameof(ClientID)}, \n"
  64. + $" c.cust_name as {nameof(ClientName)}, \n"
  65. + $" coalesce(a.addr_1,'') + coalesce(char(13)+char(10)+a.addr_2,'') as {nameof(Street)}, \n"
  66. + $" a.addr_3 as {nameof(City)}, \n"
  67. + $" a.addr_4 as {nameof(State)}, \n"
  68. + $" a.addr_5 as {nameof(PostCode)}, \n"
  69. + $" q.quote_title as {nameof(Title)}, \n"
  70. + $" q.nett_sell_price + q.nett_sell_prc_lab as {nameof(SellPrice)} \n"
  71. + "from quote q \n"
  72. + " left outer join customer c on q.cust_id = c.cust_id \n"
  73. + " left outer join addr a on q.del_addr_id = a.addr_id \n"
  74. + "where \n"
  75. + " q.quote_vers = (select max(quote_vers) from quote where quote_id = q.quote_id) \n"
  76. + "order by \n"
  77. + " q.quote_num, \n"
  78. + " q.quote_num_suff";
  79. }
  80. }