Coding/Listing :
public
{ Public declarations }
procedure aktif;
procedure nonaktif;
procedure bersih;
procedure tampil;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.aktif;
begin
eid.Enabled := true;
enama.Enabled := true;
epass.Enabled := true;
ealamat.Enabled := true;
etelepon.Enabled := true;
rbadmin.Checked := true;
rbkasir.Checked := true;
end;
procedure TForm1.nonaktif;
begin
eid.Enabled := false;
enama.Enabled := false;
epass.Enabled := false;
ealamat.Enabled := false;
etelepon.Enabled := false;
rbadmin.Checked := false;
rbkasir.Checked := false;
end;
procedure TForm1.bersih;
begin
rbadmin.Checked := false;
rbkasir.Checked := false;
eid.Text := '';
enama.Text := '';
epass.Text := '';
ealamat.Text := '';
etelepon.Text := '';
end;
procedure TForm1.tampil;
begin
if Tabel1['Level'] = rbadmin.Caption then
rbadmin.Checked := true
else
rbkasir.Checked := true;
eid.Text := Tabel1['Id_user'];
enama.Text := Tabel1['Nm_user'];
epass.Text := Tabel1['Password'];
ealamat.Text := Tabel1['Alamat'];
etelepon.Text := Tabel1['Telp'];
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
bersih;
nonaktif;
badd.Enabled := true;
bsave.Enabled := false;
bedit.Enabled := false;
bcancel.Enabled := false;
bdelete.Enabled := false;
bexit.Enabled := true;
badd.SetFocus;
end;
procedure TForm1.beditClick(Sender: TObject);
begin
aktif;
tampil;
eid.Enabled := false;
enama.SetFocus;
bsave.Caption := '&Update';
badd.Enabled := true;
bedit.Enabled := false;
bsave.Enabled := true;
bcancel.Enabled := true;
bexit.Enabled := true;
bdelete.Enabled := true;
end;
procedure TForm1.bsaveClick(Sender: TObject);
begin
if bsave.Caption = '&Save' then
begin
Tabel1.Append;
Tabel1['Id_user'] := eid.Text;
Tabel1['Nm_user'] := enama.Text;
Tabel1['Password'] := epass.Text;
Tabel1['Alamat'] := ealamat.Text;
Tabel1['Telp'] := etelepon.Text;
if rbadmin.Checked = true then
Tabel1['Level'] := rbadmin.Caption
else
Tabel1['Level'] := rbkasir.Caption;
showmessage('Data Telah Tersimpan');
Tabel1.Post;
Tabel1.Next;
nonaktif;
end
else
begin
Tabel1.Edit;
Tabel1['Id_user'] := eid.Text;
Tabel1['Nm_user'] := enama.Text;
Tabel1['Password'] := epass.Text;
Tabel1['Alamat'] := ealamat.Text;
Tabel1['Telp'] := etelepon.Text;
if rbadmin.Checked = true then
Tabel1['Level'] := rbadmin.Caption
else
Tabel1['Level'] := rbkasir.Caption;
Tabel1.Post;
nonaktif;
showmessage('Data Telah Diperbaharui');
bsave.Enabled := true;
bsave.Caption := '&Save';
bsave.Enabled := false;
badd.Enabled := true;
bdelete.Enabled := true;
bcancel.Enabled := true;
bexit.Enabled := true;
bedit.Enabled := true;
end;
end;
procedure TForm1.bcancelClick(Sender: TObject);
begin
if(application.MessageBox('Yakin Ingin Membatalkan Penginputan..?!','Quesiton',4+32)=6)then
nonaktif;
bersih;
Tabel1.First;
badd.Enabled := true;
bsave.Enabled := false;
bedit.Enabled := false;
bdelete.Enabled := false;
bcancel.Enabled := false;
bexit.Enabled := true;
bsave.Caption := '&Save';
end;
procedure TForm1.bdeleteClick(Sender: TObject);
var del:string;
begin
Tabel1.IndexName :='';
del:= (Inputbox('Pencarian','Masukan ID Yang Mau Dihapus',''));
if Tabel1.FindKey([del]) then
begin
bersih;
nonaktif;
Tabel1.Delete;
end
else
showmessage('Data Tidak DiTemukan');
badd.Enabled := true;
bsave.Enabled := false;
bedit.Enabled := true;
bdelete.Enabled := true;
bcancel.Enabled := true;
bdelete.Enabled := true;
bsave.Caption := '&Save';
end;
procedure TForm1.baddClick(Sender: TObject);
begin
aktif;
bersih;
eid.SetFocus;
badd.Enabled := false;
bdelete.Enabled := true;
bsave.Enabled := true;
bedit.Enabled := true;
bcancel.Enabled := true;
bexit.Enabled := true;
bsave.Caption := '&Save';
end;
procedure TForm1.bexitClick(Sender: TObject);
begin
if(application.MessageBox('Yakin Ingin Keluar Dari Program Ini..?!','Quesiton',4+32)=6)then
Tabel1.Close;
close;
end;
end.
0 komentar:
Posting Komentar