⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bookqueryunit.~pas

📁 图书馆管理系统,非常有用,希望给你带来帮助
💻 ~PAS
字号:
unit BookQueryUnit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, StdCtrls, ExtCtrls, Buttons, ADODB;

type
  TBookQueryForm = class(TForm)
    ListView1: TListView;
    RadioGroup1: TRadioGroup;
    GroupBox1: TGroupBox;
    ComboBox1: TComboBox;
    BitBtn1: TBitBtn;
    CheckBox1: TCheckBox;
    procedure RadioGroup1Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
    procedure WMNCpaint(var Msg:TWMNCPaint); message WM_NCPAINT;
  public
    { Public declarations }
  end;

var
  BookQueryForm: TBookQueryForm;

implementation
uses DMUnit,Share;

{$R *.dfm}

procedure TBookQueryForm.RadioGroup1Click(Sender: TObject);
var
  tempstr:TStrings;
begin
  tempstr:=TStringList.Create;
  try
    case RadioGroup1.ItemIndex of
    2: begin
         tempstr:=DM.GetPub;
         combobox1.Items.Clear;
         combobox1.Items.Assign(tempstr);
       end;
    3: begin
         tempstr:=DM.GetAuth;
         combobox1.Items.Clear;
         combobox1.Items.Assign(tempstr);
       end;
    4: begin
         tempstr:=DM.GetTypeSno;
         combobox1.Items.Clear;
         combobox1.Items.Assign(tempstr);
       end;
    end;
  finally
    tempstr.Free;
  end;
  combobox1.ItemIndex:=0;
end;

procedure TBookQueryForm.BitBtn1Click(Sender: TObject);
var
  Query:TADOQuery;
begin
  Query:=TADOQuery.Create(self);
  Query.Connection:=DM.ADOConn;
  Query.SQL.Text:='select s.book_isbn,s.book_name,i.publish,i.author,i.type_sno,'+
                  ' i.book_year from book_stock as s inner join book_info as i '+
                  ' on s.book_name=i.book_name ';
  case RadioGroup1.ItemIndex of
  1: begin
       if checkbox1.Checked then
         Query.SQL.Add(' where s.book_name like :in0')
       else
         Query.SQL.Add(' where s.book_name like :in0 and s.lendout="n"');
       Query.Parameters[0].Value:='%'+combobox1.Text+'%';
     end;
  2: begin
       if checkbox1.Checked then
         Query.SQL.Add(' where i.publish=:in0')
       else
         Query.SQL.Add(' where i.publish=:in0 and s.lendout="n"');
       Query.Parameters[0].Value:=combobox1.Text;
     end;
  3: begin
       if checkbox1.Checked then
         Query.SQL.Add(' where i.author=:in0')
       else
         Query.SQL.Add(' where i.author=:in0 and s.lendout="n"');
       Query.Parameters[0].Value:=combobox1.Text;
     end;
  4: begin
       if checkbox1.Checked then
         Query.SQL.Add(' where i.type_sno=:in0')
       else
         Query.SQL.Add(' where i.type_sno=:in0 and s.lendout="n"');
       Query.Parameters[0].Value:=Trim(combobox1.Text);
     end;
  end;
  Query.Prepared;
  Query.Open;
  listview1.Items.Clear;
  while not Query.Eof do
  begin
    with listview1.Items.Add do
    begin
      Caption:=Query.Fields[0].AsString;
      Subitems.Add(Query.Fields[1].AsString);
      Subitems.Add(Query.Fields[2].AsString);
      Subitems.Add(Query.Fields[3].AsString);
      Subitems.Add(Query.Fields[4].AsString);
      Subitems.Add(Query.Fields[5].AsString);
    end;
    Query.Next;
  end;
  Query.Close;
  Query.Free;
end;

procedure TBookQueryForm.WMNCpaint(var Msg: TWMNCPaint);
begin
  inherited;
  Draw(BookQueryForm);
end;

procedure TBookQueryForm.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  AboutForm:=nil;
  Action:=caFree;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -