Rabu, 20 April 2011

latihan Quis






procedure TForm1.ckodeClick(Sender: TObject);
begin
if ckode.Text ='LNV' then
begin
enama.Text :='Lenovo Pentium4';
eharga.Text :='3000000';
end
else
begin
enama.Text :='Acer Pentium4';
eharga.Text :='3500000';
end;
end;

procedure TForm1.rcorei3Click(Sender: TObject);
begin
if rcorei3.Checked =true then
etambahan.Text :='500000'

end;

procedure TForm1.rcorei5Click(Sender: TObject);
begin
if rcorei5.Checked =true then
etambahan.Text :='1000000'

end;

procedure TForm1.chkipasClick(Sender: TObject);
begin
if chkipas.Checked =true then
ekipas.Text :='30000'
else
ekipas.Text :='0' ;
ejumbel.SetFocus
end;

procedure TForm1.ejumbelKeyPress(Sender: TObject; var Key: Char);
var a,b,c,d,total,diskon:real;
begin
if key=#13 then
begin
a:=strtofloat(eharga.Text);
b:=strtofloat(etambahan.Text);
c:=strtofloat(ekipas.Text);
d:=strtofloat(ejumbel.Text);
total:=(a*d)+(b+c);
etotal.Text :=floattostr(total);
if ejumbel.Text >= '3' then
begin
diskon :=(a*d)*0.1;
ediskon.Text :=floattostr(diskon);
end
else
if ejumbel.Text > '1' then
begin
diskon:=(a*d)*0.05;
ediskon.Text :=floattostr(diskon);
end
else
begin
diskon:=0;
ediskon.Text :=floattostr(diskon);
end;
ejumbay.Text :=floattostr(total -diskon );
end;
end;



procedure TForm1.binputClick(Sender: TObject);
begin
etgl.Text :=datetostr(date);
ckode.Text :='';
enama.Text :='';
eharga.Text :='0';
ekipas.Text :='0';
etambahan.Text :='0';
ejumbel.Text :='0';
etotal.Text :='0';
ediskon.Text :='0' ;
ejumbay.Text :='0' ;
rcorei3.Checked :=false ;
rcorei5.Checked :=false  ;
chkipas.Checked :=false  ;
end;

procedure TForm1.bkeluarClick(Sender: TObject);
begin
if(Application.MessageBox('Yakin Ingin Keluar?','informasi',mb_yesno)=idyes)then
close;

end;

end.

Jumat, 08 April 2011


listing Program
procedure TForm1.FormCreate(Sender: TObject);
begin
cpener.Items.Add('GA733');
cpener.Items.Add('MP373');
cpener.Items.Add('BT202');
cpener.Items.Add('LI909');
ejtiket.Text :='0';
ehrg1.Text :='0';
ehrg2.Text :='0';
ejml1.Text :='0';
ejml2.Text :='0';
etharga1.Text :='0';
etharga2.Text :='0';
etotbay.Text :='0';
ebayar.Text :='0';
ekembali.Text :='0';
//dateseparator:='-';u pemisah antara tgl.bln&thn
ShortDateFormat :='dd-mmmm-yyyy';
etgl.Text :=datetostr(date);

end;

procedure TForm1.cpenerClick(Sender: TObject);
begin
if cpener.Text ='GA733' then
enmpswt.Text :='GARUDA AIR'
else
if cpener.Text ='MP373' then
enmpswt.Text :='MERPATI AIR'
else
if cpener.Text ='BT202' then
enmpswt.Text :='BATAVIA AIR'
else
enmpswt.Text :='LION AIR'
end;

procedure TForm1.cb1Click(Sender: TObject);
begin
if cb1.Checked =true then
 begin
 if cpener.Text ='GA733' then
 ehrg1.Text :='560000'
 else
 if cpener.Text ='MP373' then
 ehrg1.Text :='450000'
 else
 if cpener.Text ='BT202' then
 ehrg1.Text :='350000'
 else
 ehrg1.Text :='4500000'
 end
 else
 begin
 cb1.Checked :=false;
 ehrg1.Text :='0';
 end ;
 ejml1.SetFocus ;
end;

procedure TForm1.cb2Click(Sender: TObject);
var a,b:real;
begin
if cb2.Checked =true then
 begin
 a:=strtofloat(ehrg1.Text );
 b:=(3/100)*a;
 ehrg2.Text :=floattostr(b);
 end
else
 begin
 cb2.Checked :=false;
 ehrg2.Text :='0';
 end;
ejml2.SetFocus ;
end;

procedure TForm1.bhitungClick(Sender: TObject);
begin
etharga1.Text :=floattostr(strtofloat(ehrg1.Text )*strtofloat(ejml1.Text ));
etharga2.Text :=floattostr(strtofloat(ehrg2.Text )*strtofloat(ejml2.Text ));
ejtiket.Text :=floattostr(strtofloat(ejml2.Text )+strtofloat(ejml1.Text ));
etotbay.Text :=floattostr(strtofloat(etharga2.Text )+strtofloat(etharga1.Text ));
ebayar.SetFocus ;

end;

procedure TForm1.FormActivate(Sender: TObject);
begin
ehrg1.Enabled :=false;
etharga1.Enabled :=false;
ehrg2.Enabled :=false;
etharga2.Enabled :=false;
ejtiket.Enabled :=false;
etotbay.Enabled :=false;
ekembali.Enabled :=false;
enmpswt.Enabled :=false;

end;

procedure TForm1.bbersihClick(Sender: TObject);
begin
enmpembeli.Text :='';
cpener.Text :='';
enmpswt.Text :='';
cb1.Checked :=false;
cb2.Checked :=false;
ejtiket.Text :='0';
ehrg1.Text :='0';
ehrg2.Text :='0';
ejml1.Text :='0';
ejml2.Text :='0';
etharga1.Text :='0';
etharga2.Text :='0';
etotbay.Text :='0';
ebayar.Text :='0';
ekembali.Text :='0';
enmpembeli.SetFocus ;

end;

procedure TForm1.bcloseClick(Sender: TObject);
begin
if(Application.MessageBox('anda yakin akan keluar','informasi',mb_yesno+mb_iconwarning )=idyes)then
close

end;

procedure TForm1.ebayarChange(Sender: TObject);
begin
ekembali.Text :=floattostr(strtofloat(ebayar.Text )-strtofloat(etotbay.Text ));

end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
ejam.Text :=timetostr(time);
end;

end.