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


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

主题:加载所有数据

帅哥哟,离线,有人找我吗?
狐狸爸爸
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | 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) & "'"

 

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


 回到顶部
帅哥哟,离线,有人找我吗?
狐狸爸爸
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | 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


 回到顶部