2007-10-26 18:19:55 +00:00
|
|
|
unit uPresupuestosClienteReportController;
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
Classes, SysUtils, uDADataTable, uControllerBase, uIDataModulePresupuestosClienteReport,
|
|
|
|
|
uClientesController, uPresupuestosClienteController, uDetallesPresupuestoClienteController,
|
|
|
|
|
uBizPresupuestosCliente;
|
|
|
|
|
|
|
|
|
|
type
|
2008-02-06 14:28:09 +00:00
|
|
|
IPresupuestosClienteReportController = interface(IControllerBase)
|
2007-10-26 18:19:55 +00:00
|
|
|
['{D0686358-251C-43C4-9927-6112F2F4D3B8}']
|
2008-02-06 14:28:09 +00:00
|
|
|
procedure Preview(const AListaID : String);
|
|
|
|
|
procedure Print(const AListaID : String);
|
|
|
|
|
function ExportToWord(const AID: Integer; const AFileName : String = ''): Boolean;
|
2007-10-26 18:19:55 +00:00
|
|
|
end;
|
|
|
|
|
|
2008-02-06 14:28:09 +00:00
|
|
|
TPresupuestosClienteReportController = class(TControllerBase, IPresupuestosClienteReportController)
|
2007-10-26 18:19:55 +00:00
|
|
|
private
|
|
|
|
|
FDataModule : IDataModulePresupuestosClienteReport;
|
|
|
|
|
function CreateEditor(const AName: String; const IID: TGUID; out Intf): Boolean;
|
|
|
|
|
public
|
|
|
|
|
constructor Create;
|
|
|
|
|
destructor Destroy; override;
|
|
|
|
|
|
2008-02-06 14:28:09 +00:00
|
|
|
procedure Preview(const AListaID : String);
|
|
|
|
|
procedure Print(const AListaID : String);
|
|
|
|
|
function ExportToWord(const AID: Integer; const AFileName : String = ''): Boolean;
|
2007-10-26 18:19:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
uROTypes, uEditorRegistryUtils, uIEditorPresupuestosClientePreview,
|
2007-12-20 21:05:11 +00:00
|
|
|
uEditorPreview, uDataModulePresupuestosCliente, uEditorBase,
|
2008-02-06 14:28:09 +00:00
|
|
|
cxControls, uFactuGES_App, uStringsUtils, uSistemaFunc;
|
2007-10-26 18:19:55 +00:00
|
|
|
|
|
|
|
|
{ TPresupuestosClienteReportController }
|
|
|
|
|
|
|
|
|
|
constructor TPresupuestosClienteReportController.Create;
|
|
|
|
|
begin
|
|
|
|
|
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-02-06 14:28:09 +00:00
|
|
|
function TPresupuestosClienteReportController.ExportToWord(const AID: Integer; const AFileName : String) : Boolean;
|
|
|
|
|
var
|
|
|
|
|
AStream: Binary;
|
|
|
|
|
AFile : String;
|
|
|
|
|
begin
|
|
|
|
|
AFile := AFileName;
|
|
|
|
|
if EsCadenaVacia(AFile) and (not DarFicheroWordExportar(AFile)) then
|
|
|
|
|
Exit;
|
|
|
|
|
|
|
|
|
|
ShowHourglassCursor;
|
|
|
|
|
try
|
|
|
|
|
AStream := FDataModule.GetRptWordPresupuesto(AID);
|
|
|
|
|
try
|
|
|
|
|
AStream.SaveToFile(AFile);
|
|
|
|
|
Result := True;
|
|
|
|
|
finally
|
|
|
|
|
FreeAndNil(AStream);
|
|
|
|
|
end;
|
|
|
|
|
finally
|
|
|
|
|
HideHourglassCursor;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TPresupuestosClienteReportController.Preview(const AListaID : String);
|
2007-10-26 18:19:55 +00:00
|
|
|
var
|
|
|
|
|
AStream: Binary;
|
|
|
|
|
AEditor : IEditorPresupuestosClientePreview;
|
|
|
|
|
begin
|
|
|
|
|
AEditor := NIL;
|
|
|
|
|
ShowHourglassCursor;
|
|
|
|
|
try
|
2008-02-06 14:28:09 +00:00
|
|
|
AStream := FDataModule.GetRptPresupuestos(AListaID);
|
2007-10-26 18:19:55 +00:00
|
|
|
try
|
|
|
|
|
CreateEditor('EditorPresupuestosClientePreview', IEditorPresupuestosClientePreview, AEditor);
|
2007-11-13 19:36:56 +00:00
|
|
|
if Assigned(AEditor) then
|
2007-12-20 21:05:11 +00:00
|
|
|
with AEditor do
|
|
|
|
|
begin
|
2008-02-06 14:28:09 +00:00
|
|
|
AEditor.Controller := Self;
|
|
|
|
|
AEditor.ListaID := AListaID;
|
2007-12-20 21:05:11 +00:00
|
|
|
Title := 'Presupuesto - ' + AppFactuGES.EmpresaActiva.NOMBRE;
|
|
|
|
|
LoadFromStream(AStream);
|
|
|
|
|
Preview;
|
|
|
|
|
Release;
|
|
|
|
|
end;
|
2007-10-26 18:19:55 +00:00
|
|
|
finally
|
2007-11-13 19:36:56 +00:00
|
|
|
FreeAndNil(AStream);
|
|
|
|
|
AEditor := Nil;
|
2007-10-26 18:19:55 +00:00
|
|
|
end;
|
|
|
|
|
finally
|
|
|
|
|
HideHourglassCursor;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
2008-02-06 14:28:09 +00:00
|
|
|
procedure TPresupuestosClienteReportController.Print(const AListaID : String);
|
2007-10-26 18:19:55 +00:00
|
|
|
var
|
|
|
|
|
AStream: Binary;
|
|
|
|
|
AEditor : IEditorPresupuestosClientePreview;
|
|
|
|
|
begin
|
|
|
|
|
AEditor := NIL;
|
|
|
|
|
ShowHourglassCursor;
|
|
|
|
|
try
|
2008-02-06 14:28:09 +00:00
|
|
|
AStream := FDataModule.GetRptPresupuestos(AListaID);
|
2007-10-26 18:19:55 +00:00
|
|
|
try
|
|
|
|
|
CreateEditor('EditorPresupuestosClientePreview', IEditorPresupuestosClientePreview, AEditor);
|
2007-11-13 19:36:56 +00:00
|
|
|
if Assigned(AEditor) then
|
|
|
|
|
with AEditor do
|
|
|
|
|
begin
|
2008-02-06 14:28:09 +00:00
|
|
|
AEditor.Controller := Self;
|
|
|
|
|
AEditor.ListaID := AListaID;
|
2007-11-13 19:36:56 +00:00
|
|
|
AEditor.LoadFromStream(AStream);
|
|
|
|
|
AEditor.Print;
|
|
|
|
|
AEditor.Release;
|
|
|
|
|
end;
|
2007-10-26 18:19:55 +00:00
|
|
|
finally
|
2007-11-13 19:36:56 +00:00
|
|
|
FreeAndNil(AStream);
|
|
|
|
|
AEditor := Nil;
|
2007-10-26 18:19:55 +00:00
|
|
|
end;
|
|
|
|
|
finally
|
|
|
|
|
HideHourglassCursor;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
if Assigned(AEditor) then
|
2007-11-13 19:36:56 +00:00
|
|
|
|
2007-10-26 18:19:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end.
|