Jika sudah benar dari kata-kata dan penulisan sesuai prosedure, selanjutnya
perhatikan untuk tombol Cari dan tombol Refresh, dari kedua tombol tersebut akan diberikan
perintah dalam pencarian yaitu :
1. Klik double tombol Cari dan ketik perintah/skrip dibawah ini :
29
Created By : Purnama Alamsyah, M.Kom
pilih.SetFocus;
bCari.Visible:=true
end
else
begin
if cmPilih.Text = 'Kode Supplier' then
sQuery:='select * from TSupplier where kd_supplier like "%'+pilih.Text+' " '
else
if cmPilih.Text = 'Nama Supplier' then
sQuery:='select * from TSupplier where nama_supplier like " % ' + pilih.Text +'
%"'
else
sQuery:='select * from TSupplier';
DMPembelian.TSupplier.Close;
DMPembelian.TSupplier.SQL.Clear;
DMPembelian.TSupplier.SQL.Add(sQuery);
DMPembelian.TSupplier.Open;
if DMPembelian.TSupplier.RecordCount>0 then
begin
showmessage('Data Ditemukan');
cmPilih.Text:=('Kategori Pencarian');
Pilih.Enabled:=false;
cmPilih.Enabled:=false;
bRefresh.Visible:=true;
bRefresh.SetFocus
end
else
begin
showmessage('Data Tidak Ditemukan !');
begin
showmessage('Silahkan Coba Lagi !!');
bCari.Enabled:=true;
bCari.Visible:=true;
Pilih.Enabled:=true;
Pilih.Clear;
Pilih.SetFocus;
end;
end;
end;
end;
30
Created By : Purnama Alamsyah, M.Kom
sQuery:='select * from TSupplier where kd_supplier like " % '+pilih.Text+' " '
else
if cmPilih.Text = 'Nama Supplier' then
sQuery:='select * from TSupplier where nama_supplier like " % ' +pilih.Text+' %
"'
else
sQuery:='select * from TSupplier';
DMPembelian.TSupplier.Close;
DMPembelian.TSupplier.SQL.Clear;
DMPembelian.TSupplier.SQL.Add(sQuery);
DMPembelian.TSupplier.Open;
if DMPembelian.TSupplier.RecordCount>0 then
Pilih.Clear;
Pilih.Enabled:=false;
cmPilih.Enabled:=true;
cmPilih.Text:=('Kategori Pencarian');
pilih.Clear;
end;
3. Klik double Combobox (cmPilih) atau klik event pilih onChange dan klik double kotak
kosong kemudian ketik perintah/skrip dibawah ini :
procedure TFSupplier.cmPilihChange(Sender: TObject);
begin
Pilih.Enabled:=true;
Pilih.SetFocus;
Pilih.Clear;
bCari.Visible:=true;
bCari.Enabled:=true;
bRefresh.Visible:=false;
Pilih.Clear;
end;
31
Created By : Purnama Alamsyah, M.Kom
Gambar 7.2. Tampilan Perintah Pencarian
32
Created By : Purnama Alamsyah, M.Kom