- Repaso general git-svn-id: https://192.168.0.254/svn/Proyectos.Varela_PuntosVenta/trunk@117 1c943782-d109-9647-9548-93b3ac332352
260 lines
6.5 KiB
ObjectPascal
260 lines
6.5 KiB
ObjectPascal
unit uEditorUsuarios;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, uEditorGridBase, Menus, JvAppStorage, JvAppRegistryStorage, DB,
|
||
uDAInterfaces, uDADataTable, JvComponentBase, JvFormPlacement, ImgList,
|
||
PngImageList, StdActns, ActnList, ComCtrls, JvExComCtrls, JvStatusBar, TBX,
|
||
TB2ExtItems, TBXExtItems, TB2Item, TB2Dock, TB2Toolbar, pngimage, ExtCtrls,
|
||
JvExControls, JvNavigationPane, uCustomView, uViewBase, uViewGridBase,
|
||
uViewGrid, uViewUsuarios, uIEditorUsuarios, uUsuariosController,
|
||
uBizUsuarios;
|
||
|
||
type
|
||
TfEditorUsuarios = class(TfEditorGridBase, IEditorUsuarios)
|
||
actCambiarPassword: TAction;
|
||
TBXSubmenuItem2: TTBXSubmenuItem;
|
||
TBXItem38: TTBXItem;
|
||
TBXItem39: TTBXItem;
|
||
Cambiarlacontrasea1: TMenuItem;
|
||
actControlAcceso: TAction;
|
||
Controldeacceso1: TMenuItem;
|
||
N3: TMenuItem;
|
||
TBXItem35: TTBXItem;
|
||
procedure actEliminarUpdate(Sender: TObject);
|
||
procedure actCambiarPasswordUpdate(Sender: TObject);
|
||
procedure actCambiarPasswordExecute(Sender: TObject);
|
||
procedure actNuevoExecute(Sender: TObject);
|
||
procedure actEliminarExecute(Sender: TObject);
|
||
procedure actModificarExecute(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure actControlAccesoExecute(Sender: TObject);
|
||
procedure actControlAccesoUpdate(Sender: TObject);
|
||
private
|
||
FUsuarios : IBizUsuario;
|
||
FController : IUsuariosController;
|
||
protected
|
||
function GetController : IUsuariosController;
|
||
procedure SetController (const Value : IUsuariosController);
|
||
|
||
function GetUsuarios: IBizUsuario;
|
||
procedure SetUsuarios(const Value: IBizUsuario);
|
||
|
||
procedure ActualizarEstadoEditor;
|
||
procedure NuevoInterno;
|
||
procedure EliminarInterno;
|
||
procedure ModificarInterno;
|
||
procedure ImprimirInterno;
|
||
procedure PrevisualizarInterno;
|
||
procedure DuplicarInterno;
|
||
|
||
//Si queremos crear otra vista para el editor heredado solo tendriamos que
|
||
//sobreescribir este metodo
|
||
procedure AsignarVista; virtual;
|
||
public
|
||
procedure PonerTitulos(const ATitulo: string = '');
|
||
property Usuarios: IBizUsuario read GetUsuarios write SetUsuarios;
|
||
property Controller : IUsuariosController read GetController write SetController;
|
||
constructor Create(AOwner: TComponent); override;
|
||
destructor Destroy; override;
|
||
end;
|
||
|
||
implementation
|
||
|
||
{$R *.dfm}
|
||
|
||
uses
|
||
uDialogUtils;
|
||
|
||
{ TfEditorUsuarios }
|
||
|
||
procedure TfEditorUsuarios.actCambiarPasswordExecute(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
FController.CambiarPassword(FUsuarios.ID);
|
||
end;
|
||
|
||
procedure TfEditorUsuarios.actCambiarPasswordUpdate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
if (Sender as TAction).Enabled then
|
||
(Sender as TAction).Enabled := HayDatos;
|
||
end;
|
||
|
||
procedure TfEditorUsuarios.actControlAccesoExecute(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
FController.AdministrarAccesos(FUsuarios);
|
||
end;
|
||
|
||
procedure TfEditorUsuarios.actControlAccesoUpdate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
if (Sender as TAction).Enabled then
|
||
(Sender as TAction).Enabled := HayDatos;
|
||
end;
|
||
|
||
procedure TfEditorUsuarios.actEliminarExecute(Sender: TObject);
|
||
begin
|
||
if actEliminar.Enabled then
|
||
begin
|
||
EliminarInterno;
|
||
ActualizarEstadoEditor;
|
||
end;
|
||
end;
|
||
|
||
procedure TfEditorUsuarios.actEliminarUpdate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
if (Sender as TAction).Enabled then
|
||
(Sender as TAction).Enabled := (FUsuarios.PRIVILEGED = 0);
|
||
end;
|
||
|
||
procedure TfEditorUsuarios.actModificarExecute(Sender: TObject);
|
||
begin
|
||
if actModificar.Enabled then
|
||
begin
|
||
ModificarInterno;
|
||
ActualizarEstadoEditor;
|
||
end;
|
||
end;
|
||
|
||
procedure TfEditorUsuarios.actNuevoExecute(Sender: TObject);
|
||
begin
|
||
if actNuevo.Enabled then
|
||
begin
|
||
NuevoInterno;
|
||
ActualizarEstadoEditor;
|
||
end;
|
||
end;
|
||
|
||
procedure TfEditorUsuarios.ActualizarEstadoEditor;
|
||
begin
|
||
PonerTitulos;
|
||
end;
|
||
|
||
procedure TfEditorUsuarios.AsignarVista;
|
||
begin
|
||
ViewGrid := CreateView(TfrViewUsuarios) as IViewUsuarios;
|
||
end;
|
||
|
||
constructor TfEditorUsuarios.Create(AOwner: TComponent);
|
||
begin
|
||
inherited;
|
||
AsignarVista;
|
||
end;
|
||
|
||
destructor TfEditorUsuarios.Destroy;
|
||
begin
|
||
FUsuarios := NIL;
|
||
FController := NIl;
|
||
|
||
inherited;
|
||
end;
|
||
|
||
procedure TfEditorUsuarios.DuplicarInterno;
|
||
begin
|
||
inherited;
|
||
end;
|
||
|
||
procedure TfEditorUsuarios.EliminarInterno;
|
||
begin
|
||
if (ShowConfirmMessage('Eliminar un usuario', Format('<27>Desea borrar el usuario %s?', [FUsuarios.USERNAME])) = IDYES) then
|
||
begin
|
||
inherited;
|
||
//Para que en el caso de no poderse realizar la operaci<63>n se refresquen
|
||
//los datos y no nos permita eliminar un registro a la segunda
|
||
FController.EliminarUsuario(FUsuarios.ID);
|
||
actRefrescar.Execute;
|
||
end;
|
||
end;
|
||
|
||
procedure TfEditorUsuarios.FormShow(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
ActualizarEstadoEditor;
|
||
if Assigned(Parent) then
|
||
begin
|
||
StatusBar.Visible := False;
|
||
actCerrar.ShortCut := 0
|
||
end
|
||
else begin
|
||
StatusBar.Visible := True;
|
||
actCerrar.ShortCut := ShortCut(VK_ESCAPE, []);
|
||
end;
|
||
end;
|
||
|
||
function TfEditorUsuarios.GetController: IUsuariosController;
|
||
begin
|
||
Result := FController;
|
||
end;
|
||
|
||
function TfEditorUsuarios.GetUsuarios: IBizUsuario;
|
||
begin
|
||
Result := FUsuarios;
|
||
end;
|
||
|
||
procedure TfEditorUsuarios.ImprimirInterno;
|
||
begin
|
||
inherited;
|
||
end;
|
||
|
||
procedure TfEditorUsuarios.ModificarInterno;
|
||
begin
|
||
inherited;
|
||
FController.VerUsuario(FUsuarios.ID);
|
||
actRefrescar.Execute;
|
||
end;
|
||
|
||
procedure TfEditorUsuarios.NuevoInterno;
|
||
var
|
||
ANuevoUsuario : IBizUsuario;
|
||
begin
|
||
inherited;
|
||
ANuevoUsuario := FController.NuevoUsuario;
|
||
FController.VerUsuario(ANuevoUsuario);
|
||
actRefrescar.Execute;
|
||
end;
|
||
|
||
procedure TfEditorUsuarios.PonerTitulos(const ATitulo: string);
|
||
var
|
||
FTitulo : String;
|
||
begin
|
||
FTitulo := 'Lista de usuarios';
|
||
|
||
if ReadOnly then
|
||
begin
|
||
JvNavPanelHeader.Caption := FTitulo + ' (NO MODIFICABLE)';
|
||
Caption := FTitulo + ' (NO MODIFICABLE)';
|
||
end
|
||
else
|
||
begin
|
||
JvNavPanelHeader.Caption := FTitulo;
|
||
Caption := FTitulo;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfEditorUsuarios.PrevisualizarInterno;
|
||
begin
|
||
inherited;
|
||
//
|
||
end;
|
||
|
||
procedure TfEditorUsuarios.SetController(const Value: IUsuariosController);
|
||
begin
|
||
FController := Value;
|
||
end;
|
||
|
||
procedure TfEditorUsuarios.SetUsuarios(const Value: IBizUsuario);
|
||
begin
|
||
FUsuarios := Value;
|
||
dsDataTable.DataTable := FUsuarios.DataTable;
|
||
if Assigned(ViewGrid) then
|
||
(ViewGrid as IViewUsuarios).Usuarios := FUsuarios;
|
||
end;
|
||
|
||
end.
|