?? 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 + -