Private Sub cmdOk_Click()
Dim mrc As ADODB.Recordset
Dim MsgText As String
Dim txtsql As String
If txtpassword.Text = "" Then
MsgBox "请输入当前密码!", vbOKOnly + vbInformation, "提示信息"
txtpassword.SetFocus
ElseIf txtnewpassword.Text = "" Then
MsgBox "请输入新密码!", vbOKOnly + vbInformation, "提示信息"
txtnewpassword.SetFocus
ElseIf txtOkpassword.Text = "" Then
MsgBox "请输入新密码!", vbOKOnly + vbInformation, "提示信息"
txtOkpassword.SetFocus
Else
txtsql = "select * from User_Info where userID= '" & frmlogin.txtName.Text & "'"
Set mrc = ExecuteSQL(txtsql, MsgText)
If Trim(mrc.Fields(1)) <> Trim(txtpassword.Text) Then
MsgBox "原密码错误,请重新输入!", vbOKOnly + vbInformation, "提示信息"
txtpassword.Text = ""
txtpassword.SetFocus
ElseIf Trim(txtpassword.Text) = Trim(txtnewpassword.Text) Then
MsgBox "旧密码不能与新密码一致!", vbOKOnly + vbInformation, "提示信息"
txtpassword.Text = ""
txtnewpassword.Text = ""
txtnewpassword.SetFocus
ElseIf Trim(txtOkpassword.Text) <> Trim(txtOkpassword.Text) Then
MsgBox "请核对两次输入是否一致,并重新输入!", vbOKOnly + vbInformation, "提示信息"
txtpassword.Text = ""
txtnewpassword.Text = ""
txtOkpassword.Text = ""
txtpassword.SetFocus
Else
'修改密码
mrc.Fields(1) = txtnewpassword.Text
mrc.Update
mrc.Close
MsgBox "密码修改成功,请重新登录系统!", vbOKOnly, "提示信息"
Unload Me
frmlogin.Show
End If
End If
End Sub