?? password.vb
字號(hào):
Public Class Form11
Inherits System.Windows.Forms.Form
Dim Sqlstr As String
Dim OldPassword As String
Dim NewPassword As String
#Region " Windows 窗體設(shè)計(jì)器生成的代碼 "
Public Sub New()
MyBase.New()
'該調(diào)用是 Windows 窗體設(shè)計(jì)器所必需的。
InitializeComponent()
'在 InitializeComponent() 調(diào)用之后添加任何初始化
End Sub
'窗體重寫(xiě)處置以清理組件列表。
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 窗體設(shè)計(jì)器所必需的
Private components As System.ComponentModel.IContainer
'注意:以下過(guò)程是 Windows 窗體設(shè)計(jì)器所必需的
'可以使用 Windows 窗體設(shè)計(jì)器修改此過(guò)程。
'不要使用代碼編輯器修改它。
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 Label5 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 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(Form11))
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.Label5 = 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.Button1 = New System.Windows.Forms.Button()
Me.Button2 = New System.Windows.Forms.Button()
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.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(232, 205)
Me.Label1.TabIndex = 0
'
'Label2
'
Me.Label2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.Label2.Location = New System.Drawing.Point(8, 8)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(216, 192)
Me.Label2.TabIndex = 1
'
'Label3
'
Me.Label3.ForeColor = System.Drawing.Color.Navy
Me.Label3.Location = New System.Drawing.Point(24, 32)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(56, 24)
Me.Label3.TabIndex = 2
Me.Label3.Text = "原密碼"
Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'Label4
'
Me.Label4.ForeColor = System.Drawing.Color.Navy
Me.Label4.Location = New System.Drawing.Point(24, 72)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(56, 24)
Me.Label4.TabIndex = 3
Me.Label4.Text = "新密碼"
Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'Label5
'
Me.Label5.ForeColor = System.Drawing.Color.Navy
Me.Label5.Location = New System.Drawing.Point(16, 112)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(72, 24)
Me.Label5.TabIndex = 4
Me.Label5.Text = "確認(rèn)新密碼"
Me.Label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(96, 32)
Me.TextBox1.MaxLength = 10
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.TextBox1.Size = New System.Drawing.Size(120, 21)
Me.TextBox1.TabIndex = 5
Me.TextBox1.Text = ""
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(96, 72)
Me.TextBox2.MaxLength = 10
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.TextBox2.Size = New System.Drawing.Size(120, 21)
Me.TextBox2.TabIndex = 6
Me.TextBox2.Text = ""
'
'TextBox3
'
Me.TextBox3.Location = New System.Drawing.Point(96, 112)
Me.TextBox3.MaxLength = 10
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.TextBox3.Size = New System.Drawing.Size(120, 21)
Me.TextBox3.TabIndex = 7
Me.TextBox3.Text = ""
'
'Button1
'
Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup
Me.Button1.ForeColor = System.Drawing.Color.Blue
Me.Button1.Location = New System.Drawing.Point(72, 152)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(48, 24)
Me.Button1.TabIndex = 8
Me.Button1.Text = "修改"
'
'Button2
'
Me.Button2.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.Button2.FlatStyle = System.Windows.Forms.FlatStyle.Popup
Me.Button2.ForeColor = System.Drawing.Color.Blue
Me.Button2.Location = New System.Drawing.Point(128, 152)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(48, 24)
Me.Button2.TabIndex = 9
Me.Button2.Text = "取消"
'
'Form11
'
Me.AcceptButton = Me.Button1
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.CancelButton = Me.Button2
Me.ClientSize = New System.Drawing.Size(232, 205)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button2, Me.Button1, Me.TextBox3, Me.TextBox2, Me.TextBox1, Me.Label5, Me.Label4, Me.Label3, Me.Label2, Me.Label1})
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.MaximizeBox = False
Me.Name = "Form11"
Me.Text = "修改密碼"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
If Me.TextBox2.Text.CompareTo(Me.TextBox3.Text) <> 0 Then
MsgBox("確認(rèn)的新密碼不符,請(qǐng)重新輸入新密碼。", _
MsgBoxStyle.Exclamation + MsgBoxStyle.OKOnly, "密碼確認(rèn)失敗")
Me.TextBox2.Text = ""
Me.TextBox3.Text = ""
Exit Sub
Else
NewPassword = Me.TextBox2.Text.Trim
End If
OldPassword = Me.TextBox1.Text.Trim
Sqlstr = "SELECT * FROM UserInfo WHERE user_id= " & _
"'" & UserName & "' AND user_pwd='" & OldPassword & "'"
Dim objDataRow As DataRow
Try
objDataRow = GetDataFromDB(Sqlstr).Tables(0).Rows(0)
Catch
MsgBox("舊密碼和賬號(hào)不符,請(qǐng)重新輸入舊密碼。", _
MsgBoxStyle.Information + MsgBoxStyle.OKOnly, "更改密碼失敗")
Me.TextBox1.Text = ""
Exit Sub
End Try
Sqlstr = "UPDATE UserInfo SET user_pwd =" & _
"'" & NewPassword & "' WHERE user_id='" & UserName & "'"
UpdateData(Sqlstr)
MsgBox("密碼修改成功,修改后的密碼為:" & NewPassword, _
MsgBoxStyle.Information + MsgBoxStyle.OKOnly, "密碼修改成功")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button2.Click
Me.Close()
End Sub
End Class
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -