1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7. Dialogs, StdCtrls, Spin, ExtCtrls, Buttons;
  8.  
  9. type
  10. TfrmList = class(TForm)
  11. cbxOne: TComboBox;
  12. lblItem: TLabel;
  13. lblPrice: TLabel;
  14. pnlHead: TPanel;
  15. pnlItem: TPanel;
  16. pnlPrice: TPanel;
  17. lblAmount: TLabel;
  18. pnlAmount: TPanel;
  19. lblPOne: TLabel;
  20. sedOne: TSpinEdit;
  21. Button1: TButton;
  22. cbxTwo: TComboBox;
  23. sedTwo: TSpinEdit;
  24. lblPTwo: TLabel;
  25. cbxThree: TComboBox;
  26. sedThree: TSpinEdit;
  27. lblPThree: TLabel;
  28. pnlTotal: TPanel;
  29. lblTotal: TLabel;
  30. lblVat: TLabel;
  31. lblFinal: TLabel;
  32. lblPTotal: TLabel;
  33. lblPVat: TLabel;
  34. lblPFinal: TLabel;
  35. bmbClose: TBitBtn;
  36. BitBtn1: TBitBtn;
  37. procedure cbxOneChange(Sender: TObject);
  38. procedure sedOneChange(Sender: TObject);
  39. procedure FormActivate(Sender: TObject);
  40. procedure cbxTwoChange(Sender: TObject);
  41. procedure sedTwoChange(Sender: TObject);
  42. procedure cbxThreeChange(Sender: TObject);
  43. procedure sedThreeChange(Sender: TObject);
  44. procedure Button1Click(Sender: TObject);
  45. procedure BitBtn1Click(Sender: TObject);
  46. private
  47. { Private declarations }
  48. public
  49. { Public declarations }
  50. end;
  51.  
  52. var
  53. frmList: TfrmList;
  54. iPriceOne : Integer;
  55. iPriceTwo : Integer;
  56. IPriceThree : Integer;
  57. iPriceBread : Integer;
  58. iPriceCoke : Integer;
  59. iPriceChips : Integer;
  60. iTotal : Integer;
  61. rFinal : Real;
  62. rVat : Real;
  63. rVatTotal : Real;
  64. implementation
  65.  
  66. {$R *.dfm}
  67.  
  68. //=============================================================================
  69. //cbxOneChange
  70. procedure TfrmList.cbxOneChange(Sender: TObject);
  71. begin
  72. //Process
  73. //Bread
  74. if cbxOne.Text = 'Bread'
  75. then
  76. begin
  77. iPriceOne := iPriceBread * sedOne.Value;
  78. lblPOne.Caption := 'R' + IntToStr(iPriceOne) + '.00';
  79. end;
  80. //Coke
  81. if cbxOne.Text = 'Coke'
  82. then
  83. begin
  84. iPriceOne := iPriceCoke * sedOne.Value;
  85. lblPOne.Caption := 'R' + IntToStr(iPriceOne) + '.00';
  86. end;
  87. //Chips
  88. if cbxOne.Text = 'Chips'
  89. then
  90. begin
  91. iPriceOne := iPriceChips * sedOne.Value;
  92. lblPOne.Caption := 'R' + IntToStr(iPriceOne) + '.00';
  93. end
  94. end;
  95. //=============================================================================
  96. //sedOneChange
  97. procedure TfrmList.sedOneChange(Sender: TObject);
  98. begin
  99. //Bread
  100. if cbxOne.Text = 'Bread'
  101. then
  102. begin
  103. iPriceOne := iPriceBread * sedOne.Value;
  104. lblPOne.Caption := 'R' + IntToStr(iPriceOne) + '.00';
  105. end;
  106. //Coke
  107. if cbxOne.Text = 'Coke'
  108. then
  109. begin
  110. iPriceOne := iPriceCoke * sedOne.Value;
  111. lblPOne.Caption := 'R' + IntToStr(iPriceOne) + '.00';
  112. end;
  113. //Chips
  114. if cbxOne.Text = 'Chips'
  115. then
  116. begin
  117. iPriceOne := iPriceChips * sedOne.Value;
  118. lblPOne.Caption := 'R' + IntToStr(iPriceOne) + '.00';
  119. end
  120.  
  121. end;
  122. //=============================================================================
  123. //Form Activate
  124. procedure TfrmList.FormActivate(Sender: TObject);
  125. begin
  126. //Variable Assignments
  127. iPriceBread := 5;
  128. iPriceCoke := 10;
  129. iPriceChips := 8;
  130. rVat := 14/100;
  131. end;
  132. //=============================================================================
  133. //cbxTwoChange
  134. procedure TfrmList.cbxTwoChange(Sender: TObject);
  135. begin
  136. //Process
  137. //Bread
  138. if cbxTwo.Text = 'Bread'
  139. then
  140. begin
  141. iPriceTwo := iPriceBread * sedTwo.Value;
  142. lblPTwo.Caption := 'R' + IntToStr(iPriceTwo) + '.00';
  143. end;
  144. //Coke
  145. if cbxTwo.Text = 'Coke'
  146. then
  147. begin
  148. iPriceTwo := iPriceCoke * sedTwo.Value;
  149. lblPTwo.Caption := 'R' + IntToStr(iPriceTwo) + '.00';
  150. end;
  151. //Chips
  152. if cbxTwo.Text = 'Chips'
  153. then
  154. begin
  155. iPriceTwo := iPriceChips * sedTwo.Value;
  156. lblPTwo.Caption := 'R' + IntToStr(iPriceTwo) + '.00';
  157. end
  158. end;
  159. //=============================================================================
  160. //sedTwoChange
  161. procedure TfrmList.sedTwoChange(Sender: TObject);
  162. begin
  163. //Bread
  164. if cbxTwo.Text = 'Bread'
  165. then
  166. begin
  167. iPriceTwo := iPriceBread * sedTwo.Value;
  168. lblPTwo.Caption := 'R' + IntToStr(iPriceTwo) + '.00';
  169. end;
  170. //Coke
  171. if cbxTwo.Text = 'Coke'
  172. then
  173. begin
  174. iPriceTwo := iPriceCoke * sedTwo.Value;
  175. lblPTwo.Caption := 'R' + IntToStr(iPriceTwo) + '.00';
  176. end;
  177. //Chips
  178. if cbxTwo.Text = 'Chips'
  179. then
  180. begin
  181. iPriceTwo := iPriceChips * sedTwo.Value;
  182. lblPTwo.Caption := 'R' + IntToStr(iPriceTwo) + '.00';
  183. end
  184.  
  185. end;
  186. //=============================================================================
  187. //cbxThreeChange
  188. procedure TfrmList.cbxThreeChange(Sender: TObject);
  189. begin
  190. //Process
  191. //Bread
  192. if cbxThree.Text = 'Bread'
  193. then
  194. begin
  195. iPriceThree := iPriceBread * sedThree.Value;
  196. lblPThree.Caption := 'R' + IntToStr(iPriceThree) + '.00';
  197. end;
  198. //Coke
  199. if cbxThree.Text = 'Coke'
  200. then
  201. begin
  202. iPriceThree := iPriceCoke * sedThree.Value;
  203. lblPThree.Caption := 'R' + IntToStr(iPriceThree) + '.00';
  204. end;
  205. //Chips
  206. if cbxThree.Text = 'Chips'
  207. then
  208. begin
  209. iPriceThree := iPriceChips * sedThree.Value;
  210. lblPThree.Caption := 'R' + IntToStr(iPriceThree) + '.00';
  211. end
  212. end;
  213. //=============================================================================
  214. //sedThreeChange
  215. procedure TfrmList.sedThreeChange(Sender: TObject);
  216. begin
  217. //Process
  218. //Bread
  219. if cbxThree.Text = 'Bread'
  220. then
  221. begin
  222. iPriceThree := iPriceBread * sedThree.Value;
  223. lblPThree.Caption := 'R' + IntToStr(iPriceThree) + '.00';
  224. end;
  225. //Coke
  226. if cbxThree.Text = 'Coke'
  227. then
  228. begin
  229. iPriceThree := iPriceCoke * sedThree.Value;
  230. lblPThree.Caption := 'R' + IntToStr(iPriceThree) + '.00';
  231. end;
  232. //Chips
  233. if cbxThree.Text = 'Chips'
  234. then
  235. begin
  236. iPriceThree := iPriceChips * sedThree.Value;
  237. lblPThree.Caption := 'R' + IntToStr(iPriceThree) + '.00';
  238. end
  239. end;
  240. //=============================================================================
  241. //CalculatePriceButton
  242. procedure TfrmList.Button1Click(Sender: TObject);
  243. begin
  244. //Variable Assignments Button
  245. iTotal := iPriceOne + iPriceTwo + iPriceThree;
  246. rFinal := (iTotal * rVat) + iTotal;
  247. rVatTotal := iTotal * rVat;
  248. //Process Button
  249. lblPTotal.Caption := 'R' + IntToStr(iTotal) + '.00';
  250. lblPVat.Caption := 'R' + FloatToStrF(rVatTotal, ffFixed, 5, 2);
  251. lblPFinal.Caption := 'R' + FloatToStrF(rFinal, ffFixed, 5, 2);
  252. end;
  253. //=============================================================================
  254. //Reset
  255. procedure TfrmList.BitBtn1Click(Sender: TObject);
  256. begin
  257. sedOne.Value := 0;
  258. sedTwo.Value := 0;
  259. sedThree.Value := 0;
  260. cbxOne.Clear;
  261. cbxTwo.Clear;
  262. cbxThree.Clear;
  263. lblPOne.Caption := '';
  264. lblPTwo.Caption := '';
  265. lblPThree.Caption := '';
  266. lblPTotal.Caption := '';
  267. lblPVat.Caption := '';
  268. lblPFinal.Caption := '';
  269. end;
  270.  
  271. end.
  272.