Coding/Listing :
public
procedure tampil;
procedure bersih;
procedure nonaktif;
procedure aktif;
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.aktif;
begin
ekdbarang.Enabled := true;
enmbarang.Enabled := true;
ebeli.Enabled := true;
ejual.Enabled := true;
estok.Enabled := true;
end;
procedure TForm1.nonaktif;
begin
ekdbarang.Enabled := false;
enmbarang.Enabled := false;
ebeli.Enabled := false;
ejual.Enabled := false;
estok.Enabled := false;
end;
procedure TForm1.bersih;
begin
ekdbarang.Text := '';
enmbarang.Text := '';
ebeli.Text := '0';
ejual.Text := '0';
estok.Text := '0';
end;
procedure TForm1.tampil;
begin
ekdbarang.Text := Tabel1['Kdbarang']; enmbarang.Text := Tabel1['Nmbarang']; ebeli.Text := floattostr(Tabel1['Hrgbeli']); ejual.Text := floattostr(Tabel1['Hrgjual']); estok.Text := floattostr(Tabel1['Stok']);
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
tampil;
nonaktif;
bsimpan.Enabled := false;
end;
procedure TForm1.btambahClick(Sender: TObject);
begin
aktif;
bersih;
bsimpan.Enabled := true;
ekdbarang.SetFocus;
end;
procedure TForm1.ekdbarangKeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then
if Tabel1.FindKey([ekdbarang.Text]) then
begin
showmessage('Data Sudah Ada');
tampil;
nonaktif;
exit;
end
else
begin
if(application.MessageBox('Data Tidak Ada, Anda Ingin Menambah Data..?!','Pesan', 4+32)=6)then
begin
aktif;
ekdbarang.Enabled := false;
enmbarang.SetFocus;
end
end
end;
procedure TForm1.bsimpanClick(Sender: TObject);
begin
Tabel1.Append;
Tabel1['Kdbarang']:= ekdbarang.Text;
Tabel1['Nmbarang']:= enmbarang.Text;
Tabel1['Hrgbeli']:= strtofloat(ebeli.Text);
Tabel1['Hrgjual']:= strtofloat(ejual.Text);
Tabel1['Stok']:= strtofloat(estok.Text);
nonaktif;
end;
procedure TForm1.bbatalClick(Sender: TObject);
begin
bersih;
nonaktif;
Tabel1.First;
tampil;
end;
procedure TForm1.DBGrid1CellClick(Column: TColumn);
begin
tampil;
end;
procedure TForm1.bexitClick(Sender: TObject);
begin
if(application.MessageBox('Yakin Ingin Keluar..?!','Pesan',4+32)=6)then
Tabel1.Close;
Close;
end;
procedure TForm1.bawalClick(Sender: TObject);
begin
Tabel1.First;
showmessage('Sudah Diawal Record!');
tampil;
end;
procedure TForm1.bakhirClick(Sender: TObject);
begin
Tabel1.Last;
showmessage('Sudah Diakhir Record!');
tampil;
end;
procedure TForm1.bsebelumClick(Sender: TObject);
begin
Tabel1.Prior;
tampil;
if Tabel1.Bof then
showmessage('Sudah Diawal Record!');
end;
procedure TForm1.bsesudahClick(Sender: TObject);
begin
Tabel1.Next;
tampil;
if Tabel1.Eof then
showmessage('Sudah Diakhir Record!');
end;
end.
ini ko masih debug...
BalasHapusbikin tabelnya 1/2
pake table transaksinya ga
makasih yaaa informasinya...
Hapuskga pke transaksi ini hanya input barang biasa saja..
kalau masalah debug nanti di perbaiki.. :D