git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@964 0c75b7a4-871f-7646-8a2f-f78d34cc349f
323 lines
10 KiB
ObjectPascal
323 lines
10 KiB
ObjectPascal
{
|
|
===============================================================================
|
|
Copyright (©) 2007. Rodax Software.
|
|
===============================================================================
|
|
Los contenidos de este fichero son propiedad de Rodax Software titular del
|
|
copyright. Este fichero sólo podrá ser copiado, distribuido y utilizado,
|
|
en su totalidad o en parte, con el permiso escrito de Rodax Software, o de
|
|
acuerdo con los términos y condiciones establecidas en el acuerdo/contrato
|
|
bajo el que se suministra.
|
|
-----------------------------------------------------------------------------
|
|
Web: www.rodax-software.com
|
|
===============================================================================
|
|
Fecha primera versión:
|
|
Versión actual: 1.0.0
|
|
Fecha versión actual:
|
|
===============================================================================
|
|
Modificaciones:
|
|
|
|
Fecha Comentarios
|
|
---------------------------------------------------------------------------
|
|
===============================================================================
|
|
}
|
|
|
|
unit uEditorRecibosCliente;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
Dialogs, Menus, DB, uDADataTable, JvAppStorage,
|
|
JvAppRegistryStorage, JvComponent, JvFormPlacement, ImgList,
|
|
PngImageList, StdActns, ActnList, ComCtrls, TB2ExtItems, TBXExtItems,
|
|
TBX, TB2Item, TB2Dock, TB2Toolbar, ExtCtrls, JvExControls,
|
|
JvNavigationPane, uViewGrid, pngimage, JvComponentBase,
|
|
JvExComCtrls, JvStatusBar, uViewBase, uViewBarraSeleccion, uViewGridBase,
|
|
uEditorGridBase, uCustomView,
|
|
|
|
uBizRecibosCliente, uIEditorRecibosCliente, uRecibosClienteController,
|
|
uViewRecibosCliente, JSDialog, uDAInterfaces;
|
|
|
|
type
|
|
|
|
TfEditorRecibosCliente = class(TfEditorGridBase, IEditorRecibosCliente)
|
|
frViewRecibosCliente1: TfrViewRecibosCliente;
|
|
JsPrevisualizarDialog: TJSDialog;
|
|
JsImprimirDialog: TJSDialog;
|
|
actInformes: TAction;
|
|
TBXItem38: TTBXItem;
|
|
JSInformesDialog: TJSDialog;
|
|
procedure FormShow(Sender: TObject);
|
|
procedure actInformesExecute(Sender: TObject);
|
|
procedure OnListaAnosChange(Sender: TObject; const Text: string);
|
|
|
|
private
|
|
FRecibosCliente: IBizRecibosCliente;
|
|
FController : IRecibosClienteController;
|
|
protected
|
|
function GetRecibosCliente: IBizRecibosCliente;
|
|
procedure SetRecibosCliente(const Value: IBizRecibosCliente);
|
|
|
|
function GetController : IRecibosClienteController;
|
|
procedure SetController (const Value : IRecibosClienteController);
|
|
|
|
procedure NuevoInterno; override;
|
|
procedure EliminarInterno; override;
|
|
procedure ModificarInterno; override;
|
|
procedure DuplicarInterno; override;
|
|
procedure ImprimirInterno; override;
|
|
procedure PrevisualizarInterno; override;
|
|
procedure RefrescarInterno; override;
|
|
|
|
public
|
|
procedure PonerTitulos(const ATitulo: string = ''); override;
|
|
property RecibosCliente: IBizRecibosCliente read GetRecibosCliente write SetRecibosCliente;
|
|
property Controller : IRecibosClienteController read GetController write SetController;
|
|
|
|
constructor Create(AOwner: TComponent); override;
|
|
destructor Destroy; override;
|
|
end;
|
|
|
|
|
|
implementation
|
|
|
|
uses
|
|
uDataModuleRecibosCliente, uDataModuleUsuarios, uFactuGES_App,
|
|
uGridStatusUtils, uDBSelectionListUtils, uGestorInformesController;
|
|
|
|
{$R *.dfm}
|
|
|
|
{
|
|
*************************** TfEditorRecibosCliente ***************************
|
|
}
|
|
procedure TfEditorRecibosCliente.actInformesExecute(Sender: TObject);
|
|
var
|
|
Respuesta : Integer;
|
|
AGestorInformesController : IGestorInformesController;
|
|
|
|
begin
|
|
AGestorInformesController := TGestorInformesController.Create;
|
|
try
|
|
|
|
Respuesta := JsInformesDialog.Execute;
|
|
|
|
if Respuesta <> IDCANCEL then
|
|
begin
|
|
case JsInformesDialog.CustomButtonResult of
|
|
100 : begin // Listado de recibos pendientes
|
|
AGestorInformesController.VerInformeListadoRecibosCliPendientes;
|
|
end;
|
|
200 : begin // Listado de recibos de cliente
|
|
AGestorInformesController.VerInformeListadoRecibosCliente;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
finally
|
|
AGestorInformesController := NIL;
|
|
end;
|
|
end;
|
|
|
|
constructor TfEditorRecibosCliente.Create(AOwner: TComponent);
|
|
begin
|
|
inherited;
|
|
FController := TRecibosClienteController.Create;
|
|
|
|
FHeaderText := 'Lista de recibos de cliente';
|
|
FWindowCaption := FHeaderText;
|
|
|
|
ViewGrid := frViewRecibosCliente1; // CreateView(TfrViewRecibosCliente) as IViewRecibosCliente;
|
|
end;
|
|
|
|
destructor TfEditorRecibosCliente.Destroy;
|
|
begin
|
|
FRecibosCliente := NIL;
|
|
FController := NIL;
|
|
inherited;
|
|
end;
|
|
|
|
procedure TfEditorRecibosCliente.DuplicarInterno;
|
|
begin
|
|
// No se pueden duplicar recibos
|
|
end;
|
|
|
|
procedure TfEditorRecibosCliente.EliminarInterno;
|
|
begin
|
|
//
|
|
//No se pueden eliminar recibos
|
|
end;
|
|
|
|
procedure TfEditorRecibosCliente.FormShow(Sender: TObject);
|
|
begin
|
|
cbxListaAnos.OnChange := OnListaAnosChange; //OJO SIEMPRE ANTES DEL INHERITED
|
|
|
|
inherited;
|
|
|
|
if not Assigned(ViewGrid) then
|
|
raise Exception.Create('No hay ninguna vista asignada');
|
|
|
|
if not Assigned(FRecibosCliente) then
|
|
raise Exception.Create('No hay ningún objeto asignado');
|
|
|
|
FRecibosCliente.DataTable.Active := True;
|
|
ViewGrid.GotoFirst;
|
|
end;
|
|
|
|
function TfEditorRecibosCliente.GetController: IRecibosClienteController;
|
|
begin
|
|
Result := FController;
|
|
end;
|
|
|
|
function TfEditorRecibosCliente.GetRecibosCliente: IBizRecibosCliente;
|
|
begin
|
|
Result := FRecibosCliente;
|
|
end;
|
|
|
|
procedure TfEditorRecibosCliente.ImprimirInterno;
|
|
var
|
|
Respuesta : Integer;
|
|
ARecibosCliente: IBizRecibosCliente;
|
|
AllItems: Boolean;
|
|
|
|
begin
|
|
ARecibosCliente := Nil;
|
|
AllItems := False;
|
|
|
|
if MultiSelect and Assigned(ViewGrid) then
|
|
AllItems := (ViewGrid.NumSeleccionados > 1);
|
|
|
|
//Si esta agrupado solo podré imprimir la lista de elementos visibles
|
|
if not ViewGrid.esSeleccionCeldaDatos then
|
|
inherited
|
|
else
|
|
begin
|
|
Respuesta := JsPrevisualizarDialog.Execute;
|
|
if Respuesta <> IDCANCEL then
|
|
begin
|
|
case JsPrevisualizarDialog.CustomButtonResult of
|
|
200 : begin // Lista de elementos visibles
|
|
inherited;
|
|
end;
|
|
100 : begin // Elemento Seleccionado
|
|
if AllItems then
|
|
begin
|
|
SeleccionarFilasDesdeGrid(ViewGrid._FocusedView, (RecibosCliente as ISeleccionable).SelectedRecords);
|
|
ARecibosCliente := (Controller as IRecibosClienteController).ExtraerSeleccionados(RecibosCliente) as IBizRecibosCliente;
|
|
end
|
|
else
|
|
ARecibosCliente := RecibosCliente;
|
|
|
|
if Assigned(ARecibosCliente) then
|
|
FController.Print(ARecibosCliente, AllItems);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TfEditorRecibosCliente.ModificarInterno;
|
|
begin
|
|
inherited;
|
|
FController.Ver(FRecibosCliente);
|
|
RefrescarInterno;
|
|
end;
|
|
|
|
procedure TfEditorRecibosCliente.NuevoInterno;
|
|
begin
|
|
// inherited;
|
|
//No se pueden añadir recibos nuevos
|
|
end;
|
|
|
|
procedure TfEditorRecibosCliente.OnListaAnosChange(Sender: TObject; const Text: string);
|
|
begin
|
|
Controller.FiltrarAno(RecibosCliente, DynWhereDataTable, Text);
|
|
if RecibosCliente.DataTable.Active then
|
|
RefrescarInterno;
|
|
end;
|
|
|
|
procedure TfEditorRecibosCliente.PonerTitulos(const ATitulo: string);
|
|
var
|
|
FTitulo : String;
|
|
begin
|
|
FTitulo := FWindowCaption + ' - ' + AppFactuGES.EmpresaActiva.NOMBRE;
|
|
inherited PonerTitulos(FTitulo);
|
|
end;
|
|
|
|
procedure TfEditorRecibosCliente.PrevisualizarInterno;
|
|
var
|
|
Respuesta: Integer;
|
|
ARecibosCliente: IBizRecibosCliente;
|
|
AllItems: Boolean;
|
|
|
|
begin
|
|
|
|
ARecibosCliente := Nil;
|
|
AllItems := False;
|
|
|
|
if MultiSelect and Assigned(ViewGrid) then
|
|
AllItems := (ViewGrid.NumSeleccionados > 1);
|
|
|
|
//Si esta agrupado solo podré imprimir la lista de elementos visibles
|
|
if not ViewGrid.esSeleccionCeldaDatos then
|
|
inherited
|
|
else
|
|
begin
|
|
Respuesta := JsPrevisualizarDialog.Execute;
|
|
if Respuesta <> IDCANCEL then
|
|
begin
|
|
case JsPrevisualizarDialog.CustomButtonResult of
|
|
200 : begin // Lista de elementos visibles
|
|
inherited;
|
|
end;
|
|
100 : begin // Elemento Seleccionado
|
|
if AllItems then
|
|
begin
|
|
SeleccionarFilasDesdeGrid(ViewGrid._FocusedView, (RecibosCliente as ISeleccionable).SelectedRecords);
|
|
ARecibosCliente := (Controller as IRecibosClienteController).ExtraerSeleccionados(RecibosCliente) as IBizRecibosCliente;
|
|
end
|
|
else
|
|
ARecibosCliente := RecibosCliente;
|
|
|
|
if Assigned(ARecibosCliente) then
|
|
FController.Preview(ARecibosCliente, AllItems);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TfEditorRecibosCliente.RefrescarInterno;
|
|
begin
|
|
//Volvemos a cargar los años de los albaranes
|
|
if Assigned(FController) then
|
|
ListaAnos := FController.DarListaAnosRecibos;
|
|
|
|
inherited;
|
|
end;
|
|
|
|
procedure TfEditorRecibosCliente.SetController(const Value: IRecibosClienteController);
|
|
begin
|
|
FController := Value;
|
|
|
|
if Assigned(FController) then
|
|
ListaAnos := FController.DarListaAnosRecibos;
|
|
end;
|
|
|
|
procedure TfEditorRecibosCliente.SetRecibosCliente(const Value: IBizRecibosCliente);
|
|
begin
|
|
FRecibosCliente := Value;
|
|
|
|
if Assigned(FRecibosCliente) then
|
|
begin
|
|
//Se guarda el where de la sentencia origen, por si el editor tiene filtros que
|
|
//afecten a este where y en un futuro se desea volver al where origen (filtro de año))
|
|
DynWhereDataTable := FRecibosCliente.DataTable.DynamicWhere.Xml;
|
|
|
|
dsDataTable.DataTable := FRecibosCliente.DataTable;
|
|
if Assigned(ViewGrid) then
|
|
(ViewGrid as IViewRecibosCliente).Recibos := FRecibosCliente;
|
|
end;
|
|
end;
|
|
|
|
end.
|