From a0ce5fd5be7f25be4fb1ff51f01079e55a95094a Mon Sep 17 00:00:00 2001 From: roberto Date: Mon, 22 Dec 2008 17:01:38 +0000 Subject: [PATCH] =?UTF-8?q?Se=20adapta=20la=20aplicaci=C3=B3n=20para=20los?= =?UTF-8?q?=20usuarios=20tengan=20un=20campo=20perfil=20que=20nos=20determ?= =?UTF-8?q?ine=20que=20operaciones=20pueden=20hacer=20y=20cuales=20no?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://192.168.0.254/svn/Proyectos.AbetoArmarios_FactuGES/trunk@25 0a814768-cfdd-9c42-8d01-223fcc10da9d --- BaseDatos/BaseDatos.pas | 40 ++++++++++++++++++++++++++++++++++++++-- Principal.dfm | 12 ++++++------ Principal.pas | 14 +++++++++++++- 3 files changed, 57 insertions(+), 9 deletions(-) diff --git a/BaseDatos/BaseDatos.pas b/BaseDatos/BaseDatos.pas index df36626..fbf63a4 100644 --- a/BaseDatos/BaseDatos.pas +++ b/BaseDatos/BaseDatos.pas @@ -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; diff --git a/Principal.dfm b/Principal.dfm index 1464268..f461881 100644 --- a/Principal.dfm +++ b/Principal.dfm @@ -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' diff --git a/Principal.pas b/Principal.pas index 04393c1..9e911b0 100644 --- a/Principal.pas +++ b/Principal.pas @@ -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.