以文本方式查看主题

-  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=67735)

--  作者:foxbable_saber
--  发布时间:2015/4/30 11:45:00
--  [求助]小白求助,变量逻辑语句求修正!
如题:
1、表A有,【原始地】【目的地】【国际or国内】
2、表B有,【地区三字代码】【国际国内】
3、经过如下语句,给表A【国际or国内】列赋值。


Select Case e.DataCol.name                        \'国际or国内
    Case "起始地","目的地"
        Dim UP1 As String
        Dim DW1 As String
        Dim NY As String
        If e.DataRow.IsNull("起始地") OrElse e.DataRow.IsNull("目的地") Then
            e.DataRow("国际or国内") = Nothing
        ElseIf e.DataRow("起始地") <> Nothing Then
            Dim UPAAA As DataRow
            UPAAA = DataTables("地区货币能力表").Find("[地区三字码] = \'" & e.NewValue & "\'")
            If UPAAA IsNot Nothing Then
                UP1 = UPAAA("国际国内")
            End If
        ElseIf e.DataRow("目的地") <> Nothing Then
            Dim DWAAA As DataRow
            DWAAA = DataTables("地区货币能力表").Find("[地区三字码] = \'" & e.NewValue & "\'")
            If DWAAA IsNot Nothing Then
                DW1 = DWAAA("国际国内")
            End If
        ElseIf UP1 <> "国内" OrElse DW1 <> "国内" Then
            NY = "国际"
        ElseIf UP1 = "国内" And DW1 = "国内" Then
            NY = "国内"
            If NY IsNot Nothing Then
                e.DataRow("国际or国内") = NY
            Else
                e.DataRow("国际or国内") = "错误"
            End If
        End If
End Select
[此贴子已经被作者于2015/4/30 13:07:51编辑过]

--  作者:Bin
--  发布时间:2015/4/30 11:45:00
--  
没看懂你的问题
--  作者:foxbable_saber
--  发布时间:2015/4/30 15:11:00
--  

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


Select Case e.DataCol.name                        \' 国际or国内
    Case "起始地","目的地"
        Dim UP1 As String                              ’声明变量 ”UP1“为【起始地】不为空时,且搜索表B地区三字码有内容,返回“国内“/”国际”值给它
        Dim DW1 As String                             ’声明变量 ”DW1“=【目的地】不为空,且搜索地区三字码有内容,返回“国际、国内”给它”   
        If e.DataRow.IsNull("起始地") OrElse e.DataRow.IsNull("目的地") Then
            e.DataRow("国际or国内") = Nothing
        ElseIf e.DataRow("起始地") <> Nothing Then
            Dim UPAAA As DataRow
            UPAAA = DataTables("地区货币能力表").Find("[地区三字码] = \'" & e.NewValue & "\'")
            If UPAAA IsNot Nothing Then
                UP1 = UPAAA("国际国内")
            End If
        ElseIf e.DataRow("目的地") <> Nothing Then
            Dim DWAAA As DataRow
            DWAAA = DataTables("地区货币能力表").Find("[地区三字码] = \'" & e.NewValue & "\'")
            If DWAAA IsNot Nothing Then
                DW1 = DWAAA("国际国内")
            End If
         End IF
         If UP1 = "国内" And DW1 = "国内" Then
            e.DataRow("国际or国内") = "国内"
        ElseIf UP1 = "国际" OrElse DW1 = "国际" Then
            e.DataRow("国际or国内")="国际"
        else  
            e.DataRow("国际or国内")="错误"
        End If
End Select

--  作者:Bin
--  发布时间:2015/4/30 15:16:00
--  
 e.DataRow("起始地") <> Nothing  改为
 e.DataRow.isnull("起始地")=false



--  作者:foxbable_saber
--  发布时间:2015/4/30 16:34:00
--  
项目下载:
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:货币转换项目.foxdb


bin大,经过消化,试验还是感觉不大对劲!

1、感觉缺 变量 up1 dw1 变化“datarow”声明。您给润润笔!
2、【原始地】【目的地】 同时输入数据,显示出一结果,但是输入后再单独变一个列的数据数据,【国际or国内】列不更新(或变更不积极),必须把【原始地】或【目的地】删除旧数据再填新数据才会变。
3、您给总体润润笔,谢谢!


Dim UP1 As DataRow = e.DataRow
Dim DW1 As DataRow = e.DataRow
Select Case e.DataCol.name                        \' 国际or国内
    Case "原始地","目的地"
        If e.DataRow.IsNull("原始地") OrElse e.DataRow.IsNull("目的地") Then
            e.DataRow("国际or国内") = Nothing
        ElseIf e.DataRow.IsNull("原始地") = False Then
            Dim UPAAA As DataRow
            UPAAA = DataTables("地区货币能力表").Find("[地区三字码] = \'" & e.NewValue & "\'")
            If UPAAA IsNot Nothing Then
                UP1("国际or国内") = UPAAA("国际国内特区")
            End If
        ElseIf e.DataRow.IsNull("原始地") = False Then
            Dim DWAAA As DataRow
            DWAAA = DataTables("地区货币能力表").Find("[地区三字码] = \'" & e.NewValue & "\'")
            If DWAAA IsNot Nothing Then
                DW1("国际or国内") = DWAAA("国际国内特区")
            End If
        End If
        
        If e.DataRow.IsNull("原始地") OrElse e.DataRow.IsNull("目的地") Then
            e.DataRow("国际or国内") = Nothing
        ElseIf UP1.isnull("国际or国内") And DW1.isnull("国际or国内") Then
            e.DataRow("国际or国内") = "全新"
        ElseIf UP1.isnull("国际or国内")  Then
            e.DataRow("国际or国内") = "原新"
        ElseIf DW1.isnull("国际or国内") Then
            e.DataRow("国际or国内") = "目新"
        ElseIf UP1("国际or国内") = "国内" And DW1("国际or国内") = "国内" Then
            e.DataRow("国际or国内") = "国内"
        ElseIf UP1("国际or国内") = "国际" OrElse DW1("国际or国内") = "国际" Then
            e.DataRow("国际or国内")="国际"
        Else
            e.DataRow("国际or国内")="错误"
        End If
