📄 login.vb
字号:
Imports System.Data
Imports System.Data.sqlClient
Public Class Login
Inherits System.Windows.Forms.Form
Dim j As Integer = 0
Dim i As Integer = 0
'Public Shared type As Integer
Dim conn As New SqlConnection
Dim CustDataAdapter As New SqlDataAdapter
Dim DataSetType As New DataSet
Dim dataType As DataTable
Dim result As DataRow
Dim strSql As String
Dim strType As String
Public Shared userName As String
Public Shared paw As String
Public Shared type_1 As Integer = 0
Dim ObjFrom1 As New Form1
#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 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 Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
Friend WithEvents ComboBox2 As System.Windows.Forms.ComboBox
Friend WithEvents ComboBox3 As System.Windows.Forms.ComboBox
Friend WithEvents Button4 As System.Windows.Forms.Button
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents Panel1 As System.Windows.Forms.Panel
Friend WithEvents Panel2 As System.Windows.Forms.Panel
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Login))
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.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.Button3 = New System.Windows.Forms.Button
Me.ComboBox1 = New System.Windows.Forms.ComboBox
Me.ComboBox2 = New System.Windows.Forms.ComboBox
Me.ComboBox3 = New System.Windows.Forms.ComboBox
Me.Button4 = New System.Windows.Forms.Button
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.Panel1 = New System.Windows.Forms.Panel
Me.Panel2 = New System.Windows.Forms.Panel
Me.GroupBox1.SuspendLayout()
Me.Panel2.SuspendLayout()
Me.SuspendLayout()
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(80, 32)
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(80, 72)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(72, 16)
Me.Label3.TabIndex = 2
Me.Label3.Text = "密 码:"
'
'TextBox1
'
Me.TextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.TextBox1.Location = New System.Drawing.Point(160, 24)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(152, 23)
Me.TextBox1.TabIndex = 3
Me.TextBox1.Text = ""
'
'TextBox2
'
Me.TextBox2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.TextBox2.Location = New System.Drawing.Point(160, 64)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.TextBox2.Size = New System.Drawing.Size(152, 23)
Me.TextBox2.TabIndex = 4
Me.TextBox2.Text = ""
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(88, 296)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(56, 32)
Me.Button1.TabIndex = 5
Me.Button1.Text = "登 陆"
'
'Button2
'
Me.Button2.Enabled = False
Me.Button2.Location = New System.Drawing.Point(160, 296)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(56, 32)
Me.Button2.TabIndex = 6
Me.Button2.Text = "重 置"
'
'Button3
'
Me.Button3.Location = New System.Drawing.Point(312, 296)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(72, 32)
Me.Button3.TabIndex = 7
Me.Button3.Text = "退出系统"
'
'ComboBox1
'
Me.ComboBox1.Location = New System.Drawing.Point(160, 104)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(0, 22)
Me.ComboBox1.TabIndex = 8
Me.ComboBox1.Text = "ComboBox1"
'
'ComboBox2
'
Me.ComboBox2.Location = New System.Drawing.Point(224, 104)
Me.ComboBox2.Name = "ComboBox2"
Me.ComboBox2.Size = New System.Drawing.Size(0, 22)
Me.ComboBox2.TabIndex = 9
Me.ComboBox2.Text = "ComboBox2"
'
'ComboBox3
'
Me.ComboBox3.Location = New System.Drawing.Point(240, 112)
Me.ComboBox3.Name = "ComboBox3"
Me.ComboBox3.Size = New System.Drawing.Size(0, 22)
Me.ComboBox3.TabIndex = 10
'
'Button4
'
Me.Button4.Location = New System.Drawing.Point(232, 296)
Me.Button4.Name = "Button4"
Me.Button4.Size = New System.Drawing.Size(72, 32)
Me.Button4.TabIndex = 11
Me.Button4.Text = "取消登陆"
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.Label2)
Me.GroupBox1.Controls.Add(Me.ComboBox1)
Me.GroupBox1.Controls.Add(Me.ComboBox2)
Me.GroupBox1.Controls.Add(Me.TextBox1)
Me.GroupBox1.Controls.Add(Me.Label3)
Me.GroupBox1.Controls.Add(Me.TextBox2)
Me.GroupBox1.Controls.Add(Me.ComboBox3)
Me.GroupBox1.Location = New System.Drawing.Point(24, 168)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(424, 104)
Me.GroupBox1.TabIndex = 12
Me.GroupBox1.TabStop = False
'
'Panel1
'
Me.Panel1.BackgroundImage = CType(resources.GetObject("Panel1.BackgroundImage"), System.Drawing.Image)
Me.Panel1.Location = New System.Drawing.Point(24, 16)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(424, 144)
Me.Panel1.TabIndex = 13
'
'Panel2
'
Me.Panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.Panel2.Controls.Add(Me.GroupBox1)
Me.Panel2.Controls.Add(Me.Button4)
Me.Panel2.Controls.Add(Me.Button1)
Me.Panel2.Controls.Add(Me.Panel1)
Me.Panel2.Controls.Add(Me.Button2)
Me.Panel2.Controls.Add(Me.Button3)
Me.Panel2.Location = New System.Drawing.Point(-8, 0)
Me.Panel2.Name = "Panel2"
Me.Panel2.Size = New System.Drawing.Size(464, 344)
Me.Panel2.TabIndex = 15
'
'Login
'
Me.AutoScaleBaseSize = New System.Drawing.Size(7, 16)
Me.ClientSize = New System.Drawing.Size(456, 349)
Me.Controls.Add(Me.Panel2)
Me.Font = New System.Drawing.Font("宋体", 10.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "Login"
Me.Text = "------欢迎登陆"
Me.GroupBox1.ResumeLayout(False)
Me.Panel2.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Login_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Activate()
Login_User()
For Each userRow In LoginDataSet.Tables("T_USER").Rows
Me.ComboBox1.Items.Add(userRow("UNAME"))
Next
For Each pawRow In LoginDataSet.Tables("T_USER").Rows
Me.ComboBox2.Items.Add(pawRow("UPWD"))
Next
End Sub
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 Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For i = 0 To ComboBox1.Items.Count - 1
' MsgBox("aaaaa")
'MsgBox(ComboBox1.Items.Item(i))
If TextBox1.Text.Trim() = ComboBox1.Items.Item(i) Then
' MsgBox("bbbbb")
If TextBox2.Text.Trim() = ComboBox2.Items.Item(i) Then
'MsgBox("ccccc")
userName = TextBox1.Text.Trim
paw = TextBox2.Text.Trim
closeFrom1()
type_1 = type
'MsgBox(type_1)
ObjFrom1.type_2 = type_1
ObjFrom1.Activate()
'MsgBox("*****欢迎您访问*****")
Me.ComboBox3.Text = ""
Me.Close()
Exit For
Else
MsgBox("您输入的用户名和密码错误,请核对!!!")
End If
' MsgBox("您输入的用户名和密码错误,请核对!!!")
End If
Next
' If TextBox1.Text = ComboBox1.Items.Item(i) Then
' If TextBox2.Text = ComboBox2.Items.Item(i) Then
'
' MsgBox("*****欢迎您访问*****")
' Close()
'
' Else
' MsgBox("您输入的密码错误,请核对!!!")
' End If
' Else
' If j = 3 Then
' MsgBox("输入次数达到次,系统将自动关闭!!!")
' Close()
' Else
' MsgBox("对不起您没有权限访问,请核对您的帐号和密码")
' End If
' End If
' i = i + 1
'j = j + 1
End Sub
Private Sub Login_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
falg = 0
Me.Hide()
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
If TextBox1.Text.Length = 0 Then
Button2.Enabled = False
Else
Button2.Enabled = True
End If
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
If TextBox2.Text.Length = 0 Then
Button2.Enabled = False
Else
Button2.Enabled = True
End If
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Me.Close()
End Sub
Private Sub Login_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp
If e.KeyCode = Keys.Enter Then
ObjFrom1.Show()
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -