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

📄 frmlogin.frm

📁 一个完整的仓库管理系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmLogin 
   BackColor       =   &H00C0E0FF&
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "登录"
   ClientHeight    =   1590
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   3750
   Icon            =   "frmLogin.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   1590
   ScaleWidth      =   3750
   StartUpPosition =   2  '屏幕中心
   Tag             =   "登录"
   Begin VB.Data Data2 
      BackColor       =   &H00C0E0FF&
      Caption         =   "Data2"
      Connect         =   ";pwd=prowind"
      DatabaseName    =   ""
      DefaultCursorType=   0  '缺省游标
      DefaultType     =   2  '使用 ODBC
      Exclusive       =   0   'False
      Height          =   285
      Left            =   3240
      Options         =   0
      ReadOnly        =   0   'False
      RecordsetType   =   1  'Dynaset
      RecordSource    =   ""
      Top             =   1320
      Visible         =   0   'False
      Width           =   1140
   End
   Begin VB.CommandButton cmdCancel 
      Appearance      =   0  'Flat
      BackColor       =   &H00C0FFFF&
      Cancel          =   -1  'True
      Caption         =   "取消"
      Height          =   360
      Left            =   2100
      Style           =   1  'Graphical
      TabIndex        =   5
      Tag             =   "取消"
      Top             =   1020
      Width           =   1140
   End
   Begin VB.CommandButton cmdOK 
      Appearance      =   0  'Flat
      BackColor       =   &H00C0FFFF&
      Caption         =   "确定"
      Default         =   -1  'True
      Height          =   360
      Left            =   495
      Style           =   1  'Graphical
      TabIndex        =   4
      Tag             =   "确定"
      Top             =   1020
      Width           =   1140
   End
   Begin VB.TextBox txtPassword 
      BackColor       =   &H00FFFFC0&
      ForeColor       =   &H000000FF&
      Height          =   270
      IMEMode         =   3  'DISABLE
      Left            =   1305
      PasswordChar    =   "*"
      TabIndex        =   1
      Top             =   525
      Width           =   2325
   End
   Begin VB.TextBox txtUserName 
      BackColor       =   &H00FFFFC0&
      ForeColor       =   &H000000FF&
      Height          =   270
      Left            =   1305
      TabIndex        =   3
      Top             =   135
      Width           =   2325
   End
   Begin VB.Label lblLabels 
      BackColor       =   &H00C0E0FF&
      BackStyle       =   0  'Transparent
      Caption         =   "密码(&P):"
      Height          =   248
      Index           =   1
      Left            =   105
      TabIndex        =   0
      Tag             =   "密码(&P):"
      Top             =   540
      Width           =   1080
   End
   Begin VB.Label lblLabels 
      BackColor       =   &H00C0E0FF&
      BackStyle       =   0  'Transparent
      Caption         =   "用户名(&U):"
      Height          =   248
      Index           =   0
      Left            =   105
      TabIndex        =   2
      Tag             =   "用户名(&U):"
      Top             =   150
      Width           =   1080
   End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpbuffer As String, nSize As Long) As Long

Public OK As Boolean

Private Sub Form_Load()
    Dim sBuffer As String
    Dim lSize As Long


    sBuffer = Space$(255)
    lSize = Len(sBuffer)
    Call GetUserName(sBuffer, lSize)
    If lSize > 0 Then
        txtUserName.Text = left$(sBuffer, lSize)
    Else
        txtUserName.Text = vbNullString
    End If
    '初始化数据连接
    Data2.DatabaseName = DataPath
    '数据源为user表单
    Data2.RecordSource = "用户管理"
    
End Sub



Private Sub cmdCancel_Click()
    OK = False
    Me.Hide
End Sub


Private Sub cmdOK_Click()
    'ToDo: 创建测试密码是否正确
     On Error Resume Next
    '检查正确密码
    Dim success As Boolean
    success = False
    
    Dim fit As String
    '查找用户名
    fit = "用户名='"
    fit = fit + txtUserName.Text + "'"
    Data2.Recordset.FindFirst fit
    '找不到该用户
    If Data2.Recordset.NoMatch Then
        success = False
        MsgBox "该用户不存在!", vbCritical
        Exit Sub
    Else
        '找到该用户,但密码错误
        On Error GoTo enter
        Dim OldPas As String
        OldPas = Data2.Recordset.Fields("用户密码").Value
        If OldPas = txtPassword.Text Then
enter:
            success = True
            '以下三个变量保存以备后用
            UserName = txtUserName.Text '用户名
            UserPas = txtPassword.Text '密码
            Purview = Data2.Recordset.Fields("用户权限").Value '权限
        Else
            success = False
        End If
    End If
    '如果登陆失败
    If success = False Then
        MsgBox "密码错误,再试一次!", vbExclamation, "登录"
        txtPassword.SetFocus
        txtPassword.SelStart = 0
        txtPassword.SelLength = Len(txtPassword.Text)
        Exit Sub
    Else
        OK = True
        Me.Hide
    End If
    
End Sub



'此源码由程序太平洋收集整理发布,任何人都可自由转载,但需保留本站信息
'╭⌒╮┅~ ¤ 欢迎光临程序太平洋╭⌒╮
'╭⌒╭⌒╮╭⌒╮~╭⌒╮  ︶  ,︶︶
',︶︶︶︶,''︶~~ ,''~︶︶  ,''
'╔ ╱◥███◣═╬╬╬╬╬╬╬╬╬╗
'╬ ︱田︱田 田 ︱          ╬
'╬       http://www.5ivb.net ╬
'╬  ╭○╮●                     ╬
'╬  /■\/■\                    ╬
'╬   <| ||    有希望,就有成功! ╬
'╬                 ╬
'╚╬╬╬╬╬╬╬╬╬╬╗  ╔╬╬╬╬╝
'
'说明:
'专业提供VB、.NET、Delphi、ASP、PB源码下载
'包括:程序源码,控件,商业源码,系统方案,开发工具,书籍教程,技术文档


⌨️ 快捷键说明

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