Rss & SiteMap
Foxtable(狐表) http://www.foxtable.com
下载信息 [文件大小: 下载次数: ] | |
![]() |
没有弄清语句的意思。
能不能不用FOR语句,直接用IF 语句,即直接统计张三总金额,李四总金额,因为姓名就那么几个。
这样好,通用,否则增加、删除、修改人员,你就需要重新修改代码。
不需要通用
是不是这样:
Dim dr As
DataRow = e.DataRow
Dim dt As
DataTable =DataTables("明细表")
If e.DataCol.Name = "时间"
And dr.IsNull("时间") = False
Then
dr("张三总金额") = dt.Compute("sum(金额)")
End
If
如果这样的话:
If e.DataCol.Name = "时间" Then
e.DataRow("张三总金额") = DataTables("明细表").Compute("Sum(金额)","姓名 = '张三' And 时间 = '" & e.DataRow("时间") & "'")
e.DataRow("李四总金额") = DataTables("明细表").Compute("Sum(金额)","姓名 = '李四' And 时间 = '" & e.DataRow("时间") & "'")
e.DataRow("王五总金额") = DataTables("明细表").Compute("Sum(金额)","姓名 = '王五' And 时间 = '" & e.DataRow("时间") & "'")
e.DataRow("赵六总金额") = DataTables("明细表").Compute("Sum(金额)","姓名 = '赵六' And 时间 = '" & e.DataRow("时间") & "'")
End If