180 lines
4.7 KiB
ObjectPascal
180 lines
4.7 KiB
ObjectPascal
|
|
unit uAlbaranesProveedorReportController;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Classes, SysUtils, uDADataTable, uControllerBase, uIDataModuleAlbaranesProveedorReport,
|
|||
|
|
uAlbaranesProveedorController, uDetallesAlbaranProveedorController,
|
|||
|
|
uBizAlbaranesProveedor, uIntegerListUtils;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
IAlbaranesProveedorReportController = interface(IControllerBase)
|
|||
|
|
['{11F9D087-C6BE-4401-AB13-4342025D62BB}']
|
|||
|
|
procedure Preview(const AListaID : TIntegerList);
|
|||
|
|
procedure Print(const AListaID : TIntegerList);
|
|||
|
|
function ExportToWord(const AID: Integer; const AFileName : String = ''): Boolean;
|
|||
|
|
function ExportToPDF(const AID: Integer; const AFileName : String = ''): Boolean;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
TAlbaranesProveedorReportController = class(TControllerBase, IAlbaranesProveedorReportController)
|
|||
|
|
private
|
|||
|
|
FDataModule : IDataModuleAlbaranesProveedorReport;
|
|||
|
|
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 ExportToWord(const AID: Integer; const AFileName : String = ''): Boolean;
|
|||
|
|
function ExportToPDF(const AID: Integer; const AFileName : String = ''): Boolean;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
uROTypes, uEditorRegistryUtils, uIEditorAlbaranesProveedorPreview,
|
|||
|
|
uEditorPreview, uDataModuleAlbaranesProveedor, uEditorBase, cxControls,
|
|||
|
|
uStringsUtils, uSistemaFunc, uFactuGES_App;
|
|||
|
|
|
|||
|
|
{ TAlbaranesProveedorReportController }
|
|||
|
|
|
|||
|
|
constructor TAlbaranesProveedorReportController.Create;
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
FDataModule := TDataModuleAlbaranesProveedor.Create(Nil);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TAlbaranesProveedorReportController.CreateEditor(const AName: String;
|
|||
|
|
const IID: TGUID; out Intf): Boolean;
|
|||
|
|
begin
|
|||
|
|
Result := Supports(EditorRegistry.CreateEditor(AName), IID, Intf);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
|
|||
|
|
destructor TAlbaranesProveedorReportController.Destroy;
|
|||
|
|
begin
|
|||
|
|
FDataModule := NIL;
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TAlbaranesProveedorReportController.ExportToPDF(const AID: Integer;
|
|||
|
|
const AFileName: String): Boolean;
|
|||
|
|
var
|
|||
|
|
AStream: Binary;
|
|||
|
|
begin
|
|||
|
|
Result := False;
|
|||
|
|
if EsCadenaVacia(AFileName) then
|
|||
|
|
Exit;
|
|||
|
|
|
|||
|
|
ShowHourglassCursor;
|
|||
|
|
try
|
|||
|
|
AStream := FDataModule.GetRptPDFAlbaran(AID);
|
|||
|
|
try
|
|||
|
|
AStream.SaveToFile(AFileName);
|
|||
|
|
Result := True;
|
|||
|
|
finally
|
|||
|
|
FreeAndNil(AStream);
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
HideHourglassCursor;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TAlbaranesProveedorReportController.ExportToWord(const AID: Integer;
|
|||
|
|
const AFileName: String): Boolean;
|
|||
|
|
var
|
|||
|
|
AStream: Binary;
|
|||
|
|
AFile : String;
|
|||
|
|
begin
|
|||
|
|
Result := False;
|
|||
|
|
AFile := AFileName;
|
|||
|
|
|
|||
|
|
if EsCadenaVacia(AFile) and (not PreguntarFicheroWordExportar(AFile)) then
|
|||
|
|
Exit;
|
|||
|
|
|
|||
|
|
ShowHourglassCursor;
|
|||
|
|
try
|
|||
|
|
AStream := FDataModule.GetRptWordAlbaran(AID);
|
|||
|
|
try
|
|||
|
|
AStream.SaveToFile(AFile);
|
|||
|
|
Result := True;
|
|||
|
|
finally
|
|||
|
|
FreeAndNil(AStream);
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
HideHourglassCursor;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TAlbaranesProveedorReportController.Preview(
|
|||
|
|
const AListaID: TIntegerList);
|
|||
|
|
var
|
|||
|
|
AStream: Binary;
|
|||
|
|
AEditor : IEditorAlbaranesProveedorPreview;
|
|||
|
|
begin
|
|||
|
|
AEditor := NIL;
|
|||
|
|
|
|||
|
|
ShowHourglassCursor;
|
|||
|
|
try
|
|||
|
|
AStream := FDataModule.GetReport(AListaID);
|
|||
|
|
try
|
|||
|
|
CreateEditor('EditorAlbaranesProveedorPreview', IEditorAlbaranesProveedorPreview, AEditor);
|
|||
|
|
if Assigned(AEditor) then
|
|||
|
|
begin
|
|||
|
|
try
|
|||
|
|
AEditor.Controller := Self;
|
|||
|
|
AEditor.ListaID := AListaID;
|
|||
|
|
AEditor.Title := 'Albar<61>n de proveedor - ' + AppFactuGES.EmpresaActiva.NOMBRE;
|
|||
|
|
AEditor.LoadFromStream(AStream);
|
|||
|
|
AEditor.Preview;
|
|||
|
|
finally
|
|||
|
|
AEditor.Release;
|
|||
|
|
AEditor := Nil;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
FreeANDNil(AStream)
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
HideHourglassCursor;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TAlbaranesProveedorReportController.Print(
|
|||
|
|
const AListaID: TIntegerList);
|
|||
|
|
var
|
|||
|
|
AStream: Binary;
|
|||
|
|
AEditor : IEditorAlbaranesProveedorPreview;
|
|||
|
|
begin
|
|||
|
|
AEditor := NIL;
|
|||
|
|
|
|||
|
|
ShowHourglassCursor;
|
|||
|
|
try
|
|||
|
|
AStream := FDataModule.GetReport(AListaID);
|
|||
|
|
try
|
|||
|
|
CreateEditor('EditorAlbaranesProveedorPreview', IEditorAlbaranesProveedorPreview, AEditor);
|
|||
|
|
if Assigned(AEditor) then
|
|||
|
|
begin
|
|||
|
|
try
|
|||
|
|
AEditor.Controller := Self;
|
|||
|
|
AEditor.ListaID := AListaID;
|
|||
|
|
AEditor.Title := 'Albar<61>n de proveedor - ' + AppFactuGES.EmpresaActiva.NOMBRE;
|
|||
|
|
AEditor.LoadFromStream(AStream);
|
|||
|
|
AEditor.Print;
|
|||
|
|
finally
|
|||
|
|
AEditor.Release;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
FreeAndNil(AStream);
|
|||
|
|
AEditor := Nil;
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
HideHourglassCursor;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|