2007-11-28 17:40:31 +00:00
|
|
|
unit uPresupuestosClienteReportController;
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
uses
|
2008-07-14 14:35:47 +00:00
|
|
|
Classes, SysUtils, uDADataTable, uIDataModulePresupuestosClienteReport,
|
2007-11-28 17:40:31 +00:00
|
|
|
uClientesController, uPresupuestosClienteController, uDetallesPresupuestoClienteController,
|
2008-10-03 17:15:51 +00:00
|
|
|
uBizPresupuestosCliente, uControllerBase, uIntegerListUtils;
|
2007-11-28 17:40:31 +00:00
|
|
|
|
|
|
|
|
type
|
2008-07-14 14:35:47 +00:00
|
|
|
IPresupuestosClienteReportController = interface(IControllerBase)
|
2007-11-28 17:40:31 +00:00
|
|
|
['{D0686358-251C-43C4-9927-6112F2F4D3B8}']
|
2008-10-03 17:15:51 +00:00
|
|
|
procedure Preview(const AListaID : TIntegerList);
|
|
|
|
|
procedure Print(const AListaID : TIntegerList);
|
|
|
|
|
function ExportToPDF(const AID: Integer; const AFileName : String = ''): Boolean;
|
2007-11-28 17:40:31 +00:00
|
|
|
end;
|
|
|
|
|
|
2008-07-14 14:35:47 +00:00
|
|
|
TPresupuestosClienteReportController = class(TControllerBase, IPresupuestosClienteReportController)
|
2007-11-28 17:40:31 +00:00
|
|
|
private
|
|
|
|
|
FDataModule : IDataModulePresupuestosClienteReport;
|
|
|
|
|
function CreateEditor(const AName: String; const IID: TGUID; out Intf): Boolean;
|
|
|
|
|
public
|
2008-11-11 12:25:58 +00:00
|
|
|
constructor Create; override;
|
2007-11-28 17:40:31 +00:00
|
|
|
destructor Destroy; override;
|
|
|
|
|
|
2008-10-03 17:15:51 +00:00
|
|
|
procedure Preview(const AListaID : TIntegerList);
|
|
|
|
|
procedure Print(const AListaID : TIntegerList);
|
|
|
|
|
function ExportToPDF(const AID: Integer; const AFileName : String = ''): Boolean;
|
2007-11-28 17:40:31 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
uROTypes, uEditorRegistryUtils, uIEditorPresupuestosClientePreview,
|
2008-10-03 17:15:51 +00:00
|
|
|
uEditorPreview, uDataModulePresupuestosCliente, uEditorBase, cxControls,
|
|
|
|
|
uFactuGES_App, uStringsUtils;
|
2007-11-28 17:40:31 +00:00
|
|
|
|
|
|
|
|
{ TPresupuestosClienteReportController }
|
|
|
|
|
|
|
|
|
|
constructor TPresupuestosClienteReportController.Create;
|
|
|
|
|
begin
|
2008-11-11 12:25:58 +00:00
|
|
|
inherited;
|
2007-11-28 17:40:31 +00:00
|
|
|
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;
|
|
|
|
|
|
2008-10-03 17:15:51 +00:00
|
|
|
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);
|
2007-11-28 17:40:31 +00:00
|
|
|
var
|
|
|
|
|
AStream: Binary;
|
|
|
|
|
AEditor : IEditorPresupuestosClientePreview;
|
|
|
|
|
begin
|
|
|
|
|
AEditor := NIL;
|
2008-11-11 18:52:28 +00:00
|
|
|
AStream := FDataModule.GetRptPresupuestos(AListaID);
|
2007-11-28 17:40:31 +00:00
|
|
|
try
|
2008-11-11 18:52:28 +00:00
|
|
|
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;
|
2007-11-28 17:40:31 +00:00
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
finally
|
2008-11-11 18:52:28 +00:00
|
|
|
FreeAndNil(AStream);
|
2007-11-28 17:40:31 +00:00
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
2008-10-03 17:15:51 +00:00
|
|
|
procedure TPresupuestosClienteReportController.Print(const AListaID : TIntegerList);
|
2007-11-28 17:40:31 +00:00
|
|
|
var
|
|
|
|
|
AStream: Binary;
|
|
|
|
|
AEditor : IEditorPresupuestosClientePreview;
|
|
|
|
|
begin
|
|
|
|
|
AEditor := NIL;
|
|
|
|
|
ShowHourglassCursor;
|
|
|
|
|
try
|
2008-10-03 17:15:51 +00:00
|
|
|
AStream := FDataModule.GetRptPresupuestos(AListaID);
|
2007-11-28 17:40:31 +00:00
|
|
|
try
|
|
|
|
|
CreateEditor('EditorPresupuestosClientePreview', IEditorPresupuestosClientePreview, AEditor);
|
|
|
|
|
if Assigned(AEditor) then
|
|
|
|
|
begin
|
2008-10-03 17:15:51 +00:00
|
|
|
try
|
|
|
|
|
AEditor.Controller := Self;
|
|
|
|
|
AEditor.ListaID := AListaID;
|
|
|
|
|
AEditor.Title := 'Presupuesto - ' + AppFactuGES.EmpresaActiva.NOMBRE;
|
|
|
|
|
AEditor.LoadFromStream(AStream);
|
|
|
|
|
AEditor.Print;
|
|
|
|
|
finally
|
|
|
|
|
AEditor.Release;
|
2008-11-11 18:52:28 +00:00
|
|
|
AEditor := Nil;
|
2008-10-03 17:15:51 +00:00
|
|
|
end;
|
2007-11-28 17:40:31 +00:00
|
|
|
end;
|
|
|
|
|
finally
|
|
|
|
|
FreeAndNil(AStream);
|
|
|
|
|
end;
|
|
|
|
|
finally
|
|
|
|
|
HideHourglassCursor;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end.
|