{
===============================================================================
  Copyright (©) 2001. Rodax Software.
===============================================================================
  Los contenidos de este fichero son propiedad de Rodax Software titular del
  copyright. Este fichero sólo podrá ser copiado, distribuido y utilizado,
  en su totalidad o en parte, con el permiso escrito de Rodax Software, o de
  acuerdo con los términos y condiciones establecidas en el acuerdo/contrato
  bajo el que se suministra.
  -----------------------------------------------------------------------------
  Web:  www.rodax-software.com
===============================================================================
  Fecha primera versión: 11-08-2002
  Versión actual: 1.0.3
  Fecha versión actual: 30-06-2004
===============================================================================
  Modificaciones:

    Fecha         Comentarios
    ---------------------------------------------------------------------------
    09-03-2003    p253. En el listado de presupuesto de cliente añadir la
                  columna de factura para ver si el presupuesto está
                  facturado o no.

    10-03-2003    p259. Informe con la lista de todos los presupuestos
                  de cliente.

    30-06-2004    p272. Adaptación a multiempresa.

    30-06-2004    p274. Migración a FastReport.
===============================================================================
}

unit InfEstReportBeneficios;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  InformeBase, IBDatabase, Db, FR_IBXDB, FR_Shape, FR_Class, FR_DSet,
  FR_DBSet, IBCustomDataSet, IBQuery, Tipos, RxMemDS, DBTables, MemTable;

type
  TdmInfEstReportBeneficios = class(TdmInformeBase)
    frdsTablaGeneral: TfrDBDataSet;
    TMemGeneral: TRxMemoryData;
  private
    FAno1: Variant;
    FAno2: Variant;
    FA1T1: Variant;
    FA1T2: Variant;
    FA1T3: Variant;
    FA1T4: Variant;
    FA2T1: Variant;
    FA2T2: Variant;
    FA2T3: Variant;
    FA2T4: Variant;
    FA3T1: Variant;
    FA3T2: Variant;
    FA3T3: Variant;
    FFichero: Variant;

  protected
    procedure PrepararConsultas; override;
    procedure RellenarBanda(Band: TfrBand); override;
  public
    function setDatosGeneral(const Datos: TRxMemoryData): Boolean;

    constructor Create(AOwner: TComponent); override;
  published
    property Ano1 : Variant read FAno1 write FAno1;
    property Ano2 : Variant read FAno2 write FAno2;
    property A1T1 : Variant read FA1T1 write FA1T1;
    property A1T2 : Variant read FA1T2 write FA1T2;
    property A1T3 : Variant read FA1T3 write FA1T3;
    property A1T4 : Variant read FA1T4 write FA1T4;
    property A2T1 : Variant read FA2T1 write FA2T1;
    property A2T2 : Variant read FA2T2 write FA2T2;
    property A2T3 : Variant read FA2T3 write FA2T3;
    property A2T4 : Variant read FA2T4 write FA2T4;    
    property A3T1 : Variant read FA3T1 write FA3T1;
    property A3T2 : Variant read FA3T2 write FA3T2;
    property A3T3 : Variant read FA3T3 write FA3T3;
    property Fichero : Variant read FFichero write FFichero;
  end;

var
  dmInfEstReportBeneficios: TdmInfEstReportBeneficios;

implementation

{$R *.DFM}

{ TdmInformeListadoFacturasCli }

uses
  RdxEmpresaActiva, Literales;

constructor TdmInfEstReportBeneficios.Create(
  AOwner: TComponent);
begin
  inherited;
  FAno1 := NULL;
  FAno2 := NULL;

  FNombreInforme := 'ListadoInfEstBeneficios.frf';
end;

procedure TdmInfEstReportBeneficios.PrepararConsultas;
begin
//
end;

procedure TdmInfEstReportBeneficios.RellenarBanda(Band: TfrBand);
var
  iCont : Integer;
  Objeto : TfrView;

