Select Case e.DataCol.Name
Case "收入_股东入资","收入_其他","支出_伙食采购","支出_劳保用品","支出_设备材料","支出_加油","支出_过路费","支出_住宿费","支出_吃饭费","支出_其他"
Dim dr As DataRow
Dim drs As List(of DataRow)
dr = e.DataTable.Find("[_SortKey] < " & e.DataRow("_SortKey"), "[_SortKey] Desc") '找出上一行
If dr Is Nothing Then '如果没有找到上一行,说明本行就是第一行
e.DataRow("余额") = e.DataRow("收入_当日收入") - e.DataRow("支出_当日支出")
dr = e.DataRow
End If
drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey"), "[_SortKey]")
For i As Integer = 1 To drs.Count - 1 '重算余下行的余额
drs(i)("余额") = drs(i-1)("余额") + drs(i)("收入_当日收入") - drs(i)("支出_当日支出")
Next
End Select