- VERSION 5.00
- Begin VB.Form AdminPass
- ClientHeight = 4755
- ClientLeft = 60
- ClientTop = 450
- ClientWidth = 5940
- LinkTopic = "Form1"
- ScaleHeight = 4755
- ScaleWidth = 5940
- StartUpPosition = 3 'Windows Default
- Begin VB.Frame Frame1
- Caption = "修改管理员密码"
- Height = 4455
- Left = 120
- TabIndex = 0
- Top = 120
- Width = 5655
- Begin VB.CommandButton Command2
- Cancel = -1 'True
- Caption = "取消"
- Height = 495
- Left = 3000
- TabIndex = 10
- Top = 3720
- Width = 2295
- End
- Begin VB.CommandButton Command1
- Caption = "确认"
- Default = -1 'True
- Height = 495
- Left = 240
- TabIndex = 9
- Top = 3720
- Width = 2295
- End
- Begin VB.TextBox OldPass
- Height = 375
- IMEMode = 3 'DISABLE
- Left = 240
- PasswordChar = "#"
- TabIndex = 8
- Top = 1440
- Width = 5055
- End
- Begin VB.TextBox ChkPass
- Height = 375
- IMEMode = 3 'DISABLE
- Left = 240
- PasswordChar = "#"
- TabIndex = 6
- Top = 3000
- Width = 5055
- End
- Begin VB.TextBox NewPass
- Height = 375
- IMEMode = 3 'DISABLE
- Left = 240
- PasswordChar = "#"
- TabIndex = 4
- Top = 2280
- Width = 5055
- End
- Begin VB.TextBox User
- Height = 375
- Left = 240
- TabIndex = 1
- Top = 720
- Width = 5055
- End
- Begin VB.Label Label4
- Caption = "管理员原始密码"
- Height = 255
- Left = 240
- TabIndex = 7
- Top = 1200
- Width = 2535
- End
- Begin VB.Label Label3
- Caption = "验证输入"
- Height = 255
- Left = 240
- TabIndex = 5
- Top = 2760
- Width = 3735
- End
- Begin VB.Label Label2
- Caption = "新密码"
- Height = 255
- Left = 240
- TabIndex = 3
- Top = 2040
- Width = 1815
- End
- Begin VB.Label Label1
- Caption = "管理员ID"
- Height = 255
- Left = 240
- TabIndex = 2
- Top = 480
- Width = 2175
- End
- End
- End
- Attribute VB_Name = "AdminPass"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- Private Sub Command1_Click()
- Dim sql As String
- Dim rs As New ADODB.Recordset
- If NewPass.Text <> ChkPass.Text Then '新密码和验证密码要相同
- MsgBox "新密码不一致!", vbCritical
- NewPass.SetFocus
- Exit Sub
- End If
- If User = "" Then '密码和用户ID输入框不能为空
- MsgBox "管理员ID不能为空!", vbCritical
- User.SetFocus
- Exit Sub
- End If
- If OldPass.Text = "" Then
- MsgBox "管理员密码不能为空!", vbCritical
- OldPass.SetFocus
- Exit Sub
- End If
- If DbHandle.DbConnection Then
- sql = "TBL_ADMIN" '打开管理员表,查看是否要添加的管理员ID已经存在
- rs.CursorType = adOpenDynamic
- rs.LockType = adLockOptimistic
- rs.Filter = "ADMIN_ID='" & User.Text & "'"
- rs.Open sql, DbFinance
- If DbHandle.resultcount(rs) <> 1 Then '不存在出错退出
- MsgBox "管理员ID不存在!", vbExclamation
- rs.Close
- DbHandle.DbClose
- User.SetFocus
- Exit Sub
- Else '存在查看输入的原是密码是否和数据库保存的密码相一致
- If rs("ADMIN_PASSWORD") <> OldPass.Text Then '不一致要求重新输入原是密码
- MsgBox "管理员密码错误!", vbExclamation
- rs.Close
- OldPass.SetFocus
- Exit Sub
- End If
- rs("ADMIN_PASSWORD") = NewPass.Text '一致就设置新的管理员密码
- rs.Update
- rs.Close
- End If
- MsgBox "管理员密码成功修改!"
- Unload Me
- Else '数据库打开失败退出
- MsgBox "数据库错误!", vbExclamation
- DbHandle.DbClose
- End
- End If
- End Sub
- Private Sub Command2_Click()
- Me.Hide '返回主窗体
- End Sub
- Private Sub Form_Load()
- Me.Left = (Screen.Width - Me.ScaleWidth) / 2 '窗体居中显示
- Me.Top = (Screen.Height - Me.ScaleHeight) / 2
- End Sub
- Private Sub Form_Unload(Cancel As Integer)
- On Error Resume Next '对话框关闭时候关闭数据库连接
- DbHandle.DbClose
- End Sub