Foxtable(狐表)用户栏目专家坐堂 → [求助] 修改密码报错。


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

主题:[求助] 修改密码报错。

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


加好友 发短信
等级:六尾狐 帖子:1353 积分:9868 威望:0 精华:0 注册:2015/6/30 8:46:00
[求助] 修改密码报错。  发帖心情 Post By:2019/12/6 22:04:00 [只看该作者]

 

老师,以下代码,在服务端,有时会报错,这种情况的偶尔发生,但一但报错了,服务器就不运行了,没找到问题点在那里?

 


Dim wb As New weui

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim pkey As Integer = e.GetValues("key")
If e.PostValues.count = 0 Then
    wb.AddForm("","editpwd1","editpwd.htm")
    With wb.AddInputGroup("editpwd1","ipg1","更改密码")
        If pkey > 0 Then
            Dim fr As DataRow = DataTables("人员表").SQLFind("序号 = " & pkey)
            If fr IsNot Nothing Then
                .AddInput("name","姓名","text").Value = fr("姓名")
            Else
                .AddInput("name","姓名","text")
            End If
        Else
            .AddInput("name","姓名","text")
        End If
        .AddInput("opwd","旧 密 码","password").Placeholder = "第一次设置密码时为空"
        .AddInput("Npwd1","新 密 码","password")
        .AddInput("Npwd2","重复密码","password")
    End With
    With wb.AddButtonGroup("editpwd1","btg1",True)
        .Add("btn1", "确认", "submit")
        .Add("btn1", "返回","","logon.htm").Kind = 1
    End With
Else
    Dim fr As DataRow = Functions.Execute("fir",e.PostValues("name") )
    If fr Is Nothing Then
        With wb.AddMsgPage("","msgpage","提示", "您不是本公司的员工或您输入的用户名错误!")
            .icon = "Warn" '改变图标
            .AddButton("btn1","返回").Attribute = ""
        End With
    Else
        If fr.IsNull("pwd") = False Then
            If e.PostValues("opwd") <> fr("pwd") Then
                With wb.AddMsgPage("","msgpage","密码错误", "您输入的旧密码错误!")
                    .icon = "Warn" '改变图标
                    .AddButton("btn1","返回").Attribute = ""
                End With
            End If
        End If
        If e.PostValues("npwd1") = e.PostValues("npwd2") Then
            fr("pwd") = e.PostValues("npwd2")
            fr.Save
            With wb.AddMsgPage("","msgpage","修改提示", "密码修改完成!")
                .AddButton("btn1","返回","logon.htm")
            End With
        Else
            With wb.AddMsgPage("","msgpage","输入错误", "您二次输入的密码不一致!")
                .icon = "Warn" '改变图标
                .AddButton("btn1","返回").Attribute = ""
            End With
        End If
    End If
End If
'wb.AddPageFooter("","pf1","").AddLink("返回登录","logon.htm")
e.WriteString(wb.Build) '生成网页


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


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

提示什么错误?

httprequest完整代码发上来看看
[此贴子已经被作者于2019/12/6 22:31:21编辑过]

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


加好友 发短信
等级:六尾狐 帖子:1353 积分:9868 威望:0 精华:0 注册:2015/6/30 8:46:00
  发帖心情 Post By:2019/12/7 8:40:00 [只看该作者]

.NET Framework 版本:4.0.30319.18063
Foxtable 版本:2019.11.3.1
错误所在事件:自定义函数editpwd
详细错误信息:
调用的目标发生了异常。
已添加了具有相同键的项。

老师,试过,在点击确认后,网页未刷新完成,再点击确认就会有这样的错误!

 

Dim wb As New weui
wb.AddPageTitle("","pageheader","2020","上格兰格春节联欢晚会")
Select Case e.Path   
    Case "wefox"
        Functions.Execute("wefox",e)
    Case  "getBrands.htm"
        Dim pps As String = DataTables("人员表").SQLGetComboListString("部门","公司='" & e.PostValues("公司") & "'")
        e.WriteString(pps)
    Case "logon.htm",""
        Dim path As String = e.Path
        If path = Nothing Then path = "logon.htm"
        Functions.Execute(path.replace(".htm",""),e)
    Case Else
        Functions.Execute(e.path.replace(".htm",""),e)       
    End  Select

 

'~~~~~~~~以下为函数

