Пример #1
0
        /// <summary>
        /// Valida los datos del usuario
        /// </summary>
        /// <history>
        /// [edgrodriguez] 29/Feb/2016 Created
        /// [wtorres]      06/Jul/2016 Modified. Ahora se despliega un mensaje de error cuando la contraseña nueva
        ///                            es igual a la anterior
        /// </history>
        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            //Si los textbox se encuentran vacios.
            if (txtNewPwd.Password == string.Empty)
            {
                UIHelper.ShowMessage("Specify the New Password");
                return;
            }
            if (txtConfirmNewPwd.Password == string.Empty)
            {
                UIHelper.ShowMessage("Please confirm the new password");
                return;
            }

            //Si el password y la confirmacion son diferentes.
            if (!txtNewPwd.Password.Equals(txtConfirmNewPwd.Password))
            {
                UIHelper.ShowMessage("New password and confirm password are different");
                return;
            }

            // encriptamos la nueva contraseña
            string encryptPass = EncryptHelper.Encrypt(txtNewPwd.Password);

            //Si la nueva contraseña es igual a la anterior.
            if (userLogin.pePwd.Equals(encryptPass))
            {
                UIHelper.ShowMessage("The new password can not be the same as the previous password");
                return;
            }

            //Si ocurrio un error al cambiar el password.
            if (!BRPersonnel.ChangePassword(userLogin.peID, encryptPass, serverDate))
            {
                UIHelper.ShowMessage("Could not change password");
                return;
            }

            blnOk            = true;
            userLogin.pePwd  = encryptPass;
            userLogin.pePwdD = serverDate.Date;
            UIHelper.ShowMessage("Your password was changed succesfully");
            Close();
        }