Foxtable(狐表)用户栏目专家坐堂 → [求助]关联表统计问题


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

主题:[求助]关联表统计问题

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


加好友 发短信
等级:八尾狐 帖子:1812 积分:12999 威望:0 精华:14 注册:2008/10/11 18:07:00
  发帖心情 Post By:2009/4/11 13:31:00 [显示全部帖子]

必須去掉數據中的『'』才能統計,因『'』在狐表中比較特殊:表達式中,字符串用单引号引用.

Dim T,Tj,T1,Ts As String
Dim Ls As List(Of String)
Dim dt As DataTable = DataTables("柜型")

For Each r As Row In Tables("统计").Rows
    T = "关联 = " & r("_Identify")
    Ls = dt.GetUniqueValues( T ,"柜型")
    For Each T1 In Ls
        Tj = T & " and 柜型 = '" & T1 & "'"
        Ts = Ts & " " & dt.Compute("Count(柜型)",Tj) & "×" & T1
    Next
    r("统计")=Ts.substring(1)
    Ts =Nothing
Next


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


加好友 发短信
等级:八尾狐 帖子:1812 积分:12999 威望:0 精华:14 注册:2008/10/11 18:07:00
  发帖心情 Post By:2009/4/11 14:37:00 [显示全部帖子]

這樣可以不必去掉數據中的『'

一:按鈕

Dim T,Tj,T1,Ts As String
Dim Ls As List(Of String)
Dim dt As DataTable = DataTables("柜型")

For Each r As Row In Tables("统计").Rows
    T = "关联 = " & r("_Identify")
    Ls = dt.GetUniqueValues( T ,"柜型")
   
    if Ls.count > 0 then
        For Each T1 In Ls
            Tj = T & " and 柜型 = '" & T1.Replace("'","''") & "'"
            Ts = Ts & " " & dt.Compute("Count(柜型)",Tj) & "×" & T1
        Next
        r("统计")=Ts.substring(1)
        Ts =Nothing
    end if
Next


二:DataColChanged事件

If e.DataCol.Name = "柜型" Then
    Dim dr,pr As DataRow
    dr = e.DataRow
    pr = dr.GetParentRow("统计")
   
    if pr isnot nothing then
        Dim T,Tj,T1,Ts As String
        Dim Ls As List(Of String)        
        Dim dt As DataTable = DataTables("柜型")
       
        T = "关联 = " & dr("关联")
        Ls = dt.GetUniqueValues( T ,"柜型")
        For Each T1 In Ls
            Tj = T & " and 柜型 = '" & T1.Replace("'","''") & "'"
            Ts = Ts & " " & dt.Compute("Count(柜型)",Tj) & "×" & T1
        Next
        pr("统计") =Ts.substring(1)
    End If
End If

[此贴子已经被作者于2009-4-11 14:55:49编辑过]

 回到顶部