Foxtable(狐表)用户栏目专家坐堂 → 加载所有数据


  共有2160人关注过本帖树形打印复制链接

主题:加载所有数据

帅哥哟,离线,有人找我吗?
fanjq8686
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:277 积分:2328 威望:0 精华:0 注册:2015/4/5 16:28:00
加载所有数据  发帖心情 Post By:2015/4/29 9:54:00 [只看该作者]

请教:

'--------------树目录筛选--------------
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
Forms("综合查询窗口").Controls("Label1").Text = "业务受理情况"

'三级目录
NodeLevel0 = "产品类别"
NodeLevel1 = "产品分类"
NodeLevel2 = ""

'查询的日期字段
DateSt = "受理日期"

Dim TreeSt As String
If NodeLevel2 = "" Then
    If  NodeLevel1 = "" Then
        TreeSt = NodeLevel0
    Else
        TreeSt = NodeLevel0 & "|" & NodeLevel1
    End If
Else
    TreeSt = NodeLevel0 & "|" & NodeLevel1 & "|"  &  NodeLevel2
End If

 

trv.BuildTree("业务流程表", TreeSt)
trv.Nodes.Insert("加载所有数据","加载所有数据",0)


'MessageBox.Show("节点名称: " & e.node.NAME)

Tables("业务流程表").SetColVisibleWidth("受理日期|90|报告编号|160|任务来源|80|检验类别|50|检验分类|110|产品类别|80|产品分类|110|客户名称|250|样品名称|150|样品型号规格|100|样品数量|50|")
Tables("业务流程表").Filter = ""

 

NodeMouseDoubleClick

 

'--------------树目录筛选--------------
Dim CountStr As String
Dim Filter As String
Dim Filter0 As String
Dim Filter1 As String
Dim Filter2 As String

Dim dr As DataRow = e.Node.DataRow '获取生成此节点的行
If NodeLevel2 = "" Then
    Filter2 = ""
Else
    Filter2 = " And [" & NodeLevel2 & "] = '" & dr(NodeLevel2) & "'"
End If
If  NodeLevel1 = "" Then
    Filter1 = ""
Else
    Filter1 = " And [" & NodeLevel1 & "] = '" & dr(NodeLevel1) & "'"
End If
Filter0 = " AND [" & NodeLevel0 & "] = '" & dr(NodeLevel0) & "'"

Dim cnt As Integer
'MessageBox.Show(NodeLevel0)
If e.node.TEXT = "加载所有数据" Then
    Filter = ""
Else
    Select Case e.Node.Level
        Case 0
            Filter = FilterDate & Filter0 & "And " & DateSt & " Is NOT Null"
            CountStr = "Count([" & NodeLevel0 & "])"
        Case 1
            Filter = FilterDate & Filter0 & Filter1 & "And " & DateSt & " Is NOT Null"
            CountStr = "Count([" & NodeLevel1 & "])"
        Case 2
            Filter = FilterDate & Filter0 & Filter1 & Filter2 & "And " & DateSt & " Is NOT Null"
            CountStr = "Count([" & NodeLevel2 & "])"
    End Select
End If
Tables("业务流程表").Filter = Filter
cnt = DataTables("业务流程表").Compute(CountStr,Filter)
e.Form.Controls("Label4").TEXT = "产品类别: " & e.node.TEXT
e.Form.Controls("Label5").TEXT = "项目总数: " & cnt
e.Form.Controls("Label6").TEXT = "时间范围: " & dt1 & " 至 " & dt2
'MessageBox.Show(cnt)

 

双击"加载所有数据",出现:

错误所在事件:窗口,综合查询窗口,TreeView1,NodeMouseDoubleClick
详细错误信息:
未将对象引用设置到对象的实例。


 回到顶部
帅哥哟,离线,有人找我吗?
狐狸爸爸
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2015/4/29 9:58:00 [只看该作者]

加载所有数据是你用代码插入的节点,没有对应的DataRow,所以下面的代码一定出错:

 

Dim dr As DataRow = e.Node.DataRow '获取生成此节点的行
If NodeLevel2 = "" Then
    Filter2 = ""
Else
    Filter2 = " And [" & NodeLevel2 & "] = '" & dr(NodeLevel2) & "'"
End If
If  NodeLevel1 = "" Then
    Filter1 = ""
Else
    Filter1 = " And [" & NodeLevel1 & "] = '" & dr(NodeLevel1) & "'"
End If
Filter0 = " AND [" & NodeLevel0 & "] = '" & dr(NodeLevel0) & "'"

 

明白了原因,你可以自己调整代码结构。


 回到顶部
帅哥哟,离线,有人找我吗?
fanjq8686
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:277 积分:2328 威望:0 精华:0 注册:2015/4/5 16:28:00
  发帖心情 Post By:2015/4/29 10:07:00 [只看该作者]

老师好!因为上周刚买的软件,是新手,能麻烦告诉我应如何调整吗?谢谢!

 回到顶部
帅哥哟,离线,有人找我吗?
狐狸爸爸
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2015/4/29 10:44:00 [只看该作者]

这样就能避免错误了:

 

 

'--------------树目录筛选--------------
Dim CountStr As String
Dim Filter As String
Dim Filter0 As String
Dim Filter1 As String
Dim Filter2 As String
If e.node.Level = 0 AndAlso e.node.Text =  "加载所有数据"  Then
    filter = ""
Else
    Dim dr As DataRow = e.Node.DataRow '获取生成此节点的行
    If NodeLevel2 = "" Then
        Filter2 = ""
    Else
        Filter2 = " And [" & NodeLevel2 & "] = '" & dr(NodeLevel2) & "'"
    End If
    If  NodeLevel1 = "" Then
        Filter1 = ""
    Else
        Filter1 = " And [" & NodeLevel1 & "] = '" & dr(NodeLevel1) & "'"
    End If
    Filter0 = " AND [" & NodeLevel0 & "] = '" & dr(NodeLevel0) & "'"
    Dim cnt As Integer
    Select Case e.Node.Level
        Case 0
            Filter = FilterDate & Filter0 & "And " & DateSt & " Is NOT Null"
            CountStr = "Count([" & NodeLevel0 & "])"
        Case 1
            Filter = FilterDate & Filter0 & Filter1 & "And " & DateSt & " Is NOT Null"
            CountStr = "Count([" & NodeLevel1 & "])"
        Case 2
            Filter = FilterDate & Filter0 & Filter1 & Filter2 & "And " & DateSt & " Is NOT Null"
            CountStr = "Count([" & NodeLevel2 & "])"
    End Select
End If
Tables("业务流程表").Filter = Filter
cnt = DataTables("业务流程表").Compute(CountStr,Filter)
e.Form.Controls("Label4").TEXT = "产品类别: " & e.node.TEXT
e.Form.Controls("Label5").TEXT = "项目总数: " & cnt
e.Form.Controls("Label6").TEXT = "时间范围: " & dt1 & " 至 " & dt2


 回到顶部
帅哥哟,离线,有人找我吗?
fanjq8686
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:277 积分:2328 威望:0 精华:0 注册:2015/4/5 16:28:00
  发帖心情 Post By:2015/4/29 11:04:00 [只看该作者]

谢谢老师!问题解决了。

 回到顶部