以下代码是铖实现自动计算,为什么实现不了呢?黄色代码怎么修改?因为项目列合计行前面会一些空格。
Dim filter As String = " 年度 = '" & e.DataRow("年度") & "' And 期间 = '" & e.DataRow("期间") & "'And 公司名称 = '" & e.DataRow("公司名称") & "'And 部门编号 = '" & e.DataRow("部门编号") & "'"
Select Case e.DataCol.name
Case "数量","单价"
e.DataRow("金额") = e.DataRow("数量") * e.DataRow("单价")
Case "年度","期间"
Dim drgh As DataRow = e.DataTable.find(filter & " And 项目 = '挂号收入'and 收入明细 like '%合计%'")
'msgbox(2)
If drgh IsNot Nothing Then
'msgbox(1)
drgh("单价") = e.DataTable.Compute("sum(单价)",filter & " And 项目 = '挂号收入'and 收入明细 not like '%合计%'")
drgh("数量") = e.DataTable.Compute("sum(数量)",filter & " And 项目 = '挂号收入'and 收入明细 not like '%合计%'")
drgh("金额") = e.DataTable.Compute("sum(金额)",filter & " And 项目 = '挂号收入'and 收入明细 not like '%合计%'")
'msgbox(drgh("单价"))
End If
Case "数量","单价","金额"
If e.DataRow("收入明细") <> "合计" Then
e.DataTable.DataCols("年度").RaiseDataColChanged(filter)
End If
End Select