git-svn-id: https://192.168.0.254/svn/Proyectos.Miguelo_FactuGES/trunk@4 172823e9-465a-9d4b-80ba-0a9f016f4eb1
215 lines
6.0 KiB
ObjectPascal
215 lines
6.0 KiB
ObjectPascal
unit InformePresupuestoCliente;
|
|
|
|
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, RdxEmpresaActiva, Entidades, VistaPreviaPresupuestos;
|
|
|
|
const
|
|
//Cambio de tamaño letra
|
|
CTE_TamLetraIni = 10;
|
|
CTE_TamLetraMin = 5;
|
|
CTE_TamLetraMax = 40;
|
|
CTE_TamLetraIntervalo = 2;
|
|
|
|
type
|
|
TdmInformePresupuestoCliente = class(TdmInformeBase)
|
|
TablaCab: TfrDBDataSet;
|
|
TablaDet: TfrDBDataSet;
|
|
TablaPresupuesto: TIBQuery;
|
|
TablaDetallesPresupuesto: TIBQuery;
|
|
TablaPropiedadesPresupuesto: TIBQuery;
|
|
TablaProp: TfrDBDataSet;
|
|
dsDetallesPresupuesto: TDataSource;
|
|
dsPropiedadesPresupuesto: TDataSource;
|
|
dsPresupuesto: TDataSource;
|
|
TablaPrecios1: TIBQuery;
|
|
TablaPrec1: TfrDBDataSet;
|
|
dsPrecios1: TDataSource;
|
|
private
|
|
//Cambio de tamaño letra
|
|
FVistaPrevia: TfrVistaPreviaPresupuestos;
|
|
FTamLetra: Integer;
|
|
|
|
FCodigoPresupuesto : Variant;
|
|
FEntidad: TRdxEntidad;
|
|
procedure SetEntidad(const Value: TRdxEntidad);
|
|
procedure SetVistaPrevia(const Value: TfrVistaPreviaPresupuestos);
|
|
|
|
//Cambio de tamaño letra
|
|
procedure actAmpliar(Sender: TObject);
|
|
procedure actDisminuir(Sender: TObject);
|
|
|
|
protected
|
|
procedure PrepararConsultas; override;
|
|
procedure PrepararInforme; override;
|
|
|
|
public
|
|
constructor Create(AOwner: TComponent); override;
|
|
published
|
|
|
|
//Cambio de tamaño letra
|
|
property VistaPrevia : TfrVistaPreviaPresupuestos read FVistaPrevia write SetVistaPrevia;
|
|
property TamLetra : Integer read FTamLetra write FTamLetra;
|
|
|
|
property CodigoPresupuesto : variant read FCodigoPresupuesto write FCodigoPresupuesto;
|
|
property Entidad : TRdxEntidad read FEntidad write SetEntidad;
|
|
end;
|
|
|
|
var
|
|
dmInformePresupuestoCliente: TdmInformePresupuestoCliente;
|
|
|
|
implementation
|
|
|
|
{$R *.dfm}
|
|
|
|
uses
|
|
StrFunc, Constantes;
|
|
|
|
{ TdmInformePresupuestoCliente }
|
|
|
|
procedure TdmInformePresupuestoCliente.actAmpliar(Sender: TObject);
|
|
begin
|
|
if TamLetra >= CTE_TamLetraMax then
|
|
Exit;
|
|
|
|
TamLetra := TamLetra + CTE_TamLetraIntervalo;
|
|
Previsualizar;
|
|
end;
|
|
|
|
procedure TdmInformePresupuestoCliente.actDisminuir(Sender: TObject);
|
|
begin
|
|
if TamLetra <= CTE_TamLetraMin then
|
|
Exit;
|
|
|
|
TamLetra := TamLetra - CTE_TamLetraIntervalo;
|
|
Previsualizar;
|
|
end;
|
|
|
|
constructor TdmInformePresupuestoCliente.Create(AOwner: TComponent);
|
|
begin
|
|
inherited;
|
|
TamLetra := CTE_TamLetraIni;
|
|
end;
|
|
|
|
procedure TdmInformePresupuestoCliente.PrepararConsultas;
|
|
begin
|
|
inherited;
|
|
|
|
with TablaPresupuesto do
|
|
begin
|
|
Database := FBaseDatos;
|
|
Transaction := FTransaccion;
|
|
SQL.Clear;
|
|
SQL.Add('select * from PRESUPUESTOSCLIENTE ');
|
|
SQL.Add('where CODIGO = :CODIGO');
|
|
ParamByName('CODIGO').AsString := FCodigoPresupuesto;
|
|
Prepare;
|
|
Open;
|
|
end;
|
|
|
|
with TablaDetallesPresupuesto do
|
|
begin
|
|
Database := FBaseDatos;
|
|
Transaction := FTransaccion;
|
|
SQL.Clear;
|
|
SQL.Add('select * from DETALLESPRESUPUESTOSARTICULOS ');
|
|
SQL.Add('where CODIGOPRESUPUESTO = :CODIGO ');
|
|
|
|
case Entidad of
|
|
entPresupuestoCocina,
|
|
entPresupuestoBano : SQL.Add('and NUMCONCEPTO = 0');
|
|
|
|
entPresupuestoArmarios : SQL.Add('and NUMCONCEPTO < 2');
|
|
end;
|
|
Params.ParseSQL(SQL.Text, True);
|
|
Prepare;
|
|
Open;
|
|
end;
|
|
|
|
with TablaPropiedadesPresupuesto do
|
|
begin
|
|
Database := FBaseDatos;
|
|
Transaction := FTransaccion;
|
|
SQL.Clear;
|
|
SQL.Add('select CODIGOPRESUPUESTO, NUMCONCEPTO, NUMPROPIEDAD, ');
|
|
SQL.Add('PROP.DESCRIPCION as DESCRIPCION, CODIGOPROPIEDAD, VALOR ');
|
|
SQL.Add('from DETALLESPRESUPUESTOSPROPIEDADES, PROPIEDADES PROP ');
|
|
SQL.Add('where CODIGOPRESUPUESTO = :CODIGOPRESUPUESTO and ');
|
|
SQL.Add('NUMCONCEPTO = :NUMCONCEPTO and ');
|
|
SQL.Add('PROP.CODIGO = CODIGOPROPIEDAD ');
|
|
SQL.Add('order by NUMPROPIEDAD');
|
|
Params.ParseSQL(SQL.Text, True);
|
|
Prepare;
|
|
Open;
|
|
end;
|
|
|
|
TablaCab.Open;
|
|
TablaDet.Open;
|
|
TablaProp.Open;
|
|
|
|
with TablaPrecios1 do
|
|
begin
|
|
Database := FBaseDatos;
|
|
Transaction := FTransaccion;
|
|
SQL.Clear;
|
|
SQL.Add('select * ');
|
|
SQL.Add('from DETALLESPRESUPUESTOSARTICULOS ');
|
|
SQL.Add('where CODIGOPRESUPUESTO = :CODIGO ');
|
|
SQL.Add('and TIPOCONCEPTO = ''PRECIO'' ');
|
|
SQL.Add('order by NUMCONCEPTO');
|
|
Params.ParseSQL(SQL.Text, True);
|
|
Prepare;
|
|
Open;
|
|
end;
|
|
TablaPrec1.Open;
|
|
end;
|
|
|
|
procedure TdmInformePresupuestoCliente.PrepararInforme;
|
|
begin
|
|
inherited;
|
|
if Entidad = entPresupuestoCocina then
|
|
if esCadenaVacia(TablaPresupuesto.FieldByName('DESGLOSES').AsVariant) then
|
|
FReport.Pages.Pages[1].Visible := False;
|
|
|
|
FReport.Dictionary.Variables.Value[1] := TamLetra;
|
|
end;
|
|
|
|
procedure TdmInformePresupuestoCliente.SetEntidad(const Value: TRdxEntidad);
|
|
begin
|
|
if FEntidad = Value then
|
|
Exit;
|
|
FEntidad := Value;
|
|
case FEntidad of
|
|
entPresupuestoCocina : begin
|
|
FNombreInforme := 'PresupuestoCocina.frf';
|
|
FVistaPrevia.bAmpliar.Visible := True;
|
|
FVistaPrevia.bDisminuir.Visible := True;
|
|
end;
|
|
entPresupuestoBano : FNombreInforme := 'PresupuestoBano.frf';
|
|
entPresupuestoArmarios : FNombreInforme := 'PresupuestoArmarios.frf';
|
|
entPresupuestoReforma : begin
|
|
FNombreInforme := 'PresupuestoReforma.frf';
|
|
FVistaPrevia.bAmpliar.Visible := True;
|
|
FVistaPrevia.bDisminuir.Visible := True;
|
|
end;
|
|
else
|
|
FNombreInforme := 'PresupuestoCliente.frf';
|
|
end;
|
|
end;
|
|
|
|
procedure TdmInformePresupuestoCliente.SetVistaPrevia(const Value: TfrVistaPreviaPresupuestos);
|
|
begin
|
|
FVistaPrevia := Value;
|
|
|
|
if Assigned(FVistaPrevia) then
|
|
begin
|
|
FVistaPrevia.bAmpliar.OnClick := actAmpliar;
|
|
FVistaPrevia.bDisminuir.OnClick := actDisminuir;
|
|
end;
|
|
end;
|
|
|
|
end.
|