git-svn-id: https://192.168.0.254/svn/Proyectos.ConstruccionesCNJ_FactuGES/trunk@4 6cb6b671-b4a0-dd4c-8bdc-3006503d97e9
205 lines
5.8 KiB
ObjectPascal
205 lines
5.8 KiB
ObjectPascal
unit uEditorPresupuestos;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
|
uCustomEditor, ImgList,
|
|
PngImageList, StdActns, ActnList, TB2ExtItems, TBXExtItems, TBX, TB2Item,
|
|
TB2Dock, TB2Toolbar, JvExControls, JvComponent, JvNavigationPane,
|
|
uViewPresupuestos, Menus, DB, uDADataTable, ComCtrls, uViewGrid,
|
|
uDAScriptingProvider, uDACDSDataTable, JvAppStorage,
|
|
JvAppRegistryStorage, JvFormPlacement, pngimage, ExtCtrls, uCustomView,
|
|
uViewBase, uViewBarraSeleccion, JvComponentBase, uIEditorPresupuestos,
|
|
uEditorGridBase, uBizPresupuestos, uPresupuestosController, uViewGridBase,
|
|
JvExComCtrls, JvStatusBar;
|
|
|
|
type
|
|
TfEditorPresupuestos = class(TfEditorGridBase, IEditorPresupuestos)
|
|
frViewPresupuestos1: TfrViewPresupuestos;
|
|
actCambiarSituacion: TAction;
|
|
TBXItem38: TTBXItem;
|
|
TBXSubmenuItem2: TTBXSubmenuItem;
|
|
Cambiarlasituacin1: TMenuItem;
|
|
|
|
procedure FormShow(Sender: TObject);
|
|
procedure frViewBarraSeleccionactSeleccionarExecute(Sender: TObject);
|
|
procedure frViewBarraSeleccionbCancelarClick(Sender: TObject);
|
|
procedure actCambiarSituacionExecute(Sender: TObject);
|
|
procedure actCambiarSituacionUpdate(Sender: TObject);
|
|
|
|
private
|
|
FPresupuestos: IBizPresupuesto;
|
|
FController : IPresupuestosController;
|
|
function HayPresupuestos : Boolean;
|
|
protected
|
|
function GetPresupuestos: IBizPresupuesto;
|
|
procedure SetPresupuestos(const Value: IBizPresupuesto);
|
|
function GetController : IPresupuestosController; virtual;
|
|
procedure SetController (const Value : IPresupuestosController); virtual;
|
|
procedure NuevoInterno; override;
|
|
procedure EliminarInterno; override;
|
|
procedure ModificarInterno; override;
|
|
procedure DuplicarInterno; override;
|
|
public
|
|
procedure PonerTitulos(const ATitulo: string = ''); override;
|
|
property Controller : IPresupuestosController read GetController write SetController;
|
|
constructor Create(AOwner: TComponent); override;
|
|
destructor Destroy; override;
|
|
property Presupuestos: IBizPresupuesto read GetPresupuestos write
|
|
SetPresupuestos;
|
|
end;
|
|
|
|
var
|
|
fEditorPresupuestos : TfEditorPresupuestos;
|
|
|
|
implementation
|
|
|
|
uses
|
|
cxControls, uDataModulePresupuestos, uEditorBase, uDataModuleUsuarios,
|
|
DateUtils;
|
|
|
|
{$R *.DFM}
|
|
|
|
{
|
|
***************************** TfEditorPresupuestos *****************************
|
|
}
|
|
constructor TfEditorPresupuestos.Create(AOwner: TComponent);
|
|
begin
|
|
inherited;
|
|
ViewGrid := frViewPresupuestos1;
|
|
end;
|
|
|
|
destructor TfEditorPresupuestos.Destroy;
|
|
begin
|
|
FPresupuestos := NIL;
|
|
inherited;
|
|
end;
|
|
|
|
procedure TfEditorPresupuestos.DuplicarInterno;
|
|
var
|
|
APresupuesto : IBizPresupuesto;
|
|
begin
|
|
inherited;
|
|
APresupuesto := FController.Duplicar(Presupuestos);
|
|
try
|
|
FController.Ver(APresupuesto);
|
|
finally
|
|
actRefrescar.Execute;
|
|
end;
|
|
end;
|
|
|
|
procedure TfEditorPresupuestos.EliminarInterno;
|
|
begin
|
|
if (Application.MessageBox('¿Desea borrar este presupuesto?', 'Atención', MB_YESNO) = IDYES) then
|
|
begin
|
|
FController.Eliminar(Presupuestos);
|
|
inherited;
|
|
end;
|
|
end;
|
|
|
|
procedure TfEditorPresupuestos.FormShow(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
|
|
if not Assigned(ViewGrid) then
|
|
raise Exception.Create('No hay ninguna vista asignada');
|
|
|
|
if not Assigned(Presupuestos) then
|
|
raise Exception.Create('No hay ningún presupuesto asignado');
|
|
|
|
Presupuestos.DataTable.Active := True;
|
|
ViewGrid.GotoFirst;
|
|
end;
|
|
|
|
procedure TfEditorPresupuestos.frViewBarraSeleccionactSeleccionarExecute(
|
|
Sender: TObject);
|
|
begin
|
|
inherited;
|
|
if (Presupuestos.DataTable.RecordCount > 0) then
|
|
begin
|
|
// ViewGrid.SyncFocusedRecordsFromGrid;
|
|
ModalResult := mrOK;
|
|
end;
|
|
end;
|
|
|
|
procedure TfEditorPresupuestos.frViewBarraSeleccionbCancelarClick(Sender:
|
|
TObject);
|
|
begin
|
|
inherited;
|
|
// frViewBarraSeleccion.actCancelarExecute(Sender);
|
|
end;
|
|
|
|
function TfEditorPresupuestos.GetController: IPresupuestosController;
|
|
begin
|
|
Result := FController;
|
|
end;
|
|
|
|
function TfEditorPresupuestos.GetPresupuestos: IBizPresupuesto;
|
|
begin
|
|
Result := FPresupuestos;
|
|
end;
|
|
|
|
function TfEditorPresupuestos.HayPresupuestos: Boolean;
|
|
begin
|
|
Result := Assigned(FPresupuestos) and (FPresupuestos.DataTable.Active) and
|
|
(not FPresupuestos.DataTable.Opening) and
|
|
(not FPresupuestos.DataTable.Closing) and
|
|
(not FPresupuestos.DataTable.Fetching) and
|
|
(not FPresupuestos.DataTable.Opening) and
|
|
(not FPresupuestos.DataTable.IsEmpty);
|
|
end;
|
|
|
|
procedure TfEditorPresupuestos.ModificarInterno;
|
|
begin
|
|
inherited;
|
|
FController.Ver(Presupuestos);
|
|
end;
|
|
|
|
procedure TfEditorPresupuestos.NuevoInterno;
|
|
begin
|
|
inherited;
|
|
FController.Anadir(Presupuestos);
|
|
FController.Ver(Presupuestos);
|
|
end;
|
|
|
|
procedure TfEditorPresupuestos.PonerTitulos(const ATitulo: string);
|
|
var
|
|
FTitulo : String;
|
|
begin
|
|
FTitulo := 'Lista de presupuestos - ' + dmUsuarios.EmpresaActual.NOMBRE;
|
|
inherited PonerTitulos(FTitulo);
|
|
end;
|
|
|
|
procedure TfEditorPresupuestos.SetController(const Value: IPresupuestosController);
|
|
begin
|
|
FController := Value;
|
|
end;
|
|
|
|
procedure TfEditorPresupuestos.SetPresupuestos(const Value: IBizPresupuesto);
|
|
begin
|
|
FPresupuestos := Value;
|
|
dsDataTable.DataTable := FPresupuestos.DataTable;
|
|
if Assigned(ViewGrid) then
|
|
(ViewGrid as IViewPresupuestos).Presupuestos := Presupuestos;
|
|
end;
|
|
|
|
procedure TfEditorPresupuestos.actCambiarSituacionExecute(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
FController.CambiarSituacion(FPresupuestos);
|
|
end;
|
|
|
|
procedure TfEditorPresupuestos.actCambiarSituacionUpdate(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
if HayDatos and Assigned(ViewGrid) then
|
|
(Sender as TAction).Enabled := not (dsDataTable.DataTable.State in dsEditModes)
|
|
and not ViewGrid.IsEmpty
|
|
else
|
|
(Sender as TAction).Enabled := False;
|
|
end;
|
|
|
|
end.
|
|
|