📄 form1.vb
字号:
Public Class Form1
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 TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = 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.SuspendLayout()
'
'Label1
'
Me.Label1.BackColor = System.Drawing.Color.Transparent
Me.Label1.Font = New System.Drawing.Font("SimSun", 15.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label1.Location = New System.Drawing.Point(40, 45)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(83, 21)
Me.Label1.TabIndex = 0
Me.Label1.Text = "用户名:"
'
'Label2
'
Me.Label2.BackColor = System.Drawing.Color.Transparent
Me.Label2.Font = New System.Drawing.Font("SimSun", 15.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label2.Location = New System.Drawing.Point(40, 97)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(83, 21)
Me.Label2.TabIndex = 1
Me.Label2.Text = "密码:"
'
'TextBox1
'
Me.TextBox1.BackColor = System.Drawing.SystemColors.Info
Me.TextBox1.Cursor = System.Windows.Forms.Cursors.Hand
Me.TextBox1.Location = New System.Drawing.Point(133, 45)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(107, 20)
Me.TextBox1.TabIndex = 2
Me.TextBox1.Text = ""
'
'TextBox2
'
Me.TextBox2.BackColor = System.Drawing.SystemColors.Info
Me.TextBox2.Cursor = System.Windows.Forms.Cursors.Hand
Me.TextBox2.Location = New System.Drawing.Point(133, 97)
Me.TextBox2.MaxLength = 6
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.TextBox2.Size = New System.Drawing.Size(107, 20)
Me.TextBox2.TabIndex = 3
Me.TextBox2.Text = ""
'
'Button1
'
Me.Button1.BackColor = System.Drawing.Color.Transparent
Me.Button1.Font = New System.Drawing.Font("SimSun", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Button1.Location = New System.Drawing.Point(47, 149)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(81, 35)
Me.Button1.TabIndex = 4
Me.Button1.Text = "登陆"
'
'Button2
'
Me.Button2.BackColor = System.Drawing.Color.Transparent
Me.Button2.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.Button2.Font = New System.Drawing.Font("SimSun", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Button2.Location = New System.Drawing.Point(173, 149)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(83, 35)
Me.Button2.TabIndex = 5
Me.Button2.Text = "退出"
'
'Form1
'
Me.AcceptButton = Me.Button1
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.SystemColors.InactiveCaption
Me.BackgroundImage = CType(resources.GetObject("$this.BackgroundImage"), System.Drawing.Image)
Me.CancelButton = Me.Button2
Me.ClientSize = New System.Drawing.Size(332, 214)
Me.ControlBox = False
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Cursor = System.Windows.Forms.Cursors.Default
Me.ForeColor = System.Drawing.SystemColors.InactiveCaptionText
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "酒店管理系统(郑州轻工业学院软件学院04-1毕业设计作品)"
Me.ResumeLayout(False)
End Sub
#End Region
Public Shared logonuser As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Focus()
'在重新登陆时清空前登陆的记录
TextBox1.Text = ""
TextBox2.Text = ""
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Application.Exit()
Me.Dispose()
Me.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
If TextBox1.Text <> "" Then
If TextBox2.Text <> "" Then
Dim cn As New System.Data.SqlClient.SqlConnection(help.connectionstring)
Dim cm As New System.Data.SqlClient.SqlCommand("select 密码,权限级别 from 操作员 where 账号='" & Trim(TextBox1.Text) & "'", cn)
cn.Open()
Dim dr As System.Data.SqlClient.SqlDataReader = cm.ExecuteReader
If dr.HasRows Then
If dr.Read Then
If Trim(dr.Item(0).ToString) = TextBox2.Text Then
Select Case Trim(dr.Item(1).ToString)
Case 1
dr.Close()
cn.Close()
logonuser = TextBox1.Text.Trim
Dim main As New Form2(Me)
main.Show()
MyBase.Hide()
Case 2
dr.Close()
cn.Close()
logonuser = TextBox1.Text.Trim
Dim main As New Form2(Me)
main.MenuItem22.Enabled = False
main.MenuItem34.Enabled = False
main.Show()
MyBase.Hide()
Case Else
dr.Close()
cn.Close()
logonuser = TextBox1.Text.Trim
Dim main As New Form2(Me)
main.MenuItem20.Enabled = False
main.Show()
MyBase.Hide()
End Select
End If
End If
Else
MessageBox.Show("您的帐号或密码不正确!", "警告:", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)
End If
dr.Close()
cn.Close()
Else
MessageBox.Show("密码不能为空!", "警告:", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)
End If
Else
MessageBox.Show("用户名不能为空!", "警告:", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)
End If
Catch logonerr As SqlClient.SqlException
If MessageBox.Show("数据库连接参数不正确或者要访问的数据不存在,请检查连接,单击确定手动设置!", "数据库连接异常", MessageBoxButtons.OK, MessageBoxIcon.Warning) = DialogResult.OK Then
Dim Datasourceseting As New Form13
Datasourceseting.Show()
End If
Exit Sub
Catch ex As Exception
MsgBox(ex.ToString)
Exit Sub
End Try
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -