Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   .NET (https://www.clubdelphi.com/foros/forumdisplay.php?f=17)
-   -   Parametros en Reportman con Delphi.NET (https://www.clubdelphi.com/foros/showthread.php?t=41252)

Daniel_ASV 10-03-2007 21:03:16

Parametros en Reportman con Delphi.NET
 
Alguien sabe como se envian los parametros desde Delphi.NET al reportman?

Y si es posible tambien el titulo de la ventana gracias.



Código Delphi [-]
unit uReportes;
interface
uses
  SysUtils, Reportman.Drawing.Forms, Reportman.Reporting, FirebirdSql.Data.Firebird;
type
  TParametrosRep = record
    sParametro: String;
    sValor: String;
  end;
  TDatosReportes = record
    FBDataBase: FbConnection;
    sArchivo: String;
    sTitulo: String;
    iCopias: integer;
    bPreliminar: boolean;
    bDialogo: boolean;
    sArchivoConexion: String;
    sMensaje: string;
  end;
  TReportes = class
  private
    arrParametros: array of TParametrosRep;
    Datos: TDatosReportes;
  public
    rptReporte: Report;
    rptPreview: PrintOutWinForms;
    constructor Create;
    destructor Destroy; override;
    procedure AgregarParametro(sParametro, sValor: String);
    function Ejecutar: boolean;
    property DataBase: FbConnection write Datos.FBDatabase;
    property Archivo: String write DAtos.sArchivo;
    property Titulo: String write Datos.sTitulo;
    property Copias: integer write Datos.iCopias;
    property VistaPreliminar: boolean write Datos.bPreliminar;
    property ElegirImpresora: boolean write Datos.bDialogo;
    property ArchivoConexion: String write Datos.sArchivoConexion;
    property Mensaje: String read Datos.sMensaje;
  end;
implementation
uses StrUtils;
procedure TReportes.AgregarParametro(sParametro, sValor: String);
begin
  SetLength(arrParametros, Length(arrParametros) + 1);
  arrParametros[Length(arrParametros) - 1].sParametro:= sParametro;
  arrParametros[Length(arrParametros) - 1].sValor:= sValor;
end;
constructor TReportes.Create;
begin
  inherited;
  rptReporte:= Report.Create;
  rptPreview:= PrintOutWinForms.Create;
end;
destructor TReportes.Destroy;
begin
  FreeAndNil(rptPreview);
  FreeAndNil(rptReporte);
  inherited;
end;
function TReportes.Ejecutar: boolean;
var
  i: integer;
begin
  Result:= true;
  try
    rptReporte.Language:= 1;
    rptReporte.LoadFromFile(Datos.sArchivo);
    if(Datos.sArchivoConexion = EmptyStr) then
      rptReporte.DatabaseInfo[0].Connection := Datos.FBDataBase
    else
      rptReporte.DataInfo.Item[0].MyBaseFilename:= Datos.sArchivoConexion;
    if(Datos.iCopias = 0) then
      rptReporte.Copies:= 1
    else
      rptReporte.Copies:= Datos.iCopias;
    //rptPreview.Title:= Datos.sTitulo;
    rptPreview.ShowPrintDialog:= Datos.bDialogo;
    rptPreview.Preview:= Datos.bPreliminar;
    for i:= 0 to Length(arrParametros) -1 do
      //rptReporte.Params.ParamByName(arrParametros[i].sParametro).Value:= arrParametros[i].sValor;
    rptPreview.Print(rptReporte.MetaFile);
  except
    on e: exception do
    begin
      if(AnsiContainsStr(e.Message, 'filename')) then
        Datos.sMensaje:= 'El nombre del archivo de reporte es incorrecto'
      else if(AnsiContainsStr(e.Message, 'No data')) then
        Datos.sMensaje:= 'No hay datos disponibles para imprimir'
      else
        Datos.sMensaje:= 'Ocurrió un error al intentar imprimir';
      Result:= false;
    end;
  end;
  SetLength(arrParametros, 0);
end;end.

axesys 13-03-2007 18:33:30

Con IndexOf
 
Código Delphi [-]
rptReporte.Params.Item[rptReporte.Params.IndexOf(arrParametros[i].sParametro)].Value:= arrParametros[i].sValor;


La franja horaria es GMT +2. Ahora son las 20:58:57.

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