Foxtable(狐表)用户栏目专家坐堂 → 跨表引用逻辑问题


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

主题:跨表引用逻辑问题

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


加好友 发短信
等级:狐精 帖子:3082 积分:20596 威望:0 精华:0 注册:2016/3/28 16:57:00
跨表引用逻辑问题  发帖心情 Post By:2020/5/27 9:09:00 [只看该作者]

请老师看看,跨表引用时,先输入 付款金额,在选择供货方名称,如果 付款金额>3000,判断是否签订合同,如没签订合同,清空供货方的相关信息,提示没签订合同,应该怎么改呢?

If e.DataRow("款项类别") <> "代理费"  And e.DataRow("款项类别") <> "保险费"  Then
    If  e.DataRow("付款金额") > "30000" Then
        If  e.DataCol.Name = "供货方名称" Then
            Dim nms()As String = {"供货方账号","供货方开户银行"}
            If  e.NewValue Is Nothing Then
                For Each nm As String In nms
                    e.DataRow(nm)= Nothing
                Next
            Else
                Dim cmd As New SQLCommand
                Dim dt As DataTable
                cmd.C
                cmd.CommandText = "S ELECT DISTINCT 供货方名称,供货方账号,供货方开户银行 From {采购合同管理} where [供货方名称]= '" & e.NewValue & "'"
                dt = cmd.ExecuteReader()
                If dt.datarows.count > 0
                    Dim dr As DataRow = dt.datarows(0)
                    For Each nm As String In nms
                        e.DataRow(nm)= dr(nm)
                    Next
                    e.DataRow("是否签订采购合同") = True
                Else
                    e.DataRow("供货方名称") = Nothing
                    e.DataRow("是否签订采购合同") = False
                    MessageBox.Show("未签订合同,不能委托支付")
                    Return
                End If
            End If
        End If
    End If
End If


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


加好友 发短信
等级:超级版主 帖子:106680 积分:542589 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/5/27 9:20:00 [只看该作者]

没看出有什么问题。

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


加好友 发短信
等级:狐精 帖子:3082 积分:20596 威望:0 精华:0 注册:2016/3/28 16:57:00
  发帖心情 Post By:2020/5/27 9:22:00 [只看该作者]

小于30000,不强制签订,但是也需要引用数据过来,没引用过来啊。

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


加好友 发短信
等级:超级版主 帖子:106680 积分:542589 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/5/27 9:31:00 [只看该作者]

If e.DataRow("款项类别") <> "代理费"  And e.DataRow("款项类别") <> "保险费"  Then
   
        If  e.DataCol.Name = "供货方名称" Then
            Dim nms()As String = {"供货方账号","供货方开户银行"}
            If  e.NewValue Is Nothing Then
                For Each nm As String In nms
                    e.DataRow(nm)= Nothing
                Next
            Else
                Dim cmd As New SQLCommand
                Dim dt As DataTable
                cmd.C
                cmd.CommandText = "S ELECT DISTINCT 供货方名称,供货方账号,供货方开户银行 From {采购合同管理} where [供货方名称]= '" & e.NewValue & "'"
                dt = cmd.ExecuteReader()
                If dt.datarows.count > 0
                    Dim dr As DataRow = dt.datarows(0)
                    For Each nm As String In nms
                        e.DataRow(nm)= dr(nm)
                    Next
                    e.DataRow("是否签订采购合同") = True
                Else
                    e.DataRow("供货方名称") = Nothing
                    e.DataRow("是否签订采购合同") = False
                    MessageBox.Show("未签订合同,不能委托支付")
                    Return
                End If
 If  e.DataRow("付款金额") <= "30000" Then 
                    e.DataRow("供货方名称") = Nothing
                    e.DataRow("是否签订采购合同") = False
end if
            End If
        End If

End If

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


加好友 发短信
等级:狐精 帖子:3082 积分:20596 威望:0 精华:0 注册:2016/3/28 16:57:00
  发帖心情 Post By:2020/5/29 16:46:00 [只看该作者]

老师,你那个方法不对,我判断的有点复杂,代码如下,先选择了款项类别和付款金额,在选择供货方信息,是正确的,但是如果我先选择了供货方信息,在填金额,判断没起到作用,应该怎么写呢?

If e.DataRow("款项类别") <> "代理费"  And e.DataRow("款项类别") <> "保险费"   Then
    If  e.DataRow("付款金额") > "30000" Then
        If  e.DataCol.Name = "供货方名称" Then
            Dim nms()As String = {"供货方账号","供货方开户银行"}
            If  e.NewValue Is Nothing Then
                For Each nm As String In nms
                    e.DataRow(nm)= Nothing
                Next
            Else
                Dim cmd As New SQLCommand
                Dim dt As DataTable
                cmd.C
                cmd.CommandText = "S ELECT DISTINCT 供货方名称,供货方账号,供货方开户银行 From {采购合同管理} where [供货方名称]= '" & e.NewValue & "'"
                dt = cmd.ExecuteReader()
                If dt.datarows.count > 0  Then
                    Dim dr As DataRow = dt.datarows(0)
                    For Each nm As String In nms
                        e.DataRow(nm)= dr(nm)
                    Next
                    e.DataRow("是否签订采购合同") = True
                Else
                    e.DataRow("供货方名称") = Nothing
                    e.DataRow("是否签订采购合同") = False
                    MessageBox.Show("该供应商还未签订供应合同,不能办理委托支付事宜!","提示",MessageBoxButtons.OK,MessageBoxIcon.None)
                    Return
                End If
            End If
        End If
    Else
        Dim nmw()As String = {"供货方账号","供货方开户银行"}
        Dim cmd As New SQLCommand
        Dim dt As DataTable
        cmd.C
        cmd.CommandText = "S ELECT DISTINCT 供货方名称,供货方账号,供货方开户银行 From {采购合同管理} where [供货方名称]= '" & e.NewValue & "'"
        dt = cmd.ExecuteReader()
        If dt.datarows.count > 0  Then
            Dim dr As DataRow = dt.datarows(0)
            For Each nm As String In nmw
                e.DataRow(nm)= dr(nm)
            Next
            e.DataRow("是否签订采购合同") = True
        End If
    End If
End If


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


加好友 发短信
等级:超级版主 帖子:106680 积分:542589 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/5/29 17:12:00 [只看该作者]


If  e.DataCol.Name = "供货方名称" Then
改为
If  e.DataCol.Name = "供货方名称" orelse e.DataCol.Name = "付款金额Then

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


加好友 发短信
等级:狐精 帖子:3082 积分:20596 威望:0 精华:0 注册:2016/3/28 16:57:00
  发帖心情 Post By:2020/6/8 17:29:00 [只看该作者]

老师,我选择了款项类别和输入>30000的金额,供货方名称还未空时,会提示未签订采购合同,需要增加一个判断,增加到哪儿呢?

还有就是<30000时,如果签订了合同,是否签订合同也=true

 

[此贴子已经被作者于2020/6/8 17:30:02编辑过]

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


加好友 发短信
等级:超级版主 帖子:106680 积分:542589 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/6/8 17:36:00 [只看该作者]

需要在哪一步进行判断就增加到哪里

If  e.DataRow("付款金额") > "30000" Then
相关处理逻辑
else
<30000时的处理逻辑
endif

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


加好友 发短信
等级:狐精 帖子:3082 积分:20596 威望:0 精华:0 注册:2016/3/28 16:57:00
  发帖心情 Post By:2020/6/8 17:41:00 [只看该作者]

老师,后面问题解决了的,前面问题应该哪儿判断呢?

 

我选择了款项类别和输入>30000的金额,供货方名称为空时,会提示未签订采购合同,需要增加一个判断,增加到哪儿呢?

 

If e.DataRow("款项类别") <> "代理费"  And e.DataRow("款项类别") <> "保险费" Then
    If  e.DataRow("付款金额") >= "30000"  Then
        If  e.DataCol.Name = "供货方名称" OrElse e.DataCol.Name = "付款金额" Then
            Dim nms()As String = {"供货方账号","供货方开户银行"}
            If  e.NewValue Is Nothing Then
                For Each nm As String In nms
                    e.DataRow(nm)= Nothing
                Next
            Else
                Dim cmd As New SQLCommand
                Dim dt As DataTable
                cmd.C
                cmd.CommandText = "S ELECT DISTINCT 供货方名称,供货方账号,供货方开户银行 From {采购合同管理} where [供货方名称]= '" & e.NewValue & "'"
                dt = cmd.ExecuteReader()
                If dt.datarows.count > 0 Then
                    Dim dr As DataRow = dt.datarows(0)
                    For Each nm As String In nms
                        e.DataRow(nm)= dr(nm)
                    Next
                    e.DataRow("是否签订采购合同") = True
                Else
                    e.DataRow("供货方名称") = Nothing
                    e.DataRow("是否签订采购合同") = False
                    MessageBox.Show("该供应商还未签订供应合同,不能办理委托支付事宜!","提示",MessageBoxButtons.OK,MessageBoxIcon.None)
                    Return
                End If
            End If
        End If
    Else
        Dim nmw()As String = {"供货方账号","供货方开户银行"}
        Dim cmd As New SQLCommand
        Dim dt As DataTable
        cmd.C
        cmd.CommandText = "S ELECT DISTINCT 供货方名称,供货方账号,供货方开户银行 From {采购合同管理} where [供货方名称]= '" & e.NewValue & "'"
        dt = cmd.ExecuteReader()
        If dt.datarows.count > 0  Then
            Dim dr As DataRow = dt.datarows(0)
            For Each nm As String In nmw
                e.DataRow(nm)= dr(nm)
            Next
        e.DataRow("是否签订采购合同") = True
        End If
    End If
End If

[此贴子已经被作者于2020/6/8 17:41:37编辑过]

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


加好友 发短信
等级:超级版主 帖子:106680 积分:542589 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/6/8 20:08:00 [只看该作者]

If e.DataRow("款项类别") <> "代理费"  And e.DataRow("款项类别") <> "保险费" Then
    If  e.DataRow("付款金额") >= "30000"  Then

        If  e.DataCol.Name = "供货方名称" OrElse e.DataCol.Name = "付款金额" Then
            Dim nms()As String = {"供货方账号","供货方开户银行"}
            If  e.DataRow.isnull("供货方名称") Then
                For Each nm As String In nms
                    e.DataRow(nm)= Nothing
                Next
            Else
                Dim cmd As New SQLCommand
                Dim dt As DataTable
                cmd.C
                cmd.CommandText = "S ELECT DISTINCT 供货方名称,供货方账号,供货方开户银行 From {采购合同管理} where [供货方名称]= '" & e.DataRow("供货方名称") & "'"
                dt = cmd.ExecuteReader()
                If dt.datarows.count > 0 Then
                    Dim dr As DataRow = dt.datarows(0)
                    For Each nm As String In nms
                        e.DataRow(nm)= dr(nm)
                    Next
                    e.DataRow("是否签订采购合同") = True
                Else
                    e.DataRow("供货方名称") = Nothing
                    e.DataRow("是否签订采购合同") = False
                    MessageBox.Show("该供应商还未签订供应合同,不能办理委托支付事宜!","提示",MessageBoxButtons.OK,MessageBoxIcon.None)
                    Return
                End If
            End If
        End If
    Else
        Dim nmw()As String = {"供货方账号","供货方开户银行"}
        Dim cmd As New SQLCommand
        Dim dt As DataTable
        cmd.C
        cmd.CommandText = "S ELECT DISTINCT 供货方名称,供货方账号,供货方开户银行 From {采购合同管理} where [供货方名称]= '" & e.DataRow("供货方名称") & "'"
        dt = cmd.ExecuteReader()
        If dt.datarows.count > 0  Then
            Dim dr As DataRow = dt.datarows(0)
            For Each nm As String In nmw
                e.DataRow(nm)= dr(nm)
            Next
        e.DataRow("是否签订采购合同") = True
        End If
    End If
End If



 回到顶部