Foxtable(狐表)用户栏目专家坐堂 → [求助]


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

主题:[求助]

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


加好友 发短信
等级:婴狐 帖子:27 积分:277 威望:0 精华:0 注册:2016/4/15 10:38:00
[求助]  发帖心情 Post By:2016/4/26 12:00:00 [只看该作者]

“区分产品的流水账”实例中,我想再加一个仓库的字段,可以按不同仓库区分商品库存。求高手指点如何实现?

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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/4/26 12:27: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 仓库 = '" & e.DataRow("仓库") & "'"
            Dim Val1 As Double = e.DataTable.Compute("Sum(入库)",Filter)
            Dim Val2 As Double = e.DataTable.Compute("Sum(出库)",Filter)
            dr("库存") = Val1 - Val2
        Next
        filter = ""
        If e.DataCol.Name = "产品" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then
            Filter = "[_SortKey] > " & e.DataRow("_SortKey") & " And [产品] = '" & e.OldValue & "' and 仓库 = '" & e.DataRow("仓库") & "'"
        ElseIf e.DataCol.Name = "仓库" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue 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)
                Dim Val2 As Double = e.DataTable.Compute("Sum(出库)",Filter)
                dr("库存") = Val1 - Val2
            Next
        End If
End Select

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


加好友 发短信
等级:婴狐 帖子:27 积分:277 威望:0 精华:0 注册:2016/4/15 10:38:00
  发帖心情 Post By:2016/4/27 10:25:00 [只看该作者]

谢谢!

 回到顶部