您的位置首页百科问答

关于DELPHI的一些问题

关于DELPHI的一些问题

的有关信息介绍如下:

关于DELPHI的一些问题

一)实现模糊查询的代码,自己看下,希望对你有帮助!

var

cName1,poNo1,poType1,moldNo1,quoNo1,cloNO1,jobNo1,qDate1:string;

begin

if length(trim(cName.Text ))=0 then

cName1:='1=1'

else

cName1:='客户名称 like '+quotedstr(cName.Text );

if length(trim(poNo.Text ))=0 then

poNo1:='1=1'

else

poNo1:='订单号码 like '+quotedstr(poNo.Text );

if length(trim(poType.Text ))=0 then

poType1:='1=1'

else

poType1:='订单类别 like '+quotedstr(poType.Text );

if length(trim(moldNo.Text ))=0 then

moldNo1:='1=1'

else

moldNo1:='本司模号 like '+quotedstr(moldNo.Text );

if length(trim(quoNo.Text ))=0 then

quoNo1:='1=1'

else

quoNo1:='报价单号 like '+quotedstr(quoNo.Text );

if length(trim(cloNo.Text ))=0 then

cloNo1:='1=1'

else

cloNo1:='成交通知书 like '+quotedstr(cloNo.Text );

if length(trim(jobNo.Text ))=0 then

jobNo1:='1=1'

else

jobNo1:='JobOrderNo like '+quotedstr(jobNo.Text );

if length(trim(sDate.Text ))=0 then

qDate1:='1=1'

else

qDate1:='成交日期 >= '+quotedstr(trim(sDate.Text))+' and 成交日期 <= '+quotedstr(trim(eDate.Text));

with adoquery1 do

begin

close;

sql.Clear ;

sql.Add('select * from tb模具订单资料 where '+cName1+' and '+poNo1+' and '+poType1+' and '+moldNo1+' and '+quoNo1+' and '+cloNo1+' and '+JobNo1+' and '+qDate1);

open;

end;

二)Combobox

cName.Clear ;

with frm_main.adols do

begin

close;

sql.Clear ;

sql.Add('select 客户名称 from tb客户基本资料 order by 客户名称');

open;

end;

if frm_main.adols.RecordCount >0 then

while not frm_main.adols.Eof do

begin

cName.Items.Add(frm_main.adols.fieldbyname('客户名称').Value );

frm_main.adols.Next ;

end;

那是一个枚举类型,你保存ini时,可以将这个TFrameStyleEx值转为int型,保存,读取时,对int值转为TFrameStyleEx即可

通常都是与操作系统有关的常量定义。

类似的应用比较多。比如数学用的一些常量,键盘符的定义等。

在微软的操作系统下,大部分也API的定义一致。

这些做起来都不难,只是烦了些,要在这写出代码比较多的。

像你第一个问题:

if combobox2.text = '' then exit

这样就行了。

sql.add里这样写

先是,sql.add('select * form 表名 where 1=1');

再判断:

if edit1.text <> '' then sql.add('and 条件');

if edit2.text <> '' then sql.add('and 条件');

二。如果要想COMBOBOX2连数据库的话,在combobox2的下拉事件中写代码,就是Mousedown。

combobox2.clear;

再通过。sql.add('select * form 条件');// 把要添加在combobox2.items中的数据显示出来并添加进去就OK了

三 四的话就是日期计算,复杂点而已。