📄 unit10.~pas
字号:
unit Unit10;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, Grids, DBGrids, StdCtrls;
type
Tsearch = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
ADODataSet1: TADODataSet;
ADODataSet2: TADODataSet;
GroupBox1: TGroupBox;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
Label4: TLabel;
Edit4: TEdit;
Edit5: TEdit;
Label5: TLabel;
Label6: TLabel;
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton2Click(Sender: TObject);
procedure RadioButton3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure RadioButton4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
search: Tsearch;
implementation
uses unit3,unit1;
{$R *.dfm}
procedure Tsearch.RadioButton1Click(Sender: TObject);
begin
Label1.Visible:=true;
Label2.Visible:=false;
Label3.Visible:=false;
Label4.Visible:=false;
edit1.Visible:=true;
edit2.Visible:=false;
edit3.Visible:=false;
edit4.Visible:=false;
adodataset1.Close;
adodataset2.Close;
end;
procedure Tsearch.RadioButton2Click(Sender: TObject);
begin
Label1.Visible:=false;
Label2.Visible:=true;
Label3.Visible:=false;
Label4.Visible:=false;
edit1.Visible:=false;
edit2.Visible:=true;
edit3.Visible:=false;
edit4.Visible:=false;
adodataset1.Close;
adodataset2.Close;
end;
procedure Tsearch.RadioButton3Click(Sender: TObject);
begin
Label1.Visible:=false;
Label2.Visible:=false;
Label3.Visible:=true;
Label4.Visible:=false;
edit1.Visible:=false;
edit2.Visible:=false;
edit3.Visible:=true;
edit4.Visible:=false;
adodataset1.Close;
adodataset2.Close;
end;
procedure Tsearch.Button1Click(Sender: TObject);
begin
if(RadioButton1.Checked=true)then
begin
datasource1.DataSet:=adodataset1;
adodataset1.Active:=false;
adodataset1.CommandText:='select * from book where auther='+''''+edit1.Text+'''';
adodataset1.Active:=true;
if(adodataset1.RecordCount=0)then
showmessage('对不起,找不到您要查询的图书');
edit1.Text:='';
end
else if(RadioButton2.Checked=true)then
begin
datasource1.DataSet:=adodataset2;
adodataset2.Active:=false;
adodataset2.CommandText:='select * from book_type where book_type_no='+''''+edit2.Text+'''';
adodataset2.Active:=true;
if(adodataset2.RecordCount=0)then
showmessage('对不起,找不到您要查询的图书');
edit2.Text:='';
end
else if(RadioButton3.Checked=true)then
begin
datasource1.DataSet:=adodataset1;
adodataset1.Active:=false;
adodataset1.CommandText:='select * from book where publish='+''''+edit3.Text+'''';
adodataset1.Active:=true;
if(adodataset1.RecordCount=0)then
showmessage('对不起,找不到您要查询的图书');
edit3.Text:='';
end
else if(RadioButton4.Checked=true)then
begin
datasource1.DataSet:=adodataset1;
adodataset1.Active:=false;
adodataset1.CommandText:='select * from book where book_name='+''''+edit4.Text+'''';
adodataset1.Active:=true;
if(adodataset1.RecordCount=0)then
showmessage('对不起,找不到您要查询的图书');
begin
edit5.Text:=inttostr(adodataset1.RecordCount);
adodataset1.Active:=false;
adodataset1.Active:=true;
end;
edit4.Text:='';
end
end;
procedure Tsearch.Button3Click(Sender: TObject);
begin
if(RadioButton1.Checked=true)then
begin
datasource1.DataSet:=adodataset1;
adodataset1.Active:=false;
adodataset1.CommandText:='select * from book where auther like'+'''%'+edit1.Text+'%''';
adodataset1.Active:=true;
if(adodataset1.RecordCount=0)then
showmessage('对不起,找不到您要查询的图书');
edit1.Text:='';
end
else if(RadioButton2.Checked=true)then
begin
datasource1.DataSet:=adodataset2;
adodataset2.Active:=false;
adodataset2.CommandText:='select * from book_type where book_type_no like'+'''%'+edit2.Text+'%''';
adodataset2.Active:=true;
if(adodataset2.RecordCount=0)then
showmessage('对不起,找不到您要查询的图书');
edit2.Text:='';
end
else if(RadioButton3.Checked=true)then
begin
datasource1.DataSet:=adodataset1;
adodataset1.Active:=false;
adodataset1.CommandText:='select * from book where publish like'+'''%'+edit3.Text+'%''';
adodataset1.Active:=true;
if(adodataset1.RecordCount=0)then
showmessage('对不起,找不到您要查询的图书');
edit3.Text:='';
end
else if(RadioButton4.Checked=true)then
begin
datasource1.DataSet:=adodataset1;
adodataset1.Active:=false;
adodataset1.CommandText:='select * from book where book_name like'+'''%'+edit4.Text+'%''';
adodataset1.Active:=true;
if(adodataset1.RecordCount=0)then
showmessage('对不起,找不到您要查询的图书');
edit4.Text:='';
end
end;
procedure Tsearch.Button2Click(Sender: TObject);
begin
search.Hide;
jiemian.Show;
end;
procedure Tsearch.FormCreate(Sender: TObject);
begin
Label1.Visible:=false;
Label2.Visible:=false;
Label3.Visible:=false;
Label4.Visible:=false;
end;
procedure Tsearch.RadioButton4Click(Sender: TObject);
begin
Label1.Visible:=false;
Label2.Visible:=false;
Label3.Visible:=false;
Label4.Visible:=true;
edit1.Visible:=false;
edit2.Visible:=false;
edit3.Visible:=false;
edit4.Visible:=true;
adodataset1.Close;
adodataset2.Close;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -