Foxtable(狐表)用户栏目专家坐堂 → 变量赋值问题


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

主题:变量赋值问题

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


加好友 发短信
等级:狐精 帖子:3082 积分:20596 威望:0 精华:0 注册:2016/3/28 16:57:00
变量赋值问题  发帖心情 Post By:2022/9/19 9:35:00 [只看该作者]


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

老师,请教一下:我有个窗口,如上图:

1、供货方名称控件:

Enter事件代码如下:

Dim r As Row = Tables("委托支付管理").Current
If r IsNot Nothing Then  '如果找到的话
    e.Sender.ComboList = DataTables("采购合同管理").SQLGetComboListString("供货方名称 + ',' + 供货方账号 + ',' + 供货方开户银行","[项目名称] = '" & r("项目名称") & "'")
End If

ValueChanged事件代码如下:

Dim cmb As WinForm.ComboBox = e.Form.Controls("ComboBox6")
Dim cmb1 As WinForm.TextBox = e.Form.Controls("TextBox6")
Dim cmb2 As WinForm.TextBox = e.Form.Controls("TextBox10")
Dim Multi As String = cmb.text
Dim Values() As String
Values = Multi.split(",")
If Values.Length > 1
    Tables("委托支付管理").Current("供货方名称")=Values(0)
    Tables("委托支付管理").Current("供货方账号")=Values(1)
    Tables("委托支付管理").Current("供货方开户银行")=Values(2)
End If

 

2、付款方户名控件

Enter事件代码如下:

e.Sender.ComboList = DataTables("委托支付管理").sqlGetComboListString("付款方户名 + ',' + 付款方账号 + ',' + 付款方开户银行")

ValueChanged事件代码如下:

Dim cmb As WinForm.ComboBox = e.Form.Controls("ComboBox4")
Dim cmb1
As WinForm.TextBox = e.Form.Controls("TextBox1")
Dim cmb2 As WinForm.TextBox = e.Form.Controls("TextBox03")
Dim Multi As String = cmb.text
Dim Values() As String
Values = Multi.split(",")
If Values.Length > 1
    Tables("委托支付管理").Current("付款方户名")=Values(0)
    Tables("委托支付管理").Current("付款方账号")=Values(1)
    Tables("委托支付管理").Current("付款方开户银行")=Values(2)
End If

问题:我先选择供货方名称,然后在选择付款方户名时,付款方的账号和付款方开户银行会替换掉前面已经选择的:供货方账号、供货方开户银行,是哪儿问题呢?



 回到顶部
帅哥,在线噢!
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


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

控件事件还有其它什么代码?控件有没有绑定表格?"委托支付管理"表事件有什么代码?

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


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

控件事件没有其他代码了,控件绑定了表格,表事件DataColChanged代码只有这个:

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 c  md As New SQLCommand
        Dim dt As DataTable
        cmd.C 
        cmd.C  ommandText = "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
        End If
    End If
End If

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
            If e.DataRow("供货方名称") <> Nothing Then
                Dim c  md As New SQLCommand
                Dim dt As DataTable
                cmd.C 
                'cmd.C  ommandText = "S  ELECT DISTINCT 供货方名称,供货方账号,供货方开户银行 From {采购合同管理} where [供货方名称]= '" & e.NewValue & "'"
                cmd.C  ommandText = "ELECT DISTINCT 项目名称,供货方名称,供货方账号,供货方开户银行 From {采购合同管理} where [供货方名称]= '" & e.NewValue & "' and [项目名称] = '" & 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
    End If
Else
    Dim nmw()As String = {"供货方账号","供货方开户银行"}
    Dim c  md As New SQLCommand
    Dim dt As DataTable
    cmd.C 
    'cmd.C  ommandText = "ELECT DISTINCT 供货方名称,供货方账号,供货方开户银行 From {采购合同管理} where [供货方名称]= '" & e.NewValue & "'"
     cmd.C  ommandText = "ELECT DISTINCT 项目名称,供货方名称,供货方账号,供货方开户银行 From {采购合同管理} where [供货方名称]= '" & e.NewValue & "' and [项目名称] = '" & 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
而且只有一个项目会有这种情况,其他项目没这样的情况

[此贴子已经被作者于2022/9/19 10:19:11编辑过]

 回到顶部
帅哥,在线噢!
有点蓝
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


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

只有一个项目会有这种情况】是指发布后的程序?意思是只有一个客户端电脑会有这种情况?

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


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

不是的,我有很多项目名称,只有一个项目是指项目名称:“S305开江县八庙镇(川渝界)至靖安乡(达川界)段改建工程(二标段)施工”会出现这个问题,其他的项目名称不会出现这个问题

 


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

 回到顶部
帅哥,在线噢!
有点蓝
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


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

把DataColChanged事件注释掉测试有没有问题?

关闭退出项目,删除项目所在的文件夹里的bin目录,然后重启项目试试。

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


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

这一段代码注释掉就没问题,但是没想明白为什么只有这一个项目名称会出现这种情况

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
            If e.DataRow("供货方名称") <> Nothing Then
                Dim c  md As New SQLCommand
                Dim dt As DataTable
                cmd.C 
                'cmd.C  ommandText = "S  ELECT DISTINCT 供货方名称,供货方账号,供货方开户银行 From {采购合同管理} where [供货方名称]= '" & e.NewValue & "'"
                cmd.C  ommandText = "ELECT DISTINCT 项目名称,供货方名称,供货方账号,供货方开户银行 From {采购合同管理} where [供货方名称]= '" & e.NewValue & "' and [项目名称] = '" & 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
    End If
Else
    Dim nmw()As String = {"供货方账号","供货方开户银行"}
    Dim c  md As New SQLCommand
    Dim dt As DataTable
    cmd.C 
    'cmd.C  ommandText = "ELECT DISTINCT 供货方名称,供货方账号,供货方开户银行 From {采购合同管理} where [供货方名称]= '" & e.NewValue & "'"
     cmd.C  ommandText = "ELECT DISTINCT 项目名称,供货方名称,供货方账号,供货方开户银行 From {采购合同管理} where [供货方名称]= '" & e.NewValue & "' and [项目名称] = '" & 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


 回到顶部
帅哥,在线噢!
有点蓝
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


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

调试跟踪每一行代码执行的结果

msgbox("付款金额=" & e.DataRow("付款金额") )
If  e.DataRow("付款金额") >= "30000"  Then
msgbox("触发的列名=" & e.DataCol.Name )
    If  e.DataCol.Name = "供货方名称" OrElse e.DataCol.Name = "付款金额" Then
        Dim nms()As String = {"供货方账号","供货方开户银行"}
msgbox("触发的列数据=" & e.NewValue )
        If  e.NewValue Is Nothing Then
            For Each nm As String In nms
                e.DataRow(nm)= Nothing
            Next
        Else
msgbox(其它调试自行写.....)
            If e.DataRow("供货方名称") <> Nothing Then
                Dim c  md As New SQLCommand
msgbox(其它调试自行写....)
……
Else

    Dim nmw()As String = {"供货方账号","供货方开户银行"}
    Dim c  md As New SQLCommand
    Dim dt As DataTable
    cmd.C 
    'cmd.C  ommandText = "S  ELECT DISTINCT 供货方名称,供货方账号,供货方开户银行 From {采购合同管理} where [供货方名称]= '" & e.NewValue & "'"
     cmd.C  ommandText = "S  ELECT DISTINCT 项目名称,供货方名称,供货方账号,供货方开户银行 From {采购合同管理} where [供货方名称]= '" & e.NewValue & "' and [项目名称] = '" & e.DataRow("项目名称") & "'"
    dt = cmd.ExecuteReader()
msgbox("dt.datarows.count=" & dt.datarows.count )
    If dt.datarows.count > 0  Then
        Dim dr As DataRow = dt.datarows(0)
        For Each nm As String In nmw
msgbox("nm=" & nm & “,赋值=” & dr(nm))
            e.DataRow(nm)= dr(nm)
        Next
        e.DataRow("是否签订采购合同") = True
    End If
End If

 回到顶部