?? frmsuperadminmodify.vb
字號:
Imports System.Data
Imports System.Data.SqlClient
Public Class frmsuperAdminModify
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 lbUser As System.Windows.Forms.ListBox
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents tbEmail As System.Windows.Forms.TextBox
Friend WithEvents tbUsername As System.Windows.Forms.TextBox
Friend WithEvents tbPwdConfirm As System.Windows.Forms.TextBox
Friend WithEvents tbPwd As System.Windows.Forms.TextBox
Friend WithEvents tbLoginname As System.Windows.Forms.TextBox
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label8 As System.Windows.Forms.Label
Friend WithEvents cbAdmin As System.Windows.Forms.CheckBox
Friend WithEvents bnModify As System.Windows.Forms.Button
Friend WithEvents bnCancel As System.Windows.Forms.Button
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents tbtelno As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmsuperAdminModify))
Me.lbUser = New System.Windows.Forms.ListBox
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.tbtelno = New System.Windows.Forms.TextBox
Me.Label3 = New System.Windows.Forms.Label
Me.tbEmail = New System.Windows.Forms.TextBox
Me.tbUsername = New System.Windows.Forms.TextBox
Me.tbPwdConfirm = New System.Windows.Forms.TextBox
Me.tbPwd = New System.Windows.Forms.TextBox
Me.tbLoginname = New System.Windows.Forms.TextBox
Me.Label6 = New System.Windows.Forms.Label
Me.Label5 = New System.Windows.Forms.Label
Me.Label4 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label8 = New System.Windows.Forms.Label
Me.cbAdmin = New System.Windows.Forms.CheckBox
Me.bnModify = New System.Windows.Forms.Button
Me.bnCancel = New System.Windows.Forms.Button
Me.GroupBox1.SuspendLayout()
Me.SuspendLayout()
'
'lbUser
'
Me.lbUser.ItemHeight = 12
Me.lbUser.Location = New System.Drawing.Point(8, 8)
Me.lbUser.Name = "lbUser"
Me.lbUser.Size = New System.Drawing.Size(144, 292)
Me.lbUser.TabIndex = 4
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.tbtelno)
Me.GroupBox1.Controls.Add(Me.Label3)
Me.GroupBox1.Controls.Add(Me.tbEmail)
Me.GroupBox1.Controls.Add(Me.tbUsername)
Me.GroupBox1.Controls.Add(Me.tbPwdConfirm)
Me.GroupBox1.Controls.Add(Me.tbPwd)
Me.GroupBox1.Controls.Add(Me.tbLoginname)
Me.GroupBox1.Controls.Add(Me.Label6)
Me.GroupBox1.Controls.Add(Me.Label5)
Me.GroupBox1.Controls.Add(Me.Label4)
Me.GroupBox1.Controls.Add(Me.Label2)
Me.GroupBox1.Controls.Add(Me.Label8)
Me.GroupBox1.Location = New System.Drawing.Point(168, 8)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(256, 264)
Me.GroupBox1.TabIndex = 7
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "修改信息"
'
'tbtelno
'
Me.tbtelno.Location = New System.Drawing.Point(80, 196)
Me.tbtelno.Name = "tbtelno"
Me.tbtelno.Size = New System.Drawing.Size(152, 21)
Me.tbtelno.TabIndex = 144
Me.tbtelno.Text = ""
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(24, 200)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(56, 24)
Me.Label3.TabIndex = 143
Me.Label3.Text = "電話:"
Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'tbEmail
'
Me.tbEmail.Location = New System.Drawing.Point(80, 160)
Me.tbEmail.Name = "tbEmail"
Me.tbEmail.Size = New System.Drawing.Size(152, 21)
Me.tbEmail.TabIndex = 136
Me.tbEmail.Text = ""
'
'tbUsername
'
Me.tbUsername.Location = New System.Drawing.Point(80, 124)
Me.tbUsername.Name = "tbUsername"
Me.tbUsername.Size = New System.Drawing.Size(152, 21)
Me.tbUsername.TabIndex = 135
Me.tbUsername.Text = ""
'
'tbPwdConfirm
'
Me.tbPwdConfirm.Location = New System.Drawing.Point(80, 88)
Me.tbPwdConfirm.Name = "tbPwdConfirm"
Me.tbPwdConfirm.Size = New System.Drawing.Size(152, 21)
Me.tbPwdConfirm.TabIndex = 134
Me.tbPwdConfirm.Text = ""
'
'tbPwd
'
Me.tbPwd.Location = New System.Drawing.Point(80, 52)
Me.tbPwd.Name = "tbPwd"
Me.tbPwd.Size = New System.Drawing.Size(152, 21)
Me.tbPwd.TabIndex = 133
Me.tbPwd.Text = ""
'
'tbLoginname
'
Me.tbLoginname.Location = New System.Drawing.Point(80, 16)
Me.tbLoginname.Name = "tbLoginname"
Me.tbLoginname.ReadOnly = True
Me.tbLoginname.Size = New System.Drawing.Size(152, 21)
Me.tbLoginname.TabIndex = 142
Me.tbLoginname.Text = ""
'
'Label6
'
Me.Label6.Location = New System.Drawing.Point(8, 88)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(72, 24)
Me.Label6.TabIndex = 131
Me.Label6.Text = "確認口令:"
Me.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'Label5
'
Me.Label5.Location = New System.Drawing.Point(24, 128)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(56, 24)
Me.Label5.TabIndex = 130
Me.Label5.Text = "姓名:"
Me.Label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(24, 168)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(56, 24)
Me.Label4.TabIndex = 129
Me.Label4.Text = "email:"
Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(24, 56)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(56, 24)
Me.Label2.TabIndex = 127
Me.Label2.Text = "口令:"
Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'Label8
'
Me.Label8.Location = New System.Drawing.Point(24, 16)
Me.Label8.Name = "Label8"
Me.Label8.Size = New System.Drawing.Size(56, 24)
Me.Label8.TabIndex = 126
Me.Label8.Text = "登錄名:"
Me.Label8.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'cbAdmin
'
Me.cbAdmin.Location = New System.Drawing.Point(240, 240)
Me.cbAdmin.Name = "cbAdmin"
Me.cbAdmin.RightToLeft = System.Windows.Forms.RightToLeft.Yes
Me.cbAdmin.Size = New System.Drawing.Size(112, 24)
Me.cbAdmin.TabIndex = 9
Me.cbAdmin.Text = ":超級管理用戶"
'
'bnModify
'
Me.bnModify.Location = New System.Drawing.Point(192, 288)
Me.bnModify.Name = "bnModify"
Me.bnModify.TabIndex = 10
Me.bnModify.Text = "修改"
'
'bnCancel
'
Me.bnCancel.Location = New System.Drawing.Point(312, 288)
Me.bnCancel.Name = "bnCancel"
Me.bnCancel.TabIndex = 11
Me.bnCancel.Text = "取消"
'
'frmsuperAdminModify
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(432, 317)
Me.Controls.Add(Me.bnCancel)
Me.Controls.Add(Me.bnModify)
Me.Controls.Add(Me.cbAdmin)
Me.Controls.Add(Me.GroupBox1)
Me.Controls.Add(Me.lbUser)
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "frmsuperAdminModify"
Me.Text = "----------超級管理員修改信息"
Me.GroupBox1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub frmAdminModify_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
refreshList()
End Sub
Private Sub refreshList()
lbUser.Items.Clear()
Dim strSource As String = "workstation id=郭洪博;packet size=4096;integrated security=SSPI;initial catalog=books;persist security info=False"
Dim strSelect As String = "select username from admin"
Dim conn As SqlConnection = New SqlConnection(strSource)
conn.Open()
Dim cmd As SqlCommand = New SqlCommand(strSelect, conn)
Dim reader As SqlDataReader = cmd.ExecuteReader()
If Not reader.HasRows Then
Exit Sub
End If
While reader.Read()
lbUser.Items.Add(reader.Item("username").ToString().Trim())
End While
conn.Close()
End Sub
Private Sub lbUser_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbUser.SelectedIndexChanged
Dim strSource As String = "workstation id=郭洪博;packet size=4096;integrated security=SSPI;initial catalog=books;persist security info=False"
Dim strSelect As String = "select * from admin where username = '" + lbUser.Items.Item(lbUser.SelectedIndex).ToString().Trim() + "'"
Dim conn As SqlConnection = New SqlConnection(strSource)
conn.Open()
Dim cmd As SqlCommand = New SqlCommand(strSelect, conn)
Dim dr As SqlDataReader = cmd.ExecuteReader()
If Not dr.HasRows Then
conn.Close()
Exit Sub
End If
dr.Read()
tbLoginname.Text = dr.Item("username").ToString().Trim()
tbPwd.Text = dr.Item("password").ToString().Trim()
tbPwdConfirm.Text = dr.Item("password").ToString().Trim()
tbUsername.Text = dr.Item("name").ToString().Trim()
tbEmail.Text = dr.Item("email").ToString().Trim()
tbtelno.Text = dr.Item("telno").ToString().Trim()
Dim i As Integer = Convert.ToInt32(dr.Item("control").ToString().Trim())
If i <> 0 Then
cbAdmin.Checked = False
Else
cbAdmin.Checked = True
End If
conn.Close()
End Sub
Private Sub bnModify_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bnModify.Click
Dim strSource As String = "workstation id=郭洪博;packet size=4096;integrated security=SSPI;initial catalog=books;persist security info=False"
If tbPwdConfirm.Text.Trim() <> tbPwd.Text.Trim() Then
MessageBox.Show("兩次口令不一致!")
Exit Sub
End If
Dim i As Integer
If cbAdmin.Checked Then
i = 0
Else
i = 1
End If
Dim strUpdate As String = "update admin set password='" + tbPwd.Text.Trim() + "',name='" + tbUsername.Text.Trim() + "',email='" + tbEmail.Text.Trim() + "',telno=" + tbtelno.Text.Trim() + ",control=" + i.ToString() + " where username= '" + tbLoginname.Text.Trim() + "'"
Dim conn As SqlConnection = New SqlConnection(strSource)
Try
conn.Open()
Dim cmd As SqlCommand = New SqlCommand(strUpdate, conn)
Dim ret As Integer = cmd.ExecuteNonQuery()
If ret <> 1 Then
MessageBox.Show("更新失敗!")
Else
MessageBox.Show("更新成功!")
End If
Catch ex As Exception
End Try
conn.Close()
End Sub
Private Sub bnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bnCancel.Click
Me.Close()
End Sub
End Class
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -