在PB中如何实现数据模糊查询(五)

文章作者 100test 发表时间 2007:03:13 22:11:44
来源 100Test.Com百考试题网


9.5 DataWindow: dw_where的 ue_where 事件

功能:形成WHERE子句,并更新语法框。

string hzcol, ywcol, sValue, sType //, sWhere
//sWhere 现为实例变量,在wroot_query中为局部变量.
string sOper, sLog, sLeft_kh,sRight_kh, tmpsValue
long left_kh,right_kh //左、右括号数
integer i, rownum, delnum //, typenum
dwItemStatus l_status
if ib_changed = true then
ib_changed = false
else
return 0
end if
rownum = dw_where.RowCount()
//去掉dw_where中MaxEditRow行以前所有中间为空或
//者输入不完整的行, 并更新MaxEditRow.
i = 1
delnum = 0
DO WHILE i <= MaxEditRow
l_status = dw_where.GetItemStatus(i,0, Primary!)
if l_status <> New! then
hzcol = GetItemString(i,"column1")
sValue = GetItemString(i,"value")
if (hzcol = "" or isnull(hzcol)) or (sValue = "" or isnull(sValue)) then
dw_where.DeleteRow(i)
delnum = 1
MaxEditRow = -1
Continue
end if
else
dw_where.DeleteRow(i)
delnum = 1
MaxEditRow = -1
Continue
end if
i = 1
LOOP
For i = 1 to DelNum
dw_where.InsertRow(0)
Next
//检查左右括号是否匹配, 即其数量是否一样多.
For i = 1 to MaxEditRow
l_status = dw_where.GetItemStatus(i,0, Primary!)
if l_status <> New! then
left_kh = inv_string.of_countoccurrences(GetItemString(i,"precol"),"(")
right_kh = inv_string.of_countoccurrences(GetItemString(i,"value"),")")
end if
Next
i = left_kh - right_kh
if i <> 0 then
if i > 0 then
sValue = "查询条件中左括号比右括号多了" String(i) "个"
else
sValue = "查询条件中左括号比右括号少了" String(-i) "个"
end if
if MessageBox("综合查询输入错误",sValue ",请改正;" &.
"~r~n~r~n否则,所有查询条件将被忽略。",None!,OKCancel!,2)=1 then
return 1
else
dw_where.setfocus()
return 0
end if
end if
//形成WHERE子句,并更新语法框。
sWhere = ""
For i = 1 to MaxEditRow
hzcol = GetItemString(i,"column1")
sOper = space(1) GetItemString(i,"operator") space(1)
// 去掉空格键
sValue = Trim(GetItemString(i,"value"))
sLeft_kh = GetItemString(i,"precol") //保存左括号
if isNull(sLeft_kh) then sLeft_kh = ""
if Pos(sValue,")",1) > 0 then //保存右括号
sRight_kh = Right(sValue,(Len(sValue) - Pos(sValue,")",1) 1))
else
sRight_kh = ""
end if
sValue = inv_string.of_globalreplace(sValue,"","") //去掉sValue中的单引号.
sValue = inv_string.of_globalreplace(sValue,",) //去掉sValue中的双引号.
sValue = inv_string.of_globalreplace(sValue,")","") //去掉sValue中的右括号.
sLog = GetItemString(i,"logical")
if sLog = "" or isNull(sLog) then
sLog = "and"
dw_where.SetItem(i,"logical","and")
end if


相关文章


在PB中如何实现数据模糊查询(一)
在PB中如何实现数据模糊查询(二)
在PB中如何实现数据模糊查询(三)
在PB中如何实现数据模糊查询(四)
在PB中如何实现数据模糊查询(五)
CIO也要懂网络管理(2)
CIO也要懂网络管理
50种方法巧妙优化你的SQLServer数据库(一)
50种方法巧妙优化你的SQLServer数据库(二)
澳大利亚华人论坛
考好网
日本华人论坛
华人移民留学论坛
英国华人论坛