Foxtable(狐表)用户栏目专家坐堂 → 同表,根据双列(品名和型号规格两列)累计数量


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

主题:同表,根据双列(品名和型号规格两列)累计数量

帅哥,在线噢!
有点蓝
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110574 积分:562760 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2016/12/2 10:52:00 [显示全部帖子]

试试

Select Case e.DataCol.Name
    Case "品名","型号规格", "数量"
        Dim drs As List(of DataRow)
        Dim Filter As String
        Filter = "[_SortKey] >= " & e.DataRow("_SortKey") & " And [品名] = '" & e.DataRow("品名") & "' and 型号规格 = '" & e.DataRow("型号规格") & "'"
        drs = e.DataTable.Select(Filter)
        For Each dr As DataRow In drs
            Filter = "[_SortKey] <= " & dr("_SortKey") & " And [品名] = '" & dr("品名") & "' and 型号规格 = '" & dr("型号规格") & "'"
            Dim Val1 As Double = e.DataTable.Compute("Sum(数量)",Filter)
            dr("本品名型号规格累计") = Val1
        Next
        Filter = ""
        If e.DataCol.Name = "品名" AndAlso e.OldValue IsNot Nothing  Then
            Filter = "[_SortKey] > " & e.DataRow("_SortKey") & " And [品名] = '" & e.OldValue & "' and 型号规格 = '" & e.DataRow("型号规格") & "'"
        ElseIf e.DataCol.Name = "型号规格" AndAlso e.OldValue IsNot Nothing  Then
            Filter = "[_SortKey] > " & e.DataRow("_SortKey") & " And [品名] = '" & e.DataRow("品名") & "' and 型号规格 = '" & e.OldValue & "'"
        End If
        If Filter > "" Then
            drs = e.DataTable.Select(Filter)
            For Each dr As DataRow In drs
                Filter = "[_SortKey] <= " & dr("_SortKey") & " And [品名] = '" & dr("品名") & "'and 型号规格 = '" & dr("型号规格") & "'"
                Dim Val1 As Double = e.DataTable.Compute("Sum(数量)",Filter)
                dr("本品名型号规格累计") = Val1
            Next
        End If
End Select

 回到顶部