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.ShowPrintDialog:= Datos.bDialogo;
rptPreview.Preview:= Datos.bPreliminar;
for i:= 0 to Length(arrParametros) -1 do
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.