请各位高手帮我纠正源代码,怎么不能实现综合查询?
各位高手,我在PB8里面用三个复选框做的一个综合查询,可是只能实现单个查询,当两个及以上组合的时候,却不能检索出关键词,错在哪里?源代码如下:
string ls_temp1,ls_temp2,ls_temp3
string ls_filter,ls_filter1,ls_filter2,ls_filter3
if cbx_1.checked =true then
ls_temp1=trim(sle_1.text)
ls_filter1=''
if pos(ls_temp1,'',1) > 0 then
ls_filter1=ls_filter1+"gjc like'"+trim(left(ls_temp1,pos(ls_temp1,'',1)))+"'and"
ls_temp1=replace(ls_temp1,1,pos(ls_temp1,'',1),'')
else
ls_filter1="gjc like'"+ls_temp1+"'"
ls_temp1=''
end if
end if
if cbx_2.checked =true then
ls_temp2=trim(sle_2.text)
ls_filter2=''
if pos(ls_temp2,'',1) > 0 then
ls_filter2=ls_filter2+"gj like'"+trim(left(ls_temp2,pos(ls_temp2,'',1)))+"'and"
ls_temp2=replace(ls_temp2,1,pos(ls_temp2,'',1),'')
else
ls_filter2="gj like'"+ls_temp2+"'"
ls_temp2=''
end if
end if
if cbx_3.checked =true then
ls_temp3=trim(sle_3.text)
ls_filter3=''
if pos(ls_temp1,'',1) > 0 then
ls_filter3=ls_filter3+"cbrq like'"+trim(left(ls_temp3,pos(ls_temp3,'',1)))+"'and"
ls_temp3=replace(ls_temp3,1,pos(ls_temp3,'',1),'')
else
ls_filter3="cbrq like'"+ls_temp3+"'"
ls_temp3=''
end if
end if
if cbx_1.checked=true then
if cbx_2.checked=false and cbx_3.checked=false then
ls_filter=ls_filter1
end if
elseif cbx_2.checked=true then
if cbx_1.checked=false and cbx_3.checked=false then
ls_filter=ls_filter2
end if
elseif cbx_3.checked=true then
if cbx_1.checked=false and cbx_2.checked=false then
ls_filter=ls_filter3
end if
elseif cbx_1.checked=true and cbx_2.checked=true then
if cbx_3.checked=false then
ls_filter=""+ls_filter1+""+"and"+" "+ls_filter2+""
end if
elseif cbx_1.checked=true and cbx_3.checked=true then
if cbx_2.checked=false then
ls_filter=""+ls_filter1+""+"and"+" "+ls_filter3+""
end if
elseif cbx_2.checked=true and cbx_3.checked=true then
if cbx_1.checked=false then
ls_filter=""+ls_filter2+""+"and"+" "+ls_filter3+""
end if
else
ls_filter=""+ls_filter1+""+"and"+" "+ls_filter2+""+"and"+" "+ls_filter3+""
end if
//过滤输出
dw_1.setfilter(ls_filter)
dw_1.filter()
//检索显示
dw_1.SetTransObject(sqlca)
dw_1.retrieve()
if dw_1.rowcount()=0 then
messagebox("系统提示:","对不起,数据库中无记录!")
return
end if