此例子中有一个明细,想按月汇总,以下代码是那里出错了
If e.DataCol.Name = "摘要" AndAlso e.DataRow("摘要") = "本月合计" Then
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 Then
msgbox(Date1)
msgbox(Date2)
'dr(c.name) = e.DataTable.Compute("sum(" & c.name & ")","日期 >= '" & Date1 & "' and 日期 <= '" & Date2 & "'and 摘要 <> '本月合计'")
dr(c.name) = e.DataTable.Compute("sum(" & c.name & ")","日期 >= '" & Date1 & "' and 日期 <= '" & Date2 & "'")
msgbox(dr(c.name))
End If
Next
Next
End If