procedure tmainform.speedbutton1click(sender: tobject);
var s1,s2,s3,s4,s5 :string; file://设立5个变量以方便实现模糊查询
begin file://主窗口库存查询按钮事件
with datamoduleform.mainquery do
begin
close;
sql.clear;
sql.add(''select * from bookrecord'');
sql.add(''where bookid like :bookid and bookname like :name and author like :author and publisher like :pub and booktype like :booktype'');
file://使用like语句来实现模糊查询
if edit1.text<>'''' then s1:=''%''+edit1.text+''%'' else s1:=''%'';
parameters.parambyname(''bookid'').value:=s1; file://给变量s1赋值
if edit2.text<>'''' then s2:=''%''+edit2.text+''%'' else s2:=''%'';
parameters.parambyname(''name'').value:=s2; file://给变量s2赋值
if edit3.text<>'''' then s3:=''%''+edit3.text+''%'' else s3:=''%'';
parameters.parambyname(''author'').value:=s3; file://给变量s2赋值
if edit4.text<>'''' then s4:=''%''+edit4.text+''%'' else s4:=''%'';
parameters.parambyname(''pub'').value:=s4; file://给变量s2赋值
if edit5.text <>'''' then s5:=''%''+edit5.text+''%'' else s5:=''%'';
parameters.parambyname(''booktype'').value:=s5; file://给变量s2赋值
open;
if fieldvalues[''bookid'']=null file://判断是否找到记录
then begin
messagedlg(''没有找到你所需要的记录!'',mtinformation,[mbok],0);
edit1.text:='''';edit2.text:='''';edit3.text:='''';edit4.text:='''';edit5.text:='''';
close;
<< 上一页 [31] [32] [33] [34] [35] [36] [37] [38] [39] [40] ... 下一页 >>