git-svn-id: https://192.168.0.254/svn/Proyectos.AbetoDesign_FactuGES/trunk@155 93f398dd-4eb6-7a46-baf6-13f46f578da2
681 lines
20 KiB
ObjectPascal
681 lines
20 KiB
ObjectPascal
unit uEditorContratosCliente;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Menus, DB, uDADataTable, JvAppStorage,
|
||
JvAppRegistryStorage, JvComponent, JvFormPlacement, ImgList,
|
||
PngImageList, StdActns, ActnList, ComCtrls, TB2ExtItems, TBXExtItems,
|
||
TBX, TB2Item, TB2Dock, TB2Toolbar, ExtCtrls, JvExControls,
|
||
JvNavigationPane, uViewGrid, pngimage, JvComponentBase,
|
||
uEditorGridBase,
|
||
uBizContratosCliente, uIEditorContratosCliente, uContratosClienteController,
|
||
uCustomView, uViewBase, uViewBarraSeleccion, uViewGridBase,
|
||
uViewContratosCliente, JvExComCtrls, JvStatusBar, JSDialog, StdCtrls,
|
||
uDAInterfaces;
|
||
|
||
type
|
||
TfEditorContratosCliente = class(TfEditorGridBase, IEditorContratosCliente)
|
||
actGenerarAlbaranCli: TAction;
|
||
actGenerarFactura: TAction;
|
||
TBXSubmenuItem2: TTBXSubmenuItem;
|
||
TBXSeparatorItem17: TTBXSeparatorItem;
|
||
TBXItem38: TTBXItem;
|
||
TBXItem39: TTBXItem;
|
||
N4: TMenuItem;
|
||
Generar2: TMenuItem;
|
||
JsGenerarDialog: TJSDialog;
|
||
JsPrevisualizarDialog: TJSDialog;
|
||
JsImprimirDialog: TJSDialog;
|
||
TBXItem40: TTBXItem;
|
||
JsListaContratosNoEliminados: TJSDialog;
|
||
TBXItem41: TTBXItem;
|
||
Generarcertificado1: TMenuItem;
|
||
TBXSeparatorItem18: TTBXSeparatorItem;
|
||
actEnviarEMail: TAction;
|
||
TBXItem45: TTBXItem;
|
||
Enviarporemail1: TMenuItem;
|
||
actInformes: TAction;
|
||
TBXItem46: TTBXItem;
|
||
JSInformesDialog: TJSDialog;
|
||
TBXItem47: TTBXItem;
|
||
actListadoBeneficios: TAction;
|
||
TBXItem42: TTBXItem;
|
||
TBXSubmenuItem3: TTBXSubmenuItem;
|
||
TBXItem43: TTBXItem;
|
||
JsNuevoContratoDialog: TJSDialog;
|
||
procedure FormShow(Sender: TObject);
|
||
procedure actGenerarAlbaranCliExecute(Sender: TObject);
|
||
procedure actEliminarUpdate(Sender: TObject);
|
||
procedure actGenerarFacturaUpdate(Sender: TObject);
|
||
procedure actGenerarFacturaExecute(Sender: TObject);
|
||
procedure actGenerarPresupuestoProvExecute(Sender: TObject);
|
||
procedure actGenerarExecute(Sender: TObject);
|
||
procedure actAceptarExecute(Sender: TObject);
|
||
procedure actAceptarUpdate(Sender: TObject);
|
||
procedure actAnularExecute(Sender: TObject);
|
||
procedure actAnularUpdate(Sender: TObject);
|
||
procedure actEnviarEMailExecute(Sender: TObject);
|
||
procedure actEnviarEMailUpdate(Sender: TObject);
|
||
procedure actInformesExecute(Sender: TObject);
|
||
procedure OnListaAnosChange(Sender: TObject; const Text: string);
|
||
procedure actListadoBeneficiosExecute(Sender: TObject);
|
||
procedure bCocinaClick(Sender: TObject);
|
||
procedure bArmarioClick(Sender: TObject);
|
||
procedure bBanoClick(Sender: TObject);
|
||
procedure bElectrodomesticoClick(Sender: TObject);
|
||
procedure bVariosClick(Sender: TObject);
|
||
|
||
protected
|
||
FContratos: IBizContratoCliente;
|
||
FController : IContratosClienteController;
|
||
|
||
function GetContratos: IBizContratoCliente;
|
||
procedure SetContratos(const Value: IBizContratoCliente);
|
||
|
||
function GetController : IContratosClienteController; virtual;
|
||
procedure SetController (const Value : IContratosClienteController); virtual;
|
||
|
||
procedure NuevoInterno; override;
|
||
procedure ModificarInterno; override;
|
||
procedure EliminarInterno; override;
|
||
procedure DuplicarInterno; override;
|
||
procedure ImprimirInterno; override;
|
||
procedure PrevisualizarInterno; override;
|
||
procedure RefrescarInterno; override;
|
||
|
||
//Si queremos crear otra vista para el editor heredado solo tendriamos que
|
||
//sobreescribir este metodo
|
||
procedure AsignarVista; virtual;
|
||
|
||
public
|
||
procedure PonerTitulos(const ATitulo: string = ''); override;
|
||
property Contratos: IBizContratoCliente read GetContratos write SetContratos;
|
||
property Controller : IContratosClienteController read GetController write SetController;
|
||
constructor Create(AOwner: TComponent); override;
|
||
destructor Destroy; override;
|
||
end;
|
||
|
||
implementation
|
||
|
||
uses
|
||
uDataModuleContratosCliente, uDataModuleUsuarios, uFactuGES_App,
|
||
uEditorBase, uEditorDBBase, uDialogUtils, Dialogs,
|
||
uDBSelectionListUtils, uGridUtils, uGenerarFacturasCliUtils,
|
||
uGenerarAlbaranesCliUtils, uGenerarContratosCliUtils,
|
||
uDialogOpcionesImpresionContratosCliente,
|
||
|
||
|
||
|
||
// uEditorFechaDecision,
|
||
// uBizAlbaranesCliente, uAlbaranesClienteController,
|
||
// uFacturasClienteController, uBizFacturasCliente,
|
||
|
||
uGestorInformesController;
|
||
|
||
|
||
{$R *.dfm}
|
||
|
||
{
|
||
*************************** TfEditorContratosCliente ***************************
|
||
}
|
||
procedure TfEditorContratosCliente.actAceptarExecute(Sender: TObject);
|
||
{var
|
||
AContratos: IBizContratoCliente;
|
||
AllItems: Boolean;}
|
||
begin
|
||
{ AContratos := Nil;
|
||
AllItems := False;
|
||
|
||
//Pedimos fecha de decision y realizamos todo el proceso de asignacion, en el caso de no darla no se hace nada
|
||
AFecha := Null;
|
||
with TfEditorFechaDecision.Create(nil) do
|
||
try
|
||
if ShowModal = mrOk then
|
||
AFecha := edtFechaDecision.Date;
|
||
finally
|
||
Free;
|
||
end;
|
||
|
||
if not VarIsNull(AFecha) then
|
||
begin
|
||
if MultiSelect and Assigned(ViewGrid) then
|
||
AllItems := (ViewGrid.NumSeleccionados > 1);
|
||
|
||
if AllItems then
|
||
begin
|
||
SeleccionarFilasDesdeGrid(ViewGrid._FocusedView, (Contratos as ISeleccionable).SelectedRecords);
|
||
AContratos := (Controller as IContratosClienteController).ExtraerSeleccionados(Contratos) as IBizContratoCliente;
|
||
end
|
||
else begin
|
||
AContratos := Contratos;
|
||
end;
|
||
|
||
ViewGrid._Grid.BeginUpdate;
|
||
if Assigned(AContratos) then
|
||
begin
|
||
FController.CambiarSituacion(AContratos, SITUACION_CONTRATO_TERMINADO, AFecha, AllItems);
|
||
actRefrescar.Execute;
|
||
end;
|
||
ViewGrid._Grid.EndUpdate;
|
||
end;
|
||
}
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.actAceptarUpdate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
(Sender as TAction).Enabled := HayDatos
|
||
and ViewGrid.esSeleccionCeldaDatos
|
||
and (FContratos.SITUACION <> SITUACION_CONTRATO_PENDIENTE);
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.actAnularExecute(Sender: TObject);
|
||
begin
|
||
{ AContratos := Nil;
|
||
AllItems := False;
|
||
|
||
//Pedimos fecha de decision y realizamos todo el proceso de asignacion, en el caso de no darla no se hace nada
|
||
AFecha := Null;
|
||
with TfEditorFechaDecision.Create(nil) do
|
||
try
|
||
if ShowModal = mrOk then
|
||
AFecha := edtFechaDecision.Date;
|
||
finally
|
||
Free;
|
||
end;
|
||
|
||
if not VarIsNull(AFecha) then
|
||
begin
|
||
if MultiSelect and Assigned(ViewGrid) then
|
||
AllItems := (ViewGrid.NumSeleccionados > 1);
|
||
|
||
if AllItems then
|
||
begin
|
||
SeleccionarFilasDesdeGrid(ViewGrid._FocusedView, (Contratos as ISeleccionable).SelectedRecords);
|
||
AContratos := (Controller as IContratosClienteController).ExtraerSeleccionados(Contratos) as IBizContratoCliente;
|
||
end
|
||
else begin
|
||
AContratos := Contratos;
|
||
end;
|
||
|
||
ViewGrid._Grid.BeginUpdate;
|
||
if Assigned(AContratos) then
|
||
begin
|
||
FController.CambiarSituacion(AContratos, SITUACION_PRESUPUESTO_ANULADO, AFecha, AllItems);
|
||
actRefrescar.Execute;
|
||
end;
|
||
ViewGrid._Grid.EndUpdate;
|
||
end;
|
||
}
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.actAnularUpdate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
{
|
||
(Sender as TAction).Enabled := HayDatos
|
||
and ViewGrid.esSeleccionCeldaDatos
|
||
and (FContratos.SITUACION <> SITUACION_PRESUPUESTO_ANULADO);
|
||
}
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.actEliminarUpdate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
if (Sender as TAction).Enabled then
|
||
(Sender as TAction).Enabled := (FContratos.SITUACION = SITUACION_CONTRATO_PENDIENTE);
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.actEnviarEMailExecute(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
FController.EnviarContratoPorEMail(FContratos);
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.actEnviarEMailUpdate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
if HayDatos and Assigned(ViewGrid) then
|
||
(Sender as TAction).Enabled := ViewGrid.EsSeleccionCeldaDatos
|
||
and (ViewGrid.NumSeleccionados > 0)
|
||
else
|
||
(Sender as TAction).Enabled := False;
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.actGenerarAlbaranCliExecute(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
GenerarAlbaranCli(FContratos.ID);
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.actGenerarExecute(Sender: TObject);
|
||
//var
|
||
// Respuesta : Integer;
|
||
begin
|
||
inherited;
|
||
{
|
||
Respuesta := JsGenerarDialog.Execute;
|
||
|
||
if Respuesta <> IDCANCEL then
|
||
begin
|
||
case JsGenerarDialog.CustomButtonResult of
|
||
200 : begin // Generar factura de cliente
|
||
actGenerarFactura.Execute;
|
||
end;
|
||
100 : begin // Generar albaran de cliente
|
||
// actGenerarAlbaranCli.Execute;
|
||
end;
|
||
end;
|
||
actRefrescar.Execute;
|
||
end;
|
||
}
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.actGenerarFacturaExecute(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
if (Length(Contratos.FACTURA_ASOCIADA) = 0) or (Application.MessageBox('El contrato ya tiene asociada al menos una factura. <20>Desea continuar?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
||
begin
|
||
GenerarFacturaCli(Contratos.ID);
|
||
actRefrescar.Execute;
|
||
end;
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.actGenerarFacturaUpdate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
|
||
(Sender as TAction).Enabled := HayDatos
|
||
and not (ViewGrid.NumSeleccionados > 1)
|
||
and ViewGrid.esSeleccionCeldaDatos;
|
||
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.actGenerarPresupuestoProvExecute(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
// GenerarContratosProv(FContratos);
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.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 facturas pendientes
|
||
// AGestorInformesController.VerInformeListadoContratos;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
finally
|
||
AGestorInformesController := NIL;
|
||
end;
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.actListadoBeneficiosExecute(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
FController.VerListadoBeneficios;
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.AsignarVista;
|
||
begin
|
||
ViewGrid := CreateView(TfrViewContratosCliente) as IViewContratosCliente;
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.bArmarioClick(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
if FController.Anadir(Contratos, teArmario) then
|
||
FController.Ver(Contratos);
|
||
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.bBanoClick(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
if FController.Anadir(Contratos, teBano) then
|
||
FController.Ver(Contratos);
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.bCocinaClick(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
if FController.Anadir(Contratos, teCocina) then
|
||
FController.Ver(Contratos);
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.bElectrodomesticoClick(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
if FController.Anadir(Contratos, teElectrodomestico) then
|
||
FController.Ver(Contratos);
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.bVariosClick(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
if FController.Anadir(Contratos, teVarios) then
|
||
FController.Ver(Contratos);
|
||
end;
|
||
|
||
constructor TfEditorContratosCliente.Create(AOwner: TComponent);
|
||
begin
|
||
inherited;
|
||
|
||
// FHeaderText := 'Lista de Contratos de cliente';
|
||
// FWindowCaption := FHeaderText;
|
||
|
||
AsignarVista;
|
||
end;
|
||
|
||
destructor TfEditorContratosCliente.Destroy;
|
||
begin
|
||
FContratos := NIL;
|
||
FController := NIL;
|
||
inherited;
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.DuplicarInterno;
|
||
var
|
||
APresupuesto : IBizContratoCliente;
|
||
begin
|
||
inherited;
|
||
APresupuesto := FController.Duplicar(Contratos);
|
||
try
|
||
FController.Ver(APresupuesto);
|
||
finally
|
||
actRefrescar.Execute;
|
||
end;
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.EliminarInterno;
|
||
var
|
||
AContratos: IBizContratoCliente;
|
||
AllItems: Boolean;
|
||
begin
|
||
AContratos := Nil;
|
||
AllItems := False;
|
||
|
||
if MultiSelect and Assigned(ViewGrid) then
|
||
AllItems := (ViewGrid.NumSeleccionados > 1);
|
||
|
||
if AllItems then
|
||
begin
|
||
if (Application.MessageBox('<27>Desea borrar los Contratos seleccionados?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
||
begin
|
||
SeleccionarFilasDesdeGrid(ViewGrid._FocusedView, (Contratos as ISeleccionable).SelectedRecords);
|
||
AContratos := (Controller as IContratosClienteController).ExtraerSeleccionados(Contratos) as IBizContratoCliente;
|
||
end
|
||
end
|
||
else begin
|
||
if (Application.MessageBox('<27>Desea borrar el presupuesto seleccionado?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
||
AContratos := Contratos;
|
||
end;
|
||
|
||
if Assigned(AContratos) then
|
||
begin
|
||
FController.Eliminar(AContratos, AllItems);
|
||
if AllItems then
|
||
begin
|
||
if (AContratos.DataTable.RecordCount > 0) then
|
||
begin
|
||
with AContratos.DataTable do
|
||
begin
|
||
First;
|
||
while not EOF do
|
||
begin
|
||
JsListaContratosNoEliminados.Content.Add('Ref. Presupuesto: ' + AContratos.REFERENCIA + ' ' + AContratos.NOMBRE);
|
||
Next;
|
||
end;
|
||
end;
|
||
JsListaContratosNoEliminados.Execute;
|
||
end;
|
||
actRefrescar.Execute;
|
||
end;
|
||
end;
|
||
|
||
ViewGrid.GotoFirst;
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.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(Contratos) then
|
||
raise Exception.Create('No hay ning<6E>n Presupuesto asignado');
|
||
|
||
Contratos.DataTable.Active := True;
|
||
ViewGrid.GotoFirst;
|
||
end;
|
||
|
||
function TfEditorContratosCliente.GetController: IContratosClienteController;
|
||
begin
|
||
Result := FController;
|
||
end;
|
||
|
||
function TfEditorContratosCliente.GetContratos: IBizContratoCliente;
|
||
begin
|
||
Result := FContratos;
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.ImprimirInterno;
|
||
var
|
||
Respuesta : Integer;
|
||
AContratos: IBizContratoCliente;
|
||
AllItems: Boolean;
|
||
FVerLogotipo: Boolean;
|
||
FImprimirPrecios : Boolean;
|
||
FImprimirTotales : Boolean;
|
||
FImprimirRefProveedor : Boolean;
|
||
FImprimirObservaciones: Boolean;
|
||
FImprimirIncidencias: Boolean;
|
||
|
||
|
||
begin
|
||
AContratos := Nil;
|
||
AllItems := False;
|
||
FVerLogotipo := True;
|
||
FImprimirPrecios := False;
|
||
FImprimirTotales := True;
|
||
FImprimirRefProveedor := False;
|
||
FImprimirObservaciones := False;
|
||
FImprimirIncidencias := False;
|
||
|
||
|
||
if MultiSelect and Assigned(ViewGrid) then
|
||
AllItems := (ViewGrid.NumSeleccionados > 1);
|
||
|
||
//Si esta agrupado solo podr<64> imprimir la lista de elementos visibles
|
||
if not ViewGrid.esSeleccionCeldaDatos then
|
||
inherited
|
||
else
|
||
begin
|
||
Respuesta := JsImprimirDialog.Execute;
|
||
if Respuesta <> IDCANCEL then
|
||
begin
|
||
case JsImprimirDialog.CustomButtonResult of
|
||
200 : begin // Lista de elementos visibles
|
||
inherited;
|
||
end;
|
||
100 : begin // Elemento Seleccionado
|
||
if AllItems then
|
||
begin
|
||
SeleccionarFilasDesdeGrid(ViewGrid._FocusedView, (Contratos as ISeleccionable).SelectedRecords);
|
||
AContratos := (Controller as IContratosClienteController).ExtraerSeleccionados(Contratos) as IBizContratoCliente;
|
||
end
|
||
else
|
||
AContratos := Contratos;
|
||
|
||
if Assigned(AContratos) then
|
||
begin
|
||
if ElegirOpcionesImpresionContratoCliente(FVerLogotipo, FImprimirPrecios, FImprimirTotales, FImprimirRefProveedor, FImprimirObservaciones, FImprimirIncidencias) then
|
||
FController.Print(AContratos, AllItems, FVerLogotipo, FImprimirPrecios, FImprimirTotales, FImprimirRefProveedor, FImprimirObservaciones, FImprimirIncidencias);
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.ModificarInterno;
|
||
begin
|
||
inherited;
|
||
FController.Ver(Contratos);
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.NuevoInterno;
|
||
var
|
||
Respuesta : Integer;
|
||
|
||
begin
|
||
inherited;
|
||
|
||
Respuesta := JsNuevoContratoDialog.Execute;
|
||
|
||
if Respuesta <> IDCANCEL then
|
||
begin
|
||
case JsNuevoContratoDialog.CustomButtonResult of
|
||
200 : begin // Utilizar un o mas presupuestos
|
||
GenerarContratosCli;
|
||
actRefrescar.Execute;
|
||
end;
|
||
100 : begin // Establecemos el contrato de varios por defecto
|
||
if FController.Anadir(Contratos, teVarios) then
|
||
FController.Ver(Contratos);
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.OnListaAnosChange(Sender: TObject; const Text: string);
|
||
begin
|
||
Controller.FiltrarAno(Contratos, DynWhereDataTable, Text);
|
||
if Contratos.DataTable.Active then
|
||
RefrescarInterno;
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.PonerTitulos(const ATitulo: string);
|
||
var
|
||
FTitulo : String;
|
||
begin
|
||
if (ATitulo = '') then
|
||
FTitulo := 'Lista de contratos de cliente - ' + AppFactuGES.EmpresaActiva.NOMBRE
|
||
else
|
||
FTitulo := ATitulo;
|
||
|
||
inherited PonerTitulos(FTitulo);
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.PrevisualizarInterno;
|
||
var
|
||
Respuesta : Integer;
|
||
AContratos: IBizContratoCliente;
|
||
AllItems: Boolean;
|
||
FVerLogotipo: Boolean;
|
||
FImprimirPrecios : Boolean;
|
||
FImprimirTotales : Boolean;
|
||
FImprimirRefProveedor : Boolean;
|
||
FImprimirObservaciones: Boolean;
|
||
FImprimirIncidencias: Boolean;
|
||
|
||
|
||
begin
|
||
AContratos := Nil;
|
||
AllItems := False;
|
||
FVerLogotipo := True;
|
||
FImprimirPrecios := False;
|
||
FImprimirTotales := True;
|
||
FImprimirRefProveedor := False;
|
||
FImprimirObservaciones := False;
|
||
FImprimirIncidencias := False;
|
||
|
||
|
||
if MultiSelect and Assigned(ViewGrid) then
|
||
AllItems := (ViewGrid.NumSeleccionados > 1);
|
||
|
||
//Si esta agrupado solo podr<64> 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, (Contratos as ISeleccionable).SelectedRecords);
|
||
AContratos := (Controller as IContratosClienteController).ExtraerSeleccionados(Contratos) as IBizContratoCliente;
|
||
end
|
||
else
|
||
AContratos := Contratos;
|
||
|
||
if Assigned(AContratos) then
|
||
begin
|
||
if ElegirOpcionesImpresionContratoCliente(FVerLogotipo, FImprimirPrecios, FImprimirTotales, FImprimirRefProveedor, FImprimirObservaciones, FImprimirIncidencias) then
|
||
FController.Preview(AContratos, AllItems, FVerLogotipo, FImprimirPrecios, FImprimirTotales, FImprimirRefProveedor, FImprimirObservaciones, FImprimirIncidencias);
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
AContratos := Nil;
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.RefrescarInterno;
|
||
begin
|
||
//Volvemos a cargar los a<>os de los Contratos
|
||
if Assigned(FController) then
|
||
ListaAnos := FController.DarListaAnosContratos;
|
||
|
||
inherited;
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.SetController(const Value: IContratosClienteController);
|
||
begin
|
||
FController := Value;
|
||
|
||
if Assigned(FController) then
|
||
ListaAnos := FController.DarListaAnosContratos;
|
||
end;
|
||
|
||
procedure TfEditorContratosCliente.SetContratos(const Value: IBizContratoCliente);
|
||
begin
|
||
FContratos := Value;
|
||
|
||
if Assigned(FContratos) 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 := FContratos.DataTable.DynamicWhere.Xml;
|
||
|
||
dsDataTable.DataTable := FContratos.DataTable;
|
||
if Assigned(ViewGrid) then
|
||
(ViewGrid as IViewContratosCliente).Contratos := Contratos;
|
||
end;
|
||
end;
|
||
|
||
end.
|