📄 modifypassword.vb
字号:
Public Class ModifyPassword
Inherits System.Windows.Forms.Form
Private CurUser As String
Private CurPassword As String
Private LoginSQLstr As String
'
Private Caption As String
'定义消息对话框中显示的消息标题。
Private Message As String
'定义消息对话框中显示的消息内容。
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写处置以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意:以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(ModifyPassword))
Me.Label1 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
Me.Label3 = New System.Windows.Forms.Label()
Me.Label4 = New System.Windows.Forms.Label()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.TextBox2 = New System.Windows.Forms.TextBox()
Me.TextBox3 = New System.Windows.Forms.TextBox()
Me.TextBox4 = New System.Windows.Forms.TextBox()
Me.Button1 = New System.Windows.Forms.Button()
Me.Button2 = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("黑体", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label1.ForeColor = System.Drawing.Color.Blue
Me.Label1.Location = New System.Drawing.Point(16, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(80, 21)
Me.Label1.TabIndex = 0
Me.Label1.Text = "当前账号"
'
'Label2
'
Me.Label2.Font = New System.Drawing.Font("黑体", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label2.ForeColor = System.Drawing.Color.Blue
Me.Label2.Location = New System.Drawing.Point(16, 56)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(72, 21)
Me.Label2.TabIndex = 1
Me.Label2.Text = "旧密码"
'
'Label3
'
Me.Label3.Font = New System.Drawing.Font("黑体", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label3.ForeColor = System.Drawing.Color.Blue
Me.Label3.Location = New System.Drawing.Point(16, 88)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(72, 21)
Me.Label3.TabIndex = 2
Me.Label3.Text = "新密码"
'
'Label4
'
Me.Label4.Font = New System.Drawing.Font("黑体", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label4.ForeColor = System.Drawing.Color.Blue
Me.Label4.Location = New System.Drawing.Point(16, 120)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(72, 21)
Me.Label4.TabIndex = 3
Me.Label4.Text = "确认新密码"
'
'TextBox1
'
Me.TextBox1.BackColor = System.Drawing.SystemColors.Info
Me.TextBox1.Font = New System.Drawing.Font("黑体", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.TextBox1.ForeColor = System.Drawing.Color.Blue
Me.TextBox1.Location = New System.Drawing.Point(96, 24)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(120, 22)
Me.TextBox1.TabIndex = 4
Me.TextBox1.Text = ""
'
'TextBox2
'
Me.TextBox2.Font = New System.Drawing.Font("黑体", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.TextBox2.ForeColor = System.Drawing.Color.Blue
Me.TextBox2.Location = New System.Drawing.Point(96, 56)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.TextBox2.Size = New System.Drawing.Size(120, 22)
Me.TextBox2.TabIndex = 5
Me.TextBox2.Text = ""
'
'TextBox3
'
Me.TextBox3.Font = New System.Drawing.Font("黑体", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.TextBox3.ForeColor = System.Drawing.Color.Blue
Me.TextBox3.Location = New System.Drawing.Point(96, 88)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.TextBox3.Size = New System.Drawing.Size(120, 22)
Me.TextBox3.TabIndex = 6
Me.TextBox3.Text = ""
'
'TextBox4
'
Me.TextBox4.Font = New System.Drawing.Font("黑体", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.TextBox4.ForeColor = System.Drawing.Color.Blue
Me.TextBox4.Location = New System.Drawing.Point(96, 120)
Me.TextBox4.Name = "TextBox4"
Me.TextBox4.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.TextBox4.Size = New System.Drawing.Size(120, 22)
Me.TextBox4.TabIndex = 7
Me.TextBox4.Text = ""
'
'Button1
'
Me.Button1.Font = New System.Drawing.Font("华文新魏", 9.749999!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Button1.ForeColor = System.Drawing.Color.Navy
Me.Button1.Location = New System.Drawing.Point(224, 72)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(64, 32)
Me.Button1.TabIndex = 8
Me.Button1.Text = "确定"
'
'Button2
'
Me.Button2.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.Button2.Font = New System.Drawing.Font("华文新魏", 9.749999!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Button2.ForeColor = System.Drawing.Color.Navy
Me.Button2.Location = New System.Drawing.Point(224, 112)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(64, 32)
Me.Button2.TabIndex = 9
Me.Button2.Text = "取消"
'
'ModifyPassword
'
Me.AcceptButton = Me.Button1
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.CancelButton = Me.Button2
Me.ClientSize = New System.Drawing.Size(292, 155)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button2, Me.Button1, Me.TextBox4, Me.TextBox3, Me.TextBox2, Me.TextBox1, Me.Label4, Me.Label3, Me.Label2, Me.Label1})
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "ModifyPassword"
Me.Text = "修改用户密码"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button2.Click
Me.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
CurUser = Me.TextBox1.Text
CurPassword = Me.TextBox2.Text
'
LoginSQLstr = "SELECT * FROM Login WHERE User='" & _
CurUser & " 'AND Pwd='" & CurPassword & " '"
'查询账号和密码是否一致。
Message = "对不起,您输入的密码与账号不一致,请您重新输入的密码。"
Caption = "登录失败"
'定义没有账号与密码不一致的消息
Call ConnToDB(LoginSQLstr, Message, Caption)
'调用模块中数据库访问函数来查询。
If IsError = False Then
CurPassword = Me.TextBox3.Text
'获取新的密码
If CurPassword = "" Then
MessageBox.Show("密码不能为空,请输入您的新密码。", _
"修改密码失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Exit Sub
'密码不能为空,否则退出子过程
End If
Dim tempstr As String = Me.TextBox4.Text
'获取确认的密码
If StrComp(CurPassword, tempstr, CompareMethod.Text) = 0 Then
DS.Tables.Item(0).Rows.Item(0).Item(1) = CurPassword
'如果确认密码与新密码一致,则更新新密码,不考虑大小写
Else
MessageBox.Show("请重新确认您的新密码。并检查它们是否一致。", _
"密码确认失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Exit Sub
'
End If
'没有发生错误时继续进行二级验证
Else
Exit Sub
'退出子过程。
'发生错误时需要触发的事件
End If
Call UpdateDB(DS)
'更新密码修改
MessageBox.Show("您已经成功的修改了原密码,并记住您的新密码: " & _
CurPassword & "。", "提示信息", _
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
'给出修改成功的消息,并提示用户记住新的密码
Me.Close()
'关闭本窗体
End Sub
Private Sub ModifyPassword_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Me.TextBox1.Text = User + AdminId
'获取当前登录用户的账号
Me.TextBox1.ReadOnly = True
'设置为只读,防止用户更改
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -