流水账计算,现在是从上往下计算,怎样能实现从下往上计算,让最新数据显示在最上面一行?
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)