2007-07-10 17:33:08 +00:00
|
|
|
|
unit uEditorInformes;
|
|
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
|
|
|
|
Dialogs, uEditorDBBase, Menus, DB, uDADataTable, JvAppStorage,
|
|
|
|
|
|
JvAppRegistryStorage, JvComponentBase, JvFormPlacement, ImgList,
|
|
|
|
|
|
PngImageList, StdActns, ActnList, ComCtrls, TB2ExtItems, TBXExtItems,
|
|
|
|
|
|
TBX, TB2Item, TB2Dock, TB2Toolbar, ExtCtrls, JvExControls, JvComponent,
|
|
|
|
|
|
JvNavigationPane, pngimage, uBizInformes, uEditorBase,
|
|
|
|
|
|
uViewInformes, JvExComCtrls, JvStatusBar, uIEditorInformes, uInformesController,
|
|
|
|
|
|
uCustomView, uViewBase, JSDialog;
|
|
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
|
TfEditorInformes = class(TfEditorDBBase, IEditorInformes)
|
|
|
|
|
|
ViewPopupMenu: TPopupMenu;
|
|
|
|
|
|
Modificar1: TMenuItem;
|
|
|
|
|
|
Eliminar1: TMenuItem;
|
|
|
|
|
|
N1: TMenuItem;
|
|
|
|
|
|
Nuevo1: TMenuItem;
|
|
|
|
|
|
pngImageNuevo: TPngImageList;
|
|
|
|
|
|
actPropiedades: TAction;
|
|
|
|
|
|
TBXSeparatorItem14: TTBXSeparatorItem;
|
|
|
|
|
|
TBXItem7: TTBXItem;
|
|
|
|
|
|
N2: TMenuItem;
|
|
|
|
|
|
Propiedades1: TMenuItem;
|
|
|
|
|
|
frViewInformes1: TfrViewInformes;
|
|
|
|
|
|
procedure actModificarExecute(Sender: TObject);
|
|
|
|
|
|
procedure FormShow(Sender: TObject);
|
|
|
|
|
|
procedure actPropiedadesExecute(Sender: TObject);
|
|
|
|
|
|
procedure actPropiedadesUpdate(Sender: TObject);
|
2007-07-13 09:27:48 +00:00
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
procedure ComprobarPrivilegios;
|
|
|
|
|
|
|
2007-07-10 17:33:08 +00:00
|
|
|
|
protected
|
|
|
|
|
|
FInformes : IBizInforme;
|
|
|
|
|
|
FController : IInformesController;
|
|
|
|
|
|
FViewInformes : IViewInformes;
|
|
|
|
|
|
function GetInformes: IBizInforme;
|
|
|
|
|
|
procedure SetInformes(const Value: IBizInforme);
|
|
|
|
|
|
function GetController: IInformesController;
|
|
|
|
|
|
procedure SetController(const Value: IInformesController);
|
|
|
|
|
|
|
|
|
|
|
|
procedure NuevoInterno; override;
|
|
|
|
|
|
procedure EliminarInterno; override;
|
|
|
|
|
|
procedure RefrescarInterno; override;
|
|
|
|
|
|
|
|
|
|
|
|
public
|
|
|
|
|
|
property Informes: IBizInforme read GetInformes write SetInformes;
|
|
|
|
|
|
property Controller: IInformesController read GetController write SetController;
|
|
|
|
|
|
constructor Create(AOwner: TComponent); override;
|
|
|
|
|
|
destructor Destroy; override;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
|
|
{ TfEditorInformes }
|
|
|
|
|
|
|
2007-07-13 09:27:48 +00:00
|
|
|
|
uses uDataModuleUsuarios;
|
|
|
|
|
|
|
2007-07-10 17:33:08 +00:00
|
|
|
|
function TfEditorInformes.GetController: IInformesController;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FController;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TfEditorInformes.GetInformes: IBizInforme;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FInformes;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorInformes.NuevoInterno;
|
|
|
|
|
|
var
|
|
|
|
|
|
Respuesta: integer;
|
|
|
|
|
|
Opcion: integer;
|
|
|
|
|
|
i: integer;
|
|
|
|
|
|
begin
|
|
|
|
|
|
try
|
|
|
|
|
|
Respuesta := frViewInformes1.JsNuevoDialog.Execute;
|
|
|
|
|
|
if Respuesta <> IDCANCEL then
|
|
|
|
|
|
begin
|
|
|
|
|
|
frViewInformes1.JsNuevoDialog.CustomButtonResult;
|
|
|
|
|
|
Opcion := frViewInformes1.JsNuevoDialog.CustomButtonResult;
|
|
|
|
|
|
for i := 0 to frViewInformes1.JsNuevoDialog.CustomButtons.Count - 1 do
|
|
|
|
|
|
if (frViewInformes1.JsNuevoDialog.CustomButtons.Items[i].Value = Opcion) then
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
FController.Nuevo(frViewInformes1.JsNuevoDialog.CustomButtons.Items[i].Info.Strings[0], FInformes);
|
|
|
|
|
|
// showmessage('Opcion seleccionada: ' + frViewInformes1.JsNuevoDialog.CustomButtons.Items[i].Info.Strings[0]);
|
|
|
|
|
|
end;
|
|
|
|
|
|
finally
|
|
|
|
|
|
FViewInformes.Refresh;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorInformes.RefrescarInterno;
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
if Assigned(FViewInformes) then
|
|
|
|
|
|
FViewInformes.Refresh;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorInformes.SetController(const Value: IInformesController);
|
|
|
|
|
|
begin
|
|
|
|
|
|
FController := Value;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorInformes.SetInformes(const Value: IBizInforme);
|
|
|
|
|
|
begin
|
|
|
|
|
|
FInformes := Value;
|
|
|
|
|
|
dsDataTable.DataTable := FInformes.DataTable;
|
2007-07-13 09:27:48 +00:00
|
|
|
|
|
|
|
|
|
|
ComprobarPrivilegios;
|
|
|
|
|
|
|
2007-07-10 17:33:08 +00:00
|
|
|
|
if Assigned(FViewInformes) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
FViewInformes.Informes := FInformes;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorInformes.actModificarExecute(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
try
|
|
|
|
|
|
FController.Ver(FInformes);
|
|
|
|
|
|
finally
|
|
|
|
|
|
FViewInformes.Refresh;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorInformes.FormShow(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
|
|
|
|
|
|
if not Assigned(FInformes) then
|
|
|
|
|
|
raise Exception.Create('No hay ninguna informe asociado');
|
|
|
|
|
|
|
|
|
|
|
|
if not Assigned(FViewInformes) then
|
|
|
|
|
|
raise Exception.Create('No hay ninguna vista asignada');
|
|
|
|
|
|
|
|
|
|
|
|
if not Assigned(FController) then
|
|
|
|
|
|
raise Exception.Create('No hay ning<6E>n Controller asignado');
|
|
|
|
|
|
|
2007-08-03 12:00:20 +00:00
|
|
|
|
FViewInformes.OnDblClick := actModificar.OnExecute;
|
|
|
|
|
|
FViewInformes.PopupMenu := ViewPopupMenu;
|
2007-07-10 17:33:08 +00:00
|
|
|
|
|
|
|
|
|
|
Informes.DataTable.Active := True;
|
|
|
|
|
|
FViewInformes.Refresh;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
destructor TfEditorInformes.Destroy;
|
|
|
|
|
|
begin
|
|
|
|
|
|
FViewInformes := NIL;
|
|
|
|
|
|
FController := NIL;
|
|
|
|
|
|
FInformes := NIL;
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorInformes.EliminarInterno;
|
|
|
|
|
|
begin
|
|
|
|
|
|
// if not FController.EsModificable then
|
|
|
|
|
|
// ShowMessage('Este Controller no se puede borrar')
|
|
|
|
|
|
|
|
|
|
|
|
if (Application.MessageBox('<27>Desea borrar este informe?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
FController.Eliminar(FInformes);
|
|
|
|
|
|
FViewInformes.Refresh;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorInformes.actPropiedadesExecute(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
{
|
|
|
|
|
|
if Assigned(FController) then
|
|
|
|
|
|
try
|
|
|
|
|
|
FController.VerPropiedades;
|
|
|
|
|
|
actGuardar.Execute;
|
|
|
|
|
|
finally
|
|
|
|
|
|
FViewController.Refresh;
|
|
|
|
|
|
end;
|
|
|
|
|
|
}
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorInformes.actPropiedadesUpdate(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
{
|
|
|
|
|
|
if Assigned(dsDataTable.DataTable) then
|
|
|
|
|
|
(Sender as TAction).Enabled := (not dsDataTable.DataTable.IsEmpty)
|
|
|
|
|
|
and not (dsDataTable.DataTable.State = dsInsert)
|
|
|
|
|
|
else
|
|
|
|
|
|
(Sender as TAction).Enabled := False;
|
|
|
|
|
|
}
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2007-07-13 09:27:48 +00:00
|
|
|
|
procedure TfEditorInformes.ComprobarPrivilegios;
|
|
|
|
|
|
begin
|
|
|
|
|
|
if not dmUsuarios.EsAdministrador then
|
|
|
|
|
|
begin
|
|
|
|
|
|
actNuevo.Enabled := False;
|
|
|
|
|
|
actNuevo.Visible := False;
|
|
|
|
|
|
actEliminar.Enabled := False;
|
|
|
|
|
|
actEliminar.Visible := False;
|
|
|
|
|
|
actPropiedades.Enabled := False;
|
|
|
|
|
|
actPropiedades.Visible := False;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2007-07-10 17:33:08 +00:00
|
|
|
|
constructor TfEditorInformes.Create(AOwner: TComponent);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
FViewInformes := frViewInformes1;
|
|
|
|
|
|
actModificar.ShortCut := ShortCut(VK_RETURN, []);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
end.
|