code program :
unit UPEMBAYARAN;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, jpeg, XPMan;
type
TForm1 = class(TForm)
Panel3: TPanel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Panel1: TPanel;
EDTHARGA: TEdit;
EDTDISCOUNT: TEdit;
EDTJLHTIKET: TEdit;
EDTTOTALBAYAR: TEdit;
cbojenisbus: TComboBox;
cbotujuan: TComboBox;
cbojenispenumpang: TComboBox;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Panel2: TPanel;
XPManifest1: TXPManifest;
Image1: TImage;
Timer1: TTimer;
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure cbotujuanChange(Sender: TObject);
procedure cbojenispenumpangChange(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
jenispenumpang,jlhtiket :integer;
Discount:real;
totalbayar:REAL;
hargatiket:REAL;
B:string;
implementation
uses StrUtils;
{$R *.dfm}
procedure TForm1.Button3Click(Sender: TObject);
begin
APPLICATION.Terminate ;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
cbojenisbus.Text :='';
cbojenispenumpang.Text:='';
cbotujuan.Text:='';
EDTHARGA.Text:='';
EDTTOTALBAYAR.Text:='';
EDTJLHTIKET.Text:='';
EDTDISCOUNT.Text:='';
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
cbojenisbus.Items.Add('EKONOMI');
cbojenisbus.Items.Add('AC');
cbojenispenumpang.Items.Add('ANAK-ANAK');
cbojenispenumpang.Items.Add('DEWASA');
cbotujuan.Items.Add('TEBING TINGGI') ;
cbotujuan.Items.Add('SEI RAMPAH') ;
cbotujuan.Items.Add('LUBUK PAKAM') ;
cbotujuan.Items.Add('TANJUNG MORAWA');
cbotujuan.Items.Add('MEDAN');
B:=' Pemabayaran Tiket Bus '; //text berjalan pada label1
end;
procedure TForm1.cbotujuanChange(Sender: TObject);
begin
if (cbojenisbus.ItemIndex =0) and
(cbotujuan.ItemIndex =0) then
begin
EDTHARGA.Text:='5000' ;
end
else
if (cbojenisbus.ItemIndex =0) and
(cbotujuan.ItemIndex =1) then
begin
EDTHARGA.Text:='7000' ;
end
else
if (cbojenisbus.ItemIndex =0) and
(cbotujuan.ItemIndex =2) then
begin
EDTHARGA.Text:='9000' ;
end
else
if (cbojenisbus.ItemIndex =0) and
(cbotujuan.ItemIndex =3) then
begin
EDTHARGA.Text:='10000' ;
end
else
if (cbojenisbus.ItemIndex =0) and
(cbotujuan.ItemIndex =4) then
begin
EDTHARGA.Text:='13000' ;
end
else
if (cbojenisbus.ItemIndex =1) and
(cbotujuan.ItemIndex =0) then
begin
EDTHARGA.Text:='11000'
end
else
if (cbojenisbus.ItemIndex =1) and
(cbotujuan.ItemIndex =1) then
begin
EDTHARGA.Text:='13000' ;
end
else
if (cbojenisbus.ItemIndex =1) and
(cbotujuan.ItemIndex =2) then
begin
EDTHARGA.Text:='15000' ;
end
else
if (cbojenisbus.ItemIndex =1) and
(cbotujuan.ItemIndex =3) then
begin
EDTHARGA.Text:='16000' ;
end
else
if (cbojenisbus.ItemIndex =1) and
(cbotujuan.ItemIndex =4) then
begin
EDTHARGA.Text:='19000' ;
end
end;
procedure TForm1.cbojenispenumpangChange(Sender: TObject);
begin
if cbojenispenumpang.ItemIndex =0 then
begin
hargatiket:=strtofloat(EDTHARGA.Text);
discount:=0.1*hargatiket;
EDTDISCOUNT.Text :=floattostr(discount);
end
else
begin
hargatiket:=strtofloat(EDTHARGA.Text);
discount:=0*hargatiket;
EDTDISCOUNT.Text :=floattostr(discount);
end
end ;
procedure TForm1.Button1Click(Sender: TObject);
begin
hargatiket:=strtofloat(EDTHARGA.Text);
discount:=strtofloat(EDTDISCOUNT.Text );
jlhtiket:=strtoint(EDTJLHTIKET.Text );
totalbayar:=(hargatiket*jlhtiket)-(discount*jlhtiket);
EDTTOTALBAYAR.Text:=floattostr(totalbayar) ;
end;
// code untuk teks berjalan pada label 1
procedure TForm1.Timer1Timer(Sender: TObject);
begin
B:=RightStr(B,LENGTH(Label1.Caption )-1)+LEFTSTR(B,1);
Label1.Caption:=B;
end;
end.
Tidak ada komentar:
Posting Komentar