VERSION 5.00
Begin VB.Form Change_Password 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Change password"
   ClientHeight    =   1890
   ClientLeft      =   2790
   ClientTop       =   3390
   ClientWidth     =   4065
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   1890
   ScaleWidth      =   4065
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton spp_save 
      Default         =   -1  'True
      Height          =   612
      Left            =   2460
      Style           =   1  'Graphical
      TabIndex        =   4
      Top             =   1140
      Width           =   612
   End
   Begin VB.CommandButton ssp_quit 
      Height          =   612
      Left            =   3180
      Style           =   1  'Graphical
      TabIndex        =   5
      Top             =   1140
      Width           =   612
   End
   Begin VB.TextBox txt_Password2 
      Height          =   288
      IMEMode         =   3  'DISABLE
      Left            =   2040
      PasswordChar    =   "*"
      TabIndex        =   3
      Top             =   660
      Width           =   1812
   End
   Begin VB.TextBox txt_Password 
      Height          =   288
      IMEMode         =   3  'DISABLE
      Left            =   2040
      PasswordChar    =   "*"
      TabIndex        =   2
      Top             =   300
      Width           =   1812
   End
   Begin VB.Label lbl_Password2 
      Caption         =   "ReEnter new password"
      Height          =   192
      Left            =   240
      TabIndex        =   1
      Top             =   720
      Width           =   1812
   End
   Begin VB.Label lbl_Password 
      Caption         =   "New password"
      Height          =   192
      Left            =   240
      TabIndex        =   0
      Top             =   360
      Width           =   1752
   End
End
Attribute VB_Name = "Change_Password"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Form_Load()
MouseOff

If gl_CodePage <> 1252 And gl_CodePage <> 0 Then ChangeCharset Me

spp_save.Picture = LoadResPicture(RES_OK, 1)
ssp_quit.Picture = LoadResPicture(RES_QUIT, 1)
If gut_Param.Str2 = "FREE" Then
    ssp_quit.Visible = OK
Else
    ssp_quit.Visible = KO
End If
GetScCsts
MouseOn
End Sub

Private Sub GetScCsts()
Dim ls_Field As String
Dim ls_Text As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim ls_Req As String

On Error GoTo suite

ls_Req = "EXEC Screen_Csts password_change,'" & gut_LangLogin.Code & "'"
If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
    li_Status = SQL_SUCCESS
Else
    li_Status = SQL_ERROR
End If
Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
    li_Status = SQLFetch(ll_Statement)
    If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
        ls_Field = ODBCData(ll_Statement, 1)
        ls_Text = ODBCData(ll_Statement, 2)
        Select Case ls_Field
            Case "title": Caption = ls_Text
            Case "password": lbl_Password = ls_Text
            Case "password2": lbl_Password2 = ls_Text
        End Select
    End If
Loop
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
Exit Sub

suite:
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
StdError
End Sub

Private Sub spp_save_Click()
Dim ls_Req As String
Dim ll_Statement As Long

On Error GoTo suite
MouseOff

'Controls modified and replaced by US strong password policy
'If txt_Password = txt_Password2 And txt_Password <> prg.U_PWD Then

If txt_Password = txt_Password2 Then
    If Len(txt_Password) > 4 And ChkNumericAlpha(txt_Password) Then
'        ls_Req = "EXEC Security_Alias_upd '" & prg.U_PWD & "', '" & txt_Password & "', '" & prg.LoginName & "'"
'        If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
'            li_Status = SQL_SUCCESS
'            prg.U_PWD = txt_Password
'        Else
'            li_Status = SQL_ERROR
'        End If
'        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)

        If Not Update_PassWord(txt_Password.Text) Then
            MsgBox "Password not registered correctly. Contact IT if problem in next connection."
        End If
        
        prg.U_PWD = txt_Password
        MouseOn
        Unload Me
        Exit Sub
    Else
        SendMessage 82, "Invalid password:" & Chr(10) & Chr(13) & "   - 5 characters minimum" & Chr(10) & Chr(13) & "   - only Numeric and Alphanumeric characters", gut_LangLogin.Code
        MouseOn
        Exit Sub
    End If
Else
    SendMessage 83, "Invalid password:" & Chr(10) & Chr(13) & "   The 2 passwords are not the same" & Chr(10) & Chr(13) & "   or the new password is the same than the old one", gut_LangLogin.Code
    MouseOn
    Exit Sub
End If

suite:
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
StdError
MouseOn
Unload Me
End Sub

Private Sub ssp_quit_Click()
MouseOff
Unload Me
MouseOn
End Sub


