📄 登录窗.vb
字号:
Imports System.Data
Imports System.Data.SqlClient
Public Class Form7
Inherits System.Windows.Forms.Form
Dim count As Integer = 0
#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 Button2 As System.Windows.Forms.Button
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label1 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Button2 = New System.Windows.Forms.Button
Me.Button1 = New System.Windows.Forms.Button
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Label3 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label1 = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'Button2
'
Me.Button2.Font = New System.Drawing.Font("宋体", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Button2.Location = New System.Drawing.Point(288, 299)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(112, 32)
Me.Button2.TabIndex = 13
Me.Button2.Text = "取 消"
'
'Button1
'
Me.Button1.Font = New System.Drawing.Font("宋体", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Button1.Location = New System.Drawing.Point(96, 299)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(112, 32)
Me.Button1.TabIndex = 12
Me.Button1.Text = "确 定"
'
'TextBox2
'
Me.TextBox2.AutoSize = False
Me.TextBox2.Location = New System.Drawing.Point(208, 235)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.TextBox2.Size = New System.Drawing.Size(240, 32)
Me.TextBox2.TabIndex = 11
Me.TextBox2.Text = ""
'
'TextBox1
'
Me.TextBox1.AutoSize = False
Me.TextBox1.Location = New System.Drawing.Point(208, 163)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(240, 32)
Me.TextBox1.TabIndex = 10
Me.TextBox1.Text = ""
'
'Label3
'
Me.Label3.Font = New System.Drawing.Font("宋体", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label3.Location = New System.Drawing.Point(48, 243)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(136, 32)
Me.Label3.TabIndex = 9
Me.Label3.Text = " 密 码"
'
'Label2
'
Me.Label2.Font = New System.Drawing.Font("宋体", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label2.Location = New System.Drawing.Point(48, 171)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(136, 32)
Me.Label2.TabIndex = 8
Me.Label2.Text = " 用 户 名"
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("华文彩云", 36.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label1.ForeColor = System.Drawing.SystemColors.InactiveCaption
Me.Label1.Location = New System.Drawing.Point(88, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(328, 120)
Me.Label1.TabIndex = 7
Me.Label1.Text = "老贾航空公司 管理信息系统"
'
'Form7
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(504, 390)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
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.Name = "Form7"
Me.Text = "Form7"
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 user As String
Dim pw As String
Dim frm As New Form1
Dim temp1 As String
Dim temp2 As String
Dim con As String
Dim dr As DataRow
Dim conn As New SqlConnection(constr)
user = TextBox1.Text
pw = TextBox2.Text
con = "select * from users where id='" + user + "' and password='" + pw + "'"
Dim da As New SqlDataAdapter(con, conn)
Dim ds As New DataSet
conn.Open()
da.Fill(ds)
conn.Close()
Try
If ds.Tables(0).Rows.Count > 0 Then
dr = ds.Tables(0).Rows(0)
temp1 = dr(0)
temp2 = dr(1)
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
con = "insert into log(id,module) select id,module from permission where id='" + temp1 + "'"
Dim cmd As New SqlCommand
cmd.Connection = conn
cmd.CommandType = CommandType.Text
conn.Open()
cmd.CommandText = con
If (Trim(user) = Trim(temp1) And Trim(pw) = Trim(temp2)) Then
Me.Hide()
Try
cmd.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
conn.Close()
End Try
frm.Show()
ElseIf (Trim(user) <> Trim(temp1) Or Trim(pw) <> Trim(temp2)) Then
MessageBox.Show("没有这个用户或密码错误,请重新输入!", "提示")
TextBox1.SelectAll()
TextBox1.Focus()
End If
count = count + 1
If (count = 3) Then
MessageBox.Show("三次错误,退出本系统", "提示")
End
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub
Private Sub Form7_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 + -