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

📄 frmlogin.frm

📁 学生管理系统,毕业设计+论文 vb+sql数据库
💻 FRM
字号:
VERSION 5.00
Begin VB.Form DlgLogin 
   BackColor       =   &H00FFC0C0&
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "登陆"
   ClientHeight    =   2745
   ClientLeft      =   3630
   ClientTop       =   2355
   ClientWidth     =   4575
   ForeColor       =   &H0080FFFF&
   Icon            =   "frmLogin.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   1621.836
   ScaleMode       =   0  'User
   ScaleWidth      =   4295.677
   StartUpPosition =   2  '屏幕中心
   WhatsThisHelp   =   -1  'True
   Begin VB.Timer Timer1 
      Enabled         =   0   'False
      Left            =   0
      Top             =   2160
   End
   Begin VB.CommandButton cmdCancel 
      BackColor       =   &H0080C0FF&
      Caption         =   "退出"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   300
      Left            =   2640
      Style           =   1  'Graphical
      TabIndex        =   5
      Top             =   2040
      Width           =   1095
   End
   Begin VB.CommandButton cmdOK 
      BackColor       =   &H0080C0FF&
      Caption         =   "登陆"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   300
      Left            =   960
      Style           =   1  'Graphical
      TabIndex        =   4
      Top             =   2040
      Width           =   1095
   End
   Begin VB.TextBox txtUserName 
      BackColor       =   &H00C0E0FF&
      Height          =   288
      Left            =   1560
      TabIndex        =   0
      Top             =   840
      Width           =   1845
   End
   Begin VB.TextBox txtPassword 
      BackColor       =   &H00C0E0FF&
      Height          =   288
      IMEMode         =   3  'DISABLE
      Left            =   1560
      PasswordChar    =   "*"
      TabIndex        =   1
      Top             =   1320
      Width           =   1845
   End
   Begin VB.Image Image1 
      Height          =   480
      Left            =   3600
      Picture         =   "frmLogin.frx":0CCA
      Top             =   360
      Width           =   480
   End
   Begin VB.Label Label2 
      BackStyle       =   0  'Transparent
      Caption         =   "00"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   255
      Left            =   3720
      TabIndex        =   7
      Top             =   1080
      Width           =   255
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "欢迎登陆"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   300
      Left            =   1560
      TabIndex        =   6
      Top             =   120
      Width           =   1260
   End
   Begin VB.Line Line5 
      X1              =   4056.246
      X2              =   4056.246
      Y1              =   354.5
      Y2              =   1063.499
   End
   Begin VB.Line Line4 
      X1              =   3605.552
      X2              =   4056.246
      Y1              =   354.5
      Y2              =   354.5
   End
   Begin VB.Line Line3 
      X1              =   112.673
      X2              =   4056.246
      Y1              =   1063.499
      Y2              =   1063.499
   End
   Begin VB.Line Line2 
      X1              =   112.673
      X2              =   112.673
      Y1              =   354.5
      Y2              =   1063.499
   End
   Begin VB.Line Line1 
      BorderColor     =   &H00000000&
      X1              =   112.673
      X2              =   3718.225
      Y1              =   354.5
      Y2              =   354.5
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "密  码:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   180
      Index           =   3
      Left            =   360
      TabIndex        =   3
      Top             =   1320
      Width           =   795
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "用户名:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   180
      Index           =   2
      Left            =   360
      TabIndex        =   2
      Top             =   960
      Width           =   795
   End
End
Attribute VB_Name = "DlgLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim hours As Integer
Dim Minutes As Integer
Dim Seconds As Integer
Dim Time As Date
Public LoginSucceeded As Boolean

Private Sub cmdCancel_Click()
    LoginSucceeded = False
    Unload Me
End Sub

Private Sub cmdOK_Click()
On Error GoTo errh:
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    Set rs = cn.Execute("SELECT UserName , Password  FROM 超级用户 ")
    If rs.EOF Then
        rs.Close
        Set rs = Nothing
        Unload Me
        Load FrmMain
        Exit Sub
    End If
    rs.MoveFirst
    Dim i As Integer
    '校验是否为超级用户
    Do
        If rs.Fields("UserName") = txtUserName.Text Then
            If rs.Fields("Password") = txtPassword.Text Then
                UserType = True
                LoginSucceeded = True
                rs.Close
                If txtPassword.Text = "Admin" Then IsAdmin = True
                Unload Me
                Load FrmMain
                Exit Sub
                Exit Do
            End If
        End If
        rs.MoveNext
    Loop Until rs.EOF
    '校验是否为普通用户
    Set rs = cn.Execute("SELECT 学号 FROM 学生 WHERE 学号 =" & "'" & txtPassword.Text & "'")
    If rs.EOF Then
        MsgBox "无效密码或用户名请重试!", , "Login"
        txtPassword.SetFocus
        SendKeys "{Home}+{End}"
    Else
        rs.Close
        UserType = False
        LoginSucceeded = True
        Unload Me
        Load FrmMain
    End If
    Exit Sub
errh:
    MsgBox Err.Description
End Sub

Private Sub Form_Load()
    Timer1.Enabled = True
    Timer1.Interval = 1000
    hours = 0
    Minutes = 0
    Seconds = 10
     Time = TimeSerial(hours, Minutes, Seconds)
    Label2.Caption = Format$(Time, "ss")
    Dim s As String
    MakeCenter DlgLogin
    s = MakeConnection() '创建全局ADO连接
    If s <> "OK" Then
        MsgBox s, , "错误!"
        Unload Me
        LoginSucceeded = False
    End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
    If Not LoginSucceeded Then '如果登陆失败
        cn.Close '释放连接
        Set cn = Nothing
    End If
End Sub
Private Sub Timer1_Timer()
    If (Format$(Time, "ss")) <> "00" Then
        Time = DateAdd("s", -1, Time)
        Label2.Visible = False
        Label2.Caption = Format$(Time, "ss")
        Label2.Visible = True
        Timer1.Enabled = True
    Else
        Timer1.Enabled = False
        Beep
        Beep
        Unload Me
    End If
End Sub

⌨️ 快捷键说明

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