{ =============================================================================== 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; procedure FormShow(Sender: TObject); procedure actEliminarUpdate(Sender: TObject); 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; 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, uGridUtils, uDBSelectionListUtils; {$R *.dfm} { *************************** TfEditorRecibosCliente *************************** } procedure TfEditorRecibosCliente.actEliminarUpdate(Sender: TObject); begin inherited; if (Sender as TAction).Enabled then (Sender as TAction).Enabled := (FRecibosCliente.SITUACION = CTE_PENDIENTE) AND (FRecibosCliente.ID_FACTURA < 1); end; constructor TfEditorRecibosCliente.Create(AOwner: TComponent); begin inherited; FController := TRecibosClienteController.Create; 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; var ARecibos: IBizRecibosCliente; AllItems: Boolean; begin ARecibos := Nil; AllItems := False; if MultiSelect and Assigned(ViewGrid) then AllItems := (ViewGrid.NumSeleccionados > 1); if AllItems then begin if (Application.MessageBox('¿Desea borrar los recibos de cliente seleccionados?', 'Atención', MB_YESNO) = IDYES) then begin SeleccionarFilasDesdeGrid(ViewGrid._FocusedView, (RecibosCliente as ISeleccionable).SelectedRecords); ARecibos := (Controller as IRecibosClienteController).ExtraerSeleccionados(RecibosCliente) as IBizRecibosCliente; end end else begin if (Application.MessageBox('¿Desea borrar el recibo de cliente seleccionado?', 'Atención', MB_YESNO) = IDYES) then ARecibos := RecibosCliente; end; if Assigned(ARecibos) then begin FController.Eliminar(ARecibos, AllItems); if AllItems then begin if (ARecibos.DataTable.RecordCount > 0) then begin with ARecibos.DataTable do begin First; while not EOF do begin // JsListaPresupuestosNoEliminados.Content.Add('Ref. Presupuesto: ' + APresupuestos.REFERENCIA + ' ' + APresupuestos.NOMBRE); Next; end; end; // JsListaRecibosNoEliminados.Execute; end; actRefrescar.Execute; end; end; ViewGrid.GotoFirst; end; procedure TfEditorRecibosCliente.FormShow(Sender: TObject); begin 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; //Para que coja el ancho automático actAnchoAuto.Execute; 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.Preview(ARecibosCliente, AllItems); end; end; end; end; end; procedure TfEditorRecibosCliente.ModificarInterno; begin inherited; FController.Ver(FRecibosCliente); RefrescarInterno; end; procedure TfEditorRecibosCliente.NuevoInterno; begin inherited; //Se pueden añadir recibos nuevos sin tener factura asociada, ya que acana emite recibos independientes a las facturas //por ser particulares en lugar de empresas el cliente final. FController.Anadir(FRecibosCliente); FController.Ver(FRecibosCliente); end; procedure TfEditorRecibosCliente.PonerTitulos(const ATitulo: string); var FTitulo : String; begin FTitulo := 'Lista de recibos de cliente - ' + 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.SetController(const Value: IRecibosClienteController); begin FController := Value; end; procedure TfEditorRecibosCliente.SetRecibosCliente(const Value: IBizRecibosCliente); begin FRecibosCliente := Value; dsDataTable.DataTable := FRecibosCliente.DataTable; if Assigned(ViewGrid) then (ViewGrid as IViewRecibosCliente).Recibos := FRecibosCliente; end; end.