📄 frmxg.frm
字号:
VERSION 5.00
Begin VB.Form frmxg
BorderStyle = 1 'Fixed Single
Caption = "修改密码"
ClientHeight = 4365
ClientLeft = 45
ClientTop = 330
ClientWidth = 5415
ControlBox = 0 'False
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 4365
ScaleWidth = 5415
Begin VB.CommandButton Command2
Caption = "取消"
Height = 375
Left = 3360
TabIndex = 9
Top = 3600
Width = 975
End
Begin VB.CommandButton Command1
Caption = "确定"
Height = 375
Left = 960
TabIndex = 8
Top = 3600
Width = 975
End
Begin VB.TextBox Text4
Height = 375
IMEMode = 3 'DISABLE
Left = 2520
MaxLength = 20
PasswordChar = "*"
TabIndex = 7
Top = 2640
Width = 2415
End
Begin VB.TextBox Text3
Height = 375
IMEMode = 3 'DISABLE
Left = 2520
MaxLength = 20
PasswordChar = "*"
TabIndex = 6
Top = 1920
Width = 2415
End
Begin VB.TextBox Text2
Height = 375
IMEMode = 3 'DISABLE
Left = 2520
MaxLength = 20
PasswordChar = "*"
TabIndex = 5
Top = 1200
Width = 2415
End
Begin VB.TextBox Text1
Height = 375
Left = 2520
MaxLength = 20
TabIndex = 4
Top = 480
Width = 2415
End
Begin VB.Label Label4
Caption = "密码确认:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 480
TabIndex = 3
Top = 2640
Width = 1575
End
Begin VB.Label Label3
Caption = "新密码:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 480
TabIndex = 2
Top = 1920
Width = 1575
End
Begin VB.Label Label2
Caption = "旧密码:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 480
TabIndex = 1
Top = 1200
Width = 1575
End
Begin VB.Label Label1
Caption = "用户名:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 480
TabIndex = 0
Top = 480
Width = 1575
End
End
Attribute VB_Name = "frmxg"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
'声明变量
Dim username As String
Dim oldpassword As String
Dim newpassword As String
Dim cnn As New ADODB.Connection
Dim ret As New ADODB.Recordset
Dim local_db As String
'检查文本框是否为空
If Text1.Text = "" Then
MsgBox "请输入用户名", , "警告"
Text1.SetFocus
Else
If Text2.Text = "" Then
MsgBox "请输入旧密码", , "警告"
Text2.SetFocus
Else
If Text3.Text = "" Then
MsgBox "请输入新密码", , "警告"
Text3.SetFocus
Else
If Text4.Text = "" Then
MsgBox "请确认密码", , "警告"
Text4.SetFocus
End If
End If
End If
End If
If Text1.Text <> "" And Text2.Text <> "" _
And Text3.Text <> "" And Text4.Text <> "" Then
If Text3.Text <> Text4.Text Then
MsgBox "密码不一致", , "警告"
Text4.SetFocus
Else
Set cnn = New ADODB.Connection
Set ret = New ADODB.Recordset
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path & "\data\db.mdb" + ";Persist Security Info=False;" '连接数据库
username = Trim(Text1.Text)
oldpassword = Text2.Text
local_db = "select 用户名 from 用户表" + _
" where 用户表.用户名=" + "'" + username + "'"
ret.Open local_db, cnn
'检查用户是否存在
If ret.BOF And ret.EOF Then
MsgBox "系统中无此用户", , "警告"
'初始化文本框
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text1.SetFocus '设置光标焦点
ret.Close
'检查密码是否正确
Else
ret.Close
local_db = "select 用户名 from 用户表" + _
" where 用户表.用户名=" + "'" + username + "' and" + _
" 用户表.密码=" + "'" + oldpassword + "'"
ret.Open local_db, cnn
If ret.BOF And ret.EOF Then
MsgBox "旧密码不正确", , "警告"
Text2.SetFocus
ret.Close
Else
ret.Close
'修改密码
newpassword = Text3.Text
local_db = "update 用户表" + _
" set 密码=" + "'" + newpassword + "'" + _
" where 用户表.用户名=" + "'" + username + "'"
cnn.Execute local_db
MsgBox "密码修改成功!", , "提示"
frmxg.Hide
'初始化文本框
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
'初始化主窗口
mainfrm.guanli.Enabled = True
mainfrm.chaxun.Enabled = True
mainfrm.tongji.Enabled = True
If userid = "admin" Then
mainfrm.xitong.Enabled = True
mainfrm.bdb.Enabled = True
Else
mainfrm.xitong.Enabled = False
mainfrm.bdb.Enabled = False
End If
mainfrm.Command1.Enabled = True
mainfrm.Command2.Enabled = True
mainfrm.Command3.Enabled = True
If userid = "admin" Then
mainfrm.Command4.Enabled = True
Else
mainfrm.Command4.Enabled = False
End If
End If
End If
End If
End If
End Sub
Private Sub Command2_Click()
frmxg.Hide
'初始化文本框
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
'初始化主窗口
mainfrm.guanli.Enabled = True
mainfrm.chaxun.Enabled = True
mainfrm.tongji.Enabled = True
If userid = "admin" Then
mainfrm.xitong.Enabled = True
mainfrm.bdb.Enabled = True
Else
mainfrm.xitong.Enabled = False
mainfrm.bdb.Enabled = False
End If
mainfrm.Command1.Enabled = True
mainfrm.Command2.Enabled = True
mainfrm.Command3.Enabled = True
If userid = "admin" Then
mainfrm.Command4.Enabled = True
Else
mainfrm.Command4.Enabled = False
End If
GetStatus "<就绪>"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -