Select Case e.DataCol.Name
Case "摘要"
Select Case e.DataRow("摘要")
Case "本月合计","本年累计"
Dim Dowss As List(of DataRow) = e.DataTable.Select("摘要 = '本月合计'")
For Each dr As DataRow In Dowss
Dim year As Integer = dr("日期").Year
Dim month As Integer = dr("日期").Month
Dim Date1 As Date = new Date(year,month,1)
Dim Date2 As Date = new Date(year,month,Date.DaysInMonth(year,month))
For Each c As DataCol In e.DataTable.DataCols
If c.IsNumeric AndAlso e.DataCol.name <> "汇总_余额" Then
dr(c.name) = Nothing
dr(c.name) = e.DataTable.Compute("sum(" & c.name & ")","日期 >= '" & Date1 & "' and 日期 <= '" & Date2 & "' and 摘要 is null")
End If
Next
Next
Dowss = e.DataTable.Select("摘要 = '本年累计'")
For Each dr As DataRow In Dowss
Dim year As Integer = dr("日期").Year
Dim month As Integer = dr("日期").Month
Dim Date1 As Date = new Date(year,1,1)
Dim Date2 As Date = new Date(year,month,Date.DaysInMonth(year,month))
For Each c As DataCol In e.DataTable.DataCols
If c.IsNumeric AndAlso e.DataCol.name <> "汇总_余额" Then
dr(c.name) = Nothing
dr(c.name) = e.DataTable.Compute("sum(" & c.name & ")","日期 >= '" & Date1 & "' and 日期 <= '" & Date2 & "'and 摘要 = '本月合计'")
End If
Next
Next
End Select
Case "汇总_借方金额","汇总_贷方金额"
If e.DataRow("摘要") = "本月合计" OrElse e.DataRow("摘要") ="本年累计" Then Return
For Each dr As DataRow In e.DataTable.Select("[_SortKey] >= " & e.DataRow("_SortKey"))
Dim Val1 As Double = e.DataTable.Compute("Sum(汇总_借方金额)","[_SortKey] <= " & dr("_SortKey") & " And (摘要 <> '本月合计'or 摘要 is null)")
'msgbox(val1)
Dim Val2 As Double = e.DataTable.Compute("Sum(汇总_贷方金额)","[_SortKey] <= " & dr("_SortKey") & " And (摘要 <> '本月合计'or 摘要 is null)")
dr("汇总_余额") = Val1 + Val2
Next
End Select