- target
- library
Libreria app - Aplicacion app
evento open
open(w_inicio)
evento close
f_desconectar(SQLCA)
Libreria datos
f_conectar (return boolean, by reference, transaction at_ot)
string ls_ac
"PROVIDER='SQLOLEDB',DATASOURCE='.',PROVIDERSTRING='database=northwind',PERSISTSENSITIVE='True',INTEGRATEDSECURITY='SSPI'"
at_ot.DBMS = profileString("app.ini","conexion","dbms","NO encontrado")
at_ot.DBParm = profileString("app.ini","conexion","dbparm","NO encontrado")
ls_ac = profileString("app.ini","conexion","ac","NO encontrado")
ls_ac = trim(ls_ac)
ls_ac = lower(ls_ac)
if ls_ac = "false" then
at_ot.AutoCommit = false
elseif ls_ac = "true" then
at_ot.AutoCommit = true
end if
//Paso 2
connect using at_ot;
//Paso 3
if at_ot.SQLCode <> 0 then
messagebox("Error",at_ot.SQLErrText)
return false
else
return true
end if
f_desconectar(by reference transaction at_ot)
disconnect using at_ot;
library accesodatos - funcion validar (return boolean, by value string as_usuario, as_pass)
string ls_clave
select
usuario,
clave,
idTipoUsuario
into
:gs_usuario,
:ls_clave,
:gi_tipo
from
usuarios
where
usuario = :as_usuario;
if SQLCA.SQLCode <> 0 then
messagebox("ERROR", "Usuario NO encontrado!!!", stopsign!)
f_desconectar(SQLCA)
return false
elseif ls_clave <> as_clave then
messagebox("ERROR", "Clave Incorrecta!!!", stopsign!)
f_desconectar(SQLCA)
return false
else
f_desconectar(SQLCA)
setProfileString("app.ini", "registro", "ultUsuario", gs_usuario)
return true
end if
else
return false
end if
libreria logica - ventana w_rep
constructor dw_1
//Conecto
if f_conectar(SQLCA) then
//establecer el objeto transaccional
this.setTransObject(SQLCA)
//recuperar los datos
this.retrieve( )
//Asigno el dato del usuario conectado a la etiqueta t_usuario
this.modify("t_usuario.text=' " + "Usuario: " + gs_usuario + " ' " )
//Desconecto
f_desconectar(SQLCA)
end if
libreria presentacion - menu principal
ventana
parentwindow.arrangesheets(TileHorizontal!) tile! icons! cascade!
opensheet(w_rep_empleados, w_principal, 2, Original!)
ventana inicio
evento open
this.triggerevent("ue_config")
evento timer
this.title = string(datetime(today(), now()), "dd/mm/yyyy hh:mm.ss am/pm")
evento ue_config
integer li_time, li_r, li_g, li_b
li_time = profileInt("app.ini","configuracion","titulo",1)
timer(li_time)
li_r=profileInt("app.ini","configuracion","r",1)
li_g=profileInt("app.ini","configuracion","g",1)
li_b=profileInt("app.ini","configuracion","b",1)
this.backcolor = rgb(li_r, li_g, li_b)
gb_1.backcolor = rgb(li_r, li_g, li_b)
st_1.backcolor = rgb(li_r, li_g, li_b)
st_2.backcolor = rgb(li_r, li_g, li_b)
sle_usuario.text = ProfileString("app.ini", "registro", "ultUsuario", "")
sle_usuario.selecttext( 1, len(sle_usuario.text))
eveto ue_salir
integer li_retorno
li_retorno = messagebox("Consulta", "Desea salir?", question!, yesno!, 2)
if li_retorno=1 then
halt close
end if
boton acceptar
evento clicked
string ls_usuario, ls_clave
ls_usuario = trim(sle_usuario.text)
ls_clave = trim(sle_clave.text)
n_cryptoapi lnv_crypto
ls_clave = lnv_crypto.of_encrypt(ls_clave, "1234567890987654")
if f_validar(ls_usuario, ls_clave) then
open(w_principal)
else
gi_contador++
end if
if gi_contador > 2 then
messagebox("ERROR", "Alcanzó el número máximo de intentos!!!", stopsign!)
halt close
end if
boton salir
evento clicked
parent.triggerevent("ue_salir")
ventana principal (no layout, return long)
evento open
close(w_inicio)
choose case gi_tipo
case 2
m_principal.m_mantenimientos.hide()
end choose