Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Impresión
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo Hace 1 Día
delphi50jmb delphi50jmb is offline
Miembro
 
Registrado: jul 2007
Posts: 28
Poder: 0
delphi50jmb Va por buen camino
Smile Reporte subtotalizado con datos SQLFirebird no funciona

Hola Estimados.
Esta pregunta la hice hace un a±o atras y no logre resolver el problema. Por eso vuelvo a platear la inquietud.

Estoy migrando mis aplicaciones desde Paradox a SQL. Tengo un reporte muy sencillo, con cuatro bandas de detalle. Una banda para los titulos, una banda para agrupar por una expresion, una banda para el detalle de productos, y una banda para los totales. Este reporte muestra los detalles de venta de un cliente, y subTotaliza por mes.

Este reporte funciona perfecto con delphi y paradox. Pero ahora al trabajar con SQL-Firebird, al poner un valor en la "propiedad Expresion" (Expresion = Mes) de la segunda banda (Banda tipo: TQRGroup), me aparece un mensaje que dice: "Operation not allowed on a unidirectional dataset". Si quito el valor en la propiedad "expresion", este funciona correctamente, pero obiamente no subtotaliza.

Con tablas paradox, el reporte funciona perfectamente. Pero la realizar el mismo con SQL-Firebird no funciona.

El archivo que estoy tratando de imprimir esta ordenado por el campo: Mes.

Esta es la consulta SQL. Funciona perfectamente. Lo que no funciona es el reporte subTotalizado.

Código SQL [-]
 SQL_String.Close;

   SQL_Text := 'SELECT DetFact.TipoDoc, DetFact.Rut, DetFact.CodAux, DetFact.Numero, ' +
                     'DetFact.FechaEmi, DetFact.Mes, DetFact.Codigo, DetFact.Descrip, DetFact.Cantidad, ' +
                     'DetFact.TotalLinDe, DetFact.Vendedor, Vendedores.Nombre ' +
                     'FROM DetFact '                                 +
                     'LEFT JOIN Vendedores '                            +
                     'ON Vendedores.Codigo=DetFact.Vendedor ' +
                                       'WHERE DetFact.FechaEmi>=' + QuotedStr( sFechaSel ) +  ' ' +
                     'ORDER BY Mes ASC ' + ';';

   SQL_String.CommandText := SQL_Text;
   SQL_String.Open;

Estoy usando componentes DbExpres.

Alguna idea de que pasa? , y como solucionar esto?

Gracias de antemano.

Saludos.
Jose Miguel B.
Responder Con Cita
  #2  
Antiguo Hace 1 Día
delphi50jmb delphi50jmb is offline
Miembro
 
Registrado: jul 2007
Posts: 28
Poder: 0
delphi50jmb Va por buen camino
Red face

Este es la estructura del reporte.

Código Delphi [-]
unit UQrDetDocVta;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Qrctrls, Db, QuickRpt, ExtCtrls;

type
  TFQrDetDocVta = class(TForm)
    QrDetDocVta: TQuickRep;
    QRBand2: TQRBand;
    QrBandDet: TQRBand;
    QRlNombEmpresa: TQRLabel;
    QRTitulo: TQRLabel;
    QRShape2: TQRShape;
    QRShape1: TQRShape;
    QrTipDoc: TQRLabel;
    QRPagina: TQRLabel;
    QRFecha: TQRLabel;
    QRBand1: TQRBand;
    QRShape3: TQRShape;
    QRHora: TQRLabel;
    QRSysHora: TQRSysData;
    QRLabel4: TQRLabel;
    QRMaxMinimo: TQRLabel;
    QrTotDoc: TQRLabel;
    QrNombre: TQRLabel;
    QRSysData1: TQRSysData;
    QRSysData2: TQRSysData;
    QrLabel1: TQRLabel;
    QrFecDoc: TQRLabel;
    QRLabel3: TQRLabel;
    QRGDetMes: TQRGroup;
    QRSubTotalMes: TQRBand;
    QrProveed: TQRLabel;
    qrNeto: TQRLabel;
    QRShape6: TQRShape;
    QRLabel2: TQRLabel;
    QrNumDoc: TQRLabel;
    QRLabel8: TQRLabel;
    QrCantDoc: TQRLabel;
    QrSubTitulo: TQRLabel;
    QrCodigo: TQRLabel;
    QRLabel7: TQRLabel;
    QRLabel5: TQRLabel;
    QrCostoDoc: TQRLabel;
    QRLabel9: TQRLabel;
    QrIva: TQRLabel;
    QrLabel20: TQRLabel;
    QrTotal: TQRLabel;
    QRLabel13: TQRLabel;
    procedure QrDetDocVtaBeforePrint(Sender: TCustomQuickRep;
      var PrintReport: Boolean);
    procedure QrBandDetBeforePrint(Sender: TQRCustomBand;
      var PrintBand: Boolean);
    procedure QrDetDocVtaStartPage(Sender: TCustomQuickRep);
    procedure FormActivate(Sender: TObject);

    procedure QRSubTotalMesBeforePrint(Sender: TQRCustomBand;
      var PrintBand: Boolean);

  private
    { Private declarations }

  public
    { Public declarations }
  end;

var
  FQrDetDocVta: TFQrDetDocVta;
  nPagina : Integer;
  iTTotal   : Extended;

implementation
uses UVarGlobales, ULibrerias, UDt1;

{$R *.DFM}



procedure TFQrDetDocVta.FormActivate(Sender: TObject);
begin
   nPagina :=0;
end;


procedure TFQrDetDocVta.QrDetDocVtaStartPage(Sender: TCustomQuickRep);
begin
   nPagina := nPagina + 1;
end;


procedure TFQrDetDocVta.QrDetDocVtaBeforePrint(Sender: TCustomQuickRep;
  var PrintReport: Boolean);

begin
   sMenuOpc := 'Informe Detallado de Ventas';

   QRlNombEmpresa.Caption := sEmpresa;
   QrTitulo.Caption := sMenuOpc;
   QrSubTitulo.Caption := '(' + 'Desde: ' + sParam1 + ' Hasta: ' + sParam2 + ')';

   QrDetDocVta.DataSet := SQL_String;
   QRSysHora.Data      := qrsTime;
end;


procedure TFQrDetDocVta.QrBandDetBeforePrint(Sender: TQRCustomBand;
  var PrintBand: Boolean);
begin
   QrFecDoc.Caption   := SQL_String.FieldByName( 'FechaEmi'  ).AsString;
   QrTipDoc.Caption   := SQL_String.FieldByName( 'TipoDoc'  ).AsString;
   QrNumDoc.Caption   := SQL_String.FieldByName( 'Numero'  ).AsString;
   QrCodigo.Caption   := SQL_String.FieldByName( 'Codigo'  ).AsString;
   QrNombre.Caption   := SQL_String.FieldByName( 'Descrip'  ).AsString;
   QrCantDoc.Caption  := SQL_String.FieldByName( 'Cantidad' ).AsString;

   QrTotDoc.Caption   := Picture(SQL_String.FieldByName( 'TotalLinDe' ).AsString);

   itTotal := itTotal + StrToFloat(SQL_String.FieldByName( 'TotalLinDe' ).AsString);
end;



procedure TFQrDetDocVta.QRSubTotalMesBeforePrint(
  Sender: TQRCustomBand; var PrintBand: Boolean);          <------- Cuando entra aqui para subtotalizar por mes, se cae, y presenta el mensaje: "Operation not allowed on a unidirectional dataset".
begin
   QrTotal.Caption := FloatToStr(itTotal);
   itTotal := 0;
end;
end.

Gracias de antemano.
Saludos.
Jose Miguel B.
Responder Con Cita
  #3  
Antiguo Hace 1 Día
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.182
Poder: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
Responder Con Cita
  #4  
Antiguo Hace 1 Día
delphi50jmb delphi50jmb is offline
Miembro
 
Registrado: jul 2007
Posts: 28
Poder: 0
delphi50jmb Va por buen camino
Hola Casimiro.
Agradesco tu respuesta. Pero estoy usando Componentes DbExpres, y el DataSet no tiene esa propiedad que me indicas.

Saludos.
Jose Miguel.
Responder Con Cita
  #5  
Antiguo Hace 11 Horas
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.182
Poder: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
¿Y cuál estás usando exactamente?
Responder Con Cita
  #6  
Antiguo Hace 10 Horas
chenech chenech is offline
Miembro
 
Registrado: dic 2013
Posts: 76
Poder: 11
chenech Va por buen camino
DBExpress no tiene esa propiedad, por eso te da el error, yo lo solucioné pasando el SQL resultante del DBExpress a un TClientDataSet y este es el que enlazo con el reporte.
Un saludo.
Responder Con Cita
  #7  
Antiguo Hace 9 Horas
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.182
Poder: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
Es algo extraño, yo uso esos componentes (DbExpres) para informes con report manager y no tengo ese problema.
Es que además no tiene lógica, un informe no tiene que ir "hacia atrás y hacia adelante" en ningún momento.
Responder Con Cita
  #8  
Antiguo Hace 9 Horas
chenech chenech is offline
Miembro
 
Registrado: dic 2013
Posts: 76
Poder: 11
chenech Va por buen camino
A mi me pasa solo con QuickReport, con Fastreport y otros no.
Responder Con Cita
  #9  
Antiguo Hace 32 Minutos
delphi50jmb delphi50jmb is offline
Miembro
 
Registrado: jul 2007
Posts: 28
Poder: 0
delphi50jmb Va por buen camino
Unhappy

Hola Chenech.

Como pasas el SQL resultante del DBExpress a un TClientDataSet?.. me podrias indicar?..

Yo estoy usando este formato en mi programa.

Código Delphi [-]
DataSource  --> ClienDataSet --> DataSetProvider --> SqlDataSet --> SqlConnecction

El DataSource en su propiedad: Dataset, apunta a: ClientDataSet.
El ClientDataSet en su propiedad: ProviderName, apunta a: DataSetProvider.
El DataSetProvider, en su propiedad: DataSet, apunta a: SQLDataSet.
El SQLDataSet, en su propiedad: SQLConnection, apunta a: SQLConnection.

SQL_String, es una variable global de tipo TSQLDataSet, que se inicializa de la siguiente manera:

Código Delphi [-]
   SQL_String := TSQLDataSet.Create(nil);
   SQL_String.SQLConnection := SQLConnection;

La consulta la hago de la siguiente forma:

Código Delphi [-]
procedure TFPreparaFile.TrasDetalleVentas;
begin
   sPar1Aux := Stuff(sFechaIni, SeparadorFecha, '.', 'A');

   Dt1.SQLDataSet.Close;

   SQL_Text := 'SELECT DetFact.Mes, DetFact.TipoDoc, DetFact.Rut, DetFact.CodAux, DetFact.Numero, ' +
                     'DetFact.FechaEmi, DetFact.Codigo, DetFact.Descrip, DetFact.Cantidad, ' +
                     'DetFact.TotalLinDe, DetFact.Vendedor, Vendedores.Nombre ' +
               'FROM DetFact '                                 +
               'LEFT JOIN Vendedores '                            +
               'ON Vendedores.Codigo=DetFact.Vendedor ' +
               'WHERE DetFact.FechaEmi>=' + QuotedStr( sPar1Aux ) + ' ' +
               'ORDER BY Mes ASC ' + ';';

   SQL_String := Dt1.SQLDataSet;
   SQL_String.Close;

   SQL_String.CommandText := SQL_Text;

   SQL_String.Open;
end;

y, luego el reporte. Que tiene un titulo, y solo 3 bandas para el detalle.

Esta es la estructura basica de mi reporte:

Código Delphi [-]
---------------------------------------------------------------------------------------
Fecha  TipoDoc Numero Codigo    Nombre                   Cantidad   Costo   Total
---------------------------------------------------------------------------------------
================================================
QRGDetMes - TQRGroup
Expression: Mes
FooterBand: QrSubTotalMes
LinkBand: QrBandDet
---------------------------------------------------------------------------------

=================================================================================
QrBandDet - TQrBand 
BandType: rbDetail
--------------------------------------------------------------------------------

================================================================================
QrSubTotalMes - TQrBand
BandType: rbGroupFooter
--------------------------------------------------------------------------------

Funciona bien hasta que tiene que hacer el corte para subtotalizar por mes, y se cae, con el mensaje: "Operation not allowed on a unidirectional dataset".

Código Delphi [-]
procedure TFQrDetDocVta.QRSubTotalMesBeforePrint(
  Sender: TQRCustomBand; var PrintBand: Boolean);          <------- Cuando entra aqui para subtotalizar por mes, se cae, y presenta el mensaje: "Operation not allowed on a unidirectional dataset".
begin
   QrTotal.Caption := FloatToStr(itTotal);
   itTotal := 0;
end;

El Reporte lo simplifique para que se entienda mejor.

Agradeceria si me pudieran ayudar.

Gracias.

Saludos.
Jose Miguel B.
Responder Con Cita
  #10  
Antiguo Hace 17 Minutos
chenech chenech is offline
Miembro
 
Registrado: dic 2013
Posts: 76
Poder: 11
chenech Va por buen camino
Por la estructura que estas usando ya tienes enlazado el ClientDataSet al resultado del SQL_String.
Pon el ClientDataSet.Active = false antes de la llamada al SQL y ClientDataSet.Active = true después del open del SQL.
Ya tendrías los datos en el ClientDataSet que es el que tendrías que asociar a los campos del QuickReport.

Si quieres simplificar mucho, usa FastReport u otro ya que QuickReport no tiene soporte ni saldrán nuevas versiones y por otro lado usa FireDac que creo será mas el futuro de Embarcadero que DBExpress.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Reporte sin datos Nomad Impresión 3 25-09-2013 04:33:07
Reporte agrupando datos ingabraham Impresión 9 13-07-2011 15:20:35
reporte con varios datos ingabraham Impresión 0 14-10-2010 19:48:47
Mostrar datos en reporte natalinuyo Varios 3 22-03-2007 21:08:53
Actualizar datos de una base de datos en un reporte Marymania Impresión 4 27-11-2006 19:47:32


La franja horaria es GMT +2. Ahora son las 22:21:30.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi