⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmlogin.frm

📁 学籍管理系统 建立学生学籍管理系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmLogin 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "登录系统"
   ClientHeight    =   2685
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   4350
   Icon            =   "frmLogin.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   2685
   ScaleWidth      =   4350
   StartUpPosition =   2  '屏幕中心
   Begin VB.Frame Frame1 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1455
      Left            =   120
      TabIndex        =   4
      ToolTipText     =   "欢迎使用成绩管理系统,请登录系统"
      Top             =   480
      Width           =   4095
      Begin VB.TextBox txtusername 
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   315
         Left            =   1560
         TabIndex        =   6
         Top             =   360
         Width           =   2175
      End
      Begin VB.TextBox txtpassword 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   315
         IMEMode         =   3  'DISABLE
         Left            =   1560
         PasswordChar    =   "*"
         TabIndex        =   5
         Top             =   840
         Width           =   2175
      End
      Begin VB.Label Label1 
         Caption         =   "用 户 名:"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   400
         TabIndex        =   8
         Top             =   405
         Width           =   975
      End
      Begin VB.Label Label2 
         Caption         =   "密    码:"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   400
         TabIndex        =   7
         Top             =   885
         Width           =   975
      End
   End
   Begin VB.CommandButton Command1 
      Caption         =   "登录系统(&I)"
      Height          =   375
      Left            =   1560
      TabIndex        =   3
      Top             =   2160
      Width           =   1215
   End
   Begin VB.CommandButton Command2 
      Caption         =   "退出系统(&E)"
      Height          =   375
      Left            =   3000
      TabIndex        =   2
      Top             =   2160
      Width           =   1215
   End
   Begin VB.CommandButton Command3 
      Caption         =   "注册用户(&N)"
      Height          =   375
      Left            =   120
      TabIndex        =   1
      ToolTipText     =   "注册要使用本系统的用户"
      Top             =   2160
      Width           =   1215
   End
   Begin VB.Label Label3 
      Caption         =   "    学 籍 管 理 系 统"
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   15
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   4095
   End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpbuffer As String, nSize As Long) As Long
Private Sub Command1_Click()
Dim txtSQL As String
Dim txtSQL1 As String
Dim sMeg As String
Dim MRC As ADODB.Recordset
Dim mrc1 As ADODB.Recordset
Dim MsgText As String
Dim Authority, IsValid As String
Dim OK As Boolean
    UserName = ""
    If Trim(txtusername.Text = "") Then
              MsgBox "请输入您的用户名!", vbOKOnly + vbApplicationModal, "登录系统"
        txtusername.SetFocus
    Else
        txtSQL = "select * from userLogin where username = '" & txtusername.Text & "'and (SystemName='SYSTEM' or SystemName='Student')"
        Set MRC = ExecuteSQL(txtSQL, MsgText)
        If (MsgText = "查询错误: [Microsoft][ODBC SQL Server Driver][SQL Server]无法打开登录 'Exam' 中请求的数据库。登录失败。") Then
            MsgBox "系统无法运行,请建立运行本系统所需的数据库!", vbOKOnly + vbCritical, "警告"
        End
        Exit Sub
        End If
        If MRC.EOF = True Then
            MsgBox "没有这个用户,请重新输入用户名和密码!", vbOKOnly + vbExclamation, "登录系统"
            txtusername.Text = ""
            txtpassword.Text = ""
            txtusername.SetFocus
        Else
            If Trim(MRC.Fields(2)) = Trim(txtpassword.Text) Then
               OK = True
'---------------------------------对用户的权限进行检查------------------------------------
               txtSQL1 = "select * from userLogin where username = '" & txtusername.Text & "'and (SystemName='SYSTEM' or SystemName='Student')"
               Set mrc1 = ExecuteSQL(txtSQL1, MsgText)
               Authority = Trim(MRC.Fields(3)) '获得用户的权限类别
               IsValid = Trim(MRC.Fields(4))
               If (IsValid = 0) Then
                   MsgBox "用户名[" & frmLogin.txtusername.Text & "]正在使用,请使用您的用户名!", vbOKOnly + vbCritical, "警告"
                   txtusername.Text = ""
                   txtpassword.Text = ""
               Else
                txtSQL = "update USERLOGIN set IsValid=0 where UserName='" & frmLogin.txtusername.Text & "'"
                Set MRC = Module1.ExecuteSQL(txtSQL, MsgText)
 
                If Authority = "A" Then
                sMeg = "您的权限为:可以对学籍管理系统各功能模块进行任何操作!"
                MsgBox sMeg, vbOKOnly + vbInformation, "登录成功"
                Me.Hide
                frmMain.Show
                End If
                If Authority = "B" Then
                sMeg = "您的权限为:仅可以添加学生以及所在系和班级的信息,并对这些信息进行查询!"
                MsgBox sMeg, vbOKOnly + vbInformation, "登录成功"
                Me.Hide
                frmMain.adm_teacher.Visible = False
                frmMain.mod_dept.Visible = False
                frmMain.mod_major.Visible = False
                frmMain.mod_stu.Visible = False
                frmMain.adm_user.Visible = False
                frmMain.Show
                End If
                If Authority = "C" Then
                sMeg = "您的权限为:仅可以添加教师信息以及所在系的信息,并对数据进行查询!"
                MsgBox sMeg, vbOKOnly + vbInformation, "登录成功"
                Me.Hide
                frmMain.adm_stu.Visible = False
                frmMain.mod_dept.Visible = False
                frmMain.mod_major.Visible = False
                frmMain.mod_teacher.Visible = False
                frmMain.adm_user.Visible = False
                frmMain.Show
                End If
                If Authority = "No Authority" Then
                sMeg = "您是新注册的用户,尚未设定操作权限,请通知系统管理员分配您的操作权限!"
                MsgBox sMeg, vbOKOnly + vbInformation, "登录成功"
                Call Module1.cnn_UPDATE
                txtusername.Text = ""
                txtpassword.Text = ""
                End If
               End If
'-----------------------------------------------------------------------------------------------
            ElseIf txtpassword.Text = "" Then MsgBox "请输入密码!", vbOKOnly + vbApplicationModal, "登录系统"
                   txtpassword.SetFocus
            Else
                MsgBox "输入密码不正确,请重新输入!", vbOKOnly + vbExclamation, "登录系统"
                txtpassword.Text = ""
                txtpassword.SetFocus
            End If
        End If
    End If
End Sub

Private Sub Command2_Click()
Dim i As String
i = MsgBox("是否要退出学籍管理系统!", 4 + 256 + 64, "学籍管理系统")
If i = vbYes Then
End
End If
End Sub

Private Sub Command3_Click()
addUser.Show
Unload Me
End Sub

Private Sub Form_Load()
txtusername.Text = ""
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -