- preguntar fecha de cierre de una ejecución - mejorado el editor git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@716 0c75b7a4-871f-7646-8a2f-f78d34cc349f
331 lines
8.8 KiB
ObjectPascal
331 lines
8.8 KiB
ObjectPascal
unit uEditorObra;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, uEditorDBItem, ToolWin, ComCtrls, JvExControls, JvComponent,
|
||
uViewObra, uBizObras, JvNavigationPane, ActnList,
|
||
uEditorBase, StdActns, TB2Dock, TB2Toolbar, TBX, ImgList, PngImageList,
|
||
TB2Item, uEditorItem, DB, uDADataTable, uEditorDBBase, JvFormAutoSize,
|
||
uDAScriptingProvider, uDACDSDataTable, StdCtrls, pngimage, ExtCtrls,
|
||
TBXDkPanels, JvButton, AppEvnts, uCustomView, uViewBase,
|
||
JvAppStorage, JvAppRegistryStorage, JvFormPlacement, JvComponentBase,
|
||
|
||
uViewObras, uIEditorObra, uObrasController, JvExComCtrls,
|
||
JvStatusBar, dxLayoutLookAndFeels, uDAInterfaces, dxGDIPlusClasses,
|
||
cxControls, cxContainer, cxEdit, cxLabel, uViewDetallesGenerico,
|
||
uViewListaEjecucionesObra, uViewEjecucionObra, Grids, DBGrids;
|
||
|
||
type
|
||
TfEditorObra = class(TfEditorDBItem, IEditorObra)
|
||
dxLayoutLookAndFeelList1: TdxLayoutLookAndFeelList;
|
||
dxLayoutOfficeLookAndFeel1: TdxLayoutOfficeLookAndFeel;
|
||
pagEjecucionActual: TTabSheet;
|
||
pagListaEjecuciones: TTabSheet;
|
||
frViewListaEjecucionesObra1: TfrViewListaEjecucionesObra;
|
||
actNuevaEjecucion: TAction;
|
||
actFinalizarEjecucion: TAction;
|
||
TBXSubmenuItem2: TTBXSubmenuItem;
|
||
TBXItem7: TTBXItem;
|
||
TBXItem33: TTBXItem;
|
||
DBGrid1: TDBGrid;
|
||
dsEjecucionActiva: TDADataSource;
|
||
TBXItem34: TTBXItem;
|
||
TBXItem35: TTBXItem;
|
||
procedure FormShow(Sender: TObject);
|
||
procedure CustomEditorClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure actNuevaEjecucionExecute(Sender: TObject);
|
||
procedure actNuevaEjecucionUpdate(Sender: TObject);
|
||
procedure actFinalizarEjecucionExecute(Sender: TObject);
|
||
procedure actFinalizarEjecucionUpdate(Sender: TObject);
|
||
procedure pgPaginasChange(Sender: TObject);
|
||
protected
|
||
FController : IObrasController;
|
||
FObra: IBizObra;
|
||
FViewObra : IViewObra;
|
||
FViewEjecucionActual: IViewEjecucionObra;
|
||
|
||
function GetController : IObrasController;
|
||
procedure SetController (const Value : IObrasController); virtual;
|
||
function GetObra: IBizObra; virtual;
|
||
procedure SetObra(const Value: IBizObra); virtual;
|
||
function GetViewObra: IViewObra;
|
||
procedure SetViewObra(const Value: IViewObra);
|
||
property ViewObra: IViewObra read GetViewObra write SetViewObra;
|
||
|
||
procedure GuardarInterno; override;
|
||
procedure EliminarInterno; override;
|
||
|
||
procedure PonerTitulos(const ATitulo: string = ''); override;
|
||
procedure ActualizarPestanas;
|
||
|
||
//Si queremos crear otra vista para el editor heredado solo tendriamos que
|
||
//sobreescribir este metodo
|
||
procedure AsignarVista; virtual;
|
||
procedure AsignarVistaEjecucion;
|
||
procedure DestruirVistaEjecucion;
|
||
|
||
public
|
||
property Obra: IBizObra read GetObra write SetObra;
|
||
constructor Create(AOwner: TComponent); override;
|
||
destructor Destroy; override;
|
||
end;
|
||
|
||
implementation
|
||
|
||
{$R *.dfm}
|
||
|
||
uses
|
||
uCustomEditor, uDataModuleObras, uDataModuleBase, uDialogUtils;
|
||
|
||
function ShowEditorObra (ABizObject : TDADataTableRules): TModalResult;
|
||
var
|
||
AEditor: TfEditorObra;
|
||
begin
|
||
AEditor := TfEditorObra.Create(Application);
|
||
try
|
||
AEditor.Obra := (ABizObject as IBizObra);
|
||
Result := AEditor.ShowModal;
|
||
finally
|
||
AEditor.Release;
|
||
end;
|
||
end;
|
||
|
||
{
|
||
******************************* TfEditorObra *******************************
|
||
}
|
||
function TfEditorObra.GetObra: IBizObra;
|
||
begin
|
||
Result := FObra;
|
||
end;
|
||
|
||
function TfEditorObra.GetController: IObrasController;
|
||
begin
|
||
Result := FController;
|
||
end;
|
||
|
||
function TfEditorObra.GetViewObra: IViewObra;
|
||
begin
|
||
Result := FViewObra;
|
||
end;
|
||
|
||
procedure TfEditorObra.GuardarInterno;
|
||
{var
|
||
FPresupuestos : IBizEjecucionPresupuestos;}
|
||
begin
|
||
inherited;
|
||
|
||
{ FPresupuestos := NIL;
|
||
if Assigned(FViewEjecucionActual) then
|
||
FPresupuestos := FViewEjecucionActual.Presupuestos;}
|
||
|
||
FController.Guardar(FObra);
|
||
Modified := False;
|
||
end;
|
||
|
||
procedure TfEditorObra.pgPaginasChange(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
if pgPaginas.ActivePage = pagEjecucionActual then
|
||
begin
|
||
if FObra.Ejecuciones.State in dsEditModes then
|
||
FObra.Ejecuciones.Post;
|
||
|
||
FController.LocalizarEjecucionActiva(FObra.Ejecuciones)
|
||
end
|
||
else
|
||
if pgPaginas.ActivePage = pagListaEjecuciones then
|
||
FObra.Ejecuciones.First;
|
||
end;
|
||
|
||
procedure TfEditorObra.PonerTitulos(const ATitulo: string);
|
||
var
|
||
FTitulo : String;
|
||
begin
|
||
if Assigned(Obra) then
|
||
begin
|
||
if Obra.EsNuevo then
|
||
FTitulo := 'Nueva obra'
|
||
else
|
||
FTitulo := 'Obra' + ' - ' + Obra.NOMBRE;
|
||
end;
|
||
|
||
inherited PonerTitulos(FTitulo);
|
||
end;
|
||
|
||
procedure TfEditorObra.SetObra(const Value: IBizObra);
|
||
begin
|
||
FObra := Value;
|
||
dsDataTable.DataTable := FObra.DataTable;
|
||
|
||
if Assigned(FViewObra) and Assigned(FObra) then
|
||
begin
|
||
FViewObra.Obra := FObra;
|
||
dsEjecucionActiva.DataTable := FObra.Ejecuciones.DataTable;
|
||
|
||
frViewListaEjecucionesObra1.dsDetalles.DataTable := FObra.Ejecuciones.DataTable;
|
||
|
||
if FController.LocalizarEjecucionActiva(FObra.Ejecuciones) then
|
||
AsignarVistaEjecucion
|
||
end
|
||
else begin
|
||
FViewObra.Obra := NIL;
|
||
dsEjecucionActiva.DataTable := NIL;
|
||
frViewListaEjecucionesObra1.dsDetalles.DataTable := NIL;
|
||
end;
|
||
ActualizarPestanas;
|
||
end;
|
||
|
||
procedure TfEditorObra.SetController(const Value: IObrasController);
|
||
begin
|
||
FController := Value;
|
||
if Assigned(FViewObra) and Assigned(FController) then
|
||
FViewObra.Controller := FController;
|
||
end;
|
||
|
||
procedure TfEditorObra.SetViewObra(const Value: IViewObra);
|
||
begin
|
||
FViewObra := Value;
|
||
|
||
if Assigned(FViewObra) and Assigned(Obra) then
|
||
FViewObra.Obra := Obra;
|
||
end;
|
||
|
||
procedure TfEditorObra.FormShow(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
|
||
if not Assigned(FViewObra) then
|
||
raise Exception.Create('No hay ninguna vista asignada');
|
||
|
||
if not Assigned(Obra) then
|
||
raise Exception.Create('No hay ninguna obra asignada');
|
||
|
||
Obra.DataTable.Active := True;
|
||
end;
|
||
|
||
destructor TfEditorObra.Destroy;
|
||
begin
|
||
// Utilizar mejor OnClose;
|
||
inherited;
|
||
end;
|
||
|
||
procedure TfEditorObra.DestruirVistaEjecucion;
|
||
begin
|
||
FViewEjecucionActual := NIL;
|
||
end;
|
||
|
||
procedure TfEditorObra.actFinalizarEjecucionExecute(Sender: TObject);
|
||
begin
|
||
if (ShowConfirmMessage('Finalizar la ejecuci<63>n en curso', 'La ejecuci<63>n actual pasar<61> a ser hist<73>rica. <20>Desea cerrar la ejecuci<63>n actual de la obra?') = IDYES) then
|
||
begin
|
||
ShowHourglassCursor;
|
||
try
|
||
FController.CerrarEjecucionActiva(FObra, Now);
|
||
DestruirVistaEjecucion;
|
||
ActualizarPestanas;
|
||
pgPaginas.ActivePageIndex := pagListaEjecuciones.PageIndex;
|
||
finally
|
||
HideHourglassCursor;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfEditorObra.actFinalizarEjecucionUpdate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
(Sender as TAction).Enabled := not actNuevaEjecucion.Enabled;
|
||
end;
|
||
|
||
procedure TfEditorObra.actNuevaEjecucionExecute(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
|
||
ShowHourglassCursor;
|
||
try
|
||
FObra.Ejecuciones.Insert;
|
||
AsignarVistaEjecucion;
|
||
ActualizarPestanas;
|
||
pgPaginas.ActivePageIndex := pagEjecucionActual.PageIndex;
|
||
finally
|
||
HideHourglassCursor;
|
||
end;
|
||
end;
|
||
|
||
|
||
procedure TfEditorObra.actNuevaEjecucionUpdate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
(Sender as TAction).Enabled := not pagEjecucionActual.TabVisible;
|
||
end;
|
||
|
||
procedure TfEditorObra.ActualizarPestanas;
|
||
begin
|
||
if Assigned(FViewEjecucionActual) then
|
||
pagEjecucionActual.TabVisible := True
|
||
else
|
||
pagEjecucionActual.TabVisible := False;
|
||
end;
|
||
|
||
procedure TfEditorObra.AsignarVista;
|
||
var
|
||
AViewObra: TfrViewObra;
|
||
begin
|
||
AViewObra := TfrViewObra.Create(Self);
|
||
with AViewObra do
|
||
begin
|
||
Parent := pagGeneral;
|
||
Align := alClient;
|
||
dxLayoutControlObra.LookAndFeel := dxLayoutOfficeLookAndFeel1;
|
||
end;
|
||
ViewObra := AViewObra;
|
||
end;
|
||
|
||
procedure TfEditorObra.AsignarVistaEjecucion;
|
||
var
|
||
AViewEjecucion: TfrViewEjecucionObra;
|
||
begin
|
||
AViewEjecucion := TfrViewEjecucionObra.Create(NIL);
|
||
|
||
with AViewEjecucion do
|
||
begin
|
||
Parent := pagEjecucionActual;
|
||
Align := alClient;
|
||
dxLayoutControlEjecucionObra.LookAndFeel := dxLayoutOfficeLookAndFeel1;
|
||
Controller := FController;
|
||
Obra := FObra;
|
||
end;
|
||
FViewEjecucionActual := AViewEjecucion;
|
||
end;
|
||
|
||
constructor TfEditorObra.Create(AOwner: TComponent);
|
||
begin
|
||
inherited;
|
||
pgPaginas.ActivePage := pagGeneral;
|
||
FViewEjecucionActual := NIL;
|
||
AsignarVista;
|
||
end;
|
||
|
||
procedure TfEditorObra.CustomEditorClose(Sender: TObject;
|
||
var Action: TCloseAction);
|
||
begin
|
||
inherited;
|
||
dsDataTable.DataTable := NIL;
|
||
FViewObra := NIL;
|
||
FObra := NIL;
|
||
end;
|
||
|
||
procedure TfEditorObra.EliminarInterno;
|
||
begin
|
||
if (ShowConfirmMessage('Eliminar la obra', '<27>Desea eliminar esta obra?') = IDYES) then
|
||
begin
|
||
inherited;
|
||
if not FController.Eliminar(FObra) then
|
||
actRefrescar.Execute;
|
||
end;
|
||
end;
|
||
|
||
end.
|
||
|