This repository has been archived on 2024-11-28. You can view files and clone it, but cannot push or open issues or pull requests.
Miguelo_FactuGES/Informes/InformeBeneficiosAnualesContratos.pas
2007-06-25 15:19:31 +00:00

102 lines
2.8 KiB
ObjectPascal

unit InformeBeneficiosAnualesContratos;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, InformeBase, FR_IBXDB, FR_Shape, FR_DSet, FR_DBSet, FR_Class,
DB, IBCustomDataSet, IBQuery, FR_Cross, IBDatabase, RdxEmpresaActiva;
type
TdmInformeBeneficiosAnualesContratos = class(TdmInformeBase)
TablaCon: TfrDBDataSet;
TablaContratos: TIBQuery;
frCrossObject1: TfrCrossObject;
procedure FReportBeforePrint(Memo: TStringList; View: TfrView);
private
FFechaInicio : Variant;
FFechaFin : Variant;
protected
procedure RellenarCabecera(Band: TfrBand); override;
procedure PrepararConsultas; override;
public
constructor Create(AOwner: TComponent); override;
published
property FechaInicio : Variant read FFechaInicio write FFechaInicio;
property FechaFin : Variant read FFechaFin write FFechaFin;
end;
var
dmInformeBeneficiosAnualesContratos: TdmInformeBeneficiosAnualesContratos;
implementation
{$R *.dfm}
uses
StrFunc, DateFunc;
{ TdmInformeBase1 }
constructor TdmInformeBeneficiosAnualesContratos.Create(AOwner: TComponent);
begin
inherited;
FNombreInforme := 'InformeBeneficiosAnualesContratos.frf';
FReport.OnBeforePrint := FReportBeforePrint;
end;
procedure TdmInformeBeneficiosAnualesContratos.PrepararConsultas;
begin
inherited;
with TablaContratos do
begin
Database := FBaseDatos;
Transaction := FTransaccion;
SQL.Clear;
SQL.Add('select extract(month from c.FECHACONTRATO), d.descripcion, c.IMPORTETOTAL ');
SQL.Add('from CONTRATOSCLIENTE c, DOCUMENTOS d');
SQL.Add('where c.CODIGODOCUMENTO = d.CODIGO');
SQL.Add('and c.FECHACONTRATO between :FECHAINI and :FECHAFIN');
ParamByName('FECHAINI').AsString := FFechaInicio;
ParamByName('FECHAFIN').AsString := FFechaFin;
Prepare;
end;
end;
procedure TdmInformeBeneficiosAnualesContratos.RellenarCabecera(Band: TfrBand);
var
iCont : Integer;
Objeto : TfrView;
begin
inherited;
with Band do
begin
for iCont := 0 to Objects.Count - 1 do
begin
Objeto := Objects[iCont];
if ((Objeto is TfrMemoView) and (Objeto.Name = 'CabParametros')) then
begin
with (Objeto as TfrMemoView) do
begin
Memo.Clear;
Memo.Add('Empresa: ' + EmpresaActiva.NombreComercial);
Memo.Add('Rango de fechas: ' + FechaInicio + ' - ' + FechaFin);
end;
end;
end;
end;
end;
procedure TdmInformeBeneficiosAnualesContratos.FReportBeforePrint(Memo: TStringList; View: TfrView);
begin
inherited;
if (View.FormatStr = '#0')
and (StrToIntDef(View.Memo.CommaText, -1) <> -1) then
View.Memo.Text := DarMes(StrToIntDef(View.Memo.CommaText, -1));
end;
end.