- Video
Ketentuan Soal :
Gunakan perintah “if” untuk mencari nama dokter, spesialis dan biaya ketika kode dokter dipilih (klik).
Kode Dokter
|
Nama Dokter
|
Spesialis
|
Biaya Periksa
|
DRD01
|
Dr Oka
|
Penyakit Dalam
|
2.000.000
|
DRJ02
|
Dr Yondra
|
Gangguan Jiwa
|
150.000
|
DRM03
|
Dr Wulan
|
Mata
|
1.000.000
|
Gunakan perintah “if” untuk mencari nama obat dan harga obat ketika kode obat diinput lalu di enter..
Kode Obat
|
Nama Obat
|
Harga Obat
|
B001
|
Paracetamol
|
10.000
|
B002
|
Paratusin
|
12.000
|
B003
|
Amoxilin
|
15.000
|
Total bayar didapat dari harga Obat + Harga Dokter (buat fungsi untuk menghitung total.).
Uang bayar diinput, ketika di enter maka uang kembali keluar.
Tombol bersih untuk membersihkan seluruh objek (buat procedure bersih).
Tombol keluar untuk keluar dari form (harus menggunakan message box).- Form Awal
- Form Berjalan
- Listing Code
unit Quis;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls;
type
TForm1 = class(TForm)
Image1: TImage;
Ltanggal: TLabel;
Label2: TLabel;
Label13: TLabel;
Label14: TLabel;
Panel1: TPanel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
CMBkddokter: TComboBox;
Enmdokter: TEdit;
Espesialis: TEdit;
Ebiaya: TEdit;
Pembayaran: TGroupBox;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Etotal: TEdit;
Eppn: TEdit;
Etotbar: TEdit;
BBhitung: TBitBtn;
GroupBox1: TGroupBox;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Ekdobat: TEdit;
Enmobat: TEdit;
Ehrgobat: TEdit;
Euangbyr: TEdit;
Euangkmbli: TEdit;
BBtotal: TBitBtn;
BBEXIT: TBitBtn;
Ljam: TLabel;
Timer1: TTimer;
Lnama: TLabel;
Lnim: TLabel;
Lkeles: TLabel;
Timer2: TTimer;
procedure FormCreate(Sender: TObject);
procedure CMBkddokterChange(Sender: TObject);
procedure EkdobatKeyPress(Sender: TObject; var Key: Char);
procedure EkdobatClick(Sender: TObject);
procedure BBhitungClick(Sender: TObject);
procedure EuangbyrKeyPress(Sender: TObject; var Key: Char);
procedure BBEXITClick(Sender: TObject);
procedure BBtotalClick(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure bersih;
procedure hitung;
end;
var
Form1: TForm1;
biayaP,biayaO,total,PPN,totbar,uangbar,uangkem : real ;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
BorderStyle:=bsDialog;
CMBkddokter.Items.add ('DRD01');
CMBkddokter.items.add ('DRJ02');
CMBkddokter.items.Add('DRM03');
CMBkddokter.Text:= 'Pilih Kode';
Ekdobat.Text:='Pilih Kode';
Enmdokter.Enabled:=False;
Espesialis.Enabled:=False;
Ebiaya.Enabled:=false;
Enmobat.Enabled:=False;
Ehrgobat.enabled:=false;
end;
procedure TForm1.CMBkddokterChange(Sender: TObject);
begin
if CMBkddokter.Text='DRD01' then
begin
Enmdokter.Text := 'Dr Oka' ;
ebiaya.Text := '2000000';
espesialis.Text := 'Penyakit Dalam' ;
end
else if CMBkddokter.Text='DRJ02' then
begin
Enmdokter.Text:= 'Dr Yondra';
Ebiaya.Text := '150000' ;
Espesialis.Text := 'Gangguan Jiwa';
end
else if CMBkddokter.Text='DRM03' then
begin
enmdokter.Text := 'Dr Wulan';
ebiaya.Text := '1000000' ;
Espesialis.Text := 'Mata';
end ;
end;
procedure TForm1.EkdobatKeyPress(Sender: TObject; var Key: Char);
begin
if (key=#13) then
if (Ekdobat.Text='B001') or (Ekdobat.Text='b001') then
begin
Enmobat.Text:= 'Paracetamol';
Ehrgobat.Text:= '10000';
BBhitung.SetFocus;
end
else if (Ekdobat.Text='B002') or (Ekdobat.Text='b002')then
begin
Enmobat.Text :='Paratusin';
Ehrgobat.Text:='12000';
BBhitung.SetFocus;
end
else if (Ekdobat.Text='B003') or (Ekdobat.Text='b003') then
begin
Enmobat.Text:='Amoxilin';
Ehrgobat.Text:='15000';
BBhitung.SetFocus;
end;
end;
procedure TForm1.EkdobatClick(Sender: TObject);
begin
Ekdobat.Text:='';
end;
procedure TForm1.BBhitungClick(Sender: TObject);
begin
hitung;
end;
procedure TForm1.EuangbyrKeyPress(Sender: TObject; var Key: Char);
begin
if (key=#13) then
uangbar:= StrToInt(Euangbyr.Text);
uangkem:= uangbar-totbar ;
Euangkmbli.Text:= Format('%m',[uangkem]) ;
Etotbar.Text:= Format('%m',[totbar]);
end;
procedure TForm1.BBEXITClick(Sender: TObject);
begin
if (Application.MessageBox('anda ingin keluar dari program?','konfirmasi',MB_YESNO or MB_ICONQUESTION or MB_DEFBUTTON1)= IDYES) then close;
end;
procedure TForm1.BBtotalClick(Sender: TObject);
begin
bersih
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Ltanggal.Caption:=FormatDateTime('dd/mm/yyyy',date);
Ljam.Caption:=FormatDateTime('hh:mm:ss',time);
end;
procedure TForm1.Timer2Timer(Sender: TObject);
var
a1,a2,a3,b1,b2,b3,c1,c2,c3 : string;
begin
a1:= Lnama.Caption;
a2:= Lnim.Caption;
a3:= Lkeles.Caption;
b1:= copy(a1,1,1);
c1:= copy (a1,2,length(a1));
b2:= copy (a2,2,1);
c2:= copy (a2,2,length(a2));
b3:= copy (a3,1,1);
c3:= copy (a3,2,length(a3));
Lnama.Caption:= c1+b1;
Lnim.Caption:=c2+b2;
Lkeles.Caption:=c3+b3;
end;
procedure TForm1.bersih;
begin
CMBkddokter.Text:='Kode Dokter';
Enmdokter.Clear;
Espesialis.clear;
Ebiaya.Clear;
Etotal.Clear;
Eppn.Clear;
Etotbar.Clear;
Ekdobat.Text:= 'Kode Obat';
Enmobat.Clear;
Ehrgobat.Clear;
Euangbyr.Clear;
Euangkmbli.Clear;
end;
procedure TForm1.hitung;
begin
biayaP:= StrToInt(Ebiaya.Text);
biayaO:= StrToInt(Ehrgobat.Text);
total:= biayaP + biayaO ;
Etotal.Text:= Format('%m',[total]);
PPN:= (total * 0.1) ;
Eppn.Text:= Format('%m',[ppn]) ;
totbar:= total + PPN;
Etotbar.Text:= Format('%m',[totbar]);
euangbyr.setfocus;
end;
end.
mas ppn rumus nya apa mas maaf enggak ngerti mas
BalasHapus