2007-10-26 18:19:55 +00:00
unit uEditorPresupuestosCliente;
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,
uBizPresupuestosCliente, uIEditorPresupuestosCliente, uPresupuestosClienteController,
uCustomView, uViewBase, uViewBarraSeleccion, uViewGridBase,
uViewPresupuestosCliente, JvExComCtrls, JvStatusBar, JSDialog, StdCtrls,
uDAInterfaces;
type
TfEditorPresupuestosCliente = class( TfEditorGridBase, IEditorPresupuestosCliente)
actGenerarAlbaranCli: TAction;
actGenerarFactura: TAction;
TBXSubmenuItem2: TTBXSubmenuItem;
TBXSeparatorItem17: TTBXSeparatorItem;
TBXItem38: TTBXItem;
TBXItem39: TTBXItem;
N4: TMenuItem;
Generar2: TMenuItem;
JsGenerarDialog: TJSDialog;
JsPrevisualizarDialog: TJSDialog;
JsImprimirDialog: TJSDialog;
TBXItem40: TTBXItem;
2007-11-05 17:49:11 +00:00
JsListaPresupuestosNoEliminados: TJSDialog;
2008-08-06 18:18:27 +00:00
actGenerarCertificado: TAction;
TBXItem41: TTBXItem;
TBXItem42: TTBXItem;
Generarcertificado1: TMenuItem;
2008-08-13 12:01:59 +00:00
actAceptar: TAction;
actAnular: TAction;
TBXItem43: TTBXItem;
TBXItem44: TTBXItem;
TBXSeparatorItem18: TTBXSeparatorItem;
2008-08-21 17:01:02 +00:00
actEnviarEMail: TAction;
TBXItem45: TTBXItem;
Enviarporemail1: TMenuItem;
2008-10-22 17:20:36 +00:00
actInformes: TAction;
TBXItem46: TTBXItem;
JSInformesDialog: TJSDialog;
2009-03-18 15:43:07 +00:00
TBXItem47: TTBXItem;
2007-10-26 18:19:55 +00:00
procedure FormShow( Sender: TObject) ;
procedure actGenerarAlbaranCliExecute( Sender: TObject) ;
procedure actEliminarUpdate( Sender: TObject) ;
procedure actGenerarFacturaUpdate( Sender: TObject) ;
procedure actGenerarFacturaExecute( Sender: TObject) ;
2007-11-05 17:49:11 +00:00
procedure actGenerarPresupuestoProvExecute( Sender: TObject) ;
2007-10-26 18:19:55 +00:00
procedure actGenerarExecute( Sender: TObject) ;
2008-08-06 18:18:27 +00:00
procedure actGenerarCertificadoUpdate( Sender: TObject) ;
procedure actGenerarCertificadoExecute( Sender: TObject) ;
2008-08-13 12:01:59 +00:00
procedure actAceptarExecute( Sender: TObject) ;
procedure actAceptarUpdate( Sender: TObject) ;
procedure actAnularExecute( Sender: TObject) ;
procedure actAnularUpdate( Sender: TObject) ;
2008-08-21 17:01:02 +00:00
procedure actEnviarEMailExecute( Sender: TObject) ;
procedure actEnviarEMailUpdate( Sender: TObject) ;
2008-10-22 17:20:36 +00:00
procedure actInformesExecute( Sender: TObject) ;
2009-02-27 10:44:29 +00:00
procedure OnListaAnosChange( Sender: TObject; const Text : string ) ;
2007-10-26 18:19:55 +00:00
protected
2007-11-05 17:49:11 +00:00
FPresupuestos: IBizPresupuestoCliente;
2007-10-26 18:19:55 +00:00
FController : IPresupuestosClienteController;
2007-11-05 17:49:11 +00:00
function GetPresupuestos: IBizPresupuestoCliente;
procedure SetPresupuestos( const Value: IBizPresupuestoCliente) ;
2007-10-26 18:19:55 +00:00
function GetController : IPresupuestosClienteController; virtual ;
procedure SetController ( const Value : IPresupuestosClienteController) ; virtual ;
procedure NuevoInterno; override ;
procedure ModificarInterno; override ;
procedure EliminarInterno; override ;
procedure DuplicarInterno; override ;
procedure ImprimirInterno; override ;
procedure PrevisualizarInterno; override ;
2009-02-27 10:44:29 +00:00
procedure RefrescarInterno; override ;
2007-10-26 18:19:55 +00:00
//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 ;
2007-11-05 17:49:11 +00:00
property Presupuestos: IBizPresupuestoCliente read GetPresupuestos write SetPresupuestos;
2007-10-26 18:19:55 +00:00
property Controller : IPresupuestosClienteController read GetController write SetController;
constructor Create( AOwner: TComponent) ; override ;
destructor Destroy; override ;
end ;
implementation
uses
2010-09-23 10:49:10 +00:00
cxControls, uDataModulePresupuestosCliente, uDataModuleUsuarios, uFactuGES_App,
2008-08-13 12:01:59 +00:00
uEditorBase, uEditorDBBase, uDialogUtils, Dialogs,
2010-07-12 18:03:50 +00:00
uDBSelectionListUtils, uGridStatusUtils, uDialogOpcionesImpresionPresupuestosCliente,
2008-08-13 12:01:59 +00:00
uGenerarFacturasCliPreCliUtils, uEditorFechaDecision,
2008-05-30 17:59:41 +00:00
// uBizAlbaranesCliente, uAlbaranesClienteController,
2007-10-26 18:19:55 +00:00
// uFacturasClienteController, uBizFacturasCliente,
2008-10-22 17:20:36 +00:00
uGenerarAlbaranesCliUtils, uGestorInformesController;
2007-10-26 18:19:55 +00:00
{$R *.dfm}
{
* * * * * * * * * * * * * * * * * * * * * * * * * * * TfEditorPresupuestosCliente * * * * * * * * * * * * * * * * * * * * * * * * * * *
}
2008-08-13 12:01:59 +00:00
procedure TfEditorPresupuestosCliente. actAceptarExecute( Sender: TObject) ;
var
APresupuestos: IBizPresupuestoCliente;
AllItems: Boolean ;
AFecha: Variant ;
begin
APresupuestos : = 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, ( Presupuestos as ISeleccionable) . SelectedRecords) ;
APresupuestos : = ( Controller as IPresupuestosClienteController) . ExtraerSeleccionados( Presupuestos) as IBizPresupuestoCliente;
end
else begin
APresupuestos : = Presupuestos;
end ;
ViewGrid. _Grid. BeginUpdate;
if Assigned( APresupuestos) then
begin
FController. CambiarSituacion( APresupuestos, SITUACION_PRESUPUESTO_ACEPTADO, AFecha, AllItems) ;
actRefrescar. Execute;
end ;
ViewGrid. _Grid. EndUpdate;
end ;
end ;
procedure TfEditorPresupuestosCliente. actAceptarUpdate( Sender: TObject) ;
begin
inherited ;
( Sender as TAction) . Enabled : = HayDatos
and ViewGrid. esSeleccionCeldaDatos
and ( FPresupuestos. SITUACION < > SITUACION_PRESUPUESTO_ACEPTADO) ;
end ;
procedure TfEditorPresupuestosCliente. actAnularExecute( Sender: TObject) ;
var
APresupuestos: IBizPresupuestoCliente;
AllItems: Boolean ;
AFecha: Variant ;
begin
APresupuestos : = 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, ( Presupuestos as ISeleccionable) . SelectedRecords) ;
APresupuestos : = ( Controller as IPresupuestosClienteController) . ExtraerSeleccionados( Presupuestos) as IBizPresupuestoCliente;
end
else begin
APresupuestos : = Presupuestos;
end ;
ViewGrid. _Grid. BeginUpdate;
if Assigned( APresupuestos) then
begin
FController. CambiarSituacion( APresupuestos, SITUACION_PRESUPUESTO_ANULADO, AFecha, AllItems) ;
actRefrescar. Execute;
end ;
ViewGrid. _Grid. EndUpdate;
end ;
end ;
procedure TfEditorPresupuestosCliente. actAnularUpdate( Sender: TObject) ;
begin
inherited ;
( Sender as TAction) . Enabled : = HayDatos
and ViewGrid. esSeleccionCeldaDatos
and ( FPresupuestos. SITUACION < > SITUACION_PRESUPUESTO_ANULADO) ;
end ;
2007-10-26 18:19:55 +00:00
procedure TfEditorPresupuestosCliente. actEliminarUpdate( Sender: TObject) ;
begin
inherited ;
if ( Sender as TAction) . Enabled then
2007-11-05 17:49:11 +00:00
( Sender as TAction) . Enabled : = ( FPresupuestos. SITUACION = SITUACION_PRESUPUESTO_PENDIENTE) ;
2007-10-26 18:19:55 +00:00
end ;
2008-08-21 17:01:02 +00:00
procedure TfEditorPresupuestosCliente. actEnviarEMailExecute( Sender: TObject) ;
2010-06-22 14:38:19 +00:00
var
APresupuestos : IBizPresupuestoCliente;
2008-08-21 17:01:02 +00:00
begin
inherited ;
2010-06-22 14:38:19 +00:00
if ViewGrid. NumSeleccionados = 1 then
2010-09-23 10:49:10 +00:00
FController. GenerarEmailPresupuesto( FPresupuestos)
// FController.EnviarPresupuestoPorEMail(FPresupuestos)
2010-06-22 14:38:19 +00:00
else begin
2010-09-23 10:49:10 +00:00
ShowHourglassCursor;
2010-06-22 14:38:19 +00:00
try
SeleccionarFilasDesdeGrid( ViewGrid. _FocusedView, ( Presupuestos as ISeleccionable) . SelectedRecords) ;
APresupuestos : = ( Controller as IPresupuestosClienteController) . ExtraerSeleccionados( Presupuestos) as IBizPresupuestoCliente;
if Assigned( APresupuestos) then
FController. EnviarEmailPresupuestos( APresupuestos) ;
// RefrescarInterno;
finally
APresupuestos : = NIL ;
2010-09-23 10:49:10 +00:00
HideHourglassCursor;
2010-06-22 14:38:19 +00:00
end ;
end ;
2008-08-21 17:01:02 +00:00
end ;
procedure TfEditorPresupuestosCliente. actEnviarEMailUpdate( Sender: TObject) ;
begin
inherited ;
2008-08-25 14:12:55 +00:00
if HayDatos and Assigned( ViewGrid) then
( Sender as TAction) . Enabled : = ViewGrid. EsSeleccionCeldaDatos
and ( ViewGrid. NumSeleccionados > 0 )
else
( Sender as TAction) . Enabled : = False ;
2008-08-21 17:01:02 +00:00
end ;
2007-10-26 18:19:55 +00:00
procedure TfEditorPresupuestosCliente. actGenerarAlbaranCliExecute( Sender: TObject) ;
begin
inherited ;
2008-06-02 11:29:05 +00:00
GenerarAlbaranCli( FPresupuestos. ID) ;
2007-10-26 18:19:55 +00:00
end ;
2008-08-06 18:18:27 +00:00
procedure TfEditorPresupuestosCliente. actGenerarCertificadoExecute(
Sender: TObject) ;
var
APresupuestos: IBizPresupuestoCliente;
AllItems: Boolean ;
2008-08-07 15:50:46 +00:00
ATexto : String ;
2008-08-06 18:18:27 +00:00
begin
APresupuestos : = Nil ;
AllItems : = False ;
if MultiSelect and Assigned( ViewGrid) then
AllItems : = ( ViewGrid. NumSeleccionados > 1 ) ;
if AllItems then
begin
SeleccionarFilasDesdeGrid( ViewGrid. _FocusedView, ( Presupuestos as ISeleccionable) . SelectedRecords) ;
APresupuestos : = ( Controller as IPresupuestosClienteController) . ExtraerSeleccionados( Presupuestos) as IBizPresupuestoCliente;
2008-08-07 15:50:46 +00:00
ATexto : = 'Se han generado los certificados de trabajos.' ;
2008-08-06 18:18:27 +00:00
end
2008-08-07 15:50:46 +00:00
else begin
2008-08-06 18:18:27 +00:00
APresupuestos : = Presupuestos;
2008-08-07 15:50:46 +00:00
ATexto : = 'Se ha generado el certificado de trabajos.' ;
end ;
2008-08-06 18:18:27 +00:00
if Assigned( APresupuestos) then
2008-08-07 15:50:46 +00:00
if FController. GenerarCertificados( APresupuestos, AllItems) then
ShowInfoMessage( 'Generar certificado de trabajo' , ATexto)
2008-08-06 18:18:27 +00:00
end ;
procedure TfEditorPresupuestosCliente. actGenerarCertificadoUpdate(
Sender: TObject) ;
begin
( Sender as TAction) . Enabled : = HayDatos
and ViewGrid. EsSeleccionCeldaDatos
and ( FPresupuestos. SITUACION = SITUACION_PRESUPUESTO_ACEPTADO) ;
end ;
2007-10-26 18:19:55 +00:00
procedure TfEditorPresupuestosCliente. actGenerarExecute( Sender: TObject) ;
2008-06-02 11:29:05 +00:00
//var
// Respuesta : Integer;
2007-10-26 18:19:55 +00:00
begin
inherited ;
2008-06-02 11:29:05 +00:00
{
2007-10-26 18:19:55 +00:00
Respuesta : = JsGenerarDialog. Execute;
if Respuesta < > IDCANCEL then
begin
case JsGenerarDialog. CustomButtonResult of
2008-05-30 17:59:41 +00:00
2 0 0 : begin // Generar factura de cliente
actGenerarFactura. Execute;
2007-10-26 18:19:55 +00:00
end ;
2008-05-30 17:59:41 +00:00
1 0 0 : begin // Generar albaran de cliente
2008-06-02 11:29:05 +00:00
// actGenerarAlbaranCli.Execute;
2007-10-26 18:19:55 +00:00
end ;
end ;
actRefrescar. Execute;
end ;
2008-06-02 11:29:05 +00:00
}
2007-10-26 18:19:55 +00:00
end ;
procedure TfEditorPresupuestosCliente. actGenerarFacturaExecute( Sender: TObject) ;
begin
inherited ;
2008-06-05 09:32:50 +00:00
if ( ShowConfirmMessage( 'Generar factura' , Format( '<27> Desea copiar todos los conceptos del presupuesto %s a la factura?' , [ Presupuestos. REFERENCIA] ) ) = IDYES) then
2008-08-12 14:02:15 +00:00
GenerarFacturaCliPre( Presupuestos. ID)
2008-06-05 09:32:50 +00:00
else
2008-08-12 14:02:15 +00:00
GenerarFacturaCliPre( Presupuestos. ID, False ) ;
2008-06-05 09:32:50 +00:00
2008-06-02 11:29:05 +00:00
actRefrescar. Execute;
2007-10-26 18:19:55 +00:00
end ;
procedure TfEditorPresupuestosCliente. actGenerarFacturaUpdate( Sender: TObject) ;
begin
inherited ;
( Sender as TAction) . Enabled : = HayDatos
2008-08-12 14:02:15 +00:00
and not ( ViewGrid. NumSeleccionados > 1 )
and ( FPresupuestos. FACTURA = '' )
2007-10-26 18:19:55 +00:00
and ViewGrid. esSeleccionCeldaDatos
2008-08-12 14:02:15 +00:00
and ( FPresupuestos. SITUACION = SITUACION_PRESUPUESTO_ACEPTADO) ;
2007-10-26 18:19:55 +00:00
end ;
2007-11-05 17:49:11 +00:00
procedure TfEditorPresupuestosCliente. actGenerarPresupuestoProvExecute( Sender: TObject) ;
2007-10-26 18:19:55 +00:00
begin
inherited ;
2007-11-05 17:49:11 +00:00
// GenerarPresupuestosProv(FPresupuestos);
2007-10-26 18:19:55 +00:00
end ;
2008-10-22 17:20:36 +00:00
procedure TfEditorPresupuestosCliente. 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
1 0 0 : begin // Listado de facturas pendientes
AGestorInformesController. VerInformeListadoPresupuestos;
end ;
end ;
end ;
finally
AGestorInformesController : = NIL ;
end ;
end ;
2007-10-26 18:19:55 +00:00
procedure TfEditorPresupuestosCliente. AsignarVista;
begin
ViewGrid : = CreateView( TfrViewPresupuestosCliente) as IViewPresupuestosCliente;
end ;
constructor TfEditorPresupuestosCliente. Create( AOwner: TComponent) ;
begin
inherited ;
2008-11-10 11:29:57 +00:00
FHeaderText : = 'Lista de presupuestos de cliente' ;
FWindowCaption : = FHeaderText;
2007-10-26 18:19:55 +00:00
AsignarVista;
end ;
destructor TfEditorPresupuestosCliente. Destroy;
begin
2007-11-05 17:49:11 +00:00
FPresupuestos : = NIL ;
2008-11-10 11:29:57 +00:00
FController : = NIL ;
2007-10-26 18:19:55 +00:00
inherited ;
end ;
procedure TfEditorPresupuestosCliente. DuplicarInterno;
var
2007-11-05 17:49:11 +00:00
APresupuesto : IBizPresupuestoCliente;
2007-10-26 18:19:55 +00:00
begin
inherited ;
2007-11-05 17:49:11 +00:00
APresupuesto : = FController. Duplicar( Presupuestos) ;
2007-10-26 18:19:55 +00:00
try
2007-11-05 17:49:11 +00:00
FController. Ver( APresupuesto) ;
2007-10-26 18:19:55 +00:00
finally
actRefrescar. Execute;
end ;
end ;
procedure TfEditorPresupuestosCliente. EliminarInterno;
var
2007-11-05 17:49:11 +00:00
APresupuestos: IBizPresupuestoCliente;
2007-10-26 18:19:55 +00:00
AllItems: Boolean ;
begin
2007-11-05 17:49:11 +00:00
APresupuestos : = Nil ;
2007-10-26 18:19:55 +00:00
AllItems : = False ;
if MultiSelect and Assigned( ViewGrid) then
AllItems : = ( ViewGrid. NumSeleccionados > 1 ) ;
if AllItems then
begin
2007-12-20 21:05:11 +00:00
if ( Application. MessageBox( '<27> Desea borrar los presupuestos seleccionados?' , 'Atenci<63> n' , MB_YESNO) = IDYES) then
2007-10-26 18:19:55 +00:00
begin
2007-11-05 17:49:11 +00:00
SeleccionarFilasDesdeGrid( ViewGrid. _FocusedView, ( Presupuestos as ISeleccionable) . SelectedRecords) ;
APresupuestos : = ( Controller as IPresupuestosClienteController) . ExtraerSeleccionados( Presupuestos) as IBizPresupuestoCliente;
2007-10-26 18:19:55 +00:00
end
end
else begin
2007-12-20 21:05:11 +00:00
if ( Application. MessageBox( '<27> Desea borrar el presupuesto seleccionado?' , 'Atenci<63> n' , MB_YESNO) = IDYES) then
2007-11-05 17:49:11 +00:00
APresupuestos : = Presupuestos;
2007-10-26 18:19:55 +00:00
end ;
2007-11-05 17:49:11 +00:00
if Assigned( APresupuestos) then
2007-10-26 18:19:55 +00:00
begin
2007-11-05 17:49:11 +00:00
FController. Eliminar( APresupuestos, AllItems) ;
2007-10-26 18:19:55 +00:00
if AllItems then
begin
2007-11-05 17:49:11 +00:00
if ( APresupuestos. DataTable. RecordCount > 0 ) then
2007-10-26 18:19:55 +00:00
begin
2007-11-05 17:49:11 +00:00
with APresupuestos. DataTable do
2007-10-26 18:19:55 +00:00
begin
First;
while not EOF do
begin
2008-08-13 12:01:59 +00:00
JsListaPresupuestosNoEliminados. Content. Add( 'Ref. Presupuesto: ' + APresupuestos. REFERENCIA + ' ' + APresupuestos. NOMBRE) ;
2007-10-26 18:19:55 +00:00
Next;
end ;
end ;
2007-11-05 17:49:11 +00:00
JsListaPresupuestosNoEliminados. Execute;
2007-10-26 18:19:55 +00:00
end ;
actRefrescar. Execute;
end ;
end ;
ViewGrid. GotoFirst;
end ;
procedure TfEditorPresupuestosCliente. FormShow( Sender: TObject) ;
begin
2009-02-27 10:44:29 +00:00
cbxListaAnos. OnChange : = OnListaAnosChange; //OJO SIEMPRE ANTES DEL INHERITED
2007-10-26 18:19:55 +00:00
inherited ;
if not Assigned( ViewGrid) then
raise Exception. Create( 'No hay ninguna vista asignada' ) ;
2007-11-05 17:49:11 +00:00
if not Assigned( Presupuestos) then
raise Exception. Create( 'No hay ning<6E> n Presupuesto asignado' ) ;
2007-10-26 18:19:55 +00:00
2007-11-05 17:49:11 +00:00
Presupuestos. DataTable. Active : = True ;
2007-10-26 18:19:55 +00:00
ViewGrid. GotoFirst;
end ;
function TfEditorPresupuestosCliente. GetController: IPresupuestosClienteController;
begin
Result : = FController;
end ;
2007-11-05 17:49:11 +00:00
function TfEditorPresupuestosCliente. GetPresupuestos: IBizPresupuestoCliente;
2007-10-26 18:19:55 +00:00
begin
2007-11-05 17:49:11 +00:00
Result : = FPresupuestos;
2007-10-26 18:19:55 +00:00
end ;
procedure TfEditorPresupuestosCliente. ImprimirInterno;
var
Respuesta : Integer ;
2007-11-05 17:49:11 +00:00
APresupuestos: IBizPresupuestoCliente;
2007-10-26 18:19:55 +00:00
AllItems: Boolean ;
2010-07-12 18:03:50 +00:00
AVerSello: Integer ;
bPrevisualizar: Boolean ;
2007-10-26 18:19:55 +00:00
begin
2007-11-05 17:49:11 +00:00
APresupuestos : = Nil ;
2007-10-26 18:19:55 +00:00
AllItems : = False ;
2010-07-12 18:03:50 +00:00
bPrevisualizar : = True ;
2007-10-26 18:19:55 +00:00
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
2 0 0 : begin // Lista de elementos visibles
inherited ;
end ;
1 0 0 : begin // Elemento Seleccionado
if AllItems then
begin
2007-11-05 17:49:11 +00:00
SeleccionarFilasDesdeGrid( ViewGrid. _FocusedView, ( Presupuestos as ISeleccionable) . SelectedRecords) ;
APresupuestos : = ( Controller as IPresupuestosClienteController) . ExtraerSeleccionados( Presupuestos) as IBizPresupuestoCliente;
2007-10-26 18:19:55 +00:00
end
else
2007-11-05 17:49:11 +00:00
APresupuestos : = Presupuestos;
2007-10-26 18:19:55 +00:00
2010-07-12 18:03:50 +00:00
if ( AppFactuGES. EmpresaActiva. ID = 1 ) then
//Preguntamos si desea que en los presupuestos se vea el Sello de Paco u Oscar,
//solo para empresa Tecsitel
2014-02-18 22:41:52 +00:00
bPrevisualizar : = ElegirOpcionesImpresionPresupuestoCliente( AVerSello) ;
2010-07-12 18:03:50 +00:00
if bPrevisualizar and Assigned( APresupuestos) then
2014-02-18 22:41:52 +00:00
FController. Print( APresupuestos, AllItems, AVerSello) ;
2007-10-26 18:19:55 +00:00
end ;
end ;
end ;
end ;
end ;
procedure TfEditorPresupuestosCliente. ModificarInterno;
begin
inherited ;
2007-11-05 17:49:11 +00:00
FController. Ver( Presupuestos) ;
2007-10-26 18:19:55 +00:00
end ;
procedure TfEditorPresupuestosCliente. NuevoInterno;
begin
inherited ;
2007-11-05 17:49:11 +00:00
if FController. Anadir( Presupuestos) then
FController. Ver( Presupuestos) ;
2007-10-26 18:19:55 +00:00
end ;
2009-02-27 10:44:29 +00:00
procedure TfEditorPresupuestosCliente. OnListaAnosChange( Sender: TObject; const Text : string ) ;
begin
Controller. FiltrarAno( Presupuestos, DynWhereDataTable, Text ) ;
if Presupuestos. DataTable. Active then
RefrescarInterno;
end ;
2007-10-26 18:19:55 +00:00
procedure TfEditorPresupuestosCliente. PonerTitulos( const ATitulo: string ) ;
var
FTitulo : String ;
begin
2008-11-10 11:29:57 +00:00
FTitulo : = FWindowCaption + ' - ' + AppFactuGES. EmpresaActiva. NOMBRE;
2007-10-26 18:19:55 +00:00
inherited PonerTitulos( FTitulo) ;
end ;
procedure TfEditorPresupuestosCliente. PrevisualizarInterno;
var
Respuesta : Integer ;
2007-11-05 17:49:11 +00:00
APresupuestos: IBizPresupuestoCliente;
2007-10-26 18:19:55 +00:00
AllItems: Boolean ;
2010-07-12 18:03:50 +00:00
AVerSello: Integer ;
bPrevisualizar: Boolean ;
2007-10-26 18:19:55 +00:00
begin
2007-11-05 17:49:11 +00:00
APresupuestos : = Nil ;
2007-10-26 18:19:55 +00:00
AllItems : = False ;
2010-07-12 18:03:50 +00:00
bPrevisualizar : = True ;
2007-10-26 18:19:55 +00:00
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
2 0 0 : begin // Lista de elementos visibles
inherited ;
end ;
1 0 0 : begin // Elemento Seleccionado
if AllItems then
begin
2007-11-05 17:49:11 +00:00
SeleccionarFilasDesdeGrid( ViewGrid. _FocusedView, ( Presupuestos as ISeleccionable) . SelectedRecords) ;
APresupuestos : = ( Controller as IPresupuestosClienteController) . ExtraerSeleccionados( Presupuestos) as IBizPresupuestoCliente;
2007-10-26 18:19:55 +00:00
end
else
2007-11-05 17:49:11 +00:00
APresupuestos : = Presupuestos;
2007-10-26 18:19:55 +00:00
2010-07-12 18:03:50 +00:00
if ( AppFactuGES. EmpresaActiva. ID = 1 ) then
//Preguntamos si desea que en los presupuestos se vea el Sello de Paco u Oscar,
//solo para empresa Tecsitel
2014-02-18 22:41:52 +00:00
bPrevisualizar : = ElegirOpcionesImpresionPresupuestoCliente( AVerSello) ;
2010-07-12 18:03:50 +00:00
if bPrevisualizar and Assigned( APresupuestos) then
2014-02-18 22:41:52 +00:00
FController. Preview( APresupuestos, AllItems, AVerSello) ;
2007-10-26 18:19:55 +00:00
end ;
end ;
end ;
end ;
2007-11-13 19:36:56 +00:00
APresupuestos : = Nil ;
2007-10-26 18:19:55 +00:00
end ;
2009-02-27 10:44:29 +00:00
procedure TfEditorPresupuestosCliente. RefrescarInterno;
begin
//Volvemos a cargar los a<> os de los presupuestos
if Assigned( FController) then
ListaAnos : = FController. DarListaAnosPresupuestos;
inherited ;
end ;
2007-10-26 18:19:55 +00:00
procedure TfEditorPresupuestosCliente. SetController( const Value: IPresupuestosClienteController) ;
begin
FController : = Value;
2009-02-27 10:44:29 +00:00
if Assigned( FController) then
ListaAnos : = FController. DarListaAnosPresupuestos;
2007-10-26 18:19:55 +00:00
end ;
2007-11-05 17:49:11 +00:00
procedure TfEditorPresupuestosCliente. SetPresupuestos( const Value: IBizPresupuestoCliente) ;
2007-10-26 18:19:55 +00:00
begin
2007-11-05 17:49:11 +00:00
FPresupuestos : = Value;
2009-02-27 10:44:29 +00:00
if Assigned( FPresupuestos) 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 : = FPresupuestos. DataTable. DynamicWhere. Xml;
dsDataTable. DataTable : = FPresupuestos. DataTable;
if Assigned( ViewGrid) then
( ViewGrid as IViewPresupuestosCliente) . Presupuestos : = Presupuestos;
end ;
2007-10-26 18:19:55 +00:00
end ;
end .