266 lines
8.2 KiB
ObjectPascal
266 lines
8.2 KiB
ObjectPascal
|
|
{
|
|||
|
|
===============================================================================
|
|||
|
|
Copyright (<EFBFBD>) 2002. Rodax Software.
|
|||
|
|
===============================================================================
|
|||
|
|
Los contenidos de este fichero son propiedad de Rodax Software titular del
|
|||
|
|
copyright. Este fichero s<EFBFBD>lo podr<EFBFBD> ser copiado, distribuido y utilizado,
|
|||
|
|
en su totalidad o en parte, con el permiso escrito de Rodax Software, o de
|
|||
|
|
acuerdo con los t<EFBFBD>rminos y condiciones establecidas en el acuerdo/contrato
|
|||
|
|
bajo el que se suministra.
|
|||
|
|
-----------------------------------------------------------------------------
|
|||
|
|
Web: www.rodax-software.com
|
|||
|
|
===============================================================================
|
|||
|
|
Fecha primera versi<EFBFBD>n: 31-12-2002
|
|||
|
|
Versi<EFBFBD>n actual: 1.0.1
|
|||
|
|
Fecha versi<EFBFBD>n actual: 30-01-2004
|
|||
|
|
===============================================================================
|
|||
|
|
Modificaciones:
|
|||
|
|
|
|||
|
|
Fecha Comentarios
|
|||
|
|
---------------------------------------------------------------------------
|
|||
|
|
30-01-2004 Se utiliza el trimestre por defecto.
|
|||
|
|
===============================================================================
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
unit ImprimirLibro;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
|||
|
|
RDXFRAME, StdCtrls, RdxComboBox, RdxBotones, RdxCampos,
|
|||
|
|
ExtCtrls, RdxBarras, RdxTitulos, InformeLibro, Configuracion,
|
|||
|
|
Grids, DBGrids, RdxPaneles, RdxRadioButton, VistaPrevia, AdvPanel,
|
|||
|
|
cxDBEdit, cxControls, cxContainer, cxEdit, cxTextEdit, cxMaskEdit,
|
|||
|
|
cxButtonEdit, cxDropDownEdit, cxCalendar, DB,
|
|||
|
|
cxLookupEdit, cxDBLookupEdit, cxDBLookupComboBox, IBCustomDataSet,
|
|||
|
|
RdxShape, TablaTrimestres, Entidades, cxGraphics;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
TfrImprimirLibro = class(TRdxFrame)
|
|||
|
|
pnlVistaPrevia: TPanel;
|
|||
|
|
pnlCuerpo: TPanel;
|
|||
|
|
pnlInforme: TAdvPanel;
|
|||
|
|
pnlTitulo: TRdxPanelTituloOperacion;
|
|||
|
|
eLibro: TLabel;
|
|||
|
|
dsLibros: TDataSource;
|
|||
|
|
cbxLibro: TcxComboBox;
|
|||
|
|
RdxShape1: TRdxShape;
|
|||
|
|
rbTrimestre: TRdxRadioButton;
|
|||
|
|
cbxTrimestres: TcxComboBox;
|
|||
|
|
rbFechas: TRdxRadioButton;
|
|||
|
|
FechaInicial: TcxDateEdit;
|
|||
|
|
eFechaFin: TLabel;
|
|||
|
|
FechaFinal: TcxDateEdit;
|
|||
|
|
procedure bCancelarClick(Sender: TObject);
|
|||
|
|
procedure bImprimirClick(Sender: TObject);
|
|||
|
|
procedure rbTrimestreClick(Sender: TObject);
|
|||
|
|
procedure rbFechasClick(Sender: TObject);
|
|||
|
|
procedure cbxTrimestresPropertiesEditValueChanged(Sender: TObject);
|
|||
|
|
procedure FechaInicialPropertiesValidate(Sender: TObject;
|
|||
|
|
var DisplayValue: Variant; var ErrorText: TCaption;
|
|||
|
|
var Error: Boolean);
|
|||
|
|
procedure FechaFinalPropertiesValidate(Sender: TObject;
|
|||
|
|
var DisplayValue: Variant; var ErrorText: TCaption;
|
|||
|
|
var Error: Boolean);
|
|||
|
|
procedure cbxLibroPropertiesEditValueChanged(Sender: TObject);
|
|||
|
|
private
|
|||
|
|
FTipoLibro : Variant;
|
|||
|
|
FFechaInicial : TDateTime;
|
|||
|
|
FFechaFinal : TDateTime;
|
|||
|
|
FInformeLibro : TdmInformeLibro;
|
|||
|
|
FVistaPrevia : TfrVistaPrevia;
|
|||
|
|
FListaTipoLibro : TStringList;
|
|||
|
|
FListaLibroTipo: TStringList;
|
|||
|
|
FListaTrimestres : TListaTrimestres;
|
|||
|
|
procedure Refresco;
|
|||
|
|
protected
|
|||
|
|
procedure SetTipoLibro (const Value : Variant);
|
|||
|
|
procedure SetFechaFinal(const Value: TDateTime);
|
|||
|
|
procedure SetFechaInicial(const Value: TDateTime);
|
|||
|
|
function CloseFrame : Boolean; override;
|
|||
|
|
function CambiarEntidad(EntidadAnterior, Entidad : TRdxEntidad): Boolean; override;
|
|||
|
|
public
|
|||
|
|
constructor Create(AOwner : TComponent); override;
|
|||
|
|
destructor Destroy; override;
|
|||
|
|
property TipoLibro: Variant read FTipoLibro write SetTipoLibro;
|
|||
|
|
property FechaIni: TDateTime read FFechaInicial write SetFechaInicial;
|
|||
|
|
property FechaFin: TDateTime read FFechaFinal write SetFechaFinal;
|
|||
|
|
published
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
var
|
|||
|
|
frImprimirLibro: TfrImprimirLibro;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
{$R *.DFM}
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Variants, RdxFrameFacturasCliente, FacturasClientes,
|
|||
|
|
DateFunc, Clientes, TablaFacturasCliente, Mensajes, StrFunc, InformeBase,
|
|||
|
|
TablaLibros, BaseDatos, Literales, cxDateUtils;
|
|||
|
|
|
|||
|
|
constructor TfrImprimirLibro.Create(AOwner : TComponent);
|
|||
|
|
begin
|
|||
|
|
inherited Create(AOwner);
|
|||
|
|
Entidad := entListadoLibros;
|
|||
|
|
|
|||
|
|
FVistaPrevia := TfrVistaPrevia.Create(Self);
|
|||
|
|
FVistaPrevia.Parent := pnlVistaPrevia;
|
|||
|
|
FInformeLibro := TdmInformeLibro.Create(Self);
|
|||
|
|
FInformeLibro.Preview := FVistaPrevia.Preview;
|
|||
|
|
|
|||
|
|
FListaLibroTipo := TStringList.Create;
|
|||
|
|
FListaTipoLibro := TStringList.Create;
|
|||
|
|
|
|||
|
|
dmTablaLibros.darLibros(FListaLibroTipo, FListaTipoLibro);
|
|||
|
|
cbxLibro.Properties.Items := dmTablaLibros.darLibros;
|
|||
|
|
cbxLibro.EditText := cbxLibro.Properties.Items[0];
|
|||
|
|
|
|||
|
|
FListaTrimestres := TListaTrimestres.Create(tlcTriTodos);
|
|||
|
|
cbxTrimestres.ItemIndex := FListaTrimestres.cargarLista(cbxTrimestres.Properties.Items);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrImprimirLibro.bCancelarClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
CloseFrame;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
destructor TfrImprimirLibro.Destroy;
|
|||
|
|
begin
|
|||
|
|
FInformeLibro.Free;
|
|||
|
|
FListaTipoLibro.Free;
|
|||
|
|
FListaLibroTipo.Free;
|
|||
|
|
|
|||
|
|
FListaTrimestres.Free;
|
|||
|
|
FListaTrimestres := Nil;
|
|||
|
|
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrImprimirLibro.bImprimirClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
FInformeLibro.Imprimir;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrImprimirLibro.CloseFrame: Boolean;
|
|||
|
|
begin
|
|||
|
|
FInformeLibro.Preview := NIL;
|
|||
|
|
(FVistaPrevia as TRdxFrame).CloseFrame;
|
|||
|
|
Result := inherited CloseFrame;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrImprimirLibro.Refresco;
|
|||
|
|
begin
|
|||
|
|
FInformeLibro.FechaInicio := FechaInicial.Date;
|
|||
|
|
FInformeLibro.FechaFin := FechaFinal.Date;
|
|||
|
|
FInformeLibro.TipoLibro := TipoLibro;
|
|||
|
|
FInformeLibro.Previsualizar;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrImprimirLibro.SetTipoLibro(const Value: Variant);
|
|||
|
|
begin
|
|||
|
|
if not esCadenaVacia(Value) and (TipoLibro <> Value) then
|
|||
|
|
begin
|
|||
|
|
FTipoLibro := Value;
|
|||
|
|
cbxLibro.ItemIndex := cbxLibro.Properties.Items.IndexOf(FListaTipoLibro.Values[Value]);
|
|||
|
|
Refresco;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrImprimirLibro.SetFechaFinal(const Value: TDateTime);
|
|||
|
|
begin
|
|||
|
|
FFechaFinal := Value;
|
|||
|
|
FechaFinal.Date := FechaFin;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrImprimirLibro.SetFechaInicial(const Value: TDateTime);
|
|||
|
|
begin
|
|||
|
|
FFechaInicial := Value;
|
|||
|
|
FechaInicial.Date := FechaIni;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrImprimirLibro.rbTrimestreClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
cbxTrimestres.Enabled := True;
|
|||
|
|
FechaInicial.Enabled := False;
|
|||
|
|
FechaFinal.Enabled := False;
|
|||
|
|
cbxTrimestresPropertiesEditValueChanged(Sender);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrImprimirLibro.rbFechasClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
cbxTrimestres.Enabled := False;
|
|||
|
|
FechaInicial.Enabled := True;
|
|||
|
|
FechaFinal.Enabled := True;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrImprimirLibro.cbxTrimestresPropertiesEditValueChanged(
|
|||
|
|
Sender: TObject);
|
|||
|
|
var
|
|||
|
|
i : integer;
|
|||
|
|
FCodigoTrimestre : String;
|
|||
|
|
begin
|
|||
|
|
FCodigoTrimestre := FListaTrimestres.getCodItem(cbxTrimestres.ItemIndex);
|
|||
|
|
FechaInicial.Date := dmTablaTrimestres.darFechaIniTrimestre(FCodigoTrimestre);
|
|||
|
|
FechaFinal.Date := dmTablaTrimestres.darFechaFinTrimestre(FCodigoTrimestre);
|
|||
|
|
Refresco;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrImprimirLibro.FechaInicialPropertiesValidate(Sender: TObject;
|
|||
|
|
var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
|
|||
|
|
var
|
|||
|
|
ADate : TDateTime;
|
|||
|
|
begin
|
|||
|
|
try
|
|||
|
|
if DisplayValue > FechaFinal.Date then
|
|||
|
|
begin
|
|||
|
|
ErrorText := msgFechasMal;
|
|||
|
|
Error := True;
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
TextToDateEx(DisplayValue, ADate);
|
|||
|
|
FechaInicial.Date := ADate;
|
|||
|
|
Refresco;
|
|||
|
|
except
|
|||
|
|
Error := True;
|
|||
|
|
ErrorText := msgFechaNoValida;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrImprimirLibro.FechaFinalPropertiesValidate(Sender: TObject;
|
|||
|
|
var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
|
|||
|
|
var
|
|||
|
|
ADate : TDateTime;
|
|||
|
|
begin
|
|||
|
|
try
|
|||
|
|
if DisplayValue < FechaInicial.Date then
|
|||
|
|
begin
|
|||
|
|
ErrorText := msgFechasMal;
|
|||
|
|
Error := True;
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
TextToDateEx(DisplayValue, ADate);
|
|||
|
|
FechaFinal.Date := ADate;
|
|||
|
|
Refresco;
|
|||
|
|
except
|
|||
|
|
Error := True;
|
|||
|
|
ErrorText := msgFechaNoValida;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrImprimirLibro.cbxLibroPropertiesEditValueChanged(
|
|||
|
|
Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
TipoLibro := FListaLibroTipo.Values[cbxLibro.Text];
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrImprimirLibro.CambiarEntidad(EntidadAnterior, Entidad: TRdxEntidad): Boolean;
|
|||
|
|
begin
|
|||
|
|
inherited CambiarEntidad(EntidadAnterior, Entidad);
|
|||
|
|
ConfigurarFrame(Self, Self.Entidad);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|