unit uEditorDiario; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, uEditorBase, ToolWin, ComCtrls, JvExControls, JvComponent, JvNavigationPane, uViewDiario, uBizAsientos, ActnList, DBActns, uViewGrid, Menus, uDataModuleBase, ImgList, PngImageList, TB2Dock, TB2Toolbar, TBX, TB2Item, StdActns, TB2ExtItems, TBXExtItems, TB2MRU, DB, uDADataTable, JvFormAutoSize, uDAScriptingProvider, uDACDSDataTable, JvAppStorage, JvAppRegistryStorage, JvFormPlacement, ExtCtrls, uCustomView, uViewBase, uViewBarraSeleccion, pngimage, uIEditorDiario, uEditorGridBase, JvComponentBase, uViewGridBase, uAsientosController, JvExComCtrls, JvStatusBar, uDAInterfaces, uViewEpigrafes, uBizDiario, dxGDIPlusClasses; type TfEditorDiario = class(TfEditorGridBase, IEditorDiario) frViewDiario1: TfrViewDiario; actPuntear: TAction; TBXItem38: TTBXItem; procedure FormShow(Sender: TObject); procedure actModificarUpdate(Sender: TObject); procedure actEliminarUpdate(Sender: TObject); procedure actNuevoUpdate(Sender: TObject); procedure actPuntearExecute(Sender: TObject); procedure actPuntearUpdate(Sender: TObject); private FDiario: IBizDiario; FController : IAsientosController; protected function GetDiario: IBizDiario; procedure SetDiario(const Value: IBizDiario); function GetController : IAsientosController; virtual; procedure SetController (const Value : IAsientosController); virtual; procedure NuevoInterno; override; procedure EliminarInterno; override; procedure ModificarInterno; override; procedure DuplicarInterno; override; procedure PrevisualizarInterno; override; procedure ImprimirInterno; override; public procedure PonerTitulos(const ATitulo: string = ''); override; property Diario: IBizDiario read GetDiario write SetDiario; property Controller : IAsientosController read GetController write SetController; constructor Create(AOwner: TComponent); override; destructor Destroy; override; end; implementation uses uCustomEditor, uDataModuleUsuarios, uBizEjercicios, uBizApuntes, uEditorDBBase, uFactuGES_App, cxGrid, cxGridCustomTableView; {$R *.dfm} { ****************************** TfEditorAsientos ******************************* } procedure TfEditorDiario.FormShow(Sender: TObject); begin inherited; if not Assigned(ViewGrid) then raise Exception.Create('No hay ninguna vista asignada'); if not Assigned(Diario) then raise Exception.Create('No hay ningún Diario asignado'); Diario.DataTable.Active := True; ViewGrid.GotoFirst; //Para que coja el ancho automático actAnchoAuto.Execute; end; function TfEditorDiario.GetDiario: IBizDiario; begin Result := FDiario; end; procedure TfEditorDiario.ImprimirInterno; begin inherited; end; function TfEditorDiario.GetController: IAsientosController; begin Result := FController; end; procedure TfEditorDiario.ModificarInterno; begin inherited; FController.Ver(FController.Buscar(Diario.ID_ASIENTO)); actRefrescar.Execute; end; procedure TfEditorDiario.NuevoInterno; {var NumOrden: Integer;} begin inherited; // NumOrden := ViewGrid._FocusedView.DataController.Summary.FooterSummaryValues[2]; // Inc(NumOrden); FController.Ver(FController.Anadir); actRefrescar.Execute; end; procedure TfEditorDiario.PonerTitulos(const ATitulo: string); var FTitulo : String; begin FTitulo := 'Libro de diario - ' + AppFactuGES.EmpresaActiva.NOMBRE + ' - ' + AppFactuGES.EjercicioActivo.NOMBRE + ' (' + AppFactuGES.EjercicioActivo.ESTADO + ')'; inherited PonerTitulos(FTitulo); end; procedure TfEditorDiario.PrevisualizarInterno; begin inherited; end; procedure TfEditorDiario.SetDiario(const Value: IBizDiario); begin FDiario := Value; dsDataTable.DataTable := FDiario.DataTable; if Assigned(ViewGrid) then (ViewGrid as IViewDiario).Diario := Diario; end; procedure TfEditorDiario.SetController(const Value: IAsientosController); begin FController := Value; end; destructor TfEditorDiario.Destroy; begin FDiario := NIL; inherited; end; procedure TfEditorDiario.DuplicarInterno; {var AEpigrafe : IBizAsiento;} begin { inherited; AEpigrafe := FController.Duplicar(Asientos); try FController.Ver(AEpigrafe); finally actRefrescar.Execute; end; } end; procedure TfEditorDiario.EliminarInterno; begin if (Application.MessageBox('¿Está seguro que desea borrar el asiento seleccionado?', 'Atención', MB_YESNO) = IDYES) then begin inherited; if FController.Eliminar(Diario.ID_ASIENTO) then actRefrescar.Execute; end; end; procedure TfEditorDiario.actEliminarUpdate(Sender: TObject); begin inherited; //No se podrá eliminar un asiento si es automático por factura, si el ejercicio esta cerrado o el asiento esta punteado if (Sender as TAction).Enabled then if Assigned(Diario) then (Sender as TAction).Enabled := Diario.ID_FACTURAIsNull and Diario.ID_PAGOIsNull and (Diario.ESTADO = CTE_ABIERTO) and (Diario.PUNTEADO = CTE_NO_PUNTEADO); end; procedure TfEditorDiario.actModificarUpdate(Sender: TObject); begin inherited; //No se podrá modificar un asiento si es automático por factura, si el ejercicio esta cerrado o el asiento esta punteado if (Sender as TAction).Enabled then if Assigned(Diario) then (Sender as TAction).Enabled := Diario.ID_FACTURAIsNull and Diario.ID_PAGOIsNull and (Diario.ESTADO = CTE_ABIERTO) and (Diario.PUNTEADO = CTE_NO_PUNTEADO); end; procedure TfEditorDiario.actNuevoUpdate(Sender: TObject); begin inherited; if (Sender as TAction).Enabled then (Sender as TAction).Enabled := (AppFactuGES.EjercicioActivo.ESTADO = CTE_ABIERTO); end; procedure TfEditorDiario.actPuntearExecute(Sender: TObject); begin inherited; FController.Puntear(Diario); // actRefrescar.Execute; end; procedure TfEditorDiario.actPuntearUpdate(Sender: TObject); begin inherited; if HayDatos and Assigned(ViewGrid) then (Sender as TAction).Enabled := not (dsDataTable.DataTable.State in dsEditModes) and not ViewGrid.IsEmpty and ViewGrid.esSeleccionCeldaDatos else (Sender as TAction).Enabled := False; if (Sender as TAction).Enabled then (Sender as TAction).Enabled := (AppFactuGES.EjercicioActivo.ESTADO = CTE_ABIERTO); end; constructor TfEditorDiario.Create(AOwner: TComponent); begin inherited; ViewGrid := frViewDiario1; //CreateView(TfrViewAsientos) as IViewAsientos; end; end.