begin
  inherited;

  with Band do
  begin
    if Name = 'CabeceraGeneral' then
    begin
       for iCont := 0 to Objects.Count - 1 do
       begin
          Objeto := Objects[iCont];

          if ((Objeto is TfrMemoView) and (Pos('Titulo1', Objeto.Name) > 0)) then
          begin
            with (Objeto as TfrMemoView) do
            begin
              Memo.Clear;
              Memo.Add('Valores del año ' + Ano1);
            end;
          end;

          if ((Objeto is TfrMemoView) and (Pos('Titulo2', Objeto.Name) > 0)) then
          begin
            with (Objeto as TfrMemoView) do
            begin
              Memo.Clear;
              if not VarIsNull(Ano2)
              then Memo.Add('Valores del año ' + Ano2);
            end
          end;

          if ((Objeto is TfrMemoView) and (Pos('Titulo3', Objeto.Name) > 0)) then
          begin
            with (Objeto as TfrMemoView) do
            begin
              Memo.Clear;
              if not VarIsNull(Ano2)
              then Memo.Add('Comparativa del año ' + Ano1 + ' respecto al año ' + Ano2);
            end
          end;
       end;
    end;

    if Name = 'PieGeneral' then
    begin
       for iCont := 0 to Objects.Count - 1 do
       begin
          Objeto := Objects[iCont];

          if ((Objeto is TfrMemoView) and (Pos('A1T1', Objeto.Name) > 0)) then
          begin
            with (Objeto as TfrMemoView) do
            begin
              Memo.Clear;
              Memo.Add(A1T1);
            end
          end
          else if ((Objeto is TfrMemoView) and (Pos('A1T2', Objeto.Name) > 0)) then
          begin
            with (Objeto as TfrMemoView) do
            begin
              Memo.Clear;
              Memo.Add(A1T2);
            end
          end
          else if ((Objeto is TfrMemoView) and (Pos('A1T3', Objeto.Name) > 0)) then
          begin
            with (Objeto as TfrMemoView) do
            begin
              Memo.Clear;
              Memo.Add(A1T3);
            end
          end
          else if ((Objeto is TfrMemoView) and (Pos('A1T4', Objeto.Name) > 0)) then
          begin
            with (Objeto as TfrMemoView) do
            begin
              Memo.Clear;
              Memo.Add(A1T4);
            end
          end

          else if ((Objeto is TfrMemoView) and (Pos('A2T1', Objeto.Name) > 0)) then
          begin
            with (Objeto as TfrMemoView) do
            begin
              Memo.Clear;
              Memo.Add(A2T1);
            end
          end
          else if ((Objeto is TfrMemoView) and (Pos('A2T2', Objeto.Name) > 0)) then
          begin
            with (Objeto as TfrMemoView) do
            begin
              Memo.Clear;
              Memo.Add(A2T2);
            end
          end
          else if ((Objeto is TfrMemoView) and (Pos('A2T3', Objeto.Name) > 0)) then
          begin
            with (Objeto as TfrMemoView) do
            begin
              Memo.Clear;
              Memo.Add(A2T3);
            end
          end
          else if ((Objeto is TfrMemoView) and (Pos('A2T4', Objeto.Name) > 0)) then
          begin
            with (Objeto as TfrMemoView) do
            begin
              Memo.Clear;
              Memo.Add(A2T4);
            end
          end

          else if ((Objeto is TfrMemoView) and (Pos('A3T1', Objeto.Name) > 0)) then
          begin
            with (Objeto as TfrMemoView) do
            begin
              Memo.Clear;
              Memo.Add(A3T1);
            end
          end
          else if ((Objeto is TfrMemoView) and (Pos('A3T2', Objeto.Name) > 0)) then
          begin
            with (Objeto as TfrMemoView) do
            begin
              Memo.Clear;
              Memo.Add(A3T2);
            end
          end
          else if ((Objeto is TfrMemoView) and (Pos('A3T3', Objeto.Name) > 0)) then
          begin
            with (Objeto as TfrMemoView) do
            begin
              Memo.Clear;
              Memo.Add(A3T3);
            end
          end;

          if ((Objeto is TfrPictureView) and (Pos('Grafico', Objeto.Name) > 0)) then
          begin
            with (Objeto as TfrPictureView) do
            begin
              Picture.LoadFromFile(Fichero);
            end
          end;
       end;
    end;

  end;

end;

function TdmInfEstReportBeneficios.setDatosGeneral(const Datos: TRxMemoryData): Boolean;
begin
  TMemGeneral.LoadFromDataSet(Datos, -1, lmCopy);
end;

end.
