📄 form5.vb
字号:
Public Class Form5
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 TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents SqlDataAdapter1 As System.Data.SqlClient.SqlDataAdapter
Friend WithEvents SqlSelectCommand1 As System.Data.SqlClient.SqlCommand
Friend WithEvents SqlInsertCommand1 As System.Data.SqlClient.SqlCommand
Friend WithEvents SqlUpdateCommand1 As System.Data.SqlClient.SqlCommand
Friend WithEvents SqlDeleteCommand1 As System.Data.SqlClient.SqlCommand
Friend WithEvents SqlConnection1 As System.Data.SqlClient.SqlConnection
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form5))
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Label3 = New System.Windows.Forms.Label
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.SqlDataAdapter1 = New System.Data.SqlClient.SqlDataAdapter
Me.SqlDeleteCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection
Me.SqlInsertCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlSelectCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlUpdateCommand1 = New System.Data.SqlClient.SqlCommand
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 21.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label1.ForeColor = System.Drawing.SystemColors.ControlLightLight
Me.Label1.Image = CType(resources.GetObject("Label1.Image"), System.Drawing.Image)
Me.Label1.ImageAlign = System.Drawing.ContentAlignment.TopLeft
Me.Label1.Location = New System.Drawing.Point(64, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(248, 40)
Me.Label1.TabIndex = 0
Me.Label1.Text = "欢迎管理员登陆"
'
'Label2
'
Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label2.ForeColor = System.Drawing.Color.FromArgb(CType(224, Byte), CType(224, Byte), CType(224, Byte))
Me.Label2.Image = CType(resources.GetObject("Label2.Image"), System.Drawing.Image)
Me.Label2.ImageAlign = System.Drawing.ContentAlignment.TopLeft
Me.Label2.Location = New System.Drawing.Point(24, 88)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(120, 24)
Me.Label2.TabIndex = 1
Me.Label2.Text = "管理员账号:"
'
'TextBox1
'
Me.TextBox1.AutoSize = False
Me.TextBox1.BackColor = System.Drawing.SystemColors.MenuText
Me.TextBox1.ForeColor = System.Drawing.SystemColors.ControlLight
Me.TextBox1.Location = New System.Drawing.Point(168, 80)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(184, 40)
Me.TextBox1.TabIndex = 2
Me.TextBox1.Text = ""
'
'Label3
'
Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label3.ForeColor = System.Drawing.Color.FromArgb(CType(224, Byte), CType(224, Byte), CType(224, Byte))
Me.Label3.Image = CType(resources.GetObject("Label3.Image"), System.Drawing.Image)
Me.Label3.ImageAlign = System.Drawing.ContentAlignment.TopLeft
Me.Label3.Location = New System.Drawing.Point(24, 160)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(128, 24)
Me.Label3.TabIndex = 3
Me.Label3.Text = "管理员密码:"
'
'TextBox2
'
Me.TextBox2.AutoSize = False
Me.TextBox2.BackColor = System.Drawing.SystemColors.MenuText
Me.TextBox2.ForeColor = System.Drawing.SystemColors.ControlLight
Me.TextBox2.Location = New System.Drawing.Point(168, 160)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.TextBox2.Size = New System.Drawing.Size(184, 40)
Me.TextBox2.TabIndex = 4
Me.TextBox2.Text = ""
'
'Button1
'
Me.Button1.Cursor = System.Windows.Forms.Cursors.Hand
Me.Button1.Font = New System.Drawing.Font("黑体", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Button1.ForeColor = System.Drawing.SystemColors.ControlLight
Me.Button1.Image = CType(resources.GetObject("Button1.Image"), System.Drawing.Image)
Me.Button1.ImageAlign = System.Drawing.ContentAlignment.TopLeft
Me.Button1.Location = New System.Drawing.Point(64, 224)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(112, 40)
Me.Button1.TabIndex = 5
Me.Button1.Text = "登 陆"
'
'Button2
'
Me.Button2.Cursor = System.Windows.Forms.Cursors.Hand
Me.Button2.Font = New System.Drawing.Font("黑体", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Button2.ForeColor = System.Drawing.SystemColors.ControlLight
Me.Button2.Image = CType(resources.GetObject("Button2.Image"), System.Drawing.Image)
Me.Button2.ImageAlign = System.Drawing.ContentAlignment.TopLeft
Me.Button2.Location = New System.Drawing.Point(208, 224)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(112, 40)
Me.Button2.TabIndex = 6
Me.Button2.Text = "重 置"
'
'SqlDataAdapter1
'
Me.SqlDataAdapter1.DeleteCommand = Me.SqlDeleteCommand1
Me.SqlDataAdapter1.InsertCommand = Me.SqlInsertCommand1
Me.SqlDataAdapter1.SelectCommand = Me.SqlSelectCommand1
Me.SqlDataAdapter1.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.SqlDataAdapter1.UpdateCommand = Me.SqlUpdateCommand1
'
'SqlDeleteCommand1
'
Me.SqlDeleteCommand1.CommandText = "DELETE FROM 管理员表 WHERE (登录账号 = @Original_登录账号) AND (密码 = @Original_密码)"
Me.SqlDeleteCommand1.Connection = Me.SqlConnection1
Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_登录账号", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "登录账号", System.Data.DataRowVersion.Original, Nothing))
Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_密码", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "密码", System.Data.DataRowVersion.Original, Nothing))
'
'SqlConnection1
'
Me.SqlConnection1.ConnectionString = "workstation id=""H09-BAC"";packet size=4096;integrated security=SSPI;initial catalo" & _
"g=人事管理系统;persist security info=False"
'
'SqlInsertCommand1
'
Me.SqlInsertCommand1.CommandText = "INSERT INTO 管理员表(登录账号, 密码) VALUES (@登录账号, @密码); SELECT 登录账号, 密码 FROM 管理员表 WHERE (" & _
"登录账号 = @登录账号)"
Me.SqlInsertCommand1.Connection = Me.SqlConnection1
Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@登录账号", System.Data.SqlDbType.VarChar, 10, "登录账号"))
Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@密码", System.Data.SqlDbType.VarChar, 10, "密码"))
'
'SqlSelectCommand1
'
Me.SqlSelectCommand1.CommandText = "SELECT 登录账号, 密码 FROM 管理员表"
Me.SqlSelectCommand1.Connection = Me.SqlConnection1
'
'SqlUpdateCommand1
'
Me.SqlUpdateCommand1.CommandText = "UPDATE 管理员表 SET 登录账号 = @登录账号, 密码 = @密码 WHERE (登录账号 = @Original_登录账号) AND (密码 = @O" & _
"riginal_密码); SELECT 登录账号, 密码 FROM 管理员表 WHERE (登录账号 = @登录账号)"
Me.SqlUpdateCommand1.Connection = Me.SqlConnection1
Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@登录账号", System.Data.SqlDbType.VarChar, 10, "登录账号"))
Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@密码", System.Data.SqlDbType.VarChar, 10, "密码"))
Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_登录账号", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "登录账号", System.Data.DataRowVersion.Original, Nothing))
Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_密码", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "密码", System.Data.DataRowVersion.Original, Nothing))
'
'Form5
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.BackgroundImage = CType(resources.GetObject("$this.BackgroundImage"), System.Drawing.Image)
Me.ClientSize = New System.Drawing.Size(400, 286)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Name = "Form5"
Me.Text = "Form5"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Clear()
TextBox2.Clear()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Dim sqlstr As String = "Select * from 管理员表"
'Dim com As SqlClient.SqlCommand = New SqlClient.SqlCommand(sqlstr, SqlConnection1)
'Dim flag As Boolean
'SqlConnection1.Open()
'Dim r As SqlClient.SqlDataReader = com.ExecuteReader
'While r.Read
'If TextBox1.Text = r("登录账号") And TextBox2.Text = r("密码") Then
'flag = True
'End If
'End While
'SqlConnection1.Close()
'If Not flag Then
'MessageBox.Show("您输入的管理员账号或密码有误,请重新登录!")
' Else
'Dim f As Form6
'f = New Form6
'f.Show()
'End If
If TextBox1.Text = "20572109" And TextBox2.Text = "20572104" Then
Dim f As Form6
f = New Form6
f.Show()
Else : MessageBox.Show("您输入的管理员账号或密码有误,请重新登录")
End If
End Sub
Private Sub SqlDataAdapter1_RowUpdated(ByVal sender As System.Object, ByVal e As System.Data.SqlClient.SqlRowUpdatedEventArgs)
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click
End Sub
Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -