VERSION 5.00
Begin VB.Form frm_password_number 
   Caption         =   "Inicio de Sesión"
   ClientHeight    =   6420
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   4980
   ClipControls    =   0   'False
   ControlBox      =   0   'False
   Icon            =   "frm_password_number.frx":0000
   LinkTopic       =   "Form2"
   ScaleHeight     =   6420
   ScaleWidth      =   4980
   StartUpPosition =   1  'CenterOwner
   Begin VB.Frame FRM3 
      Caption         =   "Ingrese su Contraseña"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   6135
      Left            =   120
      TabIndex        =   4
      Top             =   120
      Width           =   4695
      Begin VB.CommandButton cmdsalir 
         Caption         =   "&Salir"
         BeginProperty Font 
            Name            =   "Arial Black"
            Size            =   12
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   975
         Left            =   3000
         Picture         =   "frm_password_number.frx":030A
         Style           =   1  'Graphical
         TabIndex        =   3
         Top             =   4920
         Width           =   1215
      End
      Begin VB.CommandButton cmdsupr 
         Caption         =   "&Supr"
         BeginProperty Font 
            Name            =   "Arial Black"
            Size            =   12
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   975
         Left            =   3000
         TabIndex        =   2
         Top             =   3795
         Width           =   1215
      End
      Begin VB.CommandButton cmdNumeros 
         Caption         =   "0"
         BeginProperty Font 
            Name            =   "Arial Black"
            Size            =   20.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   975
         Index           =   9
         Left            =   360
         TabIndex        =   5
         Top             =   3795
         Width           =   2535
      End
      Begin VB.CommandButton cmdaceptar 
         Caption         =   "&Aceptar"
         BeginProperty Font 
            Name            =   "Arial Black"
            Size            =   12
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   975
         Left            =   360
         Picture         =   "frm_password_number.frx":134C
         Style           =   1  'Graphical
         TabIndex        =   1
         Top             =   4920
         Width           =   2535
      End
      Begin VB.TextBox txtpassword 
         BackColor       =   &H00000000&
         BeginProperty Font 
            Name            =   "Courier New"
            Size            =   15.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H0000FF00&
         Height          =   495
         IMEMode         =   3  'DISABLE
         Left            =   360
         MaxLength       =   15
         PasswordChar    =   "*"
         TabIndex        =   0
         Top             =   240
         Width           =   3855
      End
      Begin VB.CommandButton cmdNumeros 
         Caption         =   "9"
         BeginProperty Font 
            Name            =   "Arial Black"
            Size            =   20.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   975
         Index           =   8
         Left            =   3000
         TabIndex        =   14
         Top             =   795
         Width           =   1215
      End
      Begin VB.CommandButton cmdNumeros 
         Caption         =   "8"
         BeginProperty Font 
            Name            =   "Arial Black"
            Size            =   20.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   975
         Index           =   7
         Left            =   1680
         TabIndex        =   13
         Top             =   795
         Width           =   1215
      End
      Begin VB.CommandButton cmdNumeros 
         Caption         =   "7"
         BeginProperty Font 
            Name            =   "Arial Black"
            Size            =   20.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   975
         Index           =   6
         Left            =   360
         TabIndex        =   12
         Top             =   795
         Width           =   1215
      End
      Begin VB.CommandButton cmdNumeros 
         Caption         =   "6"
         BeginProperty Font 
            Name            =   "Arial Black"
            Size            =   20.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   975
         Index           =   5
         Left            =   3000
         TabIndex        =   11
         Top             =   1800
         Width           =   1215
      End
      Begin VB.CommandButton cmdNumeros 
         Caption         =   "5"
         BeginProperty Font 
            Name            =   "Arial Black"
            Size            =   20.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   975
         Index           =   4
         Left            =   1680
         TabIndex        =   10
         Top             =   1800
         Width           =   1215
      End
      Begin VB.CommandButton cmdNumeros 
         Caption         =   "4"
         BeginProperty Font 
            Name            =   "Arial Black"
            Size            =   20.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   975
         Index           =   3
         Left            =   360
         TabIndex        =   9
         Top             =   1800
         Width           =   1215
      End
      Begin VB.CommandButton cmdNumeros 
         Caption         =   "3"
         BeginProperty Font 
            Name            =   "Arial Black"
            Size            =   20.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   975
         Index           =   2
         Left            =   3000
         TabIndex        =   8
         Top             =   2805
         Width           =   1215
      End
      Begin VB.CommandButton cmdNumeros 
         Caption         =   "2"
         BeginProperty Font 
            Name            =   "Arial Black"
            Size            =   20.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   975
         Index           =   1
         Left            =   1680
         TabIndex        =   7
         Top             =   2805
         Width           =   1215
      End
      Begin VB.CommandButton cmdNumeros 
         Caption         =   "1"
         BeginProperty Font 
            Name            =   "Arial Black"
            Size            =   20.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   975
         Index           =   0
         Left            =   360
         TabIndex        =   6
         Top             =   2805
         Width           =   1215
      End
   End
End
Attribute VB_Name = "frm_password_number"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim bOkFlag As Boolean 'Flag Usuario Ok (1) sino (0)
Dim iOportunidades As Integer 'Número de oportunidades

Const kMAX_OPORTUNIDADES = 3 'Cantidad máxima de oportunidades

Private Sub cmdaceptar_Click()
If ValidarUsuario Then
            
   bOkFlag = True
  
End If
      
If bOkFlag Or (Not bOkFlag And iOportunidades = kMAX_OPORTUNIDADES) Then Unload Me
        
End Sub
Private Sub cmdNumeros_Click(Index As Integer)
txtpassword.Text = Trim(txtpassword.Text) + Trim(cmdNumeros(Index).Caption)
End Sub

Private Sub cmdsalir_Click()
Unload Me
End Sub

Private Sub cmdsupr_Click()
txtpassword.Text = ""
End Sub

Private Function ValidarUsuario()

  'Valida que el usuario ingresado exista y q este activo
  
  On Error GoTo LineaError

  Dim ssql As String
  Dim ADORS As ADODB.Recordset
  Dim psw  As String
  ValidarUsuario = False
  
  psw = ReemplazarComilla(Trim(txtpassword.Text))
  If Len(psw) = txtpassword.MaxLength And Len(psw) > 0 Then
     psw = Mid(psw, 2, Len(psw) - 2)
  End If
  
  ssql = "SELECT * FROM Usuario WHERE cUserActi =1 AND TRIM(sUserPass) = '$'"
  ssql = VBsprintf(ssql, psw)
      
  If oDBAdmin.EjecutarConsulta(ADOCnn, ssql, ADORS) Then
      
    iOportunidades = iOportunidades + 1
      
    If Not ADORS.EOF Then
    
           
      If Not Trim(txtpassword.Text) = Trim(LeerCampo(ADORS!suserPass)) Then
          
        MsgBox "Password no válido", vbOKOnly + vbInformation
        txtpassword.SetFocus
        Exit Function
      
      End If
          
      piPerfil_Codigo = LeerCampo(ADORS!cPerfCode)
      psUsuario_Descripcion = LeerCampo(ADORS!sUserDesc)
      psUsuario_Password = psw
                  
      ValidarUsuario = True
        
    Else
      
      MsgBox "Usuario no válido", vbOKOnly + vbInformation
      
    End If
    
  End If
        
  Set ADORS = Nothing
  
  Exit Function
  
LineaError:
  MsgBox Err.Description, vbOKOnly + vbInformation

End Function

Private Sub Form_Load()
'Carga el Formulario
  
  On Error GoTo LineaError
  
  Screen.MousePointer = vbHourglass
    
  
  InicializarVariables
  
  Screen.MousePointer = vbDefault
  
  Exit Sub
  
LineaError:
  MsgBox Err.Description, vbOKOnly + vbInformation
  Screen.MousePointer = vbDefault

End Sub

Private Sub Form_Unload(Cancel As Integer)

  'Cierra la conexión y la aplicación o invoca al formulario principal
  
  On Error GoTo LineaError

  If Not bOkFlag Then
    Call oDBAdmin.CerrarBD(ADOCnn)
    End
  Else
      
    'SINCRONIZA
    Sincronizar
    frmPrincipal.Show
  End If
    
  Exit Sub
  
LineaError:
  MsgBox Err.Description, vbOKOnly + vbInformation

End Sub

Private Sub InicializarVariables()

  'Inicializa variables
  
  On Error GoTo LineaError
  
  bOkFlag = False
  iOportunidades = 0
  
  Exit Sub
  
LineaError:
  MsgBox Err.Description, vbOKOnly + vbInformation

End Sub

