表事件,DATACOLCAHNGED里面写,SELECT CASE
Select e.DataCol.name
Case "含量"
Dim pr As DataRow = e.DataRow.GetParentRow("清单指引")
If pr IsNot Nothing Then
e.DataRow("数量") = pr("工程量") * e.NewValue
End If
Case "数量"
Dim pr As DataRow = e.DataRow.GetParentRow("清单指引")
If pr IsNot Nothing Then
e.DataRow("含量") = e.NewValue/pr("工程量")
End If
Case "数量","单价","成本价"
If e.DataRow.IsNull(e.DataCol.Name)=False Then
e.DataRow("合价")=e.DataRow("单价")*e.DataRow("数量")
e.DataRow("成本合价")=e.DataRow("成本价")*e.DataRow("数量")
Else
e.DataRow("合价")=Nothing
e.DataRow("成本合价")=Nothing
End If
end select
我感觉,Case "数量" 在上面,它的代码会执行,Case "数量","单价","成本价"在下面,代码不执行?
是不是这个select case 语句不能这样写呢?
我把代码,合并成如下代码,就正常?
Case "数量","单价","成本价"
Dim pr As DataRow = e.DataRow.GetParentRow("清单指引")
If pr IsNot Nothing Then
If pr("工程量") > 0 Then
e.DataRow("含量") = e.DataRow("数量")/pr("工程量")
End If
End If
e.DataRow("合价") = e.DataRow("单价") * e.DataRow("数量")
e.DataRow("成本合价") = e.DataRow("成本价") * e.DataRow("数量")
[此贴子已经被作者于2015/11/8 10:03:26编辑过]