- Back to Home »
- ALGORITMA PEMOGRAMAN II (BORLAN DELPHI 7)
Posted by : Unknown
Selasa, 28 April 2015
Desain Form
Ketentuan Soal
Listing Program
unit Pemesanan;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TPemesanan_Tiket = class(TForm)
Label1: TLabel;
Label2: TLabel;
enmr: TEdit;
tgl: TLabel;
jam: TLabel;
GroupBox1: TGroupBox;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
cnama: TComboBox;
jurusan: TListBox;
jm_berangkat: TEdit;
harga: TEdit;
GroupBox2: TGroupBox;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
jb: TEdit;
tb: TEdit;
ub: TEdit;
uk: TEdit;
binput: TButton;
bclear: TButton;
bexit: TButton;
Timer1: TTimer;
Label3: TLabel;
Label4: TLabel;
procedure FormActivate(Sender: TObject);
procedure binputClick(Sender: TObject);
procedure jurusanClick(Sender: TObject);
procedure jbKeyPress(Sender: TObject; var Key: Char);
procedure ubKeyPress(Sender: TObject; var Key: Char);
procedure bclearClick(Sender: TObject);
procedure bexitClick(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
procedure bersih;
procedure aktif;
procedure nonaktif;
{ Public declarations }
end;
var
Pemesanan_Tiket: TPemesanan_Tiket;
implementation
{$R *.dfm}
procedure TPemesanan_Tiket.bersih;
begin
enmr.Text :='';
cnama.Text :='-PILIH-';
jm_berangkat.Text:='';
harga.Text :='';
jb.Text :='';
tb.Text := '';
ub.Text :='';
uk.Text :='';
end;
procedure TPemesanan_Tiket.aktif;
begin
enmr.Enabled := true;
cnama.Enabled := true;
jurusan.Enabled := true;
jm_berangkat.Enabled := true;
harga.Enabled := true;
jb.Enabled := true;
tb.Enabled := true;
ub.Enabled := true;
uk.Enabled := true;
bclear.Enabled := true;
bexit.Enabled := true;
tgl.Enabled := true;
jam.Enabled := true;
end;
Procedure TPemesanan_Tiket.nonaktif;
begin
enmr.Enabled := false;
cnama.Enabled := false;
jurusan.Enabled := false;
jm_berangkat.Enabled := false;
harga.Enabled := false;
jb.Enabled := false;
tb.Enabled := false;
ub.Enabled := false;
uk.Enabled := false;
bclear.Enabled := false;
bexit.Enabled := false;
tgl.Enabled := false;
jam.Enabled := false;
end;
procedure TPemesanan_Tiket.FormActivate(Sender: TObject);
begin
nonaktif;
tgl.Caption := datetostr(date);
jam.Caption := timetostr(time);
end;
procedure TPemesanan_Tiket.binputClick(Sender: TObject);
begin
aktif;
bersih;
enmr.SetFocus;
end;
procedure TPemesanan_Tiket.jurusanClick(Sender: TObject);
begin
case jurusan.ItemIndex of
0: begin
if (cnama.Text ='BRANTAS') then
begin
harga.Text := '250000';
jm_berangkat.Text :='12.45';
end
else
begin
harga.Text :='275000';
jm_berangkat.Text :='22.45';
end
end;
1: begin
if (cnama.Text ='BRANTAS') then
begin
harga.Text := '135000';
jm_berangkat.Text :='12.45';
end
else
begin
harga.Text :='155000';
jm_berangkat.Text :='22.45';
end
end;
2: begin
if (cnama.Text ='BRANTAS') then
begin
harga.Text := '300000';
jm_berangkat.Text :='12.45';
end
else
begin
harga.Text :='335000';
jm_berangkat.Text :='22.45';
end
end;
else
if (cnama.Text ='BRANTAS') then
begin
harga.Text := '260000';
jm_berangkat.Text :='12.45';
end
else
begin
harga.Text :='285000';
jm_berangkat.Text :='22.45';
end
end;
jb.SetFocus;
end;
procedure TPemesanan_Tiket.jbKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
tb.Text := floattostr(strtoint(jb.Text) * strtoint(harga.Text));
end;
procedure TPemesanan_Tiket.ubKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
uk.Text := floattostr(strtoint(ub.Text) - strtofloat(tb.Text));
end;
procedure TPemesanan_Tiket.bclearClick(Sender: TObject);
begin
bersih;
end;
procedure TPemesanan_Tiket.bexitClick(Sender: TObject);
begin
if (application.MessageBox('Anda Yakin Akan Keluar dari Form ?','KONFIRMASI', mb_yesno + mb_IconQuestion )=IdYes) then
close;
end;
procedure TPemesanan_Tiket.Timer1Timer(Sender: TObject);
begin
tgl.Caption := datetostr(date);
jam.Caption := timetostr(time);
end;
end.