代码如下
Dim t As Table = e.Form.Controls("居民生活电价").Table
Dim g As New GroupTableBuilder("统计表1", DataTables("电费"))
g.Groups.AddDef("日期", DateGroupEnum.Year, "年")
g.Groups.AddDef("电费代码")
g.Groups.AddDef("姓名")
g.Totals.AddDef("抄见电量",True)
g.Filter = "电费代码 is not null and 电费代码 <> '' and 电费代码 = 'A'"
t.datasource = g.BuildDataSource
t.DataTable.DataCols.Add("总费用", Gettype(Double))
For Each r As Row In t.Rows
If r("抄见电量") > 2160 Then
r("总费用") += 2160 * 0.573
If r("抄见电量") > 4800 Then
r("总费用") += (4800-2160) * (0.573+0.05)
r("总费用") += (r("抄见电量")-4800) * (0.573+0.3)
Else
r("总费用") += (r("抄见电量")-2160) * (0.573+0.05)
End If
Else
r("总费用") = r("抄见电量") * 0.573
End If
Next