📄 changpassword.vb
字号:
Imports System.Data
Imports System.Data.SqlClient
Public Class ChangPassword
Inherits System.Windows.Forms.Form
Dim ObjLogin As New Login
'Dim newPaw As String
' Dim userName 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 GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
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 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
Friend WithEvents Button3 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.TextBox1 = New System.Windows.Forms.TextBox
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.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.Button3 = New System.Windows.Forms.Button
Me.GroupBox1.SuspendLayout()
Me.SuspendLayout()
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.TextBox1)
Me.GroupBox1.Controls.Add(Me.Label1)
Me.GroupBox1.Location = New System.Drawing.Point(56, 24)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(288, 96)
Me.GroupBox1.TabIndex = 0
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "用户"
'
'TextBox1
'
Me.TextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.TextBox1.Location = New System.Drawing.Point(96, 32)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(104, 21)
Me.TextBox1.TabIndex = 1
Me.TextBox1.Text = ""
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(16, 32)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(80, 23)
Me.Label1.TabIndex = 0
Me.Label1.Text = "用户名:"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(64, 144)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(80, 16)
Me.Label2.TabIndex = 1
Me.Label2.Text = "旧密码:"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(64, 184)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(80, 16)
Me.Label3.TabIndex = 2
Me.Label3.Text = "新密码:"
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(64, 216)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(80, 23)
Me.Label4.TabIndex = 3
Me.Label4.Text = "确认密码:"
'
'TextBox2
'
Me.TextBox2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.TextBox2.Location = New System.Drawing.Point(160, 136)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.TextBox2.Size = New System.Drawing.Size(160, 21)
Me.TextBox2.TabIndex = 4
Me.TextBox2.Text = ""
'
'TextBox3
'
Me.TextBox3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.TextBox3.Location = New System.Drawing.Point(160, 176)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.TextBox3.Size = New System.Drawing.Size(160, 21)
Me.TextBox3.TabIndex = 5
Me.TextBox3.Text = ""
'
'TextBox4
'
Me.TextBox4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.TextBox4.Location = New System.Drawing.Point(160, 216)
Me.TextBox4.Name = "TextBox4"
Me.TextBox4.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.TextBox4.Size = New System.Drawing.Size(160, 21)
Me.TextBox4.TabIndex = 6
Me.TextBox4.Text = ""
'
'Button1
'
Me.Button1.Enabled = False
Me.Button1.Location = New System.Drawing.Point(96, 272)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(56, 23)
Me.Button1.TabIndex = 7
Me.Button1.Text = "确 定"
'
'Button2
'
Me.Button2.Enabled = False
Me.Button2.Location = New System.Drawing.Point(192, 272)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(48, 24)
Me.Button2.TabIndex = 8
Me.Button2.Text = "重 置"
'
'Button3
'
Me.Button3.Location = New System.Drawing.Point(272, 272)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(48, 23)
Me.Button3.TabIndex = 9
Me.Button3.Text = "关 闭"
'
'ChangPassword
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(400, 326)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox4)
Me.Controls.Add(Me.TextBox3)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.GroupBox1)
Me.MaximizeBox = False
Me.Name = "ChangPassword"
Me.Text = "---------修改用户密码"
Me.GroupBox1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub ChangPassword_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = ObjLogin.userName
'userName = TextBox1.Text
GroupBox1.Enabled = False
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
If TextBox2.Text.Length <> 0 Or TextBox3.Text.Length <> 0 Or TextBox4.Text.Length <> 0 Then
Button2.Enabled = True
Else
Button2.Enabled = False
End If
If TextBox2.Text.Length <> 0 And TextBox3.Text.Length <> 0 And TextBox4.Text.Length <> 0 Then
Button1.Enabled = True
'Else
' MsgBox("密码不能为空。。。。。")
End If
End Sub
Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
If TextBox2.Text.Length <> 0 Or TextBox3.Text.Length <> 0 Or TextBox4.Text.Length <> 0 Then
Button2.Enabled = True
Else
Button2.Enabled = False
End If
If TextBox2.Text.Length <> 0 And TextBox3.Text.Length <> 0 And TextBox4.Text.Length <> 0 Then
Button1.Enabled = True
' Else
' MsgBox("密码不能为空。。。。。")
End If
End Sub
Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged
If TextBox2.Text.Length <> 0 Or TextBox3.Text.Length <> 0 Or TextBox4.Text.Length <> 0 Then
Button2.Enabled = True
Else
Button2.Enabled = False
End If
If TextBox2.Text.Length <> 0 And TextBox3.Text.Length <> 0 And TextBox4.Text.Length <> 0 Then
Button1.Enabled = True
' Else
' MsgBox("密码不能为空。。。。。")
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox2.Text.Length <> 0 & TextBox3.Text.Length <> 0 & TextBox4.Text.Length <> 0 Then
' MsgBox(ObjLogin.paw)
If TextBox3.Text = TextBox4.Text Then
If TextBox2.Text = ObjLogin.paw Then
' MsgBox("密码一致")
Try
myConnStr = connstr()
myConnetion = New SqlConnection(myConnStr)
myConnetion.Open()
myCommand = New SqlCommand("UPDATE T_USER SET UPWD = @newPaw " & _
"WHERE UNAME = @userName", myConnetion)
myCommand.Parameters.Add("@newPaw", SqlDbType.VarChar, 6, "UPWD")
myCommand.Parameters("@newPaw").Value = TextBox4.Text
myCommand.Parameters.Add("@userName", SqlDbType.VarChar, 10, "UNAME")
myCommand.Parameters("@userName").Value = TextBox1.Text
myDataAdapter.UpdateCommand = myCommand
'myDataAdapter.Update(myDataSet, "T_USER")
Dim i As Integer
i = myCommand.ExecuteNonQuery()
'MsgBox("i is :" & i)
myConnetion.Close()
MsgBox("修改成功!!!")
TextBox3.Clear()
TextBox4.Clear()
Catch ex As Exception
MsgBox("修改失败。。。。")
End Try
Else
MsgBox("您输入的密码错误。。。。。。")
End If
Else
MsgBox("错误!!" & Chr(10) & "您输入的两次密码不一致。。。。")
End If
Else
MsgBox("密码不能为空。。。。。")
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -