166 lines
5.4 KiB
ObjectPascal
166 lines
5.4 KiB
ObjectPascal
|
|
unit uEditorEjercicios;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
|
Dialogs, uEditorBase, ToolWin, ComCtrls, JvExControls, JvComponent,
|
|||
|
|
JvNavigationPane, uViewEjercicios, uBizEjercicios, 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, uIEditorEjercicios, uEditorGridBase,
|
|||
|
|
JvComponentBase, uViewGridBase, uEjerciciosController, JvExComCtrls,
|
|||
|
|
JvStatusBar, uDAInterfaces, dxGDIPlusClasses;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
TfEditorEjercicios = class(TfEditorGridBase, IEditorEjercicios)
|
|||
|
|
frViewEjercicios1: TfrViewEjercicios;
|
|||
|
|
actCerrarEjercicio: TAction;
|
|||
|
|
TBXItem38: TTBXItem;
|
|||
|
|
procedure FormShow(Sender: TObject);
|
|||
|
|
procedure actCerrarEjercicioExecute(Sender: TObject);
|
|||
|
|
procedure actCerrarEjercicioUpdate(Sender: TObject);
|
|||
|
|
private
|
|||
|
|
FEjercicios: IBizEjercicio;
|
|||
|
|
FController : IEjerciciosController;
|
|||
|
|
protected
|
|||
|
|
function GetEjercicios: IBizEjercicio;
|
|||
|
|
procedure SetEjercicios(const Value: IBizEjercicio);
|
|||
|
|
function GetController : IEjerciciosController; virtual;
|
|||
|
|
procedure SetController (const Value : IEjerciciosController); virtual;
|
|||
|
|
|
|||
|
|
procedure NuevoInterno; override;
|
|||
|
|
procedure EliminarInterno; override;
|
|||
|
|
procedure ModificarInterno; override;
|
|||
|
|
|
|||
|
|
public
|
|||
|
|
procedure PonerTitulos(const ATitulo: string = ''); override;
|
|||
|
|
property Ejercicios: IBizEjercicio read GetEjercicios write SetEjercicios;
|
|||
|
|
property Controller : IEjerciciosController read GetController write SetController;
|
|||
|
|
constructor Create(AOwner: TComponent); override;
|
|||
|
|
destructor Destroy; override;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
uCustomEditor, uDataModuleEjercicios, uDataModuleUsuarios, uDialogUtils,
|
|||
|
|
uEditorEjercicio, uEditorDBBase, uFactuGES_App,
|
|||
|
|
cxGrid, cxGridCustomTableView, DateUtils;
|
|||
|
|
|
|||
|
|
{$R *.dfm}
|
|||
|
|
|
|||
|
|
{
|
|||
|
|
****************************** TfEditorEjercicios *******************************
|
|||
|
|
}
|
|||
|
|
procedure TfEditorEjercicios.FormShow(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
|
|||
|
|
if not Assigned(ViewGrid) then
|
|||
|
|
raise Exception.Create('No hay ninguna vista asignada');
|
|||
|
|
|
|||
|
|
if not Assigned(Ejercicios) then
|
|||
|
|
raise Exception.Create('No hay ningún Ejercicio asignado');
|
|||
|
|
|
|||
|
|
Ejercicios.DataTable.Active := True;
|
|||
|
|
ViewGrid.GotoFirst;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfEditorEjercicios.GetEjercicios: IBizEjercicio;
|
|||
|
|
begin
|
|||
|
|
Result := FEjercicios;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfEditorEjercicios.GetController: IEjerciciosController;
|
|||
|
|
begin
|
|||
|
|
Result := FController;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorEjercicios.ModificarInterno;
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
FController.Ver(Ejercicios);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorEjercicios.NuevoInterno;
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
FController.Anadir(Ejercicios);
|
|||
|
|
FController.Ver(Ejercicios);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorEjercicios.PonerTitulos(const ATitulo: string);
|
|||
|
|
var
|
|||
|
|
FTitulo : String;
|
|||
|
|
begin
|
|||
|
|
FTitulo := 'Lista de ejercicios - ' + AppFactuGES.EmpresaActiva.NOMBRE;
|
|||
|
|
inherited PonerTitulos(FTitulo);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorEjercicios.SetEjercicios(const Value: IBizEjercicio);
|
|||
|
|
begin
|
|||
|
|
FEjercicios := Value;
|
|||
|
|
dsDataTable.DataTable := FEjercicios.DataTable;
|
|||
|
|
if Assigned(ViewGrid) then
|
|||
|
|
(ViewGrid as IViewEjercicios).Ejercicios := Ejercicios;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorEjercicios.SetController(const Value: IEjerciciosController);
|
|||
|
|
begin
|
|||
|
|
FController := Value;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
destructor TfEditorEjercicios.Destroy;
|
|||
|
|
begin
|
|||
|
|
FEjercicios := NIL;
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorEjercicios.EliminarInterno;
|
|||
|
|
begin
|
|||
|
|
if (ShowConfirmMessage('Eliminar un ejercicio', Format('¿Desea borrar el ejercicio ''%s''?' + #10#13 + 'Tenga en cuenta que se eliminará también todo el plan general contable asociado al ejercicio.', [Ejercicios.NOMBRE])) = IDYES) then
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
//Para que en el caso de no poderse realizar la operación se refresquen
|
|||
|
|
//los datos y no nos permita eliminar un registro a la segunda
|
|||
|
|
if not FController.Eliminar(Ejercicios) then
|
|||
|
|
actRefrescar.Execute;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorEjercicios.actCerrarEjercicioExecute(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
Cadena: String;
|
|||
|
|
Ano: Integer;
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
Ano := YearOf(Ejercicios.FECHA_INICIO);
|
|||
|
|
Cadena := 'Se creará un nuevo ejercicio ( Ejercicio ' + InttoStr(Ano + 1) + ' ) con los asientos de apertura correspondientes a los asientos de cierre del ejercicio seleccionado. ¿Desea continuar?';
|
|||
|
|
|
|||
|
|
if (Application.MessageBox(PChar(Cadena), 'Atención', MB_YESNO) = IDYES) then
|
|||
|
|
if Controller.CerrarEjercicio(Ejercicios) then
|
|||
|
|
begin
|
|||
|
|
Ejercicios.DataTable.Refresh;
|
|||
|
|
Cadena := 'Se ha cerrado correctamente el ejercicio ' + IntToStr(Ano) + '. El ejercicio ' + IntToStr(Ano + 1) + ' será el nuevo ejercicio activo';
|
|||
|
|
Application.MessageBox(PChar(Cadena), 'FactuGES', MB_OK);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorEjercicios.actCerrarEjercicioUpdate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
(Sender as TAction).Enabled := HayDatos
|
|||
|
|
and (FEjercicios.ESTADO = CTE_ABIERTO);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
constructor TfEditorEjercicios.Create(AOwner: TComponent);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
ViewGrid := frViewEjercicios1; //CreateView(TfrViewEjercicios) as IViewEjercicios;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|