2009-12-16 17:16:54 +00:00
|
|
|
|
unit uEditorUsuarios;
|
|
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
|
|
|
|
Dialogs, uEditorGridBase, Menus, JvAppStorage, JvAppRegistryStorage, DB,
|
|
|
|
|
|
uDAInterfaces, uDADataTable, JvComponentBase, JvFormPlacement, ImgList,
|
2010-01-22 09:52:58 +00:00
|
|
|
|
PngImageList, StdActns, ActnList, ComCtrls, JvExComCtrls, JvStatusBar, SpTBXItem,
|
|
|
|
|
|
TB2ExtItems, TB2Item, TB2Dock, TB2Toolbar, pngimage, ExtCtrls,
|
2009-12-16 17:16:54 +00:00
|
|
|
|
JvExControls, JvNavigationPane, uCustomView, uViewBase, uViewGridBase,
|
|
|
|
|
|
uViewGrid, uViewUsuarios, uIEditorUsuarios, uUsuariosController,
|
2010-02-01 19:24:25 +00:00
|
|
|
|
uBizUsuarios, StdCtrls, TntStdCtrls, SpTBXEditors;
|
2009-12-16 17:16:54 +00:00
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
|
TfEditorUsuarios = class(TfEditorGridBase, IEditorUsuarios)
|
|
|
|
|
|
actCambiarPassword: TAction;
|
2010-01-22 09:52:58 +00:00
|
|
|
|
TBXSubmenuItem2: TSpTBXSubmenuItem;
|
|
|
|
|
|
TBXItem38: TSpTBXItem;
|
|
|
|
|
|
TBXItem39: TSpTBXItem;
|
2009-12-16 17:16:54 +00:00
|
|
|
|
procedure actEliminarUpdate(Sender: TObject);
|
|
|
|
|
|
procedure actCambiarPasswordUpdate(Sender: TObject);
|
|
|
|
|
|
procedure actCambiarPasswordExecute(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 NuevoInterno; override;
|
|
|
|
|
|
procedure EliminarInterno; override;
|
|
|
|
|
|
procedure ModificarInterno; override;
|
|
|
|
|
|
procedure ImprimirInterno; override;
|
|
|
|
|
|
procedure PrevisualizarInterno; override;
|
|
|
|
|
|
procedure DuplicarInterno; override;
|
|
|
|
|
|
|
|
|
|
|
|
//Si queremos crear otra vista para el editor heredado solo tendriamos que
|
|
|
|
|
|
//sobreescribir este metodo
|
|
|
|
|
|
procedure AsignarVista; virtual;
|
|
|
|
|
|
public
|
|
|
|
|
|
procedure PonerTitulos(const ATitulo: string = ''); override;
|
|
|
|
|
|
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.actEliminarUpdate(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
if (Sender as TAction).Enabled then
|
|
|
|
|
|
(Sender as TAction).Enabled := (FUsuarios.PRIVILEGED = 0);
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
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';
|
|
|
|
|
|
inherited PonerTitulos(FTitulo);
|
|
|
|
|
|
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.
|