Dim e As RequestEventArgs = args(0)
Dim wb As New weui
wb.AddPageTitle("","pageheader","2020","上格兰格春节联欢晚会")
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim pkey As Integer = e.GetValues("key")
If e.PostValues.count = 0 Then
    wb.AddForm("","editpwd1","editpwd.htm")
    With wb.AddInputGroup("editpwd1","ipg1","更改密码")
        If pkey > 0 Then
            Dim fr As DataRow = DataTables("人员表").SQLFind("序号 = " & pkey)
            If fr IsNot Nothing Then
                .AddInput("name","姓名","text").Value = fr("姓名")
            Else
                .AddInput("name","姓名","text")
            End If
        Else
            .AddInput("name","姓名","text")
        End If
        .AddInput("opwd","旧 密 码","password").Placeholder = "第一次设置密码时为空"
        .AddInput("Npwd1","新 密 码","password")
        .AddInput("Npwd2","重复密码","password")
    End With
    With wb.AddButtonGroup("editpwd1","btg1",True)
        .Add("btn1", "确认", "submit")
        .Add("btn1", "返回","","logon.htm").Kind = 1
    End With
Else
    Dim fr As DataRow = Functions.Execute("fir",e.PostValues("name") )
    If fr Is Nothing Then
        With wb.AddMsgPage("","msgpage","提示", "您不是本公司的员工或您输入的用户名错误!")
            .icon = "Warn" '改变图标
            .AddButton("btn1","返回").Attribute = ""
        End With
    Else
        If fr.IsNull("pwd") = False Then
            If e.PostValues("opwd") <> fr("pwd") Then
                With wb.AddMsgPage("","msgpage","密码错误", "您输入的旧密码错误!")
                    .icon = "Warn" '改变图标
                    .AddButton("btn1","返回").Attribute = ""
                End With
            End If
        End If
        If e.PostValues("npwd1") = e.PostValues("npwd2") Then
            fr("pwd") = e.PostValues("npwd2")
            fr.Save
            With wb.AddMsgPage("","msgpage","修改提示", "密码修改完成!")
                .AddButton("btn1","返回","logon.htm")
            End With
        Else
            With wb.AddMsgPage("","msgpage","输入错误", "您二次输入的密码不一致!")
                .icon = "Warn" '改变图标
                .AddButton("btn1","返回").Attribute = ""
            End With
        End If
    End If
End If
'wb.AddPageFooter("","pf1","").AddLink("返回登录","logon.htm")
e.WriteString(wb.Build) '生成网页


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


加好友 发短信
等级:超级版主 帖子:111412 积分:567130 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/12/7 9:13:00 [只看该作者]

同一个网页里控件的ID是不能相同的。

With wb.AddButtonGroup("editpwd1","btg1",True)
        .Add("btn1", "确认", "submit")
        .Add("btn1", "返回","","logon.htm").Kind = 1
    End With

自己再仔细检查

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


加好友 发短信
等级:六尾狐 帖子:1353 积分:9868 威望:0 精华:0 注册:2015/6/30 8:46:00
  发帖心情 Post By:2019/12/7 9:50:00 [只看该作者]

以下是引用有点蓝在2019/12/7 9:13:00的发言:
同一个网页里控件的ID是不能相同的。

With wb.AddButtonGroup("editpwd1","btg1",True)
        .Add("btn1", "确认", "submit")
        .Add("btn1", "返回","","logon.htm").Kind = 1
    End With

自己再仔细检查

 

老师,问题依旧,应该不是这个问题,还原到错误原因,但不知怎么处理。

 

在点击确认后,网页未刷新完成,再点击确认就会有这样的错误!

 


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


加好友 发短信
等级:超级版主 帖子:111412 积分:567130 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/12/7 10:48:00 [只看该作者]

如果还是提示{已添加了具有相同键的项。}肯定还有重复的名称

httprequest事件完整代码和函数的完整代码放到txt发上来,或者上传项目看看

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


加好友 发短信
等级:六尾狐 帖子:1353 积分:9868 威望:0 精华:0 注册:2015/6/30 8:46:00
  发帖心情 Post By:2019/12/7 10:52:00 [只看该作者]

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:111.txt


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


加好友 发短信
等级:超级版主 帖子:111412 积分:567130 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/12/7 11:27:00 [只看该作者]

        If fr.IsNull("EventName") = False Then
            If e.PostValues("opwd") <> fr("EventName") Then
                With wb.AddMsgPage("","msgpage","密码错误", "您输入的旧密码错误!")
                    .icon = "Warn" '改变图标
                    .AddButton("btn3","返回").Attribute = ""
                End With
                e.WriteString(wb.Build)
                Return Nothing '
            End If
        End If

每个AddMsgPage之后都必须直接返回,不应该再有其他网页代码,其它地方自己改改

 回到顶部