在查找窗口的查找按钮的Clicked事件中加入如下脚本:
boolean FindToEnd
string thecol,Expression,val
integer i
//取得用户选择的列
thecol=ddlb_1.text
If sle_FindWord.text = "" Then
MessageBox("提示", "请输入您要查找的关键字")
sle_FindWord.SetFocus()
Return
End If
val=sle_FindWord.text
//获得用户选择的列在数组中的位置
For i=1 To ColCount
If thecol=colinfo[i].coltag Then exit
Next
//确定查找方向
If rb_back.Checked = True Then
FindToEnd = True
ElseIf rb_prior.Checked = True Then
FindToEnd = False
End If
//如果第二次查找,则把"查找"按钮的标题改为"查找下一个"
This.Text = "查找下一个"
//如果第二次查找,则取消上次查找行的选中状态
i_dwtoacton.SelectRow(row,False)
//根据数据类型的不同拼写查找字符串
Choose Case colinfo[i].coltype
Case "char"
Expression = colinfo[i].colname + " like '%" + val + "%'"
Case "deci", "long", "numb", "real"
If IsNumber(val) Then
Expression = colinfo[i].colname + "=" + val
Else
MessageBox("错误","请输入数值作为查询条件")
sle_FindWord.text=""
sle_FindWord.SetFocus()
Return
End If
Case "date"
val = String(Date(val), "yyyy-mm-dd")
Expression = colinfo[i].colname + "=" + val
End Choose
If FindToEnd = True Then
//从前向后查找
//从当前行往后查找因此row ++
row ++
//如果row大于当前数据窗口的总行数,向下越界,把row设为0
If row <= i_dwtoacton.RowCount() Then
row = i_dwtoacton.Find(Expression, row, i_dwtoacton.RowCount())
Else
row=0
End If
Else
//从后向前查找
//从当前行往前查找因此row --
row --
//如果row小于1,向上越界,把row设为0
If row<1 Then
row=0
Else
row = i_dwtoacton.Find(Expression, row, 0)
End If
End If
If row = 0 Then
MessageBox("警告","当前窗口内未找到此关键字")
i_dwtoacton.SetFocus()
Close(Parent)
Return
ElseIf row < 0 Then
MessageBox("错误","查找关键字失败")
i_dwtoacton.SetFocus()
Return
Else
//把查找到的行设为选中状态并滚动到该行
i_dwtoacton.SelectRow(row,true)
i_dwtoacton.ScrollToRow(row)
End If
i_dwtoacton.SetFocus()
在查找窗口的取消按钮的Clicked事件中加入如下脚本:
Close(Parent)
3.13统计窗口
统计窗口用来显示统计结果。首先,根据需要建立用于统计的数据窗口对象。
d_bm:用来统计各部门拥有的档案数量,选择Group风格的数据窗口,用编制部门(bzbm)作为分组列。选择文件表的题名(tm)、分类号(flh)、时间(sj)、保管期限(bgqx)、编制部门(bzbm)作为数据源。在数据窗口描绘器里调整列的位置、属性,修改静态文本对象的标题、属性添加需要的计算列。
最后,在统计窗口加入一个数据控件,用来放置用于统计的数据窗口对象。
如图15所示。
在统计窗口的Open事件中加入如下脚本:
//为数据窗口分配事务对象,并检索数据
dw_st.SetTransObject (SQLCA)
dw_st.Retrieve()
图15 按部门统计的结果
统计窗口还有按照保管期限的不同进行的统计,主要介绍保管期限是长期的统计窗口,短期跟永久的功能基本相同不再重复。如图16所示。
在统计窗口的Open事件中加入如下脚本:
long therow
//为数据窗口分配事务对象,并检索数据
dw_1.SetTransObject (SQLCA)
dw_1.Retrieve()
//用静态文本显示当前日期
st_2.text=string(today(),"yyyy/mm/dd")
//设置过滤条件
this.dw_1.SetFilter("bgqx='长期'")
this.dw_1.Filter()
therow=dw_1.rowcount()
st_1.text = " 统计结果:"+string(therow)