2. Buat Tabel
Tabel : Kendaraan
Field | Type | Size | Key |
Kd_kendaraan | A | 5 | * |
Jenis | A | 20 | |
Harga | N |
Kd_kendaraan | Jenis | Harga |
KM001 | Mobil | 1500000 |
KM002 | Motor | 800000 |
Field | Type | Size | Key |
No_kembali | A | 5 | * |
Tgl_kembali | D | ||
Kd_kendaraan | A | 5 | |
Lama | N | ||
Status | A | 30 | |
Denda | N | ||
Biaya_status | N | ||
Total_biaya | N |
Buat Form: F_pengembalian.pass
3. Ketentuan
- Saat form running,semua editbox bersih dan non aktif,
- Klik ADD,maka no kembali dan tanggal kembali tampil.
- Input Kode kendaraan,saat di ENTER maka jenis dan harga tampil
- Jika Lama hari lebih dari 3 maka denda 1000 dikali dengan kelebihan hari
- Jika status Rusak,maka biaya status 350.000
- Status Hilang maka biaya status sebesar harga * 10
- Jika utuh maka biaya status 0.
4. Input uang bayar,saat di ENTER maka Uang Kembali tampil.
Listing :
unit FORM;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBTables, Grids, DBGrids, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
eNoKem: TEdit;
eTgl: TEdit;
eKode: TEdit;
cMobil: TCheckBox;
cMotor: TCheckBox;
eHarga: TEdit;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
eLama: TEdit;
rRusak: TRadioButton;
rHilang: TRadioButton;
rUtuh: TRadioButton;
eSub: TEdit;
eDenda: TEdit;
eBy_status: TEdit;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
eTotal: TEdit;
eUbay: TEdit;
eUkem: TEdit;
bAdd: TButton;
bSave: TButton;
bExit: TButton;
DBGrid1: TDBGrid;
tb_kendaraan: TTable;
tb_kembalian: TTable;
ds_kendaraan: TDataSource;
ds_Kembali: TDataSource;
procedure FormActivate(Sender: TObject);
procedure bAddClick(Sender: TObject);
procedure eKodeKeyPress(Sender: TObject; var Key: Char);
procedure eLamaKeyPress(Sender: TObject; var Key: Char);
procedure rRusakClick(Sender: TObject);
procedure rHilangClick(Sender: TObject);
procedure rUtuhClick(Sender: TObject);
procedure eUbayKeyPress(Sender: TObject; var Key: Char);
procedure bSaveClick(Sender: TObject);
procedure bExitClick(Sender: TObject);
private
{ Private declarations }
public
procedure aktif;
procedure nonaktif;
procedure bersih;
procedure tampil;
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure tform1.bersih;
begin
eNoKem.clear;
eTgl.clear;
eKode.clear;
cMobil.checked:=false;
cMotor.checked:=false;
eHarga.clear;
eLama.clear;
eSub.clear;
eDenda.clear;
eBy_status.clear;
eTotal.clear;
eUbay.clear;
eUkem.clear;
rRusak.checked:=false;
rHilang.checked:=false;
rUtuh.checked:=false;
end;
procedure tform1.aktif;
begin
eNoKem.enabled:=true;
eTgl.enabled:=true;
eKode.enabled:=true;
cMobil.enabled:=true;
cMotor.enabled:=true;
eHarga.enabled:=true;
eLama.enabled:=true;
eSub.enabled:=true;
eDenda.enabled:=true;
eBy_status.Enabled:=true;
eTotal.Enabled:=true;
eUbay.Enabled:=true;
eUkem.Enabled:=true;
rRusak.Enabled:=true;
rHilang.Enabled:=true;
rUtuh.Enabled:=true;
end;
procedure tform1.nonaktif;
begin
eNoKem.enabled:=false;
eTgl.enabled:=false;
eKode.enabled:=false;
cMobil.enabled:=false;
cMotor.enabled:=false;
eHarga.enabled:=false;
eLama.enabled:=false;
eSub.enabled:=false;
eDenda.enabled:=false;
eBy_status.Enabled:=false;
eTotal.Enabled:=false;
eUbay.Enabled:=false;
eUkem.Enabled:=false;
rRusak.Enabled:=false;
rHilang.Enabled:=false;
rUtuh.Enabled:=false;
end;
procedure tform1.tampil;
begin
eHarga.Text:=tb_kendaraan['harga'];
if tb_kendaraan['JENIS']='MOBIL' then
begin
cMobil.Checked:=true;
cMotor.Checked:=false;
end
else if tb_kendaraan['JENIS']='MOTOR' then
begin
cMobil.Checked:=false;
cMotor.Checked:=true;
end
else
begin
cMobil.Checked:=false;
cMotor.Checked:=false;
end;
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
bersih;
nonaktif;
end;
procedure TForm1.bAddClick(Sender: TObject);
var no:integer;
begin
no:=tb_kembalian.RecordCount+1;
eNoKem.Text:='DN' + '00'+(inttostr(no));
eTgl.Text:=datetostr(date);
ekode.Enabled:=true;
eKode.SetFocus;
end;
procedure TForm1.eKodeKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
if tb_kendaraan.FindKey([eKode.Text]) then
begin
tampil;
elama.Enabled:=true;
eLama.SetFocus;
end
else
begin
ShowMessage('Kode Tidak Ada');
eKode.Clear;
eKode.SetFocus;
end;
end;
end;
procedure TForm1.eLamaKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
if strtofloat(eLama.Text)>3 then
eDenda.Text:=floattostr((StrToInt(elama.Text)-3)*1000)
else
eDenda.Text:='0';
rRusak.Enabled:=true;
rHilang.Enabled:=true;
rUtuh.Enabled:=true;
end;
end;
procedure TForm1.rRusakClick(Sender: TObject);
begin
eBy_status.Text:='350000';
esub.Text:=floattostr(strtofloat(eHarga.Text)*strtofloat(eLama.Text));
eTotal.Text:=floattostr(StrToFloat(eSub.Text)+strtofloat(edenda.Text)+strtofloat(eBy_status.Text));
eubay.Enabled:=true;
eubay.SetFocus;
end;
procedure TForm1.rHilangClick(Sender: TObject);
begin
eBy_status.Text:=floattostr(StrToFloat(eHarga.Text)*10);
esub.Text:=floattostr(strtofloat(eHarga.Text)*strtofloat(eLama.Text));
eTotal.Text:=floattostr(StrToFloat(eSub.Text)+strtofloat(edenda.Text)+strtofloat(eBy_status.Text));
eubay.Enabled:=true;
eubay.SetFocus;
end;
procedure TForm1.rUtuhClick(Sender: TObject);
begin
eBy_status.Text:='0';
esub.Text:=floattostr(strtofloat(eHarga.Text)*strtofloat(eLama.Text));
eTotal.Text:=floattostr(StrToFloat(eSub.Text)+strtofloat(edenda.Text)+strtofloat(eBy_status.Text));
eubay.Enabled:=true;
eubay.SetFocus;
end;
procedure TForm1.eUbayKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
eUkem.Text:=floattostr(StrToFloat(eUbay.Text)-StrToFloat(eTotal.Text));
end;
procedure TForm1.bSaveClick(Sender: TObject);
begin
tb_kembalian.Append;
tb_kembalian['no_kembali']:=eNoKem.Text;
tb_kembalian['tgl']:=date;
tb_kembalian['kd_kendaraan']:=eKode.Text;
tb_kembalian['lama']:=eLama.Text;
if rRusak.Checked=true then
tb_kembalian['status']:='RUSAK'
else if rHilang.Checked=true then
tb_kembalian['status']:='HILANG'
else
tb_kembalian['status']:='UTUH';
tb_kembalian['denda']:=eDenda.Text;
tb_kembalian['by_status']:=eBy_status.Text;
tb_kembalian['totbay']:=eTotal.Text;
tb_kembalian.Post;
Application.MessageBox('Data Berhasil Disimpan','Simpan',MB_ICONINFORMATION);
bersih;
nonaktif;
end;
procedure TForm1.bExitClick(Sender: TObject);
begin
if (Application.MessageBox('Keluar aplikasi???','Pesan',MB_ICONQUESTION+MB_OKCANCEL)=idok)then
close;
end;
end.
Download Source code silahkan klik gambar dibawah
Download
0 Reply :
Posting Komentar
Jika ada pertanyaan atau request,Komentar pada tab blogger akan lebih memudahkan saya untuk membalasnya karena lebih mudah melakukan pengecekan komentar.