Foxtable(狐表)用户栏目专家坐堂 → 流水账


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

主题:流水账

美女呀,在线,快来找我吧!
13775189031
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:846 积分:5858 威望:0 精华:0 注册:2017/12/19 14:46:00
流水账  发帖心情 Post By:2018/2/11 17:47:00 [显示全部帖子]

流水账计算,现在是从上往下计算,怎样能实现从下往上计算,让最新数据显示在最上面一行?

DataColChangde 事件
Select Case e.DataCol.Name
    Case "生产令号","本月入库_数量","本月发出_数量"
        Dim drs As List(of DataRow)
        Dim Filter As String
        Filter = "[_SortKey] >= " & e.DataRow("_SortKey") & " And [生产令号] = '" & e.DataRow("生产令号") & "'"
        drs = e.DataTable.Select(Filter)
        For Each dr As DataRow In drs
            Filter = "[_SortKey] <= " & dr("_SortKey") & " And [生产令号] = '" & dr("生产令号") & "'"
            Dim Val1 As Double = e.DataTable.Compute("Sum(本月入库_数量)",Filter)
            Dim Val2 As Double = e.DataTable.Compute("Sum(本月发出_数量)",Filter)
            dr("月末库存_数量") = Val1 - Val2
        Next
        If e.DataCol.Name = "生产令号" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then
            Filter = "[_SortKey] > " & e.DataRow("_SortKey") & " And [生产令号] = '" & e.OldValue & "'"
            drs = e.DataTable.Select(Filter)
            For Each dr As DataRow In drs
                Filter = "[_SortKey] <= " & dr("_SortKey") & " 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

AfterMoveRow 事件
Dim Key As Decimal
Dim Index As Integer
Dim Filter As String
Dim r As Row
Index = Math.Min(e.OldIndex, e.NewIndex)
Key = e.Table.Rows(Index)("_SortKey")
r = e.Table.Rows(e.NewIndex)
Filter = "[_SortKey] >= " & Key & " And [生产令号] = '" & r("生产令号") & "'"
e.Table.DataTable.DataCols("本月入库_数量").RaiseDataColChanged(Filter)

 回到顶部
美女呀,在线,快来找我吧!
13775189031
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:846 积分:5858 威望:0 精华:0 注册:2017/12/19 14:46:00
  发帖心情 Post By:2018/2/11 18:25:00 [显示全部帖子]

在DataRowAdded设置么?
不行啊?

 回到顶部