End Select
[此贴子已经被作者于2015/4/30 16:38:41编辑过]

--  作者:Bin
--  发布时间:2015/4/30 16:43:00
--  
你这逻辑,好难理解啊.

第二个问题应该是你其中一个为空了.都不为空才可以



--  作者:foxbable_saber
--  发布时间:2015/5/4 11:06:00
--  
bin 大,如下图:

此主题相关图片如下:12312321321.jpg
按此在新窗口浏览图片


此主题相关图片如下:22222.jpg
按此在新窗口浏览图片



Dim UP1 As DataRow = e.DataRow
Dim DW1 As DataRow = e.DataRow
Select Case e.DataCol.name                        
    Case "原始地","目的地"
        If e.DataRow.IsNull("原始地") OrElse e.DataRow.IsNull("目的地") Then
            e.DataRow("国际or国内") = Nothing
        ElseIf e.DataRow.IsNull("原始地") = False Then
            Dim UPAAA As DataRow
            UPAAA = DataTables("地区货币能力表").Find("[地区三字码] = \'" & e.NewValue & "\'")
            If UPAAA IsNot Nothing Then
                UP1("国际or国内") = UPAAA("国际国内特区")
            End If
        ElseIf e.DataRow.IsNull("目的地") = False Then
            Dim DWAAA As DataRow
            DWAAA = DataTables("地区货币能力表").Find("[地区三字码] = \'" & e.NewValue & "\'")
            If DWAAA IsNot Nothing Then
                DW1("国际or国内") = DWAAA("国际国内特区")
            End If
        End If
        
        If e.DataRow.IsNull("原始地") OrElse e.DataRow.IsNull("目的地") Then
            e.DataRow("国际or国内") = Nothing
        ElseIf UP1.isnull("国际or国内") And DW1.isnull("国际or国内") Then
            e.DataRow("国际or国内") = "全新"
        ElseIf UP1.isnull("国际or国内")  Then
            e.DataRow("国际or国内") = "原新"
        ElseIf DW1.isnull("国际or国内") Then
            e.DataRow("国际or国内") = "目新"
        ElseIf UP1("国际or国内") = "国内" And DW1("国际or国内") = "国内" Then
            e.DataRow("国际or国内") = "国内"
        ElseIf UP1("国际or国内") = "国际" OrElse DW1("国际or国内") = "国际" Then
            e.DataRow("国际or国内")="国际"
        Else
            e.DataRow("国际or国内")="错误"
        End If
End Select

[此贴子已经被作者于2015/5/4 11:17:31编辑过]

--  作者:Bin
--  发布时间:2015/5/4 11:14:00
--  
1.
Dim UP1 As DataRow = e.DataRow
Dim DW1 As DataRow = e.DataRow
既然是储存查找到的行,干嘛为它赋值E.datarow . 应该

Dim UP1 As DataRow = datatables("地区表").Find("三字码=\'" & e.datarow("原始地") & "\'")
Dim DW1 As DataRow = datatables("地区表").Find("三字码=\'" & e.datarow("目的地") & "\'")


--  作者:Bin
--  发布时间:2015/5/4 11:14:00
--  
要判断是否为空.

if up1 is nothing then


--  作者:大红袍
--  发布时间:2015/5/4 11:35:00
--  
Dim UP1 As String = ""
Dim DW1 As String = ""
Select Case e.DataCol.name                        \' 国际or国内
    Case "原始地","目的地"
        If e.DataRow.IsNull("原始地") OrElse e.DataRow.IsNull("目的地") Then
            e.DataRow("国际or国内") = Nothing
        Else
            If e.DataRow.IsNull("原始地") = False Then
                Dim UPAAA As DataRow
                UPAAA = DataTables("地区货币能力表").Find("[地区三字码] = \'" & e.DataRow("原始地") & "\'")
                If UPAAA IsNot Nothing Then
                    up1 = UPAAA("国际国内特区")
                End If
            End If
            If e.DataRow.IsNull("目的地") = False Then
                Dim DWAAA As DataRow
                DWAAA = DataTables("地区货币能力表").Find("[地区三字码] = \'" & e.DataRow("目的地") & "\'")
                If DWAAA IsNot Nothing Then
                    DW1 = DWAAA("国际国内特区")
                End If
            End If
           
            If up1 = "" AndAlso dw1 <> "" Then
                e.DataRow("国际or国内") = "原新"
            ElseIf up1 <> "" AndAlso dw1 = "" Then
                e.DataRow("国际or国内") = "目新"
            ElseIf UP1 = "国内" AndAlso DW1 = "国内" Then
                e.DataRow("国际or国内") = "国内"
            ElseIf UP1 = "国际" OrElse DW1 = "国际" Then
                e.DataRow("国际or国内") = "国际"
            Else
                e.DataRow("国际or国内") = "错误"
            End If
        End If
End Select