📄 更改密码.vb
字号:
Public Class 更改密码
Inherits System.Windows.Forms.Form
#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 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
Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
Friend WithEvents OleDbDataAdapter1 As System.Data.OleDb.OleDbDataAdapter
Friend WithEvents Mi1 As 学生公寓管理系统.mi
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents OleDbSelectCommand1 As System.Data.OleDb.OleDbCommand
Friend WithEvents OleDbInsertCommand1 As System.Data.OleDb.OleDbCommand
Friend WithEvents OleDbUpdateCommand1 As System.Data.OleDb.OleDbCommand
Friend WithEvents OleDbDeleteCommand1 As System.Data.OleDb.OleDbCommand
Friend WithEvents OleDbConnection1 As System.Data.OleDb.OleDbConnection
<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.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.TextBox4 = New System.Windows.Forms.TextBox
Me.Mi1 = New 学生公寓管理系统.mi
Me.OleDbDataAdapter1 = New System.Data.OleDb.OleDbDataAdapter
Me.OleDbDeleteCommand1 = New System.Data.OleDb.OleDbCommand
Me.OleDbConnection1 = New System.Data.OleDb.OleDbConnection
Me.OleDbInsertCommand1 = New System.Data.OleDb.OleDbCommand
Me.OleDbSelectCommand1 = New System.Data.OleDb.OleDbCommand
Me.OleDbUpdateCommand1 = New System.Data.OleDb.OleDbCommand
Me.Label4 = New System.Windows.Forms.Label
CType(Me.Mi1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Font = New System.Drawing.Font("宋体", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label1.Location = New System.Drawing.Point(32, 64)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(63, 22)
Me.Label1.TabIndex = 0
Me.Label1.Text = "旧口令:"
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Font = New System.Drawing.Font("宋体", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label2.Location = New System.Drawing.Point(32, 96)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(63, 22)
Me.Label2.TabIndex = 1
Me.Label2.Text = "新口令:"
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Font = New System.Drawing.Font("宋体", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label3.Location = New System.Drawing.Point(32, 128)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(63, 22)
Me.Label3.TabIndex = 2
Me.Label3.Text = "新口令:"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(104, 32)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = ""
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(104, 64)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.TextBox2.TabIndex = 1
Me.TextBox2.Text = ""
'
'TextBox3
'
Me.TextBox3.Location = New System.Drawing.Point(104, 96)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.TextBox3.TabIndex = 2
Me.TextBox3.Text = ""
'
'Button1
'
Me.Button1.BackColor = System.Drawing.SystemColors.Control
Me.Button1.Font = New System.Drawing.Font("宋体", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Button1.Location = New System.Drawing.Point(48, 160)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(64, 32)
Me.Button1.TabIndex = 4
Me.Button1.Text = "确认"
'
'Button2
'
Me.Button2.BackColor = System.Drawing.SystemColors.Control
Me.Button2.Font = New System.Drawing.Font("宋体", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Button2.Location = New System.Drawing.Point(120, 160)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(64, 32)
Me.Button2.TabIndex = 5
Me.Button2.Text = "取消"
'
'TextBox4
'
Me.TextBox4.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.Mi1, "用户.密码"))
Me.TextBox4.Location = New System.Drawing.Point(104, 128)
Me.TextBox4.Name = "TextBox4"
Me.TextBox4.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.TextBox4.TabIndex = 3
Me.TextBox4.Text = ""
'
'Mi1
'
Me.Mi1.DataSetName = "mi"
Me.Mi1.Locale = New System.Globalization.CultureInfo("zh-CN")
'
'OleDbDataAdapter1
'
Me.OleDbDataAdapter1.DeleteCommand = Me.OleDbDeleteCommand1
Me.OleDbDataAdapter1.InsertCommand = Me.OleDbInsertCommand1
Me.OleDbDataAdapter1.SelectCommand = Me.OleDbSelectCommand1
Me.OleDbDataAdapter1.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "用户", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("用户名", "用户名"), New System.Data.Common.DataColumnMapping("密码", "密码")})})
Me.OleDbDataAdapter1.UpdateCommand = Me.OleDbUpdateCommand1
'
'OleDbDeleteCommand1
'
Me.OleDbDeleteCommand1.CommandText = "DELETE FROM 用户 WHERE (用户名 = ?) AND (密码 = ? OR ? IS NULL AND 密码 IS NULL)"
Me.OleDbDeleteCommand1.Connection = Me.OleDbConnection1
Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_用户名", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "用户名", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_密码", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "密码", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_密码1", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "密码", System.Data.DataRowVersion.Original, Nothing))
'
'OleDbConnection1
'
Me.OleDbConnection1.ConnectionString = "Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database L" & _
"ocking Mode=1;Data Source=""学生公寓管理系统.mdb"";Jet OLEDB:Engine Type=5;Provider=""Micro" & _
"soft.Jet.OLEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB:SFP=False;persist secur" & _
"ity info=False;Extended Properties=;Mode=Share Deny None;Jet OLEDB:Encrypt Datab" & _
"ase=False;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on " & _
"Compact=False;Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet O" & _
"LEDB:Global Bulk Transactions=1"
'
'OleDbInsertCommand1
'
Me.OleDbInsertCommand1.CommandText = "INSERT INTO 用户(用户名, 密码) VALUES (?, ?)"
Me.OleDbInsertCommand1.Connection = Me.OleDbConnection1
Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("用户名", System.Data.OleDb.OleDbType.VarWChar, 50, "用户名"))
Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("密码", System.Data.OleDb.OleDbType.VarWChar, 50, "密码"))
'
'OleDbSelectCommand1
'
Me.OleDbSelectCommand1.CommandText = "SELECT 用户名, 密码 FROM 用户"
Me.OleDbSelectCommand1.Connection = Me.OleDbConnection1
'
'OleDbUpdateCommand1
'
Me.OleDbUpdateCommand1.CommandText = "UPDATE 用户 SET 用户名 = ?, 密码 = ? WHERE (用户名 = ?) AND (密码 = ? OR ? IS NULL AND 密码 IS " & _
"NULL)"
Me.OleDbUpdateCommand1.Connection = Me.OleDbConnection1
Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("用户名", System.Data.OleDb.OleDbType.VarWChar, 50, "用户名"))
Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("密码", System.Data.OleDb.OleDbType.VarWChar, 50, "密码"))
Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_用户名", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "用户名", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_密码", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "密码", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_密码1", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "密码", System.Data.DataRowVersion.Original, Nothing))
'
'Label4
'
Me.Label4.AutoSize = True
Me.Label4.Font = New System.Drawing.Font("宋体", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label4.Location = New System.Drawing.Point(32, 32)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(63, 22)
Me.Label4.TabIndex = 10
Me.Label4.Text = "用户名:"
'
'更改密码
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.BackColor = System.Drawing.Color.Silver
Me.ClientSize = New System.Drawing.Size(248, 214)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.TextBox4)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox3)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.MinimizeBox = False
Me.Name = "更改密码"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "更改密码"
CType(Me.Mi1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ComStr, St, St2, St3 As String
If Trim(TextBox3.Text) <> Trim(TextBox4.Text) Then
MsgBox("您两次输入的密码不相同!")
Exit Sub
End If
St = Trim(TextBox2.Text)
St2 = Trim(TextBox1.Text)
Try
OleDbDataAdapter1.SelectCommand.CommandText = "select * from 用户 where 用户名= '" & St2 & "'" & "and 密码=" & "'" & St & "'"
Mi1.Clear()
OleDbDataAdapter1.Fill(Mi1)
If Me.BindingContext(Mi1, "用户").Count = 0 Then
MsgBox("您输入的用户名或密码不正确!")
Exit Sub
End If
Catch ex As Exception
MsgBox("您输入的用户名或密码不正确!")
Exit Sub
End Try
TextBox4.Text = TextBox3.Text
Try
Me.BindingContext(Mi1, "用户").EndCurrentEdit()
OleDbDataAdapter1.Update(Mi1)
MsgBox("您的新密码已经确定!")
Catch ex As Exception
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub 更改密码_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -