git-svn-id: https://192.168.0.254/svn/Proyectos.Acana_FactuGES2/trunk@324 f4e31baf-9722-1c47-927c-6f952f962d4b
143 lines
3.9 KiB
ObjectPascal
143 lines
3.9 KiB
ObjectPascal
unit uPresupuestosClienteReportController;
|
|
|
|
interface
|
|
|
|
uses
|
|
Classes, SysUtils, uDADataTable, uIDataModulePresupuestosClienteReport,
|
|
uClientesController, uPresupuestosClienteController, uDetallesPresupuestoClienteController,
|
|
uBizPresupuestosCliente, uControllerBase, uIntegerListUtils;
|
|
|
|
type
|
|
IPresupuestosClienteReportController = interface(IControllerBase)
|
|
['{D0686358-251C-43C4-9927-6112F2F4D3B8}']
|
|
procedure Preview(const AListaID : TIntegerList);
|
|
procedure Print(const AListaID : TIntegerList);
|
|
function ExportToPDF(const AID: Integer; const AFileName : String = ''): Boolean;
|
|
end;
|
|
|
|
TPresupuestosClienteReportController = class(TControllerBase, IPresupuestosClienteReportController)
|
|
private
|
|
FDataModule : IDataModulePresupuestosClienteReport;
|
|
function CreateEditor(const AName: String; const IID: TGUID; out Intf): Boolean;
|
|
public
|
|
constructor Create; override;
|
|
destructor Destroy; override;
|
|
|
|
procedure Preview(const AListaID : TIntegerList);
|
|
procedure Print(const AListaID : TIntegerList);
|
|
function ExportToPDF(const AID: Integer; const AFileName : String = ''): Boolean;
|
|
end;
|
|
|
|
|
|
implementation
|
|
|
|
uses
|
|
uROTypes, uEditorRegistryUtils, uIEditorPresupuestosClientePreview,
|
|
uEditorPreview, uDataModulePresupuestosCliente, uEditorBase, cxControls,
|
|
uFactuGES_App, uStringsUtils;
|
|
|
|
{ TPresupuestosClienteReportController }
|
|
|
|
constructor TPresupuestosClienteReportController.Create;
|
|
begin
|
|
inherited;
|
|
FDataModule := TDataModulePresupuestosCliente.Create(Nil);
|
|
end;
|
|
|
|
function TPresupuestosClienteReportController.CreateEditor(const AName: String;
|
|
const IID: TGUID; out Intf): Boolean;
|
|
begin
|
|
Result := Supports(EditorRegistry.CreateEditor(AName), IID, Intf);
|
|
end;
|
|
|
|
|
|
destructor TPresupuestosClienteReportController.Destroy;
|
|
begin
|
|
FDataModule := NIL;
|
|
inherited;
|
|
end;
|
|
|
|
function TPresupuestosClienteReportController.ExportToPDF(const AID: Integer;
|
|
const AFileName: String): Boolean;
|
|
var
|
|
AStream: Binary;
|
|
begin
|
|
Result := False;
|
|
if EsCadenaVacia(AFileName) then
|
|
Exit;
|
|
|
|
ShowHourglassCursor;
|
|
try
|
|
AStream := FDataModule.GetRptPDFPresupuesto(AID);
|
|
try
|
|
AStream.SaveToFile(AFileName);
|
|
Result := True;
|
|
finally
|
|
FreeAndNil(AStream);
|
|
end;
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
procedure TPresupuestosClienteReportController.Preview(const AListaID : TIntegerList);
|
|
var
|
|
AStream: Binary;
|
|
AEditor : IEditorPresupuestosClientePreview;
|
|
begin
|
|
AEditor := NIL;
|
|
AStream := FDataModule.GetRptPresupuestos(AListaID);
|
|
try
|
|
CreateEditor('EditorPresupuestosClientePreview', IEditorPresupuestosClientePreview, 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;
|
|
AEditor := Nil;
|
|
end;
|
|
end;
|
|
finally
|
|
FreeAndNil(AStream);
|
|
end;
|
|
end;
|
|
|
|
procedure TPresupuestosClienteReportController.Print(const AListaID : TIntegerList);
|
|
var
|
|
AStream: Binary;
|
|
AEditor : IEditorPresupuestosClientePreview;
|
|
begin
|
|
AEditor := NIL;
|
|
ShowHourglassCursor;
|
|
try
|
|
AStream := FDataModule.GetRptPresupuestos(AListaID);
|
|
try
|
|
CreateEditor('EditorPresupuestosClientePreview', IEditorPresupuestosClientePreview, 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;
|
|
AEditor := Nil;
|
|
end;
|
|
end;
|
|
finally
|
|
FreeAndNil(AStream);
|
|
end;
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
end.
|