PRODI TEKNIK INFORMATIKA (S-1) TERAKREDITASI BAN-PT 348/SK/BAN-PT/Akred/S/VlW20l4

Sabtu, 15 Oktober 2011

Membuat Aplikasi Pencarian Buku

Pencarian buku adalah fasilitas yang wajib ada pada software...lebih lagi pada software pustaka..
aplikasi pencarian buku ini dibuat terpisah dari software pustaka...supa bisa di pasang di komputer lain yang hanya memiliki fungsi sebagai pencarian saja.....pada gambar di bawah contoh form pencarian buku...

pada form di bawah terdapat 4 kriterian pencarian yaitu :
1. berdasarkan judul buku
2. berdasarkan pengarang
3. berdasarkan penerbit
4. berdasarkan subjek



ini adalah source program untuk pencarian buku :

procedure TForm1.sBitBtn1Click(Sender: TObject);
begin
with ZQuery1 do
begin
Close;
SQL.Text :='select KOLEKSI.KODE_BUKU,KOLEKSI.JUDUL,KOLEKSI.PENERBIT,KOLEKSI.PENGARANG,';
SQL.Text := SQL.Text+' (KOLEKSI. JLH_EKS -  COALESCE(PINJ.JUMLAH,0)) as SISA';
SQL.Text := SQL.Text+'FROM KOLEKSI LEFT JOIN(';
SQL.Text := SQL.Text+'     SELECT TBL_PEMINJAMAN.kode_buku,count(TBL_PEMINJAMAN.kode_buku) AS JUMLAH';
SQL.Text := SQL.Text+'     FROM TBL_PEMINJAMAN';
SQL.Text := SQL.Text+'     WHERE TBL_PEMINJAMAN.TGL_KEMBALI IS NULL';
SQL.Text := SQL.Text+'     GROUP BY TBL_PEMINJAMAN.KODE_BUKU) PINJ ON PINJ.KODE_BUKU = KOLEKSI.KODE_BUKU';
SQL.Text := SQL.Text+' left join(';
SQL.Text := SQL.Text+'     SELECT TBLhilang.kode_buku,count(TBLhilang.kode_buku) AS JUMLAH';
SQL.Text := SQL.Text+'    FROM TBLhilang';
SQL.Text := SQL.Text+'     WHERE upper(TBLhilang.statusbuku)="HILANG"';
SQL.Text := SQL.Text+'     GROUP BY TBLhilang.KODE_BUKU,TBLhilang.statusbuku) hilbuk on hilbuk.KODE_BUKU = KOLEKSI.KODE_BUKU';
SQL.Text := SQL.Text+'left join(';
SQL.Text := SQL.Text+'     SELECT TBLhilang.kode_buku,count(TBLhilang.kode_buku) AS JUMLAH';
SQL.Text := SQL.Text+'     FROM TBLhilang';
SQL.Text := SQL.Text+'     WHERE upper(TBLhilang.statusbuku)="RUSAK"';
SQL.Text := SQL.Text+'     GROUP BY TBLhilang.KODE_BUKU,TBLhilang.statusbuku) rusbuk on rusbuk.KODE_BUKU = KOLEKSI.KODE_BUKU';

if (CheckBox1.Checked) or (CheckBox2.Checked)or(CheckBox3.Checked)or(CheckBox4.Checked) then
begin
SQL.Text := SQL.Text+'where';
if CheckBox1.Checked then
if Length(Edit1.Text)>0 then
   SQL.Text := SQL.Text+' judul like :jdl';

if (CheckBox1.Checked) and (CheckBox2.Checked) then
begin
if (Length(Edit2.Text)>0) then
   SQL.Text := SQL.Text+'or PENGARANG like :ngarang';
end
else  if (CheckBox2.Checked) then
if (Length(Edit2.Text)>0) then
   SQL.Text := SQL.Text+'PENGARANG like :ngarang';

if (CheckBox1.Checked) or (CheckBox2.Checked) then
begin
if Length(Edit4.Text)>0 then
   SQL.Text := SQL.Text+'or PENERBIT like :terbit';
end
else if (CheckBox3.Checked) then
if Length(Edit4.Text)>0 then
   SQL.Text := SQL.Text+'PENERBIT like :terbit';

if (CheckBox1.Checked) or (CheckBox2.Checked)or(CheckBox3.Checked) then
begin
if Length(Memo1.Text)>0 then
   SQL.Text := SQL.Text+'or SUBJEK like :SUBJEK';
end
else if (CheckBox4.Checked) then
if Length(Memo1.Text)>0 then
   SQL.Text := SQL.Text+' SUBJEK like :SUBJEK';
end;
SQL.Text := SQL.Text+'group by';
SQL.Text := SQL.Text+'koleksi.kode_buku';
if CheckBox1.Checked then
   ParamByName('jdl').AsString := Edit1.Text;
if CheckBox2.Checked then
   ParamByName('ngarang').AsString := Edit2.Text;
if CheckBox3.Checked then
   ParamByName('terbit').AsString := Edit4.Text;
if CheckBox4.Checked then
   ParamByName('SUBJEK').AsString := Memo1.Text;

ZQuery1.Open;
end;
end;

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
  if CheckBox1.Checked=True then
  begin
    Edit1.Enabled:=True;
    Edit1.Color:=clYellow;
    Edit1.SetFocus;
  end
  else
  if CheckBox1.Checked=False then
  begin
    Edit1.Text:='';
    Edit1.Enabled:=False;
    Edit1.Color:=clSilver;
  end
end;

procedure TForm1.CheckBox2Click(Sender: TObject);
begin
   if CheckBox2.Checked=True then
  begin
    Edit2.Enabled:=True;
    Edit2.Color:=clYellow;
    Edit2.SetFocus;
  end
  else
  if CheckBox2.Checked=False then
  begin
    Edit2.Text:='';
    Edit2.Enabled:=False;
    Edit2.Color:=clSilver;
  end
end;

procedure TForm1.CheckBox3Click(Sender: TObject);
begin
  if CheckBox3.Checked=True then
  begin
    Edit4.Enabled:=True;
    Edit4.Color:=clYellow;
    Edit4.SetFocus;
  end
  else
  if CheckBox3.Checked=False then
  begin
    Edit4.Text:='';
    Edit4.Enabled:=False;
    Edit4.Color:=clSilver;
  end
end;

procedure TForm1.CheckBox4Click(Sender: TObject);
begin
  if CheckBox4.Checked=True then
  begin
    Memo1.Enabled:=True;
    Memo1.Color:=clYellow;
    Memo1.SetFocus;
  end
  else
  if CheckBox4.Checked=False then
  begin
    //Memo1.Lines:=;
    Memo1.Enabled:=False;
    Memo1.Color:=clSilver;
  end
end;

end.
----------------------------------
create by : muhammad,S.T    (mhd.020382@yahoo.com)


0 komentar:

Posting Komentar