git-svn-id: https://192.168.0.254/svn/Proyectos.AlonsoYSal_FactuGES2/trunk@25 40301925-124e-1c4e-b97d-170ad7a8785b
150 lines
4.2 KiB
ObjectPascal
150 lines
4.2 KiB
ObjectPascal
unit uContratosClienteReportController;
|
|
|
|
interface
|
|
|
|
uses
|
|
Classes, SysUtils, uDADataTable, uControllerBase, uIDataModuleContratosClienteReport,
|
|
uClientesController, uContratosClienteController, uDetallesContratoClienteController,
|
|
uBizContratosCliente, uIntegerListUtils;
|
|
|
|
type
|
|
IContratosClienteReportController = interface(IControllerBase)
|
|
['{FEF47B69-26A3-462A-AF6D-4B2073D4F9DC}']
|
|
procedure Preview(const AListaID : TIntegerList; AVerCondiciones: Boolean = false);
|
|
procedure Print(const AListaID : TIntegerList; AVerCondiciones: Boolean = false);
|
|
function ExportToPDF(const AID: Integer; const AFileName : String = ''): Boolean;
|
|
end;
|
|
|
|
TContratosClienteReportController = class(TControllerBase, IContratosClienteReportController)
|
|
private
|
|
FDataModule : IDataModuleContratosClienteReport;
|
|
function CreateEditor(const AName: String; const IID: TGUID; out Intf): Boolean;
|
|
public
|
|
constructor Create; override;
|
|
destructor Destroy; override;
|
|
|
|
procedure Preview(const AListaID : TIntegerList; AVerCondiciones: Boolean = false);
|
|
procedure Print(const AListaID : TIntegerList; AVerCondiciones: Boolean = false);
|
|
function ExportToPDF(const AID: Integer; const AFileName : String = ''): Boolean;
|
|
end;
|
|
|
|
|
|
implementation
|
|
|
|
uses
|
|
uROTypes, uEditorRegistryUtils, uIEditorContratosClientePreview,
|
|
uEditorPreview, uDataModuleContratosCliente, uEditorBase,
|
|
cxControls, uFactuGES_App, uStringsUtils, uSistemaFunc;
|
|
|
|
{ TContratosClienteReportController }
|
|
|
|
constructor TContratosClienteReportController.Create;
|
|
begin
|
|
inherited;
|
|
FDataModule := TDataModuleContratosCliente.Create(Nil);
|
|
end;
|
|
|
|
function TContratosClienteReportController.CreateEditor(const AName: String;
|
|
const IID: TGUID; out Intf): Boolean;
|
|
begin
|
|
Result := Supports(EditorRegistry.CreateEditor(AName), IID, Intf);
|
|
end;
|
|
|
|
|
|
destructor TContratosClienteReportController.Destroy;
|
|
begin
|
|
FDataModule := NIL;
|
|
inherited;
|
|
end;
|
|
|
|
function TContratosClienteReportController.ExportToPDF(const AID: Integer;
|
|
const AFileName: String): Boolean;
|
|
var
|
|
AStream: Binary;
|
|
begin
|
|
Result := False;
|
|
if EsCadenaVacia(AFileName) then
|
|
Exit;
|
|
|
|
ShowHourglassCursor;
|
|
try
|
|
AStream := FDataModule.GetRptPDFContrato(AID);
|
|
try
|
|
AStream.SaveToFile(AFileName);
|
|
Result := True;
|
|
finally
|
|
FreeAndNil(AStream);
|
|
end;
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
procedure TContratosClienteReportController.Preview(const AListaID : TIntegerList; AVerCondiciones: Boolean = false);
|
|
var
|
|
AStream: Binary;
|
|
AEditor : IEditorContratosClientePreview;
|
|
begin
|
|
AEditor := NIL;
|
|
|
|
ShowHourglassCursor;
|
|
try
|
|
AStream := FDataModule.GetRptContratos(AListaID, AVerCondiciones);
|
|
try
|
|
CreateEditor('EditorContratosClientePreview', IEditorContratosClientePreview, AEditor);
|
|
if Assigned(AEditor) then
|
|
begin
|
|
try
|
|
AEditor.Controller := Self;
|
|
AEditor.ListaID := AListaID;
|
|
AEditor.Title := 'Presupuesto - ' + AppFactuGES.EmpresaActiva.NOMBRE;
|
|
AEditor.LoadFromStream(AStream);
|
|
AEditor.Preview;
|
|
finally
|
|
AEditor.Release;
|
|
end;
|
|
end;
|
|
finally
|
|
FreeAndNil(AStream);
|
|
AEditor := Nil;
|
|
end;
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
procedure TContratosClienteReportController.Print(const AListaID : TIntegerList; AVerCondiciones: Boolean = false);
|
|
var
|
|
AStream: Binary;
|
|
AEditor : IEditorContratosClientePreview;
|
|
begin
|
|
AEditor := NIL;
|
|
|
|
ShowHourglassCursor;
|
|
try
|
|
AStream := FDataModule.GetRptContratos(AListaID, AVerCondiciones);
|
|
try
|
|
CreateEditor('EditorContratosClientePreview', IEditorContratosClientePreview, AEditor);
|
|
if Assigned(AEditor) then
|
|
begin
|
|
try
|
|
AEditor.Controller := Self;
|
|
AEditor.ListaID := AListaID;
|
|
AEditor.Title := 'Presupuesto - ' + AppFactuGES.EmpresaActiva.NOMBRE;
|
|
AEditor.LoadFromStream(AStream);
|
|
AEditor.Print;
|
|
finally
|
|
AEditor.Release;
|
|
end;
|
|
end;
|
|
finally
|
|
FreeAndNil(AStream);
|
|
AEditor := Nil;
|
|
end;
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
end.
|