Coding/Listing :
unit Data_Transaksi;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, DBTables, ExtCtrls, Grids, DBGrids, StrUtils;
type
TFTransaksi = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
eno: TEdit;
etanggal: TEdit;
GroupBox1: TGroupBox;
Label4: TLabel;
Label5: TLabel;
enmcustomer: TEdit;
GroupBox2: TGroupBox;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
enmkereta: TEdit;
ejurusan: TEdit;
ekelas: TEdit;
eharga: TEdit;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
ejumlah: TEdit;
etotal: TEdit;
ebayar: TEdit;
ekembali: TEdit;
binput: TButton;
bsave: TButton;
bcancel: TButton;
bexit: TButton;
Timer1: TTimer;
DataSource1: TDataSource;
tabel_transaksi: TTable;
DBGrid1: TDBGrid;
tabel_tiket: TTable;
tabel_customer: TTable;
ekdtiket: TEdit;
ekdcustomer: TEdit;
procedure FormActivate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure binputClick(Sender: TObject);
procedure ekdtiketKeyPress(Sender: TObject; var Key: Char);
procedure ekdcustomerKeyPress(Sender: TObject; var Key: Char);
procedure bsaveClick(Sender: TObject);
procedure bcancelClick(Sender: TObject);
procedure ejumlahKeyPress(Sender: TObject; var Key: Char);
procedure ebayarKeyPress(Sender: TObject; var Key: Char);
procedure bexitClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure aktif;
procedure nonaktif;
procedure bersih;
procedure nomor;
end;
var
FTransaksi: TFTransaksi;
implementation
uses Menu_Utama;
{$R *.dfm}
procedure TFTransaksi.aktif;
begin
eno.Enabled := true;
etanggal.Enabled := true;
ekdtiket.Enabled := true;
enmkereta.Enabled := true;
ejurusan.Enabled := true;
ekelas.Enabled := true;
eharga.Enabled := true;
ekdcustomer.Enabled := true;
enmcustomer.Enabled := true;
ejumlah.Enabled := true;
etotal.Enabled := true;
ebayar.Enabled := true;
ekembali.Enabled := true;
end;
procedure TFTransaksi.nonaktif;
begin
eno.Enabled := false;
etanggal.Enabled := false;
ekdtiket.Enabled := false;
enmkereta.Enabled := false;
ejurusan.Enabled := false;
ekelas.Enabled := false;
eharga.Enabled := false;
ekdcustomer.Enabled := false;
enmcustomer.Enabled := false;
ejumlah.Enabled := false;
etotal.Enabled := false;
ebayar.Enabled := false;
ekembali.Enabled := false;
end;
procedure TFTransaksi.bersih;
begin
eno.Text := '';
ekdtiket.Text := '';
enmkereta.Text := '';
ejurusan.Text := '';
ekelas.Text := '';
eharga.Text := '0';
ekdcustomer.Text := '';
enmcustomer.Text := '';
ejumlah.Text := '0';
etotal.Text := '0';
ebayar.Text := '0';
ekembali.Text := '0';
end;
procedure TFTransaksi.nomor;
var c:string;
a:integer;
begin
if tabel_transaksi.RecordCount = 0 then
begin
eno.Text := '0001';
exit;
end
else
begin
tabel_transaksi.Last;
c:=tabel_transaksi['Notrans'];
a:=strtoint(c)+1;
if a<10 then
eno.Text := '000'+(inttostr(a))
else if a<100 then
eno.Text := '00'+(inttostr(a))
else if a<1000 then
eno.Text := '0'+(inttostr(a))
else
eno.Text := inttostr(a);
end;
end;
procedure TFTransaksi.FormActivate(Sender: TObject);
begin
nonaktif;
bersih;
binput.Enabled := true;
bsave.Enabled := true;
bcancel.Enabled := true;
bexit.Enabled := true;
binput.SetFocus;
end;
procedure TFTransaksi.Timer1Timer(Sender: TObject);
begin
etanggal.Text := formatdatetime('dd-mmmm-yyyy', now());
etanggal.Enabled := false;
end;
procedure TFTransaksi.binputClick(Sender: TObject);
begin
aktif;
bersih;
nomor;
eno.Enabled := false;
etanggal.Enabled := false;
ekdtiket.SetFocus;
binput.Enabled := false;
bsave.Enabled := true;
bcancel.Enabled := true;
bexit.Enabled := true;
end;
procedure TFTransaksi.ekdtiketKeyPress(Sender: TObject; var Key: Char);
begin
ekdtiket.CharCase := ecUpperCase;
if key = #13 then
begin
if tabel_tiket.FindKey([ekdtiket.Text])then
enmkereta.Text := tabel_tiket['Nmkereta'];
ejurusan.Text := tabel_tiket['Jurusan'];
ekelas.Text := tabel_tiket['Kelas'];
eharga.Text := tabel_tiket['Harga'];
ekdcustomer.SetFocus;
end;
end;
procedure TFTransaksi.ekdcustomerKeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then
begin
if tabel_customer.FindKey([ekdcustomer.Text]) then
enmcustomer.Text := tabel_customer['Nm_customer'];
ejumlah.SetFocus;
end;
end;
procedure TFTransaksi.bsaveClick(Sender: TObject);
begin
tabel_transaksi.Append;
tabel_transaksi['Notrans']:= eno.Text;
tabel_transaksi['Tanggal_transaksi']:= etanggal.Text;
tabel_transaksi['Kd_customer']:= ekdcustomer.Text;
tabel_transaksi['Kd_tiket']:= ekdtiket.Text;
tabel_transaksi['Nm_kereta']:= enmkereta.Text;
tabel_transaksi['Jurusan']:= ejurusan.Text;
tabel_transaksi['Kelas']:= ekelas.Text;
tabel_transaksi['Harga']:= eharga.Text;
tabel_transaksi['Jumlah']:= ejumlah.Text;
tabel_transaksi['Total']:= etotal.Text;
showmessage('Data Telah Tersimpan!');
tabel_transaksi.Post;
tabel_transaksi.Last;
nonaktif;
end;
procedure TFTransaksi.bcancelClick(Sender: TObject);
begin
if(application.MessageBox('Yakin Ingin Membatalkan Penginputan..?!','Question',4+32)=6)then
begin
nonaktif;
bersih;
end;
binput.Enabled := true;
bsave.Enabled := false;
bcancel.Enabled := false;
bexit.Enabled := true;
end;
procedure TFTransaksi.ejumlahKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
etotal.Text := floattostr(strtofloat(ejumlah.Text) * strtofloat(eharga.Text));
etotal.Enabled := false;
ebayar.SetFocus;
end;
end;
procedure TFTransaksi.ebayarKeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then
begin
ekembali.Text := floattostr(strtofloat(ebayar.Text)-strtofloat(etotal.Text));
nonaktif;
bsave.SetFocus;
end;
end;
procedure TFTransaksi.bexitClick(Sender: TObject);
begin
if(application.MessageBox('Yakin Ingin Kembali Menuju Menu Utama..?!','Question',4+32)=6)then
begin
FTransaksi.Hide;
FMenuUtama.show;
end;
end;
end.
Update Contact :
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email : Fajarudinsidik@gmail.com
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email: Fajarudinsidik@gmail.com
atau Kirimkan Private messanger melalui email dengan klik tombol order dibawah ini :