📄 booksearch.pas
字号:
unit booksearch;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, DB, ADODB, StdCtrls, ExtCtrls, Buttons,data_main;
type
TForm6 = class(TForm)
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Edit1: TEdit;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Panel2: TPanel;
Label4: TLabel;
BitBtn2: TBitBtn;
BitBtn1: TBitBtn;
ComboBox3: TComboBox;
ComboBox4: TComboBox;
Edit2: TEdit;
ComboBox5: TComboBox;
Label3: TLabel;
Image1: TImage;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form6: TForm6;
s:string;
implementation
{$R *.dfm}
procedure TForm6.Bitbtn1Click(Sender: TObject);
var strfield :string;
strquote :string;
strfield1:string;
begin
datamodule1.adoquery1.close;
datamodule1.adoquery1.sql.clear;
datamodule1.adoquery1.sql.add('select * from book ');
datamodule1.adoquery1.active:=true;
strfield1 :=combobox1.text;
if (datamodule1.adoquery1.fieldbyname(strfield1).datatype=ftstring )or(datamodule1.adoquery1.fieldbyname(strfield1).datatype=ftmemo) then
strquote:=''''
else
strquote:='';
if combobox2.text='模糊查询' then
strfield:='where '+combobox1.text+' like '+strquote+'%'+trim(edit1.text)+'%'+strquote;
if combobox2.text='不等于' then
strfield:='where '+combobox1.text+' <> '+strquote+trim(edit1.text)+strquote;
if combobox2.text='等于' then
strfield:='where '+combobox1.text+' = '+strquote+trim(edit1.text)+strquote;
if combobox2.text='大于' then
strfield:='where '+combobox1.text+' > '+strquote+trim(edit1.text)+strquote;
if combobox2.text='小于' then
strfield:='where '+combobox1.text+' < '+strquote+trim(edit1.text)+strquote;
if combobox5.text='与' then
begin
if combobox4.text='模糊查询' then
strfield:=strfield+ ' and '+combobox3.text+' like '+strquote+'%'+trim(edit2.text)+'%'+strquote;
if combobox4.text='不等于' then
strfield:=strfield+' and '+combobox3.text+' <> '+strquote+trim(edit2.text)+strquote;
if combobox4.text='等于' then
strfield:=strfield+ ' and '+combobox3.text+' = '+strquote+trim(edit2.text)+strquote;
if combobox4.text='大于' then
strfield:=strfield+'and '+combobox3.text+' > '+strquote+trim(edit2.text)+strquote;
if combobox4.text='小于' then
strfield:=strfield+'and '+combobox3.text+' < '+strquote+trim(edit2.text)+strquote;
end;
if combobox5.text='或' then
begin
if combobox4.text='模糊查询' then
strfield:=strfield+ ' or '+combobox3.text+' like '+strquote+'%'+trim(edit2.text)+'%'+strquote;
if combobox4.text='不等于' then
strfield:=strfield+' or '+combobox3.text+' <> '+strquote+trim(edit2.text)+strquote;
if combobox4.text='等于' then
strfield:=strfield+ ' or '+combobox3.text+' = '+strquote+trim(edit2.text)+strquote;
if combobox4.text='大于' then
strfield:=strfield+'or '+combobox3.text+' > '+strquote+trim(edit2.text)+strquote;
if combobox4.text='小于' then
strfield:=strfield+'or '+combobox3.text+' < '+strquote+trim(edit2.text)+strquote;
end;
datamodule1.adoquery1.sql.add(strfield);
datamodule1.adoquery1.open;
end;
procedure TForm6.BitBtn2Click(Sender: TObject);
begin
form6.close;
end;
procedure TForm6.FormShow(Sender: TObject);
begin
datamodule1.adoquery1.close;
datamodule1.adoquery1.sql.clear;
datamodule1.adoquery1.sql.add('select * from book ');
datamodule1.adoquery1.open;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -