Foxtable(狐表)用户栏目专家坐堂 → [求助]


  共有1993人关注过本帖树形打印复制链接

主题:[求助]

帅哥哟,离线,有人找我吗?
陈卫
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:126 积分:813 威望:0 精华:0 注册:2015/10/22 10:35:00
[求助]  发帖心情 Post By:2016/6/8 9:02:00 [只看该作者]

专家好!我有当前表“表1”,包括以下列“A”、“B”、“C”、“D”,需要做以下工作:
1)判断“A”、“B”列的某行是否为空值,如果是空值,不做任何事情;
2)分别在“A”、“B”列输入数据,判断“B”列:如果“B”列中的该行数据=“甲”,则在“表2”中的“A”列,找到与当前表“表1”中“A”列对应的行,把“表2”中“M”列对应行的数据赋给“表1”中“C”列对应的行,把“表2”中“N”列对应行的数据赋给“表1”中“D”列对应的行.
    否则,如果“B”列中的该行数据=“乙”,则在“表3”中的“A”列,找到与当前表“表1”中“A”列对应的行,把“表3”中“M”列对应行的数据赋给“表1”中“C”列对应的行,把“表3”中“N”列对应行的数据赋给“表1”中“D”列对应的行.
    否则,如果“B”列中的该行数据=“丙”,则在“表4”中的“A”列,找到与当前表“表1”中“A”列对应的行,把“表4”中“M”列对应行的数据赋给“表1”中“C”列对应的行,把“表4”中“N”列对应行的数据赋给“表1”中“D”列对应的行.
以下程序编码如何改才能正确?
Select Case e.DataCol.Name
    Case "A","D"
        If e.DataRow.IsNull("A") OrElse e.DataRow.IsNull("B") Then
            e.DataRow("C")=Nothing OrElse e.DataRow("D")=Nothing
            Else   If e.DataRow.IsNull("B") ="甲" then     
            Dim de As DataRow = e.DataRow 
            Dim pe As DataRow = DataTables("表2").Find("A= '" & de("A") & "'")
                If pe IsNot Nothing Then
                de("C") = pe("M")
                de("D") = pe("N")
                End If    
            Else    If e.DataRow.IsNull("B") ="乙" then
            Dim de As DataRow = e.DataRow 
            Dim pe As DataRow = DataTables("表3").Find("A= '" & de("A") & "'")
                If pe IsNot Nothing Then
                de("C") = pe(("M"))
                de("D") = pe("N")
                End If    
            Else    If e.DataRow.IsNull("B") ="丙" then
            Dim de As DataRow = e.DataRow 
            Dim pe As DataRow = DataTables("表4").Find("A= '" & de("A") & "'")
                If pe IsNot Nothing Then
                de("C") = pe(("M"))
                de("D") = pe("N")
                End If 
            End If 
End Select

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/6/8 12:12:00 [只看该作者]

Select Case e.DataCol.Name
    Case "A","B"
        If e.DataRow.IsNull("A") OrElse e.DataRow.IsNull("B") Then
            e.DataRow("C")=Nothing
e.DataRow("D")=Nothing
        ElseIf e.DataRow("B") ="甲" Then
            Dim de As DataRow = e.DataRow
            Dim pe As DataRow = DataTables("表2").Find("A= '" & de("A") & "'")
            If pe IsNot Nothing Then
                de("C") = pe("M")
                de("D") = pe("N")
            End If
        ElseIf e.DataRow("B") ="乙" Then
            Dim de As DataRow = e.DataRow
            Dim pe As DataRow = DataTables("表3").Find("A= '" & de("A") & "'")
            If pe IsNot Nothing Then
                de("C") = pe(("M"))
                de("D") = pe("N")
            End If
        ElseIf e.DataRow("B") ="丙" Then
            Dim de As DataRow = e.DataRow
            Dim pe As DataRow = DataTables("表4").Find("A= '" & de("A") & "'")
            If pe IsNot Nothing Then
                de("C") = pe(("M"))
                de("D") = pe("N")
            End If
        End If
End Select

 回到顶部
帅哥哟,离线,有人找我吗?
陈卫
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:126 积分:813 威望:0 精华:0 注册:2015/10/22 10:35:00
  发帖心情 Post By:2016/6/8 15:05:00 [只看该作者]

谢谢专家,问题解决了,但其中有这样的重复编码,这样合并成一段简单、不重复的?
 ElseIf e.DataRow("B") = "乙1" Then
            Dim de As DataRow = e.DataRow
            Dim pe As DataRow = DataTables("表3").Find("A= '" & de("A") & "'")
            If pe IsNot Nothing Then
                de("C") = pe("M")
                de("D") = pe("N")
            End If
         ElseIf e.DataRow("B") = "乙2" Then
            Dim de As DataRow = e.DataRow
            Dim pe As DataRow = DataTables("表3").Find("A= '" & de("A") & "'")
            If pe IsNot Nothing Then
                de("C") = pe("M")
                de("D") = pe("N")
            End If
          ElseIf e.DataRow("B") = "乙3" Then
            Dim de As DataRow = e.DataRow
            Dim pe As DataRow = DataTables("表3").Find("A= '" & de("A") & "'")
            If pe IsNot Nothing Then
                de("C") = pe("M")
                de("D") = pe("N")
            End If

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/6/8 19:16:00 [只看该作者]

Select Case e.DataCol.Name
    Case "A","B"
        If e.DataRow.IsNull("A") OrElse e.DataRow.IsNull("B") Then
            e.DataRow("C")=Nothing
            e.DataRow("D")=Nothing
        Else
            Dim de As DataRow = e.DataRow
            Dim pe As DataRow = DataTables("表2").Find("A= '" & de("A") & "'")
            If pe IsNot Nothing Then
                If e.DataRow("B") ="甲" Then
                    de("C") = pe("M")
                    de("D") = pe("N")
                ElseIf e.DataRow("B") ="乙" Then
                    de("C") = pe(("M"))
                    de("D") = pe("N")
                ElseIf e.DataRow("B") ="丙" Then
                    de("C") = pe(("M"))
                    de("D") = pe("N")
                End If
            End If
        End If
End Select

 回到顶部