www.pudn.com > opy_LMS.rar > frmLogin.frm


VERSION 5.00 
Begin VB.Form frmLogin  
   BorderStyle     =   1  'Fixed Single 
   Caption         =   "登录" 
   ClientHeight    =   3495 
   ClientLeft      =   45 
   ClientTop       =   330 
   ClientWidth     =   3975 
   ControlBox      =   0   'False 
   LinkTopic       =   "Form1" 
   MaxButton       =   0   'False 
   MinButton       =   0   'False 
   ScaleHeight     =   3495 
   ScaleMode       =   0  'User 
   ScaleWidth      =   3975 
   StartUpPosition =   2  '屏幕中心 
   Begin VB.ComboBox cmb_as  
      Height          =   300 
      ItemData        =   "frmLogin.frx":0000 
      Left            =   1440 
      List            =   "frmLogin.frx":000A 
      TabIndex        =   0 
      ToolTipText     =   "用户权限" 
      Top             =   960 
      Width           =   2295 
   End 
   Begin VB.CommandButton cmdOK  
      Default         =   -1  'True 
      BeginProperty Font  
         Name            =   "MS Sans Serif" 
         Size            =   9.75 
         Charset         =   0 
         Weight          =   400 
         Underline       =   0   'False 
         Italic          =   0   'False 
         Strikethrough   =   0   'False 
      EndProperty 
      Height          =   615 
      Left            =   1680 
      MouseIcon       =   "frmLogin.frx":001E 
      MousePointer    =   99  'Custom 
      Picture         =   "frmLogin.frx":0170 
      Style           =   1  'Graphical 
      TabIndex        =   6 
      ToolTipText     =   "点击登入" 
      Top             =   2640 
      Width           =   1020 
   End 
   Begin VB.CommandButton cmdCancel  
      Cancel          =   -1  'True 
      BeginProperty Font  
         Name            =   "MS Sans Serif" 
         Size            =   9.75 
         Charset         =   0 
         Weight          =   400 
         Underline       =   0   'False 
         Italic          =   0   'False 
         Strikethrough   =   0   'False 
      EndProperty 
      Height          =   615 
      Left            =   2760 
      MouseIcon       =   "frmLogin.frx":06E2 
      MousePointer    =   99  'Custom 
      Picture         =   "frmLogin.frx":0834 
      Style           =   1  'Graphical 
      TabIndex        =   10 
      ToolTipText     =   "取消" 
      Top             =   2640 
      Width           =   1020 
   End 
   Begin VB.Frame Frame1  
      Height          =   1215 
      Left            =   120 
      TabIndex        =   8 
      Top             =   1320 
      Width           =   3735 
      Begin VB.TextBox txt_uname  
         BeginProperty Font  
            Name            =   "MS Sans Serif" 
            Size            =   9.75 
            Charset         =   0 
            Weight          =   700 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H00400000& 
         Height          =   345 
         Left            =   1320 
         MaxLength       =   20 
         TabIndex        =   2 
         ToolTipText     =   "操作员帐号" 
         Top             =   240 
         Width           =   2325 
      End 
      Begin VB.TextBox txt_pass  
         BeginProperty Font  
            Name            =   "MS Sans Serif" 
            Size            =   9.75 
            Charset         =   0 
            Weight          =   700 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H00400000& 
         Height          =   345 
         IMEMode         =   3  'DISABLE 
         Left            =   1320 
         MaxLength       =   20 
         PasswordChar    =   "*" 
         TabIndex        =   3 
         ToolTipText     =   "密码" 
         Top             =   720 
         Width           =   2325 
      End 
      Begin VB.Label lblLabels  
         BackStyle       =   0  'Transparent 
         Caption         =   "帐 号:" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   9.75 
            Charset         =   0 
            Weight          =   700 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H00800000& 
         Height          =   270 
         Index           =   0 
         Left            =   120 
         TabIndex        =   9 
         Top             =   240 
         Width           =   1080 
      End 
      Begin VB.Label lblLabels  
         BackStyle       =   0  'Transparent 
         Caption         =   "密 码:" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   9.75 
            Charset         =   0 
            Weight          =   700 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H00800000& 
         Height          =   270 
         Index           =   1 
         Left            =   120 
         TabIndex        =   11 
         Top             =   720 
         Width           =   1080 
      End 
   End 
   Begin VB.Label Label1  
      BackStyle       =   0  'Transparent 
      Caption         =   "登录权限" 
      BeginProperty Font  
         Name            =   "宋体" 
         Size            =   9.75 
         Charset         =   0 
         Weight          =   700 
         Underline       =   0   'False 
         Italic          =   0   'False 
         Strikethrough   =   0   'False 
      EndProperty 
      ForeColor       =   &H00800000& 
      Height          =   255 
      Left            =   240 
      TabIndex        =   1 
      Top             =   960 
      Width           =   975 
   End 
   Begin VB.Label Label2  
      Alignment       =   2  'Center 
      BackStyle       =   0  'Transparent 
      Caption         =   "取消" 
      Height          =   255 
      Left            =   2760 
      TabIndex        =   4 
      Top             =   3285 
      Width           =   975 
   End 
   Begin VB.Label Label3  
      Alignment       =   2  'Center 
      BackStyle       =   0  'Transparent 
      Caption         =   "确定" 
      Height          =   255 
      Left            =   1680 
      TabIndex        =   5 
      Top             =   3285 
      Width           =   975 
   End 
   Begin VB.Image Image1  
      Height          =   720 
      Left            =   120 
      Picture         =   "frmLogin.frx":0DB4 
      Top             =   0 
      Width           =   720 
   End 
   Begin VB.Label Label4  
      BackStyle       =   0  'Transparent 
      Caption         =   "登录图书馆管理系统的详细选项,不同权限的用户具备不同的管理功能" 
      BeginProperty Font  
         Name            =   "宋体" 
         Size            =   10.5 
         Charset         =   134 
         Weight          =   400 
         Underline       =   0   'False 
         Italic          =   0   'False 
         Strikethrough   =   0   'False 
      EndProperty 
      Height          =   735 
      Left            =   960 
      TabIndex        =   7 
      Top             =   120 
      Width           =   2655 
   End 
   Begin VB.Line Line1  
      X1              =   120 
      X2              =   3840 
      Y1              =   840 
      Y2              =   840 
   End 
