📄 admin.vb
字号:
Imports System.Data
Imports System.Data.OleDb
Public Class admin
Inherits System.Windows.Forms.Form
Dim Sql As String = "Provider=Microsoft.Jet.OLEDB.4.0;Password=;User ID=Admin;Data Source=计算机选课系统.mdb"
Dim Conn As New OleDbConnection(Sql)
Dim ds As New DataSet
Dim tb As DataTable
Dim comm As OleDbCommand
#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 Button3 As System.Windows.Forms.Button
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents t2 As System.Windows.Forms.TextBox
Friend WithEvents t1 As System.Windows.Forms.TextBox
Friend WithEvents B1 As System.Windows.Forms.Button
Friend WithEvents B2 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.B1 = New System.Windows.Forms.Button
Me.B2 = New System.Windows.Forms.Button
Me.t2 = New System.Windows.Forms.TextBox
Me.t1 = New System.Windows.Forms.TextBox
Me.Button3 = New System.Windows.Forms.Button
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'B1
'
Me.B1.Location = New System.Drawing.Point(32, 248)
Me.B1.Name = "B1"
Me.B1.TabIndex = 0
Me.B1.Text = "学生信息"
Me.B1.Visible = False
'
'B2
'
Me.B2.Location = New System.Drawing.Point(208, 248)
Me.B2.Name = "B2"
Me.B2.TabIndex = 1
Me.B2.Text = "选课信息"
Me.B2.Visible = False
'
't2
'
Me.t2.Location = New System.Drawing.Point(88, 160)
Me.t2.Name = "t2"
Me.t2.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.t2.TabIndex = 2
Me.t2.Text = ""
'
't1
'
Me.t1.Location = New System.Drawing.Point(88, 128)
Me.t1.Name = "t1"
Me.t1.TabIndex = 3
Me.t1.Text = ""
'
'Button3
'
Me.Button3.Location = New System.Drawing.Point(240, 160)
Me.Button3.Name = "Button3"
Me.Button3.TabIndex = 4
Me.Button3.Text = "登录"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(104, 32)
Me.Label1.Name = "Label1"
Me.Label1.TabIndex = 5
Me.Label1.Text = "管理入口"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(32, 128)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(48, 23)
Me.Label2.TabIndex = 6
Me.Label2.Text = "用户名"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(40, 160)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(40, 23)
Me.Label3.TabIndex = 7
Me.Label3.Text = "密码"
'
'admin
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.BackColor = System.Drawing.SystemColors.Control
Me.ClientSize = New System.Drawing.Size(342, 306)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.t1)
Me.Controls.Add(Me.t2)
Me.Controls.Add(Me.B2)
Me.Controls.Add(Me.B1)
Me.MaximizeBox = False
Me.Name = "admin"
Me.Text = "admin"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim sql As String
If t1.Text <> "" And t2.Text <> "" Then
Try
sql = "select * from 管理员 where tid =" & "'" & t1.Text & "'"
Dim da As New OleDbDataAdapter(sql, gLinkString)
Dim ds As New DataSet
Dim tb As DataTable
da.Fill(ds, "MyTable")
tb = ds.Tables("MyTable")
If tb.Rows.Count() = 0 Then
MsgBox("对不起,您输入的帐号不存在!", MsgBoxStyle.OKOnly + MsgBoxStyle.Information, "谢谢使用")
t1.Focus()
ElseIf tb.Rows(0).Item("tpws").ToString <> t2.Text Then
MsgBox("您的帐号或者密码输入不正确!请重新登录!", MsgBoxStyle.OKOnly + MsgBoxStyle.Critical, "登录失败")
t1.Focus()
Else
MessageBox.Show("登陆成功")
B1.Visible = True
B2.Visible = True
Button3.Visible = False
End If
Catch ex As Exception
MsgBox(Err.Description)
t1.Focus()
End Try
Else
t1.Focus()
If t1.Text = "" Then
MsgBox("帐号不能为空!", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "学号为空")
Else
MsgBox("密码不能为空!", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "密码为空")
End If
End If
t1.Text = ""
t2.Text = ""
End Sub
Private Sub B1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1.Click
Dim stuiform As New stui
stuiform.ShowDialog(Me)
End Sub
Private Sub B2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2.Click
Dim lciform As New lci
lciform.ShowDialog(Me)
End Sub
Private Sub admin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
t1.Focus()
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -