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;
|
||||
|
||||
Const
|
||||
CTE_PRIVILEGIO_TOTAL = 'TOTAL';
|
||||
CTE_PRIVILEGIO_1 = 'PRIVILEGIO1';
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// COMUNES
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -147,6 +150,7 @@ type
|
||||
FBD : TIBDatabase;
|
||||
FTransaccionBD : TIBTransaction;
|
||||
FNombreBD : string;
|
||||
FPrivilegios: String;
|
||||
|
||||
procedure IniciarTablasBackOffice;
|
||||
procedure IniciarTablas;
|
||||
@ -156,6 +160,7 @@ type
|
||||
function GetRutaBD: String;
|
||||
function GetNombreServidor: String;
|
||||
function validarPrivilegios: Boolean;
|
||||
|
||||
public
|
||||
procedure Commit;
|
||||
procedure Rollback;
|
||||
@ -177,6 +182,7 @@ type
|
||||
property BD : TIBDatabase read FBD;
|
||||
property Transaccion : TIBTransaction read FTransaccionBD;
|
||||
property Usuario : String read DarUsuario;
|
||||
property Privilegios : String read FPrivilegios;
|
||||
property NombreBD : String read FNombreBD write FNombreBD;
|
||||
property RutaBD : String read GetRutaBD;
|
||||
property NombreServidor : String read GetNombreServidor;
|
||||
@ -225,7 +231,8 @@ uses
|
||||
constructor TdmBaseDatos.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited;
|
||||
|
||||
FPrivilegios := '';
|
||||
|
||||
FBD := TIBDatabase.Create(Self);
|
||||
with FBD do
|
||||
begin
|
||||
@ -249,6 +256,8 @@ end;
|
||||
|
||||
destructor TdmBaseDatos.Destroy;
|
||||
begin
|
||||
FPrivilegios := '';
|
||||
|
||||
FBD.Close;
|
||||
FBD.DefaultTransaction := NIL;
|
||||
FBD.Free;
|
||||
@ -586,10 +595,37 @@ begin
|
||||
end;
|
||||
|
||||
function TdmBaseDatos.validarPrivilegios: Boolean;
|
||||
var
|
||||
oSQL : TIBSQL;
|
||||
begin
|
||||
//Por si en un futuro se desea establecer una politica de privilegios de usuario
|
||||
//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;
|
||||
|
||||
procedure TdmBaseDatos.IniciarTablasBackOffice;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
object frPrincipal: TfrPrincipal
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 443
|
||||
Width = 778
|
||||
Height = 270
|
||||
Align = alClient
|
||||
Color = 14280169
|
||||
@ -11,7 +11,7 @@ object frPrincipal: TfrPrincipal
|
||||
object BarraEstado: TStatusBar
|
||||
Left = 0
|
||||
Top = 251
|
||||
Width = 443
|
||||
Width = 778
|
||||
Height = 19
|
||||
Panels = <
|
||||
item
|
||||
@ -21,7 +21,7 @@ object frPrincipal: TfrPrincipal
|
||||
object pnlBarraSuperior: TRdxGradientePanel
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 443
|
||||
Width = 778
|
||||
Height = 70
|
||||
Align = alTop
|
||||
BevelOuter = bvNone
|
||||
@ -34,7 +34,7 @@ object frPrincipal: TfrPrincipal
|
||||
ColorShadow = clNone
|
||||
ColorStart = 7884880
|
||||
object imgFondo: TImage
|
||||
Left = -1557
|
||||
Left = -1222
|
||||
Top = 0
|
||||
Width = 2000
|
||||
Height = 70
|
||||
@ -366,12 +366,12 @@ object frPrincipal: TfrPrincipal
|
||||
object actContabilidad: TAction
|
||||
Caption = 'Contabilidad'
|
||||
OnExecute = actContabilidadExecute
|
||||
OnUpdate = actDatosUpdate
|
||||
OnUpdate = actContabilidadUpdate
|
||||
end
|
||||
object actInformes: TAction
|
||||
Caption = 'Estad'#237'sticas e informes'
|
||||
OnExecute = actInformesExecute
|
||||
OnUpdate = actDatosUpdate
|
||||
OnUpdate = actInformesUpdate
|
||||
end
|
||||
object actHacerCopia: TAction
|
||||
Caption = 'Hacer copia de seguridad'
|
||||
|
||||
@ -105,6 +105,8 @@ type
|
||||
procedure actAgendaExecute(Sender: TObject);
|
||||
procedure actConfigActualizazionExecute(Sender: TObject);
|
||||
procedure actActualizarExecute(Sender: TObject);
|
||||
procedure actContabilidadUpdate(Sender: TObject);
|
||||
procedure actInformesUpdate(Sender: TObject);
|
||||
private
|
||||
public
|
||||
Version : String;
|
||||
@ -276,7 +278,7 @@ end;
|
||||
|
||||
procedure TfrPrincipal.actDatosUpdate(Sender: TObject);
|
||||
begin
|
||||
(Sender as TAction).Enabled := (EmpresaActiva.Codigo <> -1);
|
||||
(Sender as TAction).Enabled := (EmpresaActiva.Codigo <> -1)
|
||||
end;
|
||||
|
||||
procedure TfrPrincipal.RdxFrameResize(Sender: TObject);
|
||||
@ -348,4 +350,14 @@ begin
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user