End 
Attribute VB_Name = "frmLogin" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
Dim str As String 
Dim Loginrecord As ADODB.Recordset 
Dim Loginconnection As ADODB.Connection 
 
Private Sub cmb_as_Click() 
If (cmb_as.Text = "管理员") Then 
txt_uname.Enabled = False 
Else 
txt_uname.Enabled = True 
End If 
txt_uname.Text = "" 
End Sub 
 
Private Sub cmdCancel_Click() 
Unload MDIMain 
End Sub 
Private Sub cmdOK_Click() 
If cmb_as.Text = "管理员" Then 
            If (txt_pass.Text = "") Then 
            MsgBox "请输入密码", vbInformation, "密码错误" 
            txt_pass.SetFocus 
            Exit Sub 
            End If 
  str = "Select Pass from Custom" 
 ' Set Loginrecord = exesql(str) 
  Loginrecord.Open str, Loginconnection, adOpenStatic, adLockOptimistic 
              If (txt_pass.Text = Trim(Loginrecord(0))) Then 
               Loginrecord.Close 
               uname = "管理员" 
               MDIMain.Enabled = True 
               'MDIMain.Show 
               Me.Hide 
               DoEvents 
               If (Welcome = True) Then 
               Load frmWelcome 
               frmWelcome.Show 
               End If 
               MDIMain.mnu_administer.Enabled = True 
             Else 
              Loginrecord.Close 
              MsgBox "密码错误.", vbInformation, "拒绝访问" 
              txt_pass.Text = "" 
              Exit Sub 
             End If 
ElseIf cmb_as.Text = "操作员" Then 
            If (txt_uname.Text = "") Then 
               MsgBox "请输入用户名.", vbInformation, "用户名错误" 
            ElseIf (txt_pass.Text = "") Then 
               MsgBox "请输入密码.", vbInformation, "密码错误" 
            Else 
              str = "Select count(*) from Emptab where Empid = '" & Trim(txt_uname.Text) & "' and Psword = '" & Trim(txt_pass.Text) & "'" 
              Loginrecord.Open str, Loginconnection, adOpenStatic, adLockOptimistic 
              ' Set Loginrecord = exesql(str) 
                     If (Loginrecord(0) = 0) Then 
                       MsgBox "用户名或密码不正确.", vbInformation, "拒绝访问" 
                       txt_uname.Text = "" 
                       txt_pass.Text = "" 
                       txt_uname.SetFocus 
                       Loginrecord.Close 
                      Exit Sub 
                    Else 
                Loginrecord.Close 
                str = "Select Ename from Emptab where Empid = '" & Trim(txt_uname.Text) & "' and Psword = '" & Trim(txt_pass.Text) & "'" 
                Loginrecord.Open str, Loginconnection, adOpenStatic, adLockOptimistic 
                 ' Set Loginrecord = exesql(str) 
                       
                       uname = Loginrecord(0) 
                       MDIMain.Enabled = True 
'                       mdimain.Show 
                       Me.Hide 
                       DoEvents 
                      
                      
                       If (Welcome = True) Then 
                       Load frmWelcome 
                       frmWelcome.Show 
                       End If 
                       Loginrecord.Close 
                       MDIMain.mnu_administer.Enabled = False 
                    End If 
            End If 
Else 
MsgBox "没有选择用户类别.", vbCritical, "错误信息" 
End If 
MDIMain.sbStatusBar.Panels(3).Text = uname 
End Sub 
Private Sub Form_Activate() 
 cmb_as.SetFocus 
 MDIMain.Enabled = False 
End Sub 
 
Private Sub Form_Load() 
  On Error GoTo errlable 
  Set Loginconnection = New ADODB.Connection 
  Loginconnection.ConnectionString = "DSN=library;UID=sa;PWD=;" 
   
  Loginconnection.Open 
  str = "Select count(*) from Emptab" 
  Set Loginrecord = New ADODB.Recordset 
  Loginrecord.Open str, Loginconnection, adOpenStatic, adLockOptimistic 
 If (Loginrecord(0) = 0) Then 
 cmb_as.Text = "管理员" 
 cmb_as.Locked = True 
 txt_uname.Enabled = False 
 End If 
Loginrecord.Close 
Exit Sub 
 
errlable: 
MsgBox Err.Number & Err.Description 
End Sub