Monday, March 24, 2014

- workspace
- 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