以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]同一个表3个时间列,修改其中1个时间列其他2个时间列同时修改  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=121137)

--  作者:湛江智
--  发布时间:2018/6/29 17:57:00
--  [求助]同一个表3个时间列,修改其中1个时间列其他2个时间列同时修改
如题,不想用表达式,希望用代码实现
--  作者:有点甜
--  发布时间:2018/6/29 18:00:00
--  

1、修改的逻辑是什么?

 

2、datacolchanged事件写代码不就好了?最基础的代码。


--  作者:湛江智
--  发布时间:2018/6/29 19:11:00
--  回复:(有点甜)1、修改的逻辑是什么? 2、...

下面代码,能优化吗?这样写很长

 

\'3列修改同步修改

Select Case e.DataCol.Name

    Case "第一列","第二列","第三列"

 

        If e.DataCol.Name = "第一列" Then

            If e.NewValue Is Nothing Then

                e.DataRow("第二列") = Nothing

                e.DataRow("第三列") = Nothing

            Else

               

                Dim dr As DataRow = e.DataRow

                If dr.IsNull("第一列") = False Then \'身份证号码是否为空

                    dr("第二列") = dr("第一列")

                    dr("第三列") = dr("第一列")

                End If

            End If

        End If

 

If e.DataCol.Name = "第二列" Then

            If e.NewValue Is Nothing Then

                e.DataRow("第一列") = Nothing

                e.DataRow("第三列") = Nothing

            Else

               

                Dim dr As DataRow = e.DataRow

                If dr.IsNull("第二列") = False Then \'身份证号码是否为空

                    dr("第二列") = dr("第二列")

                    dr("第三列") = dr("第二列")

                End If

            End If

        End If

 

If e.DataCol.Name = "第三列" Then

            If e.NewValue Is Nothing Then

                e.DataRow("第二列") = Nothing

                e.DataRow("第一列") = Nothing

            Else

               

                Dim dr As DataRow = e.DataRow

                If dr.IsNull("第三列") = False Then \'身份证号码是否为空

                    dr("第二列") = dr("第三列")

                    dr("第一列") = dr("第三列")

                End If

            End If

        End If

 

End Select


--  作者:有点蓝
--  发布时间:2018/6/29 20:33:00
--  
Select Case e.DataCol.Name
    Case "第一列","第二列","第三列"
        Dim str() As String = {"第一列","第二列","第三列"}
        SystemReady = False
        For Each c As String In str
            If c <> e.DataCol.Name Then
                e.DataRow(c) = e.NewValue
            End If
        Next
        SystemReady = true
End Select