Se adapta la aplicación para los usuarios tengan un campo perfil que nos determine que operaciones pueden hacer y cuales no
git-svn-id: https://192.168.0.254/svn/Proyectos.AbetoArmarios_FactuGES/trunk@25 0a814768-cfdd-9c42-8d01-223fcc10da9d
This commit is contained in:
parent
9f3f47263f
commit
a0ce5fd5be
@ -36,6 +36,9 @@ uses
|
|||||||
Entidades, Contadores, RdxGestorContadores;
|
Entidades, Contadores, RdxGestorContadores;
|
||||||
|
|
||||||
Const
|
Const
|
||||||
|
CTE_PRIVILEGIO_TOTAL = 'TOTAL';
|
||||||
|
CTE_PRIVILEGIO_1 = 'PRIVILEGIO1';
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// COMUNES
|
// COMUNES
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -147,6 +150,7 @@ type
|
|||||||
FBD : TIBDatabase;
|
FBD : TIBDatabase;
|
||||||
FTransaccionBD : TIBTransaction;
|
FTransaccionBD : TIBTransaction;
|
||||||
FNombreBD : string;
|
FNombreBD : string;
|
||||||
|
FPrivilegios: String;
|
||||||
|
|
||||||
procedure IniciarTablasBackOffice;
|
procedure IniciarTablasBackOffice;
|
||||||
procedure IniciarTablas;
|
procedure IniciarTablas;
|
||||||
@ -156,6 +160,7 @@ type
|
|||||||
function GetRutaBD: String;
|
function GetRutaBD: String;
|
||||||
function GetNombreServidor: String;
|
function GetNombreServidor: String;
|
||||||
function validarPrivilegios: Boolean;
|
function validarPrivilegios: Boolean;
|
||||||
|
|
||||||
public
|
public
|
||||||
procedure Commit;
|
procedure Commit;
|
||||||
procedure Rollback;
|
procedure Rollback;
|
||||||
@ -177,6 +182,7 @@ type
|
|||||||
property BD : TIBDatabase read FBD;
|
property BD : TIBDatabase read FBD;
|
||||||
property Transaccion : TIBTransaction read FTransaccionBD;
|
property Transaccion : TIBTransaction read FTransaccionBD;
|
||||||
property Usuario : String read DarUsuario;
|
property Usuario : String read DarUsuario;
|
||||||
|
property Privilegios : String read FPrivilegios;
|
||||||
property NombreBD : String read FNombreBD write FNombreBD;
|
property NombreBD : String read FNombreBD write FNombreBD;
|
||||||
property RutaBD : String read GetRutaBD;
|
property RutaBD : String read GetRutaBD;
|
||||||
property NombreServidor : String read GetNombreServidor;
|
property NombreServidor : String read GetNombreServidor;
|
||||||
@ -225,6 +231,7 @@ uses
|
|||||||
constructor TdmBaseDatos.Create(AOwner: TComponent);
|
constructor TdmBaseDatos.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
FPrivilegios := '';
|
||||||
|
|
||||||
FBD := TIBDatabase.Create(Self);
|
FBD := TIBDatabase.Create(Self);
|
||||||
with FBD do
|
with FBD do
|
||||||
@ -249,6 +256,8 @@ end;
|
|||||||
|
|
||||||
destructor TdmBaseDatos.Destroy;
|
destructor TdmBaseDatos.Destroy;
|
||||||
begin
|
begin
|
||||||
|
FPrivilegios := '';
|
||||||
|
|
||||||
FBD.Close;
|
FBD.Close;
|
||||||
FBD.DefaultTransaction := NIL;
|
FBD.DefaultTransaction := NIL;
|
||||||
FBD.Free;
|
FBD.Free;
|
||||||
@ -586,10 +595,37 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TdmBaseDatos.validarPrivilegios: Boolean;
|
function TdmBaseDatos.validarPrivilegios: Boolean;
|
||||||
|
var
|
||||||
|
oSQL : TIBSQL;
|
||||||
begin
|
begin
|
||||||
//Por si en un futuro se desea establecer una politica de privilegios de usuario
|
//Por si en un futuro se desea establecer una politica de privilegios de usuario
|
||||||
//para cada EmpresaActiva.
|
//para cada EmpresaActiva.
|
||||||
Result := True;
|
Result := False;
|
||||||
|
|
||||||
|
oSQL := TIBSQL.Create(Self);
|
||||||
|
with oSQL do
|
||||||
|
begin
|
||||||
|
Database := dmBaseDatos.BD;
|
||||||
|
Transaction := dmBaseDatos.Transaccion;
|
||||||
|
SQL.Add('select perfil ');
|
||||||
|
SQL.Add('from usuarios ');
|
||||||
|
SQL.Add('where UPPER(usuario) = UPPER(:usuario) ');
|
||||||
|
ParamByName('usuario').AsString := Usuario;
|
||||||
|
try
|
||||||
|
Prepare;
|
||||||
|
ExecQuery;
|
||||||
|
// Compruebo si se han recuperado datos
|
||||||
|
if (RecordCount > 0) then
|
||||||
|
begin
|
||||||
|
FPrivilegios := Fields[0].AsString;
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
Close;
|
||||||
|
Transaction := NIL;
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TdmBaseDatos.IniciarTablasBackOffice;
|
procedure TdmBaseDatos.IniciarTablasBackOffice;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
object frPrincipal: TfrPrincipal
|
object frPrincipal: TfrPrincipal
|
||||||
Left = 0
|
Left = 0
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 443
|
Width = 778
|
||||||
Height = 270
|
Height = 270
|
||||||
Align = alClient
|
Align = alClient
|
||||||
Color = 14280169
|
Color = 14280169
|
||||||
@ -11,7 +11,7 @@ object frPrincipal: TfrPrincipal
|
|||||||
object BarraEstado: TStatusBar
|
object BarraEstado: TStatusBar
|
||||||
Left = 0
|
Left = 0
|
||||||
Top = 251
|
Top = 251
|
||||||
Width = 443
|
Width = 778
|
||||||
Height = 19
|
Height = 19
|
||||||
Panels = <
|
Panels = <
|
||||||
item
|
item
|
||||||
@ -21,7 +21,7 @@ object frPrincipal: TfrPrincipal
|
|||||||
object pnlBarraSuperior: TRdxGradientePanel
|
object pnlBarraSuperior: TRdxGradientePanel
|
||||||
Left = 0
|
Left = 0
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 443
|
Width = 778
|
||||||
Height = 70
|
Height = 70
|
||||||
Align = alTop
|
Align = alTop
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
@ -34,7 +34,7 @@ object frPrincipal: TfrPrincipal
|
|||||||
ColorShadow = clNone
|
ColorShadow = clNone
|
||||||
ColorStart = 7884880
|
ColorStart = 7884880
|
||||||
object imgFondo: TImage
|
object imgFondo: TImage
|
||||||
Left = -1557
|
Left = -1222
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 2000
|
Width = 2000
|
||||||
Height = 70
|
Height = 70
|
||||||
@ -366,12 +366,12 @@ object frPrincipal: TfrPrincipal
|
|||||||
object actContabilidad: TAction
|
object actContabilidad: TAction
|
||||||
Caption = 'Contabilidad'
|
Caption = 'Contabilidad'
|
||||||
OnExecute = actContabilidadExecute
|
OnExecute = actContabilidadExecute
|
||||||
OnUpdate = actDatosUpdate
|
OnUpdate = actContabilidadUpdate
|
||||||
end
|
end
|
||||||
object actInformes: TAction
|
object actInformes: TAction
|
||||||
Caption = 'Estad'#237'sticas e informes'
|
Caption = 'Estad'#237'sticas e informes'
|
||||||
OnExecute = actInformesExecute
|
OnExecute = actInformesExecute
|
||||||
OnUpdate = actDatosUpdate
|
OnUpdate = actInformesUpdate
|
||||||
end
|
end
|
||||||
object actHacerCopia: TAction
|
object actHacerCopia: TAction
|
||||||
Caption = 'Hacer copia de seguridad'
|
Caption = 'Hacer copia de seguridad'
|
||||||
|
|||||||
@ -105,6 +105,8 @@ type
|
|||||||
procedure actAgendaExecute(Sender: TObject);
|
procedure actAgendaExecute(Sender: TObject);
|
||||||
procedure actConfigActualizazionExecute(Sender: TObject);
|
procedure actConfigActualizazionExecute(Sender: TObject);
|
||||||
procedure actActualizarExecute(Sender: TObject);
|
procedure actActualizarExecute(Sender: TObject);
|
||||||
|
procedure actContabilidadUpdate(Sender: TObject);
|
||||||
|
procedure actInformesUpdate(Sender: TObject);
|
||||||
private
|
private
|
||||||
public
|
public
|
||||||
Version : String;
|
Version : String;
|
||||||
@ -276,7 +278,7 @@ end;
|
|||||||
|
|
||||||
procedure TfrPrincipal.actDatosUpdate(Sender: TObject);
|
procedure TfrPrincipal.actDatosUpdate(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
(Sender as TAction).Enabled := (EmpresaActiva.Codigo <> -1);
|
(Sender as TAction).Enabled := (EmpresaActiva.Codigo <> -1)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrPrincipal.RdxFrameResize(Sender: TObject);
|
procedure TfrPrincipal.RdxFrameResize(Sender: TObject);
|
||||||
@ -348,4 +350,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TfrPrincipal.actContabilidadUpdate(Sender: TObject);
|
||||||
|
begin
|
||||||
|
(Sender as TAction).Enabled := (EmpresaActiva.Codigo <> -1) AND (dmBaseDatos.Privilegios = CTE_PRIVILEGIO_TOTAL);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrPrincipal.actInformesUpdate(Sender: TObject);
|
||||||
|
begin
|
||||||
|
(Sender as TAction).Enabled := (EmpresaActiva.Codigo <> -1) AND (dmBaseDatos.Privilegios = CTE_PRIVILEGIO_TOTAL);
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|||||||
Reference in New Issue
Block a user