列:季度含(第一季度,第二季度,第三季度,第四季度),在季度列选择如:第一季度时,在月考核奖金列自动显示1、2、3个月列,其他列隐藏,这时,在季度合计中计算三个月的数据,当选择第二季度时,在月考核奖金列自动显示4、5、6个月列,其他列隐藏,在季度合计中计算三个月的数据;依次类推,当季度列无选择时(也就是空)季度合计列应为空。下述代码能计算选择时的季度合计,但选择季度列为空时,季度合计列不清空,请帮助改一下代码,谢谢。
Select Case e.DataCol.Name
Case "月考核奖金_1","月考核奖金_2","月考核奖金_3","月考核奖金_4","月考核奖金_5","月考核奖金_6","月考核奖金_7","月考核奖金_8","月考核奖金_9","月考核奖金_10","月考核奖金_11","月考核奖金_12"
Dim cls() As String = {"月考核奖金_1","月考核奖金_2","月考核奖金_3","月考核奖金_4","月考核奖金_5","月考核奖金_6","月考核奖金_7","月考核奖金_8","月考核奖金_9","月考核奖金_10","月考核奖金_11","月考核奖金_12"}
Dim t As Table = Tables(e.DataTable.Name)
Dim sum As Integer = 0
For Each c As String In cls
If e.DataRow("季度") = Nothing Then
e.DataRow("季度合计") = 0
ElseIf t.Cols(c).Visible AndAlso e.DataRow("季度") <> Nothing Then
sum += e.DataRow(c)
End If
Next
e.DataRow("季度合计") = sum
End Select