以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 流水账 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=114633) |
-- 作者:13775189031 -- 发布时间: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) |
-- 作者:有点蓝 -- 发布时间:2018/2/11 17:51:00 -- 原来的用法不变,对_SortKey倒序显示即可 tables("表A").sort = "_SortKey desc"
|
-- 作者:13775189031 -- 发布时间:2018/2/11 18:25:00 -- 在DataRowAdded设置么? 不行啊?
|
-- 作者:有点甜 -- 发布时间:2018/2/12 9:04:00 -- 你如何显示,都不影响计算的。你afterOpenProject加上代码
tables("表A").sort = "_SortKey desc"
|