📄 frmmodifypassword.vb
字号:
Imports System.Data.SqlClient
Public Class frmModifyPassword
Inherits System.Windows.Forms.Form
Dim bnclose As Boolean
Dim struserid As String
Dim stroriginpwd As String
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写 dispose 以清理组件列表。
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 txtpassword As System.Windows.Forms.TextBox
Friend WithEvents txtnewpassword As System.Windows.Forms.TextBox
Friend WithEvents txtconfirmpassword As System.Windows.Forms.TextBox
Friend WithEvents btnok As System.Windows.Forms.Button
Friend WithEvents btncancel As System.Windows.Forms.Button
Friend WithEvents SqlConnection1 As System.Data.SqlClient.SqlConnection
Friend WithEvents SqlCommand1 As System.Data.SqlClient.SqlCommand
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.txtpassword = New System.Windows.Forms.TextBox
Me.txtnewpassword = New System.Windows.Forms.TextBox
Me.txtconfirmpassword = New System.Windows.Forms.TextBox
Me.btnok = New System.Windows.Forms.Button
Me.btncancel = New System.Windows.Forms.Button
Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection
Me.SqlCommand1 = New System.Data.SqlClient.SqlCommand
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(16, 16)
Me.Label1.Name = "Label1"
Me.Label1.TabIndex = 0
Me.Label1.Text = "输入原密码"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(16, 56)
Me.Label2.Name = "Label2"
Me.Label2.TabIndex = 1
Me.Label2.Text = "输入新密码"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(16, 96)
Me.Label3.Name = "Label3"
Me.Label3.TabIndex = 2
Me.Label3.Text = "确认新密码"
'
'txtpassword
'
Me.txtpassword.Location = New System.Drawing.Point(128, 16)
Me.txtpassword.Name = "txtpassword"
Me.txtpassword.TabIndex = 0
Me.txtpassword.Text = ""
'
'txtnewpassword
'
Me.txtnewpassword.Location = New System.Drawing.Point(128, 56)
Me.txtnewpassword.Name = "txtnewpassword"
Me.txtnewpassword.TabIndex = 1
Me.txtnewpassword.Text = ""
'
'txtconfirmpassword
'
Me.txtconfirmpassword.Location = New System.Drawing.Point(128, 104)
Me.txtconfirmpassword.Name = "txtconfirmpassword"
Me.txtconfirmpassword.TabIndex = 2
Me.txtconfirmpassword.Text = ""
'
'btnok
'
Me.btnok.Location = New System.Drawing.Point(16, 160)
Me.btnok.Name = "btnok"
Me.btnok.TabIndex = 3
Me.btnok.Text = "确定"
'
'btncancel
'
Me.btncancel.Location = New System.Drawing.Point(120, 160)
Me.btncancel.Name = "btncancel"
Me.btncancel.TabIndex = 4
Me.btncancel.Text = "取消"
'
'SqlConnection1
'
Me.SqlConnection1.ConnectionString = "workstation id=4D3A93FBF8BE4E6;packet size=4096;user id=sa;data source=4D3A93FBF8" & _
"BE4E6;persist security info=False;initial catalog=sqlqtgl"
'
'SqlCommand1
'
Me.SqlCommand1.Connection = Me.SqlConnection1
'
'frmModifyPassword
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(280, 214)
Me.Controls.Add(Me.btncancel)
Me.Controls.Add(Me.btnok)
Me.Controls.Add(Me.txtconfirmpassword)
Me.Controls.Add(Me.txtnewpassword)
Me.Controls.Add(Me.txtpassword)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Name = "frmModifyPassword"
Me.Text = "frmModifyPassword"
Me.ResumeLayout(False)
End Sub
#End Region
Public Property myuser() As String
Get
myuser = struserid
End Get
Set(ByVal Value As String)
struserid = Value
End Set
End Property
Private Sub frmModifyPassword_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
bnclose = True
End Sub
Private Sub frmModifyPassword_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
e.Cancel = Not bnclose
End Sub
Private Sub btnok_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnok.Click
If Trim(txtnewpassword.Text) = "" Then
MessageBox.Show("密码不可空白!", "密码格式错误", MessageBoxButtons.OK, MessageBoxIcon.Error)
bnclose = False
Exit Sub
End If
If txtnewpassword.Text <> txtconfirmpassword.Text Then
MessageBox.Show("新密码与确认密码不一致,请重新输入!", "密码格式错误", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
SqlCommand1.CommandText = "select 密码 from 用户 where 用户名='" & myuser & "'"
SqlConnection1.Open()
Try
stroriginpwd = CType(SqlCommand1.ExecuteScalar, String)
If Trim(stroriginpwd) = txtpassword.Text Then
SqlCommand1.CommandText = "update 用户 set 密码=where 用户名='" & myuser & "'"
SqlCommand1.ExecuteNonQuery()
bnclose = True
MessageBox.Show("密码修改完成!", "密码修改", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
MessageBox.Show("输入的原密码错误!", "密码格式错误", MessageBoxButtons.OK, MessageBoxIcon.Error)
bnclose = False
End If
Finally
SqlConnection1.Close()
End Try
End Sub
Private Sub btncancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btncancel.Click
MessageBox.Show("密码未修改!", "密码未修改", MessageBoxButtons.OK, MessageBoxIcon.Warning)
bnclose = True
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -