📄 unit8.pas
字号:
unit Unit8;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, DB, ADODB, StdCtrls, ExtCtrls;
type
TForm8 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Label1: TLabel;
Edit1: TEdit;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
Panel3: TPanel;
CheckBox1: TCheckBox;
ComboBox1: TComboBox;
Button1: TButton;
Button2: TButton;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
ADOQuery2: TADOQuery;
ADOQuery3: TADOQuery;
ListView1: TListView;
StatusBar1: TStatusBar;
procedure FormCreate(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure showBKlist();
end;
var
Form8: TForm8;
implementation
uses unit1;
var typeid:string;
{$R *.dfm}
procedure Tform8.showBKlist();
begin
adoquery2.Close;
adoquery2.SQL.Clear;
adoquery2.SQL.Add('select * from booktype order by typename');
adoquery2.Open;
combobox1.Text:=adoquery2.fieldbyname('typename').AsString;
typeid:=adoquery2.fieldbyname('btype').AsString;
while not adoquery2.Eof do
begin
combobox1.Items.Add(adoquery2.fieldbyname('typename').AsString);
adoquery2.Next;
end;
end;
procedure TForm8.FormCreate(Sender: TObject);
begin
edit1.Clear;
radiobutton1.Checked:=true;
ShowBKlist();
end;
procedure TForm8.ComboBox1Change(Sender: TObject);
begin
adoquery2.Close;
adoquery2.SQL.Clear;
adoquery2.SQL.Add('select * from booktype where typename=:type1');
adoquery2.Parameters.ParamByName('type1').Value:=combobox1.Text;
adoquery2.Open;
typeid:=adoquery2.fieldbyname('btype').AsString;
end;
procedure TForm8.Button1Click(Sender: TObject);
var queryStr,bor:string;
begin
listview1.Clear;
if trim(edit1.Text)='' then
QueryStr:='select * from book'
else
begin
if radiobutton1.Checked then
Querystr:='select * from book where bookname like ''%'+trim(edit1.Text)+'%'''
else if radiobutton2.Checked then
Querystr:='select * from book where author like ''%'+trim(edit1.Text)+'%'''
else if radiobutton3.Checked then
Querystr:='select * from book where publishment like ''%'+trim(edit1.Text)+'%'''
end;
if (checkbox1.Checked) and (trim(edit1.Text)<>'')then
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Text:=querystr;
adoquery1.SQL.Add('and btype=:type1');
adoquery1.Parameters.ParamByName('type1').Value:=typeid;
adoquery1.open;
end
else if (checkbox1.Checked) and (trim(edit1.Text)='')then
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Text:=querystr;
adoquery1.SQL.Add('where btype=:type1');
adoquery1.Parameters.ParamByName('type1').Value:=typeid;
adoquery1.open;
end
else
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Text:=Querystr;
adoquery1.Open;
end;
statusbar1.Panels[0].Text:='查询到'+IntToStr(adoquery1.RecordCount)+' 条记录';
while not adoquery1.Eof do
begin
adoquery3.Close;
adoquery3.SQL.Clear;
adoquery3.SQL.Add('select * from borrow where bookno=:bno1');
adoquery3.Parameters.ParamByName('bno1').Value:=adoquery1.fieldbyname('bookno').AsString;
adoquery3.Open;
if adoquery3.Eof and adoquery3.Bof then
bor:='-'
else
bor:=adoquery3.fieldbyname('borrowbook_ID').AsString;
with Listview1.Items.Add do
begin
caption:=adoquery1.fieldbyname('bookno').AsString;
subItems.Add(adoquery1.fieldbyname('bookname').AsString);
subItems.Add(adoquery1.fieldbyname('author').AsString);
subItems.Add(adoquery1.fieldbyname('publishment').AsString);
subitems.Add(bor);
end;
adoquery1.Next;
end;
end;
procedure TForm8.Button2Click(Sender: TObject);
begin
//animatewindow(handle,1000,aw_hide or aw_center);
form8.Hide;
//Application.CreateForm(Tform1,form1);
animatewindow(form1.handle,1000,aw_Activate or aw_center);
form1.Show;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -