VERSION 5.00
Begin VB.Form frmCambiarPassword 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Cambiar Password"
   ClientHeight    =   2160
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   5535
   Icon            =   "frmCambiarPassword.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2160
   ScaleWidth      =   5535
   StartUpPosition =   2  'CenterScreen
   Begin VB.CommandButton cmdEstandar 
      Cancel          =   -1  'True
      Caption         =   "&Cancelar"
      Height          =   375
      Index           =   1
      Left            =   3960
      TabIndex        =   8
      Top             =   1680
      Width           =   1335
   End
   Begin VB.CommandButton cmdEstandar 
      Caption         =   "&Aceptar"
      Default         =   -1  'True
      Height          =   375
      Index           =   0
      Left            =   2520
      TabIndex        =   6
      Top             =   1680
      Width           =   1335
   End
   Begin VB.Frame fraContEVinculada 
      Height          =   1575
      Left            =   120
      TabIndex        =   7
      Top             =   0
      Width           =   5295
      Begin VB.TextBox txtPasswordActual 
         Height          =   315
         IMEMode         =   3  'DISABLE
         Left            =   2040
         MaxLength       =   15
         PasswordChar    =   "*"
         TabIndex        =   1
         Top             =   240
         Width           =   3015
      End
      Begin VB.TextBox txtPassword 
         Height          =   315
         IMEMode         =   3  'DISABLE
         Left            =   2040
         MaxLength       =   15
         PasswordChar    =   "*"
         TabIndex        =   3
         Top             =   600
         Width           =   3015
      End
      Begin VB.TextBox txtReingresarPassword 
         Height          =   315
         IMEMode         =   3  'DISABLE
         Left            =   2040
         MaxLength       =   15
         PasswordChar    =   "*"
         TabIndex        =   5
         Top             =   960
         Width           =   3015
      End
      Begin VB.Label lblLabels 
         Caption         =   "Nuevo Password"
         Height          =   375
         Index           =   1
         Left            =   240
         TabIndex        =   2
         Top             =   720
         Width           =   1455
      End
      Begin VB.Label lblLabels 
         Caption         =   "Password Actual"
         Height          =   375
         Index           =   0
         Left            =   240
         TabIndex        =   0
         Top             =   360
         Width           =   1455
      End
      Begin VB.Label lblLabels 
         Caption         =   "Reingresar Password"
         Height          =   375
         Index           =   2
         Left            =   240
         TabIndex        =   4
         Top             =   1080
         Width           =   1695
      End
   End
End
Attribute VB_Name = "frmCambiarPassword"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub cmdEstandar_Click(Index As Integer)

  On Error GoTo LineaError

  Select Case Index
  
  Case kCMD_ACEPTAR
  
    'Valida la información ingresada
    If Not ValidarData Then Exit Sub
    
    If MsgBox("Se procederá a cambiar su password. Confirma acción?", vbQuestion + vbYesNo + vbDefaultButton2) = vbNo Then Exit Sub
    
    'Actualiza el password
    If Not ActualizarPassword Then Exit Sub
    
    Unload Me
  
  Case kCMD_CANCELAR
  
  End Select
  
  Unload Me
  
Exit Sub
  
LineaError:
  MsgBox Err.Description, vbOKOnly + vbInformation
  
End Sub

Private Function ValidarData() As Boolean

  'Valida que la información ingresada sea correcta y completa
  
  On Error GoTo LineaError
  
  ValidarData = False
  
  If Trim(txtPasswordActual.Text) <> psUsuario_Password Then
    MsgBox "Password Actual incorrecto", vbOKOnly + vbInformation
    txtPasswordActual.SetFocus
    Exit Function
  End If
  
  If Trim(txtPassword.Text) <> "" And Trim(txtReingresarPassword.Text) = "" Then
    MsgBox "Reingresar Password de Usuario", vbOKOnly + vbInformation
    txtReingresarPassword.SetFocus
    Exit Function
  End If
  
  If Trim(txtPassword.Text) <> Trim(txtReingresarPassword.Text) Then
    MsgBox "Password reingresado incorrecto", vbOKOnly + vbInformation
    txtReingresarPassword.SetFocus
    Exit Function
  End If
  
  ValidarData = True
  
  Exit Function
  
LineaError:
  MsgBox Err.Description, vbOKOnly + vbInformation
  
End Function

Private Function ActualizarPassword() As Boolean

  'Actualiza el campo password de la tabla Usuario

  On Error GoTo LineaError

  Dim sSQL As String
    
  ActualizarPassword = False
  
  sSQL = "UPDATE Usuario SET sUserPass = '$' " + _
         "WHERE TRIM(sUserDesc) = TRIM('$')"
  sSQL = VBsprintf(sSQL, ReemplazarComilla(Trim(txtPassword.Text)), ReemplazarComilla(psUsuario_Descripcion))
  
  If Not oDBAdmin.EjecutarSentencia(ADOCnn, sSQL) Then Exit Function
  
  psUsuario_Password = Trim(txtPassword.Text)
  
  ActualizarPassword = True
  
  Exit Function
  
LineaError:
  MsgBox Err.Description, vbOKOnly + vbInformation

End Function

