The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
Shopping List_Beta_School_Act
Posted by: R34p3R--X | January 22, 2011 @ 3:31pm
Revision 1 - Original post on January 22, 2011 @ 2:43pm
Delphi Code
[
Download
]
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Spin, ExtCtrls, Buttons; type TfrmList = class(TForm) cbxOne: TComboBox; lblItem: TLabel; lblPrice: TLabel; pnlHead: TPanel; pnlItem: TPanel; pnlPrice: TPanel; lblAmount: TLabel; pnlAmount: TPanel; lblPOne: TLabel; sedOne: TSpinEdit; Button1: TButton; cbxTwo: TComboBox; sedTwo: TSpinEdit; lblPTwo: TLabel; cbxThree: TComboBox; sedThree: TSpinEdit; lblPThree: TLabel; pnlTotal: TPanel; lblTotal: TLabel; lblVat: TLabel; lblFinal: TLabel; lblPTotal: TLabel; lblPVat: TLabel; lblPFinal: TLabel; bmbClose: TBitBtn; BitBtn1: TBitBtn; procedure cbxOneChange(Sender: TObject); procedure sedOneChange(Sender: TObject); procedure FormActivate(Sender: TObject); procedure cbxTwoChange(Sender: TObject); procedure sedTwoChange(Sender: TObject); procedure cbxThreeChange(Sender: TObject); procedure sedThreeChange(Sender: TObject); procedure Button1Click(Sender: TObject); procedure BitBtn1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var frmList: TfrmList; iPriceOne : Integer; iPriceTwo : Integer; IPriceThree : Integer; iPriceBread : Integer; iPriceCoke : Integer; iPriceChips : Integer; iTotal : Integer; rFinal : Real; rVat : Real; rVatTotal : Real; implementation {$R *.dfm} //============================================================================= //cbxOneChange procedure TfrmList.cbxOneChange(Sender: TObject); begin //Process //Bread if cbxOne.Text = 'Bread' then begin iPriceOne := iPriceBread * sedOne.Value; lblPOne.Caption := 'R' + IntToStr(iPriceOne) + '.00'; end; //Coke if cbxOne.Text = 'Coke' then begin iPriceOne := iPriceCoke * sedOne.Value; lblPOne.Caption := 'R' + IntToStr(iPriceOne) + '.00'; end; //Chips if cbxOne.Text = 'Chips' then begin iPriceOne := iPriceChips * sedOne.Value; lblPOne.Caption := 'R' + IntToStr(iPriceOne) + '.00'; end end; //============================================================================= //sedOneChange procedure TfrmList.sedOneChange(Sender: TObject); begin //Bread if cbxOne.Text = 'Bread' then begin iPriceOne := iPriceBread * sedOne.Value; lblPOne.Caption := 'R' + IntToStr(iPriceOne) + '.00'; end; //Coke if cbxOne.Text = 'Coke' then begin iPriceOne := iPriceCoke * sedOne.Value; lblPOne.Caption := 'R' + IntToStr(iPriceOne) + '.00'; end; //Chips if cbxOne.Text = 'Chips' then begin iPriceOne := iPriceChips * sedOne.Value; lblPOne.Caption := 'R' + IntToStr(iPriceOne) + '.00'; end end; //============================================================================= //Form Activate procedure TfrmList.FormActivate(Sender: TObject); begin //Variable Assignments iPriceBread := 5; iPriceCoke := 10; iPriceChips := 8; rVat := 14/100; end; //============================================================================= //cbxTwoChange procedure TfrmList.cbxTwoChange(Sender: TObject); begin //Process //Bread if cbxTwo.Text = 'Bread' then begin iPriceTwo := iPriceBread * sedTwo.Value; lblPTwo.Caption := 'R' + IntToStr(iPriceTwo) + '.00'; end; //Coke if cbxTwo.Text = 'Coke' then begin iPriceTwo := iPriceCoke * sedTwo.Value; lblPTwo.Caption := 'R' + IntToStr(iPriceTwo) + '.00'; end; //Chips if cbxTwo.Text = 'Chips' then begin iPriceTwo := iPriceChips * sedTwo.Value; lblPTwo.Caption := 'R' + IntToStr(iPriceTwo) + '.00'; end end; //============================================================================= //sedTwoChange procedure TfrmList.sedTwoChange(Sender: TObject); begin //Bread if cbxTwo.Text = 'Bread' then begin iPriceTwo := iPriceBread * sedTwo.Value; lblPTwo.Caption := 'R' + IntToStr(iPriceTwo) + '.00'; end; //Coke if cbxTwo.Text = 'Coke' then begin iPriceTwo := iPriceCoke * sedTwo.Value; lblPTwo.Caption := 'R' + IntToStr(iPriceTwo) + '.00'; end; //Chips if cbxTwo.Text = 'Chips' then begin iPriceTwo := iPriceChips * sedTwo.Value; lblPTwo.Caption := 'R' + IntToStr(iPriceTwo) + '.00'; end end; //============================================================================= //cbxThreeChange procedure TfrmList.cbxThreeChange(Sender: TObject); begin //Process //Bread if cbxThree.Text = 'Bread' then begin iPriceThree := iPriceBread * sedThree.Value; lblPThree.Caption := 'R' + IntToStr(iPriceThree) + '.00'; end; //Coke if cbxThree.Text = 'Coke' then begin iPriceThree := iPriceCoke * sedThree.Value; lblPThree.Caption := 'R' + IntToStr(iPriceThree) + '.00'; end; //Chips if cbxThree.Text = 'Chips' then begin iPriceThree := iPriceChips * sedThree.Value; lblPThree.Caption := 'R' + IntToStr(iPriceThree) + '.00'; end end; //============================================================================= //sedThreeChange procedure TfrmList.sedThreeChange(Sender: TObject); begin //Process //Bread if cbxThree.Text = 'Bread' then begin iPriceThree := iPriceBread * sedThree.Value; lblPThree.Caption := 'R' + IntToStr(iPriceThree) + '.00'; end; //Coke if cbxThree.Text = 'Coke' then begin iPriceThree := iPriceCoke * sedThree.Value; lblPThree.Caption := 'R' + IntToStr(iPriceThree) + '.00'; end; //Chips if cbxThree.Text = 'Chips' then begin iPriceThree := iPriceChips * sedThree.Value; lblPThree.Caption := 'R' + IntToStr(iPriceThree) + '.00'; end end; //============================================================================= //CalculatePriceButton procedure TfrmList.Button1Click(Sender: TObject); begin //Variable Assignments Button iTotal := iPriceOne + iPriceTwo + iPriceThree; rFinal := (iTotal * rVat) + iTotal; rVatTotal := iTotal * rVat; //Process Button lblPTotal.Caption := 'R' + IntToStr(iTotal) + '.00'; lblPVat.Caption := 'R' + FloatToStrF(rVatTotal, ffFixed, 5, 2); lblPFinal.Caption := 'R' + FloatToStrF(rFinal, ffFixed, 5, 2); end; //============================================================================= //Reset procedure TfrmList.BitBtn1Click(Sender: TObject); begin sedOne.Value := 0; sedTwo.Value := 0; sedThree.Value := 0; cbxOne.Clear; cbxTwo.Clear; cbxThree.Clear; lblPOne.Caption := ''; lblPTwo.Caption := ''; lblPThree.Caption := ''; lblPTotal.Caption := ''; lblPVat.Caption := ''; lblPFinal.Caption := ''; end; end.
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.50 / 8
66 Votes