VERSION 5.00
Begin VB.Form frmChangePassword 
   ClientHeight    =   7995
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   8880
   LinkTopic       =   "Form3"
   MDIChild        =   -1  'True
   ScaleHeight     =   7995
   ScaleWidth      =   8880
   WindowState     =   2  'Maximized
   Begin VB.CommandButton Command2 
      Cancel          =   -1  'True
      Caption         =   "&Close"
      Height          =   315
      Left            =   7665
      TabIndex        =   10
      Top             =   5010
      Width           =   930
   End
   Begin VB.CommandButton Command1 
      Caption         =   "&Done"
      Default         =   -1  'True
      Height          =   315
      Left            =   6735
      TabIndex        =   9
      Top             =   5010
      Width           =   930
   End
   Begin VB.Frame Frame1 
      Caption         =   "Change Password"
      Height          =   1890
      Left            =   3315
      TabIndex        =   3
      Top             =   3052
      Width           =   5250
      Begin VB.TextBox txReNewPasswd 
         Height          =   315
         IMEMode         =   3  'DISABLE
         Left            =   2460
         MaxLength       =   45
         PasswordChar    =   "*"
         TabIndex        =   2
         Top             =   1410
         Width           =   2580
      End
      Begin VB.TextBox txNewPasswd 
         Height          =   315
         IMEMode         =   3  'DISABLE
         Left            =   2460
         MaxLength       =   45
         PasswordChar    =   "*"
         TabIndex        =   1
         Top             =   1080
         Width           =   2580
      End
      Begin VB.TextBox txOldPasswd 
         Height          =   315
         IMEMode         =   3  'DISABLE
         Left            =   2460
         MaxLength       =   45
         PasswordChar    =   "*"
         TabIndex        =   0
         Top             =   750
         Width           =   2580
      End
      Begin VB.Label lblLogin 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   300
         Left            =   2490
         TabIndex        =   11
         Top             =   390
         Width           =   2610
      End
      Begin VB.Label Label4 
         Caption         =   "Re-enter New Password"
         Height          =   225
         Left            =   540
         TabIndex        =   7
         Top             =   1470
         Width           =   1800
      End
      Begin VB.Label Label3 
         Caption         =   "New Password"
         Height          =   210
         Left            =   1200
         TabIndex        =   6
         Top             =   1140
         Width           =   1140
      End
      Begin VB.Label Label2 
         Caption         =   "Old Password"
         Height          =   210
         Left            =   1290
         TabIndex        =   5
         Top             =   810
         Width           =   990
      End
      Begin VB.Label Label1 
         Caption         =   "Login Name"
         Height          =   195
         Left            =   1395
         TabIndex        =   4
         Top             =   390
         Width           =   885
      End
   End
   Begin VB.Image Image1 
      Height          =   960
      Left            =   0
      Stretch         =   -1  'True
      Top             =   -15
      Width           =   12000
   End
   Begin VB.Label Label5 
      Caption         =   "Change Password"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   270
      Left            =   4770
      TabIndex        =   8
      Top             =   1605
      Width           =   1890
   End
End
Attribute VB_Name = "frmChangePassword"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Command1_Click()

If Trim(txOldPasswd.Text) = "" Then
 MsgBox "Please enter the Old Password.", vbInformation, "Insufficient Information"
 txOldPasswd.SetFocus
 Exit Sub
End If

If Trim(txNewPasswd.Text) = "" Then
 MsgBox "Please enter the new Password.", vbInformation, "Insufficient Information"
 txNewPasswd.SetFocus
 Exit Sub
End If

If Trim(txReNewPasswd.Text) = "" Then
 MsgBox "Please re-enter the New Password.", vbInformation, "Insufficient Information"
 txReNewPasswd.SetFocus
 Exit Sub
End If

If Trim(txNewPasswd.Text) <> Trim(txReNewPasswd.Text) Then
 MsgBox "New Password and Re-entered Password is not matching.", vbCritical, "Insufficient Information"
 txNewPasswd.Text = ""
 txReNewPasswd.Text = ""
 txNewPasswd.SetFocus
 Exit Sub
End If

fnCheckLogin
End Sub

Public Sub Command2_Click()
    Unload Me
End Sub

Private Function fnCheckLogin() As Boolean
 Dim stLogin As String
 Dim stPass As String
 Dim stQry As String
 Dim cnt As Integer
  
 Dim con As ADODB.Connection
 Dim con1 As ADODB.Connection
 Dim rec As New ADODB.Recordset
  
 Set con = modConn.getConnection
 
 fnCheckLogin = False
     
 stLogin = lblLogin.Caption
 stPass = txOldPasswd.Text
 
' rec.Open "select login_name, password, user_id from users", con, adOpenDynamic
 
  rec.Open "select * from users ", con, adOpenDynamic
  If Not rec.EOF Then rec.MoveFirst
 

 
  While Not rec.EOF
     If (stLogin = rec.Fields(1) And stPass = rec.Fields(2)) Then
      stQry = "update users set password ='" & txNewPasswd.Text & "' where user_id = " & rec.Fields(0)
      con.Execute stQry
      MsgBox "Password changed successfully!!!", vbExclamation, "Successful Change"
       fnCheckLogin = True
      Exit Function
     End If
     rec.MoveNext
 Wend
  rec.Close
 If fnCheckLogin = False Then
    MsgBox "Invalid Login Name/Password.", vbCritical, "Invalid Login"
    txOldPasswd.Text = ""
    txNewPasswd.Text = ""
    txReNewPasswd.Text = ""
    txOldPasswd.SetFocus
    fnCheckLogin = False
    Exit Function
 End If
 End Function

Private Sub Form_Activate()
    '--- for shifting between the forms
    Form_GotFocus

 lblLogin.Caption = stLogin
 txOldPasswd.SetFocus
End Sub

Private Sub Form_GotFocus()
    '---- Some menu to be disabled...
    Call fnMenu(False, False, True, False, False)
    
    '--- active form ..
    stActiveForm = "chgPass"
    
    '--- set caption
    fnMDICaption ("Estimation Module - Change Password")
End Sub

Private Sub Form_Load()

    '---set the logo image
    'Image1.Picture = LoadPicture(fnGetImg)
    
    '---- Some menu to be disabled 'n some enabled...
    '---- Some menu to be disabled...
    '--- set caption
    Form_GotFocus
End Sub

Private Sub Form_LostFocus()
    '--- set mdi menu title
    '--- Argument is "" since we r assigning the title at single place
    fnLostMDIChildFocus
End Sub

Private Sub Form_Unload(Cancel As Integer)
    '--- set the file->close menu disable...
    fnUnloadMenu
    
End Sub
