⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmpwdedit.frm

📁 适用一般于毕业设计! VB代码源加SQL 数据库 ··
💻 FRM
字号:
VERSION 5.00
Begin VB.Form FrmPwdEdit 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "更改密码"
   ClientHeight    =   3180
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   4365
   Icon            =   "FrmPwdEdit.frx":0000
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3180
   ScaleWidth      =   4365
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  '屏幕中心
   Begin VB.Frame Frame1 
      Height          =   2295
      Left            =   180
      TabIndex        =   6
      Top             =   120
      Width           =   3975
      Begin VB.TextBox txtOldPwd 
         Height          =   375
         IMEMode         =   3  'DISABLE
         Left            =   1440
         PasswordChar    =   "*"
         TabIndex        =   1
         Text            =   "OldPwd"
         Top             =   780
         Width           =   2115
      End
      Begin VB.TextBox txtUserNo 
         Enabled         =   0   'False
         Height          =   375
         Left            =   1440
         TabIndex        =   0
         Text            =   "UserNo"
         Top             =   300
         Width           =   2115
      End
      Begin VB.TextBox txtNewPwd1 
         Height          =   375
         IMEMode         =   3  'DISABLE
         Left            =   1440
         PasswordChar    =   "*"
         TabIndex        =   2
         Text            =   "NewPwd1"
         Top             =   1260
         Width           =   2115
      End
      Begin VB.TextBox txtNewPwd2 
         Height          =   375
         IMEMode         =   3  'DISABLE
         Left            =   1440
         PasswordChar    =   "*"
         TabIndex        =   3
         Text            =   "New Pwd2"
         Top             =   1740
         Width           =   2115
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "原 密 码"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   180
         Left            =   420
         TabIndex        =   10
         Top             =   840
         Width           =   720
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "用户编号"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   180
         Left            =   420
         TabIndex        =   9
         Top             =   360
         Width           =   720
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "确认密码"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   180
         Left            =   420
         TabIndex        =   8
         Top             =   1800
         Width           =   720
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "新 密 码"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   180
         Left            =   420
         TabIndex        =   7
         Top             =   1320
         Width           =   720
      End
   End
   Begin VB.CommandButton cmdCancel 
      Cancel          =   -1  'True
      Caption         =   "取消"
      Height          =   400
      Left            =   2460
      TabIndex        =   5
      Top             =   2580
      Width           =   1125
   End
   Begin VB.CommandButton cmdOk 
      Caption         =   "确定"
      Default         =   -1  'True
      Height          =   400
      Left            =   600
      TabIndex        =   4
      Top             =   2580
      Width           =   1125
   End
End
Attribute VB_Name = "FrmPwdEdit"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Form_Load()
  txtUserNo.Enabled = False
  txtUserNo.Text = CurLoginUserNo   '当前登录用户的用户编号
  txtOldPwd.Text = ""         '原密码
  txtNewPwd1.Text = ""        '新密码
  txtNewPwd2.Text = ""        '新密码(确认)
End Sub

Private Sub Form_Unload(Cancel As Integer)
  Set FrmPwdEdit = Nothing
End Sub

Private Sub cmdOk_Click()
  On Error GoTo ErrorHandle
  Dim strSql As String
  Dim Rs As New ADODB.Recordset
  
  '在用户表Users中查询当前登录用户的记录
  strSql = "SELECT * FROM Users WHERE UserNo='" & txtUserNo.Text & "'"
  Rs.Open strSql, Conn, adOpenStatic, adLockOptimistic
  If Rs.RecordCount = 0 Then
    MsgBox "用户编号不存在", vbExclamation + vbOKOnly, "操作提示"
    Rs.Close
    Set Rs = Nothing
    Exit Sub
  End If
  
  '判断输入的原密码是否正确,若不正确,要求重新输入
  If txtOldPwd.Text <> IIf(IsNull(Rs!UserPwd), "", Rs!UserPwd) Then
    MsgBox "原密码错误,请重新输入", vbExclamation + vbOKOnly, "操作提示"
    Rs.Close
    Set Rs = Nothing
    txtOldPwd.SetFocus
    Exit Sub
  End If

  '判断两次输入的新密码是否相同,若不相同,要求重新输入
  If txtNewPwd1.Text <> txtNewPwd2.Text Then
    MsgBox "新密码和确认密码不相同,请重新确认", _
              vbExclamation + vbOKOnly, "操作提示"
    Rs.Close
    Set Rs = Nothing
    txtNewPwd2.SetFocus
    Exit Sub
  End If

  '更新密码
  Rs!UserPwd = txtNewPwd1.Text
  Rs.Update
  Rs.Close
  Set Rs = Nothing
  
  Unload Me
  
  On Error GoTo 0
  Exit Sub
  
ErrorHandle:
  MsgBox Error(Err.Number), vbExclamation + vbOKOnly, "操作提示"
End Sub

Private Sub cmdCancel_Click()
  Unload Me
End Sub


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -