以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  表事件,DATACOLCAHNGED里面写,SELECT CASE  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=76932)

--  作者:yancheng
--  发布时间:2015/11/8 10:00:00
--  表事件,DATACOLCAHNGED里面写,SELECT CASE
表事件,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编辑过]

--  作者:大红袍
--  发布时间:2015/11/8 11:49:00
--  

方法一:分开

 

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
End Select
 
Select Case e.DataCol.Name
    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 

 


--  作者:大红袍
--  发布时间:2015/11/8 11:49:00
--  

select case,一次,只会匹配一个。