📄 frmmodifypassword.vb
字号:
Namespace HZC.DinningService
Public Class frmModifyPassword
Inherits System.Windows.Forms.Form
Private user As String
Private Sqlstr As String
Private OldPassword As String
Private NewPassword 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 btnModify As System.Windows.Forms.Button
Friend WithEvents btnCancel As System.Windows.Forms.Button
Friend WithEvents lbOldPassword As System.Windows.Forms.Label
Friend WithEvents lbNewPassword As System.Windows.Forms.Label
Friend WithEvents lbConfirmedPassword As System.Windows.Forms.Label
Friend WithEvents txtOldPassword As System.Windows.Forms.TextBox
Friend WithEvents txtNewPassword As System.Windows.Forms.TextBox
Friend WithEvents txtConfirmedPassword As System.Windows.Forms.TextBox
Friend WithEvents UserPicture As System.Windows.Forms.PictureBox
Friend WithEvents lbCurrentUser As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmModifyPassword))
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.lbOldPassword = New System.Windows.Forms.Label
Me.lbNewPassword = New System.Windows.Forms.Label
Me.lbConfirmedPassword = New System.Windows.Forms.Label
Me.txtOldPassword = New System.Windows.Forms.TextBox
Me.txtNewPassword = New System.Windows.Forms.TextBox
Me.txtConfirmedPassword = New System.Windows.Forms.TextBox
Me.btnModify = New System.Windows.Forms.Button
Me.btnCancel = New System.Windows.Forms.Button
Me.UserPicture = New System.Windows.Forms.PictureBox
Me.lbCurrentUser = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'Label1
'
Me.Label1.BackColor = System.Drawing.Color.AntiqueWhite
Me.Label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.Label1.Dock = System.Windows.Forms.DockStyle.Fill
Me.Label1.Location = New System.Drawing.Point(0, 0)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(312, 264)
Me.Label1.TabIndex = 0
'
'Label2
'
Me.Label2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.Label2.ForeColor = System.Drawing.Color.Navy
Me.Label2.Location = New System.Drawing.Point(8, 8)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(296, 248)
Me.Label2.TabIndex = 1
'
'lbOldPassword
'
Me.lbOldPassword.ForeColor = System.Drawing.Color.Navy
Me.lbOldPassword.Location = New System.Drawing.Point(32, 80)
Me.lbOldPassword.Name = "lbOldPassword"
Me.lbOldPassword.Size = New System.Drawing.Size(80, 21)
Me.lbOldPassword.TabIndex = 2
Me.lbOldPassword.Text = "输入原密码:"
Me.lbOldPassword.TextAlign = System.Drawing.ContentAlignment.BottomRight
'
'lbNewPassword
'
Me.lbNewPassword.ForeColor = System.Drawing.Color.Navy
Me.lbNewPassword.Location = New System.Drawing.Point(24, 120)
Me.lbNewPassword.Name = "lbNewPassword"
Me.lbNewPassword.Size = New System.Drawing.Size(88, 21)
Me.lbNewPassword.TabIndex = 3
Me.lbNewPassword.Text = "输入新密码:"
Me.lbNewPassword.TextAlign = System.Drawing.ContentAlignment.BottomRight
'
'lbConfirmedPassword
'
Me.lbConfirmedPassword.ForeColor = System.Drawing.Color.Navy
Me.lbConfirmedPassword.Location = New System.Drawing.Point(32, 160)
Me.lbConfirmedPassword.Name = "lbConfirmedPassword"
Me.lbConfirmedPassword.Size = New System.Drawing.Size(80, 21)
Me.lbConfirmedPassword.TabIndex = 4
Me.lbConfirmedPassword.Text = "确认新密码:"
Me.lbConfirmedPassword.TextAlign = System.Drawing.ContentAlignment.BottomRight
'
'txtOldPassword
'
Me.txtOldPassword.BackColor = System.Drawing.SystemColors.InactiveCaptionText
Me.txtOldPassword.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.txtOldPassword.Location = New System.Drawing.Point(112, 80)
Me.txtOldPassword.MaxLength = 10
Me.txtOldPassword.Name = "txtOldPassword"
Me.txtOldPassword.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.txtOldPassword.Size = New System.Drawing.Size(152, 21)
Me.txtOldPassword.TabIndex = 5
Me.txtOldPassword.Text = ""
'
'txtNewPassword
'
Me.txtNewPassword.BackColor = System.Drawing.SystemColors.InactiveCaptionText
Me.txtNewPassword.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.txtNewPassword.Location = New System.Drawing.Point(112, 120)
Me.txtNewPassword.MaxLength = 10
Me.txtNewPassword.Name = "txtNewPassword"
Me.txtNewPassword.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.txtNewPassword.Size = New System.Drawing.Size(152, 21)
Me.txtNewPassword.TabIndex = 6
Me.txtNewPassword.Text = ""
'
'txtConfirmedPassword
'
Me.txtConfirmedPassword.BackColor = System.Drawing.SystemColors.InactiveCaptionText
Me.txtConfirmedPassword.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.txtConfirmedPassword.Location = New System.Drawing.Point(112, 160)
Me.txtConfirmedPassword.MaxLength = 10
Me.txtConfirmedPassword.Name = "txtConfirmedPassword"
Me.txtConfirmedPassword.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.txtConfirmedPassword.Size = New System.Drawing.Size(152, 21)
Me.txtConfirmedPassword.TabIndex = 7
Me.txtConfirmedPassword.Text = ""
'
'btnModify
'
Me.btnModify.FlatStyle = System.Windows.Forms.FlatStyle.Popup
Me.btnModify.ForeColor = System.Drawing.Color.Navy
Me.btnModify.Location = New System.Drawing.Point(96, 208)
Me.btnModify.Name = "btnModify"
Me.btnModify.Size = New System.Drawing.Size(72, 24)
Me.btnModify.TabIndex = 8
Me.btnModify.Text = "修改"
'
'btnCancel
'
Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Popup
Me.btnCancel.ForeColor = System.Drawing.Color.Navy
Me.btnCancel.Location = New System.Drawing.Point(176, 208)
Me.btnCancel.Name = "btnCancel"
Me.btnCancel.Size = New System.Drawing.Size(72, 24)
Me.btnCancel.TabIndex = 9
Me.btnCancel.Text = "取消"
'
'UserPicture
'
Me.UserPicture.Image = CType(resources.GetObject("UserPicture.Image"), System.Drawing.Image)
Me.UserPicture.Location = New System.Drawing.Point(32, 24)
Me.UserPicture.Name = "UserPicture"
Me.UserPicture.Size = New System.Drawing.Size(32, 32)
Me.UserPicture.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.UserPicture.TabIndex = 10
Me.UserPicture.TabStop = False
'
'lbCurrentUser
'
Me.lbCurrentUser.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.lbCurrentUser.ForeColor = System.Drawing.Color.Blue
Me.lbCurrentUser.Location = New System.Drawing.Point(80, 32)
Me.lbCurrentUser.Name = "lbCurrentUser"
Me.lbCurrentUser.Size = New System.Drawing.Size(184, 24)
Me.lbCurrentUser.TabIndex = 11
Me.lbCurrentUser.Text = "当前账号:"
Me.lbCurrentUser.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'frmModifyPassword
'
Me.AcceptButton = Me.btnModify
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.CancelButton = Me.btnCancel
Me.ClientSize = New System.Drawing.Size(312, 264)
Me.Controls.Add(Me.lbCurrentUser)
Me.Controls.Add(Me.UserPicture)
Me.Controls.Add(Me.btnCancel)
Me.Controls.Add(Me.btnModify)
Me.Controls.Add(Me.txtConfirmedPassword)
Me.Controls.Add(Me.txtNewPassword)
Me.Controls.Add(Me.txtOldPassword)
Me.Controls.Add(Me.lbConfirmedPassword)
Me.Controls.Add(Me.lbNewPassword)
Me.Controls.Add(Me.lbOldPassword)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.MaximizeBox = False
Me.Name = "frmModifyPassword"
Me.Text = "修改帐号密码"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub btnModify_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnModify.Click
If Me.txtNewPassword.Text.CompareTo(Me.txtConfirmedPassword.Text) <> 0 Then
MsgBox("确认的新密码不符,请重新输入新密码。", _
MsgBoxStyle.Exclamation + MsgBoxStyle.OKOnly, "密码确认失败")
Me.txtNewPassword.Text = String.Empty
Me.txtConfirmedPassword.Text = String.Empty
Exit Sub
Else
NewPassword = Me.txtNewPassword.Text.Trim
End If
user = Me.lbCurrentUser.Text.Substring( _
Me.lbCurrentUser.Text.IndexOf(":") + 1)
OldPassword = Me.txtOldPassword.Text.Trim
Sqlstr = "SELECT * FROM UserInfo WHERE user_id= " & _
"'" & user & "' AND user_pwd='" & Logon.Encrypt(OldPassword) & "'"
Dim objDataRow As DataRow
Try
objDataRow = AccessToDatabase.GetDataFromDB(Sqlstr).Tables(0).Rows(0)
Catch
MsgBox("旧密码和账号不符,请重新输入旧密码。", _
MsgBoxStyle.Information + MsgBoxStyle.OKOnly, "更改密码失败")
Me.txtOldPassword.Text = String.Empty
Me.txtNewPassword.Text = String.Empty
Me.txtConfirmedPassword.Text = String.Empty
Exit Sub
End Try
Sqlstr = "UPDATE UserInfo SET user_pwd =" & _
"'" & Logon.Encrypt(NewPassword) & "' WHERE user_id='" & user & "'"
AccessToDatabase.UpdateData(Sqlstr)
MsgBox("密码修改成功,修改后的密码为:" & NewPassword, _
MsgBoxStyle.Information + MsgBoxStyle.OKOnly, "密码修改成功")
End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
Me.Close()
End Sub
End Class
End Namespace
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -