git-svn-id: https://192.168.0.254/svn/Proyectos.LuisLeon_FactuGES/trunk@156 c93665c3-c93d-084d-9b98-7d5f4a9c3376
246 lines
6.7 KiB
ObjectPascal
246 lines
6.7 KiB
ObjectPascal
unit uEditorInformeBase;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, uEditorDBItem, DB, uDADataTable, JvAppStorage,
|
||
JvAppRegistryStorage, JvComponentBase, JvFormPlacement, ImgList,
|
||
PngImageList, StdActns, ActnList, ComCtrls, TBX, TB2Item, TB2Dock,
|
||
TB2Toolbar, ExtCtrls, JvExControls, JvComponent, JvNavigationPane,
|
||
uBizInformes, schInformesClient_Intf, uViewInformeBase, JvExComCtrls,
|
||
JvStatusBar, pngimage, TB2ExtItems, TBXExtItems;
|
||
|
||
type
|
||
IEditorInformeBase = interface(IEditorDBItem)
|
||
['{E8DB0818-75F8-4575-A30E-25B6599A757F}']
|
||
function GetInforme: IBizInforme;
|
||
procedure SetInforme(const Value: IBizInforme);
|
||
property Informe: IBizInforme read GetInforme write SetInforme;
|
||
end;
|
||
|
||
|
||
TfEditorInformeBase = class(TfEditorDBItem, IEditorInformeBase)
|
||
actPropiedades: TAction;
|
||
TBXSeparatorItem14: TTBXSeparatorItem;
|
||
tbxiPropiedades: TTBXItem;
|
||
tbxiPropiedades2: TTBXItem;
|
||
tbxFiltro: TTBXToolbar;
|
||
TBXLabelItem1: TTBXLabelItem;
|
||
tbxEditFiltro: TTBXEditItem;
|
||
TBXItem34: TTBXItem;
|
||
actQuitarFiltro: TAction;
|
||
procedure actPropiedadesExecute(Sender: TObject);
|
||
procedure actGuardarCerrarUpdate(Sender: TObject);
|
||
procedure actGuardarUpdate(Sender: TObject);
|
||
procedure actPrevisualizarExecute(Sender: TObject);
|
||
procedure actImprimirExecute(Sender: TObject);
|
||
procedure actEliminarExecute(Sender: TObject);
|
||
procedure actQuitarFiltroExecute(Sender: TObject);
|
||
procedure tbxEditFiltroChange(Sender: TObject; const Text: string);
|
||
|
||
private
|
||
procedure ComprobarPrivilegios;
|
||
|
||
protected
|
||
Cadena:string;
|
||
FInforme : IBizInforme;
|
||
FViewInforme : IViewInformeBase;
|
||
function GetInforme: IBizInforme; virtual;
|
||
procedure SetInforme(const Value: IBizInforme); virtual;
|
||
// function GetModified: Boolean; override;
|
||
procedure RellenarCabeceraInforme; virtual;
|
||
function GetModified: Boolean; override;
|
||
|
||
procedure RestaurarConfiguracion; virtual;
|
||
|
||
|
||
public
|
||
procedure PonerTitulos(const ATitulo: string = ''); override;
|
||
property Informe: IBizInforme read GetInforme write SetInforme;
|
||
|
||
end;
|
||
|
||
implementation
|
||
|
||
uses uEditorDBBase, uEditorBase, uDataModuleUsuarios, uFormPropiedadesInforme,
|
||
uViewGridBase, cxFilter;
|
||
|
||
{$R *.dfm}
|
||
|
||
{ TfEditorControlBase }
|
||
|
||
function TfEditorInformeBase.GetInforme: IBizInforme;
|
||
begin
|
||
Result := FInforme;
|
||
end;
|
||
|
||
function TfEditorInformeBase.GetModified: Boolean;
|
||
begin
|
||
if not dmUsuarios.EsAdministrador then
|
||
Result := False
|
||
else
|
||
Result := inherited GetModified;
|
||
end;
|
||
|
||
procedure TfEditorInformeBase.SetInforme(const Value: IBizInforme);
|
||
begin
|
||
FInforme := Value;
|
||
dsDataTable.DataTable := FInforme.DataTable;
|
||
|
||
ComprobarPrivilegios;
|
||
|
||
if Assigned(FViewInforme) then
|
||
FViewInforme.Informe := FInforme;
|
||
end;
|
||
|
||
procedure TfEditorInformeBase.tbxEditFiltroChange(Sender: TObject; const Text: string);
|
||
begin
|
||
inherited;
|
||
if not Assigned(FViewInforme) then
|
||
Exit;
|
||
|
||
if Length(Text) > 0 then
|
||
begin
|
||
//La aplicaci<63>n de los filtros aqui cambia el orden, ya que antes de aplicar el filtro establecido en el
|
||
//campo de filtro por el usuario hay que aplicar el propio del informe por ello siempre antes de aplicar el filtro
|
||
//que desea el usuario restauramos la configuraci<63>n inicial.
|
||
RestaurarConfiguracion;
|
||
FViewInforme.Filter := Text
|
||
end
|
||
else
|
||
actQuitarFiltro.Execute;
|
||
end;
|
||
|
||
procedure TfEditorInformeBase.actPropiedadesExecute(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
|
||
with TfrPropiedadesInforme.Create(NIL) do
|
||
try
|
||
Nombre := FInforme.NOMBRE;
|
||
Descripcion := FInforme.DESCRIPCION;
|
||
Modificable := True; //FInforme.EsModificable;
|
||
Icono := FInforme.ICONO;
|
||
if (ShowModal = mrOK) then
|
||
begin
|
||
FInforme.DataTable.Edit;
|
||
FInforme.NOMBRE := Nombre;
|
||
FInforme.DESCRIPCION := Descripcion;
|
||
FInforme.ICONO := Icono;
|
||
if Modificable then
|
||
FInforme.MODIFICABLE := 'S'
|
||
else
|
||
FInforme.MODIFICABLE := 'N';
|
||
end;
|
||
finally
|
||
Free;
|
||
ActualizarEstadoEditor;
|
||
// FViewInforme.Modificable := FInforme.EsModificable;
|
||
end;
|
||
end;
|
||
|
||
procedure TfEditorInformeBase.actQuitarFiltroExecute(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
if Assigned(FViewInforme) then
|
||
begin
|
||
tbxEditFiltro.Text := '';
|
||
FViewInforme.Filter := '';
|
||
//Esto al igual que en resto de las partes cambiar<61> ya que siempre que se quite el filtro
|
||
//se debe limpiar para que no queden rastros y restaurar la configuraci<63>n del informe con el filtro
|
||
//de dicho informe
|
||
FViewInforme._FocusedView.DataController.Filter.Root.Clear;
|
||
RestaurarConfiguracion;
|
||
end;
|
||
end;
|
||
|
||
procedure TfEditorInformeBase.ComprobarPrivilegios;
|
||
begin
|
||
if not dmUsuarios.EsAdministrador then
|
||
begin
|
||
actGuardarCerrar.Enabled := False;
|
||
actGuardarCerrar.Visible := False;
|
||
actGuardar.Enabled := False;
|
||
actGuardar.Visible := False;
|
||
actEliminar.Enabled := False;
|
||
actEliminar.Visible := False;
|
||
actPropiedades.Enabled := False;
|
||
actPropiedades.Visible := False;
|
||
end;
|
||
end;
|
||
|
||
{
|
||
function TfEditorInformeBase.GetModified: Boolean;
|
||
begin
|
||
Result := inherited GetModified and
|
||
(Assigned(FInforme) and FInforme.EsModificable);
|
||
end;
|
||
}
|
||
|
||
procedure TfEditorInformeBase.PonerTitulos(const ATitulo: string);
|
||
var
|
||
FTitulo : String;
|
||
begin
|
||
FTitulo := ATitulo;
|
||
if (FTitulo = '') and Assigned(FInforme) then
|
||
begin
|
||
if FInforme.EsNuevo then
|
||
FTitulo := 'Nuevo informe' + ' - ' + FInforme.NOMBRE
|
||
else
|
||
FTitulo := 'Informe ' + ' - ' + FInforme.NOMBRE;
|
||
end;
|
||
|
||
inherited PonerTitulos(FTitulo);
|
||
|
||
Self.Caption := FTitulo + ' (' + dmUsuarios.EmpresaActual.NOMBRE + ')';
|
||
end;
|
||
|
||
procedure TfEditorInformeBase.actGuardarCerrarUpdate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
// (Sender as TAction).Enabled := Assigned(FInforme) and (FInforme.EsModificable);
|
||
end;
|
||
|
||
procedure TfEditorInformeBase.actGuardarUpdate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
// (Sender as TAction).Enabled := Assigned(FInforme) and (FInforme.EsModificable);
|
||
end;
|
||
|
||
procedure TfEditorInformeBase.actPrevisualizarExecute(Sender: TObject);
|
||
begin
|
||
RellenarCabeceraInforme;
|
||
inherited;
|
||
end;
|
||
|
||
procedure TfEditorInformeBase.RellenarCabeceraInforme;
|
||
begin
|
||
inherited;
|
||
//
|
||
end;
|
||
|
||
procedure TfEditorInformeBase.RestaurarConfiguracion;
|
||
begin
|
||
//
|
||
end;
|
||
|
||
procedure TfEditorInformeBase.actImprimirExecute(Sender: TObject);
|
||
begin
|
||
RellenarCabeceraInforme;
|
||
inherited;
|
||
end;
|
||
|
||
|
||
procedure TfEditorInformeBase.actEliminarExecute(Sender: TObject);
|
||
begin
|
||
{
|
||
if not FInforme.EsModificable then
|
||
ShowMessage('Este control no se puede eliminar')
|
||
else
|
||
inherited
|
||
}
|
||
end;
|
||
|
||
end.
|