jymy788 |
30-07-2007 15:29:28 |
buenas de nuevo.
Supongo que será porque estoy colapsado pero no puedo hacerlo en el BeforePrint de la banda a menos que haya ido haciendo lo propio en las bandas anteriores y no lo puedo hacer así porque las bandas anteriores tienen TQRDBText de los que no se obtener el valor.
Te pongo el código fuente a ver si se te ocurre qué le está pasando o si tengo que rehacerlo y por qué
Código:
unit impresion;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, jpeg, ExtCtrls, DB, DBTables, QuickRpt,
QRCtrls;
type
TForm3 = class(TForm)
PrintDialog1: TPrintDialog;
QUtil: TQuery;
qClientes: TQuery;
QuickRep1: TQuickRep;
qDecoracion: TQuery;
QRBand1: TQRBand;
QRSubDetail1: TQRSubDetail;
QRDBText1: TQRDBText;
QRDireccion1: TQRLabel;
QRNombre: TQRLabel;
QRDireccion2: TQRLabel;
QRImage2: TQRImage;
QRDBText2: TQRDBText;
QRDBText3: TQRDBText;
QRDBText4: TQRDBText;
QRLabel7: TQRLabel;
QRGroup1: TQRGroup;
QRLabel1: TQRLabel;
QRLabel3: TQRLabel;
QRLabel4: TQRLabel;
QRLabel5: TQRLabel;
QRLabel6: TQRLabel;
QRTitle1: TQRLabel;
QRRef: TQRLabel;
QRArticulo: TQRLabel;
QRPrecio1: TQRLabel;
QRLabel2: TQRLabel;
qAccesorios: TQuery;
QRGroup2: TQRGroup;
QRLabel8: TQRLabel;
QRSubDetail2: TQRSubDetail;
QRDBText5: TQRDBText;
QRDBText6: TQRDBText;
QRLabel9: TQRLabel;
QRLabel10: TQRLabel;
QRLabel11: TQRLabel;
QRLabel12: TQRLabel;
QRDBText7: TQRDBText;
QRBand3: TQRBand;
QRLabel23: TQRLabel;
QRLabel28: TQRLabel;
QRVal: TQRLabel;
QRLabel29: TQRLabel;
QRFecha: TQRLabel;
QRShape3: TQRShape;
QRShape4: TQRShape;
QRShape5: TQRShape;
QRLabel30: TQRLabel;
QRLabel31: TQRLabel;
QRLabel32: TQRLabel;
QRLabel34: TQRLabel;
QRLabel35: TQRLabel;
QRNumero: TQRLabel;
QRBand2: TQRBand;
QRShape1: TQRShape;
QRSub: TQRLabel;
QRLabel13: TQRLabel;
QRLabel14: TQRLabel;
QRPrecioMonjate: TQRLabel;
QRLabel16: TQRLabel;
QRMontaje: TQRLabel;
QRDesp: TQRLabel;
QRLabel17: TQRLabel;
QRLabel15: TQRLabel;
QRPrecioD: TQRLabel;
QRLabel19: TQRLabel;
QRLabelIva: TQRLabel;
QRLabel21: TQRLabel;
QRIncrem: TQRLabel;
QRLabel22: TQRLabel;
QRLabel18: TQRLabel;
QRInc: TQRLabel;
QRLabel24: TQRLabel;
Descuento: TQRLabel;
QRDesc: TQRLabel;
QRLabel25: TQRLabel;
QRDescuento: TQRLabel;
QRLabel27: TQRLabel;
QRShape2: TQRShape;
QRLabel20: TQRLabel;
QRLabel26: TQRLabel;
QRShape6: TQRShape;
QRSubto: TQRLabel;
QRIva: TQRLabel;
QRTot: TQRLabel;
procedure FormShow(Sender: TObject);
procedure rellenarDatosCliente();
procedure rellenarDatosPresupuesto(refArticulo, desArticulo, tipoAcc,
decoracion, trabajos, articulo, desplazamiento: string;
precio1, precio2, precio3, precio4, precio5: double; iva: integer; descuento,
incremento: double; validez: integer; fecha: string; numPres: integer);
procedure QRDBText7Print(sender: TObject; var Value: String);
procedure QRDBText4Print(sender: TObject; var Value: String);
procedure QRDBText6Print(sender: TObject; var Value: String);
procedure QRPrecio1Print(sender: TObject; var Value: String);
procedure QRPrecioMonjatePrint(sender: TObject; var Value: String);
procedure QRPrecioDPrint(sender: TObject; var Value: String);
procedure QRIncremPrint(sender: TObject; var Value: String);
procedure QRDescuentoPrint(sender: TObject; var Value: String);
procedure QRSubtoPrint(sender: TObject; var Value: String);
procedure QRIvaPrint(sender: TObject; var Value: String);
procedure QRTotPrint(sender: TObject; var Value: String);
procedure QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
subtotal: double;
ivaAux, validezAux: integer;
descuentoAux, incrementoAux: double;
descuentoTotal, incrementoTotal, ivaTotal: double;
end;
var
Form3: TForm3;
subtotal: double;
ivaAux, validezAux: integer;
descuentoAux, incrementoAux: double;
descuentoTotal, incrementoTotal, ivaTotal: double;
implementation
{$R *.dfm}
procedure TForm3.FormShow(Sender: TObject);
begin
subtotal := 0;
ivaAux := 0;
validezAux := 0;
descuentoAux := 0;
incrementoAux := 0;
descuentoTotal := 0;
incrementoTotal := 0;
ivaTotal := 0;
QuickRep1.Refresh;
rellenarDatosCliente();
end;
procedure TForm3.rellenarDatosCliente();
var
nombre, apellido1, apellido2, direccion, codpostal, provincia, localidad,
telefono1, telefono2, observaciones: string;
begin
nombre := qClientes.fieldbyname('nombre').asstring;
apellido1 := qClientes.fieldbyname('apellido1').asstring;
apellido2 := qClientes.fieldbyname('apellido2').asstring;
direccion := qClientes.fieldbyname('direccion').asstring;
codpostal := qClientes.fieldbyname('cp').asstring;
provincia := qClientes.fieldbyname('provincia').asstring;
localidad := qClientes.fieldbyname('localidad').asstring;
telefono1 := qClientes.fieldbyname('telefono1').asstring;
telefono2 := qClientes.fieldbyname('telefono2').asstring;
observaciones := qClientes.fieldbyname('observaciones').asstring;
QRNombre.Caption := nombre+' '+apellido1+' '+apellido2;
QRDireccion1.Caption := direccion;
QRDireccion2.Caption := codpostal+', '+localidad+' ('+provincia+')';
end;
procedure TForm3.rellenarDatosPresupuesto(refArticulo, desArticulo, tipoAcc,
decoracion, trabajos, articulo, desplazamiento: string;
precio1, precio2, precio3, precio4, precio5: double; iva: integer; descuento,
incremento: double; validez: integer; fecha: string; numPres: integer);
var
iva2, total : double;
temp:Real;
begin
QRRef.Caption := refArticulo;
QRArticulo.Caption := desArticulo;
QRPrecio1.Caption := Format('%0.2f',[precio1]);
QRMontaje.Caption := trabajos;
QRPrecioMonjate.Caption := Format('%0.2f',[precio4]);
QRDesp.Caption := desplazamiento;
QRPrecioD.Caption := Format('%0.2f',[precio5]);
QRLabelIva.Caption := 'IVA ('+intToStr(iva)+' %)';
ivaAux := iva;
descuentoAux := descuento;
incrementoAux := incremento;
validezAux := validez;
QRInc.Caption := floatToStr(incremento);
QRDesc.Caption := floatToStr(descuento);
QRVal.Caption := intToStr(validez);
QRFecha.Caption := fecha;
QRNumero.Caption := intToStr(numPres);
end;
procedure TForm3.QRDBText7Print(sender: TObject; var Value: String);
begin
if (QAccesorios.FieldByName('accesorio').AsString = 'rbAcc1') then
begin
Value := 'Solera Suelo';
end;
if (QAccesorios.FieldByName('accesorio').AsString = 'rbAcc2') then
begin
Value := 'Rodapies';
end;
if (QAccesorios.FieldByName('accesorio').AsString = 'rbAcc3') then
begin
Value := 'Zócalo';
end;
if (QAccesorios.FieldByName('accesorio').AsString = 'rbAcc4') then
begin
Value := 'Solera';
end;
if (QAccesorios.FieldByName('accesorio').AsString = 'rbAcc5') then
begin
Value := 'Supl. Macizos';
end;
if (QAccesorios.FieldByName('accesorio').AsString = 'rbAcc6') then
begin
Value := 'Cajón';
end;
if (QAccesorios.FieldByName('accesorio').AsString = 'rbAcc7') then
begin
Value := 'Tapas Cajón';
end;
if (QAccesorios.FieldByName('accesorio').AsString = 'rbAcc8') then
begin
Value := 'Tabicas';
end;
if (QAccesorios.FieldByName('accesorio').AsString = 'rbAcc9') then
begin
Value := 'Lápidas';
end;
end;
procedure TForm3.QRDBText4Print(sender: TObject; var Value: String);
begin
subtotal := subtotal + strToFloat(Value);
Value := Format('%0.2f',[strToFloat(Value)]);
end;
procedure TForm3.QRDBText6Print(sender: TObject; var Value: String);
begin
subtotal := subtotal + strToFloat(Value);
Value := Format('%0.2f',[strToFloat(Value)]);
end;
procedure TForm3.QRPrecio1Print(sender: TObject; var Value: String);
begin
subtotal := subtotal + strToFloat(Value);
Value := Format('%0.2f',[strToFloat(Value)]);
end;
procedure TForm3.QRPrecioMonjatePrint(sender: TObject; var Value: String);
begin
subtotal := subtotal + strToFloat(Value);
Value := Format('%0.2f',[strToFloat(Value)]);
end;
procedure TForm3.QRPrecioDPrint(sender: TObject; var Value: String);
begin
subtotal := subtotal + strToFloat(Value);
end;
procedure TForm3.QRIncremPrint(sender: TObject; var Value: String);
var
incremento2 : double;
begin
incremento2 := (subtotal * incrementoAux) / 100;
incrementoTotal := incremento2;
Value := Format('%0.2f',[incremento2]);
end;
procedure TForm3.QRDescuentoPrint(sender: TObject; var Value: String);
var
descuento2 : double;
begin
descuento2 := (subtotal * descuentoAux) / 100;
descuentoTotal := descuento2;
Value := Format('%0.2f',[descuento2]);
end;
procedure TForm3.QRSubtoPrint(sender: TObject; var Value: String);
begin
Value := Format('%0.2f',[subtotal]);
end;
procedure TForm3.QRIvaPrint(sender: TObject; var Value: String);
var
iva2 : double;
begin
iva2 := ((subtotal + incrementoTotal - descuentoTotal) * ivaAux) / 100;
ivaTotal := iva2;
Value := Format('%0.2f',[iva2]);
end;
procedure TForm3.QRTotPrint(sender: TObject; var Value: String);
var
totalAux: double;
begin
totalAux := subtotal + incrementoTotal - descuentoTotal + ivaTotal;
Value := Format('%0.2f',[totalAux]);
end;
procedure TForm3.QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
begin
{
subtotal := 0;
ivaAux := 0;
validezAux := 0;
descuentoAux := 0;
incrementoAux := 0;
descuentoTotal := 0;
incrementoTotal := 0;
ivaTotal := 0;
}
end;
procedure TForm3.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Form3.Destroy;
end;
end.
|