[求助]关于多重查询的
这个是用来实现多重查询的,在没加入decimal类型变量的时候5个条件能实现组合查询,加了序号那个查询条件后也可以实现组合查询.但所有条件为空时查出来的数据不正确了,再加一个条件后不管怎么查,查出来的结果都为空了,谁能告诉我为什么啊?谢谢了!string ls_txm,ls_kh,ls_lb,ls_czy,ls_pm,ls_rk_no
decimal ld_dj,ld_zk,ld_je,ld_xh
datetime ldt_rkrq,ldt_czrq
string ls_sqlold,ls_where,ls_sqlnew
ls_kh= trim(sle_kh.text)
ls_txm=trim(sle_txm.text)
ls_pm =trim(sle_pm.text)
ls_lb =trim(sle_lb.text)
ls_czy=trim(sle_czy.text)
ls_where =''
//入库单号
ls_rk_no = trim(sle_rk_no.text)
//ld_rk_no =truncate(ls_rk_no,1)
if isnull(ls_rk_no) or ls_rk_no = '' then
ls_where = ls_where
else
ls_where = "rk_no like '" + ls_rk_no + "%'"
end if
//条形码
if isnull(ls_txm) or ls_txm ='' then
ls_where =ls_where
else
if ls_where ='' or isnull(ls_where) then
ls_where = "cg_cprk.txm like '" + ls_txm + "%'"
else
ls_where = ls_where + " and " + "cg_cprk.txm like '" + ls_txm + "%'"
end if
end if
//品名
if isnull(ls_pm) or ls_pm = '' then
ls_where =ls_where
else
if ls_where = '' or isnull(ls_where) then
ls_where = "pm_dm = '" + ls_pm + "'"
else
ls_where = ls_where + " and " + "pm_dm = '" + ls_pm + "'"
end if
end if
//操作员
if isnull(ls_czy) or ls_czy = '' then
ls_where =ls_where
else
if ls_where ='' or isnull(ls_where) then
ls_where = "gg_cpzl.czy like'" + ls_czy + "%'"
else
ls_where =ls_where + "and " + "gg_cpzl.czy like'" + ls_czy + "'"
end if
end if
//类别
if isnull(ls_lb) or ls_lb = '' then
ls_where =ls_where
else
if ls_where ='' or isnull(ls_where) then
ls_where =" lb_dm like '"+ ls_lb +"%'"
else
ls_where =ls_where + "and " + "lb_dm like'" + ls_lb + "'"
end if
end if
//款号
if isnull(ls_kh) or ls_kh = '' then
ls_where =ls_where
else
if ls_where ='' or isnull(ls_where) then
ls_where =" kh_dm like '"+ ls_kh +"%'"
else
ls_where =ls_where + "and " + "kh_dm like'" + ls_kh + "'"
end if
end if
//序号
ld_xh = dec(sle_xh.text)
if isnull(string(dec(ld_xh))) or string(dec(ld_xh)) = '' then
ls_where =ls_where
else
if ls_where ='' or isnull(ls_where) then
ls_where =" xh = '"+ string(dec(ld_xh)) +"'"
else
ls_where =ls_where + "and " + "xh ='" + string(dec(ld_xh)) + "'"
end if
end if
//单价
ld_dj = dec(sle_dj.text)
if isnull(string(dec(ld_dj))) or string(dec(ld_dj)) = '' then
ls_where =ls_where
else
if ls_where ='' or isnull(ls_where) then
ls_where =" cg_cprk.dj like '"+ string(dec(ld_dj)) +"%'"
else
ls_where =ls_where + "and " + "cg_cprk.dj like'" + string(dec(ld_dj)) + "'"
end if
end if
//折扣
/*ld_zk = dec(sle_zk.text)
if isnull(string(dec(ld_zk))) or string(dec(ld_zk)) = '' then
ls_where =ls_where
else
if ls_where ='' or isnull(ls_where) then
ls_where =" zk = '"+ string(dec(ld_zk)) +"'"
else
ls_where =ls_where + "and " + "zk ='" + string(dec(ld_zk)) + "'"
end if
end if*/
//执行查询
if ls_where = '' or isnull(ls_where) then
w_seek.dw_1.settransobject(sqlca)
w_seek.dw_1.retrieve()
else
w_seek.dw_1.settransobject(sqlca)
ls_sqlold = w_seek.dw_1.getsqlselect()
ls_sqlnew = ls_sqlold + ' and ' + ls_where
w_seek.dw_1.setsqlselect(ls_sqlnew)
w_seek.dw_1.retrieve()
w_seek.dw_1.setsqlselect(ls_sqlold)
end if
if w_seek.dw_1.rowcount() > 0 then
messagebox("查询结果!","总共查询到"+string(w_seek.dw_1.rowcount())+"条记录符合查询内容!",information!,ok!)
end if
close(w_seek_filter)