例如,表B,datacolchanged事件
Select Case e.DataCol.Name
Case "起点时间","结束时间"
If e.DataRow.IsNull("起点时间") OrElse e.DataRow.IsNull("结束时间") Then
e.DataRow("A组总收入") = Nothing
e.DataRow("B组总收入") = Nothing
Else
e.DataRow("A组总收入") = DataTables("表A基础数据").Compute("sum(收入)","立项时间 >= '" & e.DataRow("起点时间") & "' And 立项时间 <='" & e.DataRow("结束时间") & "' and 组别='A组'")
e.DataRow("B组总收入") = DataTables("表A基础数据").Compute("sum(收入)","立项时间 >= '" & e.DataRow("起点时间") & "' And 立项时间 <='" & e.DataRow("结束时间") & "' and 组别='B组'")
End If
Case "B组总收入","A组总收入","C组总收入","D组总收入"
Dim sum As Double = e.DataRow("A组总收入") + e.DataRow("B组总收入") + e.DataRow("C组总收入") + e.DataRow("D组总收入")
If sum > 0 Then
e.DataRow("A组收入占比") = e.DataRow("A组总收入")/sum
Else
e.DataRow("A组收入占比") =0
End If
End Select