*******************************
function lGetPassword()
local oDlg, oUser, oPass
local nTries := 0 //Nº de intentos que quiero permitir
local lGo := .f.
PRIVATE x_user, x_pass //Antes esto no estaba y por eso no los podia ver
x_user = UPPER(GETENV("USERNAME"))+ space(4)
x_pass = space(10)
DEFINE DIALOG oDlg ;
FROM 5, 5 TO 20, 50 ;
TITLE "Por favor identifiquese..."
@ 1, 2 BITMAP oBmp FILENAME ".\..\Bmp\Pass.Bmp" OF oDlg NOBORDER
@ 1, 10 SAY "GESTION DE PUERTAS" OF oDlg
@ 4, 1 SAY "Nombre:" OF oDlg
@ 5.3, 1 SAY "P. de Acceso:" OF oDlg
@ 4, 8 GET oUser VAR x_user picture "@!" OF oDlg SIZE 50 , 10 VALID ( oImg:LoadImage( , "..\COMU\FOTOS\"+alltrim(x_user)+".jpg" ), oImg:Refresh(), .T. )
@ 5.3, 8 GET oPass VAR x_pass picture "@!" OF oDlg PASSWORD SIZE 50 , 10
@ 2, 14 IMAGE oImg FILE "..\COMU\FOTOS\"+alltrim(x_user)+".jpg" SIZE 50, 60 ADJUST
@ 4, 4 BUTTON "&Continuar" OF oDlg ;
ACTION ( nTries++,;
lGo := ComprueboAcceso( x_user, x_pass ) ,;
If( nTries > 2 .or. lGo, oDlg:End(),;
( MsgAlert( "Datos Incorrectos..."+ Chr(13) +"Intenta otra vez" ), oUser:SetFocus(), oPass:SetFocus() ) ) )
oBmp:lTransparent = .t. // Hago el bmp transparente
ACTIVATE DIALOG oDlg CENTERED ON PAINT ( oPass:SetFocus() )
return lGo
********************************
Function ComprueboAcceso( x_user, x_pass )
//Abre la base de datos de usuarios para esta aplicación.
if !op_base("USR",.f.,1,1)
return .f.
endif
locate all for x_user= USER->user
if !found()
MsgInfo("Usuario no registrado")
use
Return .F.
elseif x_pass != USER->pasw
MsgInfo("Palabra clave incorrecta")
use
Return .F.
endif
//Me desago de la base de datos abierta y retorno acceso correcto y tomo el nivel de acceso
x_level = USER->level
use
InicioAcceso()
return .t.
*********************************
Func InicioAcceso()
if !op_base("ACC",.f.,1,1,.f.,"ACCESOS")
return .f.
endif
Select("ACCESOS")
if netapp(0)
Replace PRG with d_prg
Replace FECHAINI with date()
Replace HORAINI with time()
Replace USER with x_user
Replace LOGON with x_logon
Replace ORDENADOR with x_ord
commit
endif
clos_base("ACC",1,.f.)
Return .t.
********************************************
EXIT PROCEDURE FinalizoAcceso()
if !op_base("ACC",.f.,1,1,.f.,"ACCESOS")
return .f.
endif
Select("ACCESOS")
DBSetOrder(5)
seek alltrim(x_user) + d_Prg
LOCATE FOR USER = alltrim(x_user) .and. PRG = d_prg .and. EMPTY(FECHAFIN)
DO WHILE Found()
if rlock()
Replace FECHAFIN with date()
Replace HORAFIN with time()
commit
endif
skip
LOCATE FOR USER = alltrim(x_user) .and. PRG = d_prg .and. EMPTY(FECHAFIN)
enddo
clos_base("ACC",1,.f.)
Return .t.