git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@1000 0c75b7a4-871f-7646-8a2f-f78d34cc349f
192 lines
6.0 KiB
ObjectPascal
192 lines
6.0 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;
|
||
const VerPrecios: Boolean = True; const VerRefProveedor: Boolean = True);
|
||
procedure Print(const AListaID : TIntegerList;
|
||
const VerPrecios: Boolean = True; const VerRefProveedor: Boolean = True);
|
||
function ExportToWord(const AID: Integer; const AFileName : String = '';
|
||
const VerPrecios: Boolean = True; const VerRefProveedor: Boolean = True): Boolean;
|
||
function ExportToPDF(const AID: Integer; const AFileName : String = '';
|
||
const VerPrecios: Boolean = True; const VerRefProveedor: Boolean = True): 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;
|
||
const VerPrecios: Boolean = True; const VerRefProveedor: Boolean = True);
|
||
procedure Print(const AListaID : TIntegerList;
|
||
const VerPrecios: Boolean = True; const VerRefProveedor: Boolean = True);
|
||
function ExportToWord(const AID: Integer; const AFileName : String = '';
|
||
const VerPrecios: Boolean = True; const VerRefProveedor: Boolean = True): Boolean;
|
||
function ExportToPDF(const AID: Integer; const AFileName : String = '';
|
||
const VerPrecios: Boolean = True; const VerRefProveedor: Boolean = True): 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 = '';
|
||
const VerPrecios: Boolean = True; const VerRefProveedor: Boolean = True): Boolean;
|
||
var
|
||
AStream: Binary;
|
||
begin
|
||
Result := False;
|
||
if EsCadenaVacia(AFileName) then
|
||
Exit;
|
||
|
||
ShowHourglassCursor;
|
||
try
|
||
AStream := FDataModule.GetRptPDFAlbaran(AID, VerPrecios, VerRefProveedor);
|
||
try
|
||
AStream.SaveToFile(AFileName);
|
||
Result := True;
|
||
finally
|
||
FreeAndNil(AStream);
|
||
end;
|
||
finally
|
||
HideHourglassCursor;
|
||
end;
|
||
end;
|
||
|
||
function TAlbaranesProveedorReportController.ExportToWord(const AID: Integer; const AFileName : String = '';
|
||
const VerPrecios: Boolean = True; const VerRefProveedor: Boolean = True): 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, VerPrecios, VerRefProveedor);
|
||
try
|
||
AStream.SaveToFile(AFile);
|
||
Result := True;
|
||
finally
|
||
FreeAndNil(AStream);
|
||
end;
|
||
finally
|
||
HideHourglassCursor;
|
||
end;
|
||
end;
|
||
|
||
procedure TAlbaranesProveedorReportController.Preview(const AListaID: TIntegerList;
|
||
const VerPrecios: Boolean = True; const VerRefProveedor: Boolean = True);
|
||
var
|
||
AStream: Binary;
|
||
AEditor : IEditorAlbaranesProveedorPreview;
|
||
begin
|
||
AEditor := NIL;
|
||
|
||
ShowHourglassCursor;
|
||
try
|
||
AStream := FDataModule.GetReport(AListaID, VerPrecios, VerRefProveedor);
|
||
try
|
||
CreateEditor('EditorAlbaranesProveedorPreview', IEditorAlbaranesProveedorPreview, AEditor);
|
||
if Assigned(AEditor) then
|
||
begin
|
||
try
|
||
AEditor.Controller := Self;
|
||
AEditor.ListaID := AListaID;
|
||
AEditor.VerPrecios := VerPrecios;
|
||
AEditor.VerRefProveedor := VerRefProveedor;
|
||
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;
|
||
const VerPrecios: Boolean = True; const VerRefProveedor: Boolean = True);
|
||
var
|
||
AStream: Binary;
|
||
AEditor : IEditorAlbaranesProveedorPreview;
|
||
begin
|
||
AEditor := NIL;
|
||
|
||
ShowHourglassCursor;
|
||
try
|
||
AStream := FDataModule.GetReport(AListaID, VerPrecios, VerRefProveedor);
|
||
try
|
||
CreateEditor('EditorAlbaranesProveedorPreview', IEditorAlbaranesProveedorPreview, AEditor);
|
||
if Assigned(AEditor) then
|
||
begin
|
||
try
|
||
AEditor.Controller := Self;
|
||
AEditor.ListaID := AListaID;
|
||
AEditor.VerPrecios := VerPrecios;
|
||
AEditor.VerRefProveedor := VerRefProveedor;
|
||
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.
|