📄 frmlogin.vb
字号:
Imports System.Data
Imports System.Data.OleDb
Module Global
Public gLinkString As String = "provider=Microsoft.Jet.OLEDB.4.0;Data Source='计算机选课系统.mdb'"
End Module
Public Class frmLogin
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 Label3 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents TxtNumber As System.Windows.Forms.TextBox
Friend WithEvents TxtPass As System.Windows.Forms.TextBox
Friend WithEvents CmdLogin As System.Windows.Forms.Button
Friend WithEvents cmdExit As System.Windows.Forms.Button
Friend WithEvents cmdInfo As System.Windows.Forms.Button
Friend WithEvents cmdChoose As System.Windows.Forms.Button
Friend WithEvents cmdChangePass As System.Windows.Forms.Button
Friend WithEvents gl As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.Label4 = New System.Windows.Forms.Label
Me.Label5 = New System.Windows.Forms.Label
Me.TxtNumber = New System.Windows.Forms.TextBox
Me.TxtPass = New System.Windows.Forms.TextBox
Me.CmdLogin = New System.Windows.Forms.Button
Me.cmdExit = New System.Windows.Forms.Button
Me.cmdInfo = New System.Windows.Forms.Button
Me.cmdChoose = New System.Windows.Forms.Button
Me.cmdChangePass = New System.Windows.Forms.Button
Me.gl = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(136, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(56, 23)
Me.Label1.TabIndex = 0
Me.Label1.Text = "欢迎进入"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(120, 40)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(96, 23)
Me.Label2.TabIndex = 1
Me.Label2.Text = "计算机选课系统"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(136, 112)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(56, 23)
Me.Label3.TabIndex = 2
Me.Label3.Text = "请先登陆"
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(16, 168)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(48, 23)
Me.Label4.TabIndex = 3
Me.Label4.Text = "学号:"
'
'Label5
'
Me.Label5.Location = New System.Drawing.Point(16, 200)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(48, 23)
Me.Label5.TabIndex = 4
Me.Label5.Text = "密码:"
'
'TxtNumber
'
Me.TxtNumber.Location = New System.Drawing.Point(64, 168)
Me.TxtNumber.Name = "TxtNumber"
Me.TxtNumber.Size = New System.Drawing.Size(128, 21)
Me.TxtNumber.TabIndex = 5
Me.TxtNumber.Text = ""
'
'TxtPass
'
Me.TxtPass.Location = New System.Drawing.Point(64, 200)
Me.TxtPass.Name = "TxtPass"
Me.TxtPass.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.TxtPass.Size = New System.Drawing.Size(128, 21)
Me.TxtPass.TabIndex = 6
Me.TxtPass.Text = ""
'
'CmdLogin
'
Me.CmdLogin.Location = New System.Drawing.Point(232, 200)
Me.CmdLogin.Name = "CmdLogin"
Me.CmdLogin.TabIndex = 7
Me.CmdLogin.Text = "登陆"
'
'cmdExit
'
Me.cmdExit.Location = New System.Drawing.Point(120, 256)
Me.cmdExit.Name = "cmdExit"
Me.cmdExit.TabIndex = 8
Me.cmdExit.Text = "退出"
'
'cmdInfo
'
Me.cmdInfo.Location = New System.Drawing.Point(232, 256)
Me.cmdInfo.Name = "cmdInfo"
Me.cmdInfo.TabIndex = 9
Me.cmdInfo.Text = "选课"
Me.cmdInfo.Visible = False
'
'cmdChoose
'
Me.cmdChoose.Location = New System.Drawing.Point(232, 136)
Me.cmdChoose.Name = "cmdChoose"
Me.cmdChoose.TabIndex = 10
Me.cmdChoose.Text = "已选课程"
Me.cmdChoose.Visible = False
'
'cmdChangePass
'
Me.cmdChangePass.Location = New System.Drawing.Point(232, 168)
Me.cmdChangePass.Name = "cmdChangePass"
Me.cmdChangePass.TabIndex = 11
Me.cmdChangePass.Text = "修改密码"
Me.cmdChangePass.Visible = False
'
'gl
'
Me.gl.Location = New System.Drawing.Point(16, 256)
Me.gl.Name = "gl"
Me.gl.TabIndex = 12
Me.gl.Text = "管理员"
'
'frmLogin
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(342, 306)
Me.Controls.Add(Me.gl)
Me.Controls.Add(Me.cmdChangePass)
Me.Controls.Add(Me.cmdChoose)
Me.Controls.Add(Me.cmdInfo)
Me.Controls.Add(Me.cmdExit)
Me.Controls.Add(Me.CmdLogin)
Me.Controls.Add(Me.TxtPass)
Me.Controls.Add(Me.TxtNumber)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.MaximizeBox = False
Me.Name = "frmLogin"
Me.Text = "计算机选课系统"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub frmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TxtNumber.Focus()
End Sub
Public Shared strStrdentName As String
Public Shared strStrdentNumber As String
Public Shared strStrdentPass As String
Public Shared strStrdentClass As String
Private Sub CmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdLogin.Click
Dim sql As String
If TxtNumber.Text <> "" And TxtPass.Text <> "" Then
Try
sql = "select * from 学生 where 学号 = " & "'" & TxtNumber.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, "谢谢使用")
TxtNumber.Focus()
ElseIf tb.Rows(0).Item("密码").ToString <> TxtPass.Text Then
MsgBox("同学:" & Chr(13) & "您的学号或者密码输入不正确!" & Chr(13) & "请重新登录!", MsgBoxStyle.OKOnly + MsgBoxStyle.Critical, "登录失败")
TxtNumber.Focus()
Else
strStrdentName = tb.Rows(0).Item("姓名")
strStrdentNumber = tb.Rows(0).Item("学号")
strStrdentPass = tb.Rows(0).Item("密码")
strStrdentClass = tb.Rows(0).Item("院系班级")
MsgBox("欢迎" & strStrdentName & "同学选课" & Chr(13) & "单击'选课'按纽进行选课" & Chr(13) _
& "单击'修改密码'按纽修改您的密码" & Chr(13) _
& "请您在选课结束后务必单击'退出'按纽!", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "登录成功")
TxtNumber.Text = ""
TxtPass.Text = ""
cmdChoose.Visible = True
cmdChoose.Focus()
cmdChangePass.Visible = True
cmdInfo.Visible = True
CmdLogin.Enabled = False
gl.Enabled = False
Me.AcceptButton = cmdChoose
End If
Catch ex As Exception
MsgBox(Err.Description)
TxtNumber.Focus()
End Try
Else
TxtNumber.Focus()
If TxtNumber.Text = "" Then
MsgBox("学号不能为空!", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "学号为空")
Else
MsgBox("密码不能为空!", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "密码为空")
End If
End If
TxtNumber.Text = ""
TxtPass.Text = ""
End Sub
Private Sub cmdChangePass_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdChangePass.Click
Dim ChangePassForm As New frmChangePass
ChangePassForm.ShowDialog(Me)
End Sub
Private Sub cmdChoose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdChoose.Click
Dim frmResultForm As New frmResult
frmResultForm.ShowDialog(Me)
End Sub
Private Sub cmdInfo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdInfo.Click
Dim frmcurriculumform As New frmCurriculum
frmcurriculumform.ShowDialog(Me)
End Sub
Private Sub cmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExit.Click
End
End Sub
Private Sub gl_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles gl.Click
Dim adminform As New admin
adminform.ShowDialog(Me)
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -