以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  数据自动变化  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=85438)

--  作者:qinlao666
--  发布时间:2016/5/25 20:27:00
--  数据自动变化
请教老师,如图

后面一栏的数据是随前面一栏的数据变化而变化的,且每一横行没有任何的关联

请问有没有简洁的命令实现我的想法,而不是像我这样一个一个的写,因为有好几十个这样的数据,请老师赐教,谢谢
If e.DataCol.Name = "介质名称" Then
    If e.NewValue Is Nothing Then
        e.DataRow("介质名称英文") = Nothing
    Else
        Dim dr As DataRow
        dr = DataTables("泵电机参数").Find("[介质名称] = \'" & e.NewValue & "\'")
        If dr IsNot Nothing
            e.DataRow("介质名称英文") = 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
        dr = DataTables("泵电机参数").Find("[螺杆轴数量] = \'" & e.NewValue & "\'")
        If dr IsNot Nothing
            e.DataRow("螺杆轴数量英文") = dr("螺杆轴数量英文")
            e.DataRow("螺杆轴数量代码") = 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
        dr = DataTables("泵电机参数").Find("[压力范围] = \'" & e.NewValue & "\'")
        If dr IsNot Nothing
            e.DataRow("压力范围英文") = dr("压力范围英文")
            e.DataRow("压力范围代码") = dr("压力范围代码")
        End If
    End If
End If

--  作者:qinlao666
--  发布时间:2016/5/25 20:33:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:qq截图20160525202918.jpg
图片点击可在新窗口打开查看

--  作者:大红袍
--  发布时间:2016/5/25 20:40:00
--  
Dim cs1() As String = {"介质名称","螺杆数量"}
Dim cs2() As String = {"介质名称","螺杆轴数量"}
Dim idx As Integer = array.indexof(cs1, e.DataCol.name)
If idx >= 0 Then
    Dim dr = DataTables("泵电机参数").Find(cs2(idx) & " = \'" & e.NewValue & "\'")
    Dim n1 As String = cs2(idx) & "英文"
    Dim n2 As String = cs2(idx) & "代码"
    If dr Is Nothing Then
        If e.DataTable.datacols.contains(n1) Then e.DataRow(n1) = Nothing
        If e.DataTable.datacols.contains(n2) Then e.DataRow(n2) = Nothing
    Else
        If e.DataTable.datacols.contains(n1) Then e.DataRow(n1) = dr(n1)
        If e.DataTable.datacols.contains(n2) Then e.DataRow(n2) = dr(n2)
    End If
End If