1. Pada form data dosen
var
frmdosen:
Tfrmdosen;
implementation
uses Unit2;
{$R *.dfm}
Button out
procedure Tfrmdosen.btnoutClick(Sender: TObject);
begin
Close ;
end;
button tambah
procedure Tfrmdosen.btntambahClick(Sender: TObject);
begin
qrydosen.Append;
frminput.showmodal ;
frminput.caption := 'Input Data';
if frminput.modalresult = mryes then
begin
qrydosen.Post ;
end
else
qrydosen.Cancel;
end;
button ubah
procedure Tfrmdosen.btnubahClick(Sender: TObject);
begin
qrydosen.Edit;
frminput.caption := 'ubah data';
frminput.ShowModal;
if frminput.modalresult=mryes then
begin
qrydosen.Post;
end
else
qrydosen.Cancel;
end;
button hapus
procedure Tfrmdosen.btnhapusClick(Sender: TObject);
begin
if MessageDlg('hapus record aktif?',mtConfirmation,[mbYes,mbNo],0)=mryes
then
qrydosen.Delete;
end;
button refresh
procedure Tfrmdosen.btnrefreshClick(Sender: TObject);
begin
qrydosen.Refresh;
end;
button first
procedure Tfrmdosen.btnfirstClick(Sender: TObject);
begin
qrydosen.First;
end;
button prior
procedure Tfrmdosen.btnpriorClick(Sender: TObject);
begin
qrydosen.Prior;
end;
button next
procedure Tfrmdosen.btnnextClick(Sender: TObject);
begin
qrydosen.Next;
end;
button last
procedure Tfrmdosen.btnlastClick(Sender: TObject);
begin
qrydosen.Last;
end;
button cari
procedure Tfrmdosen.btncariClick(Sender: TObject);
var cari : string;
begin
cari:=
ComboBox1.Text;
with qrydosen do
begin
Close;
SQL.Clear;
SQL.Add('select *
from dosen where '+kategori+'like'+QuotedStr(edtcari.text+'%'));
Open;
end;
end;
button cari
procedure Tfrmdosen.ComboBox1Change(Sender: TObject);
begin
if ComboBox1.itemindex=0 then
kategori :='nid'
else kategori := 'nama';
end;
end.
2. pada form input data
Semua label
memakai DB
public
{ Public declarations }
end;
var
frminput: Tfrminput;
implementation
uses Unit1;
{$R *.dfm}
Bit button yes
kind = bk custom
modalresult = mrnone
procedure Tfrminput.BitBtn1Click(Sender: TObject);
begin
if dbedt1.text=''then
begin
ShowMessage('isi
dulu NID');
dbedt1.setfocus;
Exit;
end;
if DBedt2.text=''then
begin
ShowMessage('isi
dulu nama');
dbedt2.setfocus;
Exit;
end;
if DBedt3.text=''then
begin
ShowMessage('isi
dulu alamat');
dbedt3.setfocus;
Exit;
end;
if DBedt4.text=''then
begin
ShowMessage('isi dulu jenis_kelamin');
dbedt4.setfocus;
Exit;
end;
if DBedt5.text=''then
begin
ShowMessage('isi
dulu agama');
dbedt5.setfocus;
Exit;
end;
if DBedt6.text=''then
begin
ShowMessage('isi
dulu telepon');
dbedt6.setfocus;
Exit;
end;
modalresult := mryes ;
end ;
end ;
bit botton no
kind = bkno
modalresult = mrno
Tidak ada komentar:
Posting Komentar