I have a system developed in DelphiXE3 and I'm starting to make it modular. However another question arose. In a Unit that will be in one of the modules, I have:
type
TUsuario = record
id:Integer;
idEmpresa:Integer;
usuario:string;
foto:string;
validade: TDateTime;
senha:string;
nome:string;
admin:Boolean;
ultimoAcesso:TDateTime;
dataCadastro:TDateTime;
end;
and
var
usuario:TUsuario;
At certain times I will feed this variable and in others I will retrieve the information from it. My question: How to do this?
Updating
My system is distributed as follows:
Aplicação
- Menu
- Login
- Package Default (Runtime Package)
* Unit TUsuario
* Unit FuncoesDefault
* Unit FuncoesSeguranca
- Package Cadastros (Carregado via LoadPackage)
* CD001 - Uma tela de cadastros qualquer
Access Violation error, I'm creating the variable inside the Default package in Unit FunCodeDefault .
In my application, on the login screen, I instantiate the variable already created:
usuario:= TUsuario.Create;
In Event FormShow
of form CD001, I call a function of the Unit FunConservice , responsible for checking the user's rights (insert, edit, remove , etc). This function is given a string with the screen code and my usuario
variable, which was previously created on the login screen.
Soon on the first line of my function there is a if usuario.isAdmin
to check if the user is an administrator. At this point I already get the Access Violation error.
Updating
Following is an excerpt from my Unit FuncoesDefault
unit FuncoesDefault;
interface
uses
U_TUsuario;
var
usuario:TUsuario;
implementation
initialization
usuario := TUsuario.Create;
end.