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

📄 form1.frm

📁 <Visual Basic 数据库开发实例精粹(第二版)>一书首先介绍了Visual Basic(简称VB)开发的技巧和重点技术
💻 FRM
字号:
VERSION 5.00
Begin VB.Form FMLogin 
   BackColor       =   &H00C0C0C0&
   Caption         =   "登录"
   ClientHeight    =   3705
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5250
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   ScaleHeight     =   3705
   ScaleWidth      =   5250
   StartUpPosition =   3  '窗口缺省
   Begin VB.Frame Frame1 
      Height          =   3690
      Left            =   0
      TabIndex        =   0
      Top             =   -45
      Width           =   5265
      Begin VB.PictureBox picBG 
         Appearance      =   0  'Flat
         BackColor       =   &H80000001&
         BorderStyle     =   0  'None
         ForeColor       =   &H80000008&
         Height          =   1275
         Left            =   30
         ScaleHeight     =   1275
         ScaleWidth      =   5205
         TabIndex        =   5
         TabStop         =   0   'False
         Top             =   120
         Width           =   5205
         Begin VB.Label lblLogin 
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "特瑞飞车辆收费管理系统 演示版"
            BeginProperty Font 
               Name            =   "宋体"
               Size            =   14.25
               Charset         =   134
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00000000&
            Height          =   285
            Index           =   0
            Left            =   645
            TabIndex        =   9
            Top             =   555
            Width           =   4365
         End
         Begin VB.Label lblLogin 
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "特瑞飞车辆收费管理系统 演示版"
            BeginProperty Font 
               Name            =   "宋体"
               Size            =   14.25
               Charset         =   134
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   285
            Index           =   3
            Left            =   600
            TabIndex        =   8
            Top             =   510
            Width           =   4365
         End
         Begin VB.Label lblLogin 
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "版权所有 (C) 2007-2008 特瑞飞软件"
            Height          =   180
            Index           =   2
            Left            =   2085
            TabIndex        =   7
            Top             =   1035
            Width           =   2970
         End
         Begin VB.Label lblLogin 
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "欢迎使用"
            BeginProperty Font 
               Name            =   "宋体"
               Size            =   10.5
               Charset         =   134
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   210
            Index           =   1
            Left            =   180
            TabIndex        =   6
            Top             =   165
            Width           =   900
         End
      End
      Begin VB.CommandButton cmdCancel 
         Cancel          =   -1  'True
         Caption         =   "退出(&E)"
         Height          =   360
         Left            =   2445
         TabIndex        =   4
         Top             =   2850
         Width           =   1050
      End
      Begin VB.CommandButton cmdOK 
         Caption         =   "登录(&O)"
         Default         =   -1  'True
         Height          =   360
         Left            =   1200
         TabIndex        =   3
         Top             =   2850
         Width           =   1050
      End
      Begin VB.TextBox TextPwd 
         Height          =   300
         IMEMode         =   3  'DISABLE
         Left            =   1545
         MaxLength       =   50
         PasswordChar    =   "*"
         TabIndex        =   2
         Text            =   "Admin"
         Top             =   2220
         Width           =   2175
      End
      Begin VB.TextBox TextUser 
         Height          =   300
         Left            =   1545
         MaxLength       =   50
         TabIndex        =   1
         Text            =   "Admin"
         Top             =   1755
         Width           =   2175
      End
      Begin VB.Label lblLogin 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "注:默认登录用户:密码 是 Admin:Admin"
         ForeColor       =   &H00C00000&
         Height          =   180
         Index           =   6
         Left            =   960
         TabIndex        =   12
         Top             =   3435
         Width           =   3240
      End
      Begin VB.Image Image1 
         Height          =   1305
         Left            =   3855
         Picture         =   "Form1.frx":0000
         Stretch         =   -1  'True
         Top             =   1665
         Width           =   1050
      End
      Begin VB.Label lblLogin 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "登录密码"
         Height          =   180
         Index           =   5
         Left            =   720
         TabIndex        =   11
         Top             =   2280
         Width           =   720
      End
      Begin VB.Label lblLogin 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "用户名"
         Height          =   180
         Index           =   4
         Left            =   900
         TabIndex        =   10
         Top             =   1830
         Width           =   540
      End
   End
End
Attribute VB_Name = "FMLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Public iCount As Integer

Private Sub CmdCancel_Click()
  g_DBConn.Close
  Unload Me
End Sub

Private Sub CmdOK_Click()
  Dim Check As New Recordset
  Dim DBStr As String
  Dim UsrID As String
  Dim UsrPwd As String

  iCount = iCount + 1
    
  If Len(Trim(Me.TextUserName.Text)) <= 0 Then
    MsgBox "请输入用户名!"

    If iCount >= 3 Then
      MsgBox "您输入的错误次数过多,请核实后重新进入本系统!"
      g_DBConn.Close
      Unload Me
      Exit Sub
    End If

    Exit Sub
  End If
    
  UsrID = Trim(Me.TextUserName.Text)
    
  If Len(Trim(Me.TextUserPwd.Text)) <= 0 Then
    MsgBox "请输入密码!"

    If iCount >= 3 Then
      MsgBox "您输入的错误次数过多,请核实后重新进入本系统!"
      g_DBConn.Close
      Unload Me
      Exit Sub
    End If

    Exit Sub
  End If
    
  UsrPwd = Trim(Me.TextUserPwd.Text)
    
  DBStr = "select * from UserInfo where UserID='" & Replace(UsrID, "'", "''") & "'"
    
  Check.Open DBStr, g_DBConn, adOpenStatic, adLockReadOnly, -1
    
  If Check.RecordCount <= 0 Then
    MsgBox "找不到该用户,请重新输入!"
    Check.Close
  Else
    Check.MoveFirst

    If UsrPwd = Check.Fields("UserPwd").Value Then
      g_LoginedUser.ID = UsrID
      g_LoginedUser.Type = Check.Fields("UserType").Value
      FMMain.Show
    Else
      MsgBox "密码错误!"
      Check.Close

      If iCount >= 3 Then
        MsgBox "您输入的错误次数过多,请核实后重新进入本系统!"
        g_DBConn.Close
        Unload Me
        Exit Sub
      End If

      Exit Sub
    End If

    Check.Close
  End If
    
  Unload Me
    
End Sub

Private Sub Form_Load()
  Dim SqlStr As String

  Me.Top = (Screen.Height - Me.Height) / 2    '垂直方向居中
  Me.Left = (Screen.Width - Me.Height) / 2    '水平方向居中
    
  If App.PrevInstance Then
    MsgBox "系统已经启动!"
    Exit Sub
  End If
   
  iCount = 0
    
  SqlStr = "Provider=SQLOLEDB.1;Persist Security Info=False;" & "User ID=sa;Initial Catalog=KTVDB;Data Source=(local)"
    
  g_DBConn.Open SqlStr
    
End Sub

⌨️ 快捷键说明

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