git-svn-id: https://192.168.0.254/svn/Proyectos.LuisLeon_FactuGES2/trunk@26 b2cfbe5a-eba1-4a0c-8b32-7feea0a119f2
161 lines
4.7 KiB
ObjectPascal
161 lines
4.7 KiB
ObjectPascal
unit uPedidosClienteReportController;
|
|
|
|
interface
|
|
|
|
uses
|
|
Classes, SysUtils, uDADataTable, uControllerBase, uIDataModulePedidosClienteReport,
|
|
uClientesController, uPedidosClienteController, uDetallesPedidoClienteController,
|
|
uBizPedidosCliente, uIntegerListUtils;
|
|
|
|
type
|
|
IPedidosClienteReportController = interface(IControllerBase)
|
|
['{D68620B5-2EB6-47DE-89D9-560943990895}']
|
|
procedure Preview(const AListaID : TIntegerList;
|
|
const VerPrecios: Boolean = True; const VerRefCliente: Boolean = True);
|
|
procedure Print(const AListaID : TIntegerList;
|
|
const VerPrecios: Boolean = True; const VerRefCliente: Boolean = True);
|
|
function ExportToPDF(const AID: Integer; const AFileName : String = '';
|
|
const VerPrecios: Boolean = True; const VerRefCliente: Boolean = True): Boolean;
|
|
end;
|
|
|
|
TPedidosClienteReportController = class(TControllerBase, IPedidosClienteReportController)
|
|
private
|
|
FDataModule : IDataModulePedidosClienteReport;
|
|
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 VerRefCliente: Boolean = True);
|
|
procedure Print(const AListaID : TIntegerList;
|
|
const VerPrecios: Boolean = True; const VerRefCliente: Boolean = True);
|
|
function ExportToPDF(const AID: Integer; const AFileName : String = '';
|
|
const VerPrecios: Boolean = True; const VerRefCliente: Boolean = True): Boolean;
|
|
end;
|
|
|
|
|
|
implementation
|
|
|
|
uses
|
|
uROTypes, uEditorRegistryUtils, uIEditorPedidosClientePreview,
|
|
uEditorPreview, uDataModulePedidosCliente, uEditorBase, cxControls,
|
|
uFactuGES_App, uStringsUtils, uSistemaFunc;
|
|
|
|
{ TPedidosClienteReportController }
|
|
|
|
constructor TPedidosClienteReportController.Create;
|
|
begin
|
|
inherited;
|
|
FDataModule := TDataModulePedidosCliente.Create(Nil);
|
|
end;
|
|
|
|
function TPedidosClienteReportController.CreateEditor(const AName: String;
|
|
const IID: TGUID; out Intf): Boolean;
|
|
begin
|
|
Result := Supports(EditorRegistry.CreateEditor(AName), IID, Intf);
|
|
end;
|
|
|
|
|
|
destructor TPedidosClienteReportController.Destroy;
|
|
begin
|
|
FDataModule := NIL;
|
|
inherited;
|
|
end;
|
|
|
|
function TPedidosClienteReportController.ExportToPDF(const AID: Integer;
|
|
const AFileName: String; const VerPrecios: Boolean;
|
|
const VerRefCliente: Boolean): Boolean;
|
|
var
|
|
AStream: Binary;
|
|
begin
|
|
Result := False;
|
|
if EsCadenaVacia(AFileName) then
|
|
Exit;
|
|
|
|
ShowHourglassCursor;
|
|
try
|
|
AStream := FDataModule.GetRptPDFPedido(AID, VerPrecios, VerRefCliente);
|
|
try
|
|
AStream.SaveToFile(AFileName);
|
|
Result := True;
|
|
finally
|
|
FreeAndNil(AStream);
|
|
end;
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
procedure TPedidosClienteReportController.Preview(const AListaID : TIntegerList;
|
|
const VerPrecios: Boolean; const VerRefCliente: Boolean);
|
|
var
|
|
AStream: Binary;
|
|
AEditor : IEditorPedidosClientePreview;
|
|
begin
|
|
AEditor := NIL;
|
|
|
|
ShowHourglassCursor;
|
|
try
|
|
AStream := FDataModule.GetReport(AListaID, VerPrecios, VerRefCliente);
|
|
try
|
|
CreateEditor('EditorPedidosClientePreview', IEditorPedidosClientePreview, AEditor);
|
|
if Assigned(AEditor) then
|
|
begin
|
|
try
|
|
AEditor.Controller := Self;
|
|
AEditor.ListaID := AListaID;
|
|
// AEditor.VerPrecios := VerPrecios;
|
|
// AEditor.VerRefProveedor := VerRefProveedor;
|
|
AEditor.Title := 'Pedido de cliente - ' + AppFactuGES.EmpresaActiva.NOMBRE;
|
|
AEditor.LoadFromStream(AStream);
|
|
AEditor.Preview;
|
|
finally
|
|
AEditor.Release;
|
|
AEditor := Nil;
|
|
end;
|
|
end;
|
|
finally
|
|
FreeANDNil(AStream)
|
|
end;
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
procedure TPedidosClienteReportController.Print(const AListaID : TIntegerList;
|
|
const VerPrecios: Boolean; const VerRefCliente: Boolean);
|
|
var
|
|
AStream: Binary;
|
|
AEditor : IEditorPedidosClientePreview;
|
|
begin
|
|
AEditor := NIL;
|
|
|
|
ShowHourglassCursor;
|
|
try
|
|
AStream := FDataModule.GetReport(AListaID, VerPrecios, VerRefCliente);
|
|
try
|
|
CreateEditor('EditorPedidosClientePreview', IEditorPedidosClientePreview, AEditor);
|
|
if Assigned(AEditor) then
|
|
begin
|
|
try
|
|
AEditor.Controller := Self;
|
|
AEditor.ListaID := AListaID;
|
|
AEditor.Title := 'Pedido de cliente - ' + AppFactuGES.EmpresaActiva.NOMBRE;
|
|
AEditor.LoadFromStream(AStream);
|
|
AEditor.Print;
|
|
finally
|
|
AEditor.Release;
|
|
end;
|
|
end;
|
|
finally
|
|
FreeAndNil(AStream);
|
|
AEditor := Nil;
|
|
end;
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
end.
|