156 lines
4.4 KiB
ObjectPascal
156 lines
4.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;
|
||
procedure FormShow(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;
|
||
procedure DuplicarInterno; 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,
|
||
uEditorEjercicio, uEditorDBBase, uFactuGES_App,
|
||
cxGrid, cxGridCustomTableView; //, uListaEjercicios;
|
||
|
||
{$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.DuplicarInterno;
|
||
var
|
||
AEjercicio : IBizEjercicio;
|
||
begin
|
||
AppFactuGES.ShowCapado;
|
||
{
|
||
inherited;
|
||
AEjercicio := FController.Duplicar(Ejercicios);
|
||
try
|
||
FController.Ver(AEjercicio);
|
||
finally
|
||
actRefrescar.Execute;
|
||
end;
|
||
}
|
||
end;
|
||
|
||
procedure TfEditorEjercicios.EliminarInterno;
|
||
begin
|
||
|
||
if (Application.MessageBox('¿Desea borrar este ejercicio?, se borrará todo el PGC asociado', 'Atención', MB_YESNO) = 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;
|
||
|
||
constructor TfEditorEjercicios.Create(AOwner: TComponent);
|
||
begin
|
||
inherited;
|
||
ViewGrid := frViewEjercicios1; //CreateView(TfrViewEjercicios) as IViewEjercicios;
|
||
end;
|
||
|
||
end.
|
||
|
||
|