以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  为啥红色字体的代码不起作用呢  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=165317)

--  作者:lfz123
--  发布时间:2021/5/13 15:02:00
--  为啥红色字体的代码不起作用呢
Dim dr As DataRow = e.DataRow
Select Case e.DataCol.name   
    Case "年限"
        If dr.IsNull("年限") Then
            dr("使用期限") = Nothing
        Else
            dr("使用期限") = dr("年限") * 12
        End If
    Case "残值率"
        If dr.IsNull("残值率") Then
            dr("预计净残值") = Nothing
        Else
            dr("预计净残值") = dr("原值") * dr("残值率")
        End If
    Case "原值","年限","残值率"
        If dr.IsNull("原值") OrElse dr.IsNull("年限") OrElse dr.IsNull("残值率")  Then
            dr("月折旧额") = Nothing
        Else
            dr("月折旧额") = (dr("原值") * (1 - dr("残值率"))) / dr("使用期限")
        End If
End Select

--  作者:有点蓝
--  发布时间:2021/5/13 15:20:00
--  
原因:http://www.foxtable.com/webhelp/topics/2242.htm

Dim dr As DataRow = e.DataRow
Select Case e.DataCol.name   
    Case "年限"
        If dr.IsNull("年限") Then
            dr("使用期限") = Nothing
        Else
            dr("使用期限") = dr("年限") * 12
        End If
    Case "残值率"
        If dr.IsNull("残值率") Then
            dr("预计净残值") = Nothing
        Else
            dr("预计净残值") = dr("原值") * dr("残值率")
        End If
End Select
Select Case e.DataCol.name   
    Case "原值","使用期限","残值率"
        If dr.IsNull("原值") OrElse dr.IsNull("使用期限") OrElse dr.IsNull("残值率") orelse 
dr("使用期限") <> 0 Then
            dr("月折旧额") = Nothing
        Else
            dr("月折旧额") = (dr("原值") * (1 - dr("残值率"))) / dr("使用期限")
        End If
End Select