2007-06-21 16:02:50 +00:00
|
|
|
|
unit uEditorPresupuestos;
|
|
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
|
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
|
|
|
|
|
uCustomEditor, uEditorGrid, uBizPresupuestosCliente, 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;
|
|
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
|
IEditorPresupuestos = interface(IEditorGrid)
|
|
|
|
|
|
['{7E6689A4-BEE7-4B36-80D8-411FA1B344F7}']
|
|
|
|
|
|
function GetPresupuestos: IBizPresupuestos;
|
|
|
|
|
|
procedure SetPresupuestos(const Value: IBizPresupuestos);
|
|
|
|
|
|
property Presupuestos: IBizPresupuestos read GetPresupuestos write
|
|
|
|
|
|
SetPresupuestos;
|
|
|
|
|
|
end;
|
2009-03-05 18:57:06 +00:00
|
|
|
|
|
2007-06-21 16:02:50 +00:00
|
|
|
|
TfEditorPresupuestos = class(TfEditorGrid, IEditorPresupuestos)
|
|
|
|
|
|
frViewBarraSeleccion: TfrViewBarraSeleccion;
|
|
|
|
|
|
actAceptado: TAction;
|
|
|
|
|
|
actRechazado: TAction;
|
|
|
|
|
|
actPendiente: TAction;
|
|
|
|
|
|
N3: TMenuItem;
|
|
|
|
|
|
Aceptado1: TMenuItem;
|
|
|
|
|
|
Rechazado1: TMenuItem;
|
|
|
|
|
|
Pendiente1: TMenuItem;
|
|
|
|
|
|
TBXItem36: TTBXItem;
|
|
|
|
|
|
TBXSeparatorItem16: TTBXSeparatorItem;
|
2014-07-14 17:22:53 +00:00
|
|
|
|
TBXItem38: TTBXItem;
|
2007-06-21 16:02:50 +00:00
|
|
|
|
procedure actEliminarExecute(Sender: TObject);
|
|
|
|
|
|
procedure actModificarExecute(Sender: TObject);
|
|
|
|
|
|
procedure actNuevoExecute(Sender: TObject);
|
|
|
|
|
|
procedure frViewBarraSeleccionactSeleccionarExecute(Sender: TObject);
|
|
|
|
|
|
procedure frViewBarraSeleccionbCancelarClick(Sender: TObject);
|
|
|
|
|
|
procedure actDuplicarExecute(Sender: TObject);
|
|
|
|
|
|
procedure frViewBarraSeleccionactSeleccionarUpdate(Sender: TObject);
|
|
|
|
|
|
procedure actAceptadoExecute(Sender: TObject);
|
|
|
|
|
|
procedure actRechazadoExecute(Sender: TObject);
|
|
|
|
|
|
procedure actPendienteExecute(Sender: TObject);
|
2009-03-05 18:57:06 +00:00
|
|
|
|
procedure OnListaAnosChange(Sender: TObject; const Text: string);
|
|
|
|
|
|
procedure FormShow(Sender: TObject);
|
|
|
|
|
|
|
2007-06-21 16:02:50 +00:00
|
|
|
|
private
|
|
|
|
|
|
FPresupuestos: IBizPresupuestos;
|
2016-02-23 16:36:40 +00:00
|
|
|
|
|
2007-06-21 16:02:50 +00:00
|
|
|
|
protected
|
|
|
|
|
|
function GetPresupuestos: IBizPresupuestos;
|
|
|
|
|
|
function GetSelectionBarVisible: Boolean;
|
|
|
|
|
|
procedure SetPresupuestos(const Value: IBizPresupuestos);
|
|
|
|
|
|
procedure SetSelectionBarVisible(const Value: Boolean);
|
|
|
|
|
|
procedure SetViewGrid(const Value: IViewGrid); override;
|
|
|
|
|
|
procedure CambiarEstado(const NuevoEstado: String);
|
|
|
|
|
|
public
|
|
|
|
|
|
constructor Create(AOwner: TComponent); override;
|
|
|
|
|
|
destructor Destroy; override;
|
|
|
|
|
|
property Presupuestos: IBizPresupuestos read GetPresupuestos write
|
|
|
|
|
|
SetPresupuestos;
|
|
|
|
|
|
property SelectionBarVisible: Boolean read GetSelectionBarVisible write
|
|
|
|
|
|
SetSelectionBarVisible;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
var
|
|
|
|
|
|
fEditorPresupuestos : TfEditorPresupuestos;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
|
|
uses cxControls, uDataModulePresupuestos, uEditorUtils, uEditorBase,
|
2016-02-23 16:36:40 +00:00
|
|
|
|
DateUtils, uDataModuleMontajes, uDBSelectionList, uBizInformesBase;
|
2007-06-21 16:02:50 +00:00
|
|
|
|
|
|
|
|
|
|
{$R *.DFM}
|
|
|
|
|
|
|
|
|
|
|
|
function ShowEditorPresupuestos (ABizObject : TDADataTableRules) : TModalResult;
|
|
|
|
|
|
var
|
|
|
|
|
|
AEditor: TfEditorPresupuestos;
|
|
|
|
|
|
begin
|
|
|
|
|
|
AEditor := TfEditorPresupuestos.Create(Application);
|
|
|
|
|
|
try
|
|
|
|
|
|
AEditor.Presupuestos := (ABizObject as IBizPresupuestos);
|
|
|
|
|
|
Result := AEditor.ShowModal;
|
|
|
|
|
|
finally
|
|
|
|
|
|
AEditor.Release;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function ShowSelectEditorPresupuestos (ABizObject : TDADataTableRules) : TModalResult;
|
|
|
|
|
|
var
|
|
|
|
|
|
AEditor: TfEditorPresupuestos;
|
|
|
|
|
|
begin
|
|
|
|
|
|
AEditor := TfEditorPresupuestos.Create(Application);
|
|
|
|
|
|
try
|
|
|
|
|
|
AEditor.Presupuestos := (ABizObject as IBizPresupuestos);
|
|
|
|
|
|
AEditor.SelectionBarVisible := True;
|
|
|
|
|
|
Result := AEditor.ShowModal;
|
|
|
|
|
|
finally
|
|
|
|
|
|
AEditor.Release;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
{ TfEditorPresupuestos }
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
***************************** TfEditorPresupuestos *****************************
|
|
|
|
|
|
}
|
|
|
|
|
|
constructor TfEditorPresupuestos.Create(AOwner: TComponent);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
ViewGrid := CreateView(TfrViewPresupuestos) as IViewPresupuestos;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
destructor TfEditorPresupuestos.Destroy;
|
|
|
|
|
|
begin
|
|
|
|
|
|
FPresupuestos := NIL;
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorPresupuestos.actEliminarExecute(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
if (Application.MessageBox('<27>Desea borrar este presupuesto?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
ViewGrid.RefreshGrid;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorPresupuestos.actModificarExecute(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
Presupuestos.Show;
|
|
|
|
|
|
ViewGrid.RefreshGrid;
|
|
|
|
|
|
ViewGrid.SyncFocusedRecordsFromDataSet;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorPresupuestos.actNuevoExecute(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
Presupuestos.Insert;
|
|
|
|
|
|
Presupuestos.Show;
|
|
|
|
|
|
ViewGrid.RefreshGrid;
|
|
|
|
|
|
ViewGrid.SyncFocusedRecordsFromDataSet;
|
|
|
|
|
|
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.GetPresupuestos: IBizPresupuestos;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FPresupuestos;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TfEditorPresupuestos.GetSelectionBarVisible: Boolean;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := frViewBarraSeleccion.Visible
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorPresupuestos.SetPresupuestos(const Value: IBizPresupuestos);
|
|
|
|
|
|
begin
|
|
|
|
|
|
FPresupuestos := Value;
|
2009-03-05 18:57:06 +00:00
|
|
|
|
|
|
|
|
|
|
if Assigned(FPresupuestos) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
//Se guarda el where de la sentencia origen, por si el editor tiene filtros que
|
|
|
|
|
|
//afecten a este where y en un futuro se desea volver al where origen (filtro de a<>o))
|
|
|
|
|
|
WhereDataTable := FPresupuestos.DataTable.Where.Clause;
|
|
|
|
|
|
|
|
|
|
|
|
dsDataTable.DataTable := FPresupuestos.DataTable;
|
|
|
|
|
|
if Assigned(ViewGrid) then
|
|
|
|
|
|
(ViewGrid as IViewPresupuestos).Presupuestos := Presupuestos;
|
|
|
|
|
|
end;
|
2007-06-21 16:02:50 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorPresupuestos.SetSelectionBarVisible(const Value: Boolean);
|
|
|
|
|
|
begin
|
|
|
|
|
|
frViewBarraSeleccion.Visible := True;
|
|
|
|
|
|
ViewGrid.OnDblClick := frViewBarraSeleccion.actSeleccionar.OnExecute;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorPresupuestos.SetViewGrid(const Value: IViewGrid);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
if Assigned(ViewGrid) and Assigned(Presupuestos) then
|
|
|
|
|
|
(ViewGrid as IViewPresupuestos).Presupuestos := Presupuestos;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorPresupuestos.actDuplicarExecute(Sender: TObject);
|
|
|
|
|
|
var
|
|
|
|
|
|
APresupuesto : IBizPresupuestos;
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
APresupuesto := dmPresupuestos.GetPresupuesto(Presupuestos.CODIGO);
|
|
|
|
|
|
Presupuestos.Insert;
|
|
|
|
|
|
Presupuestos.CopyFrom(APresupuesto);
|
|
|
|
|
|
Presupuestos.DataTable.ApplyUpdates;
|
|
|
|
|
|
ViewGrid.RefreshGrid;
|
|
|
|
|
|
ViewGrid.GotoFirst;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorPresupuestos.frViewBarraSeleccionactSeleccionarUpdate(
|
|
|
|
|
|
Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
(Sender as TAction).Enabled := (Presupuestos.DataTable.RecordCount > 0);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorPresupuestos.actAceptadoExecute(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
CambiarEstado(SITUACION_ACEPTADO);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorPresupuestos.actRechazadoExecute(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
CambiarEstado(SITUACION_RECHAZADO);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorPresupuestos.actPendienteExecute(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
CambiarEstado(SITUACION_PENDIENTE);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorPresupuestos.CambiarEstado(const NuevoEstado: String);
|
|
|
|
|
|
begin
|
|
|
|
|
|
ViewGrid.SyncFocusedRecordsFromGrid;
|
|
|
|
|
|
ShowHourglassCursor;
|
|
|
|
|
|
Presupuestos.DataTable.DisableControls;
|
|
|
|
|
|
try
|
|
|
|
|
|
if not (Presupuestos.DataTable.State in dsEditModes) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
Presupuestos.DataTable.Edit;
|
|
|
|
|
|
Presupuestos.SITUACION := NuevoEstado;
|
|
|
|
|
|
Presupuestos.FECHADECISION := Today;
|
|
|
|
|
|
Presupuestos.DataTable.Post;
|
|
|
|
|
|
Presupuestos.DataTable.ApplyUpdates;
|
|
|
|
|
|
|
|
|
|
|
|
if (NuevoEstado = SITUACION_ACEPTADO)
|
|
|
|
|
|
and (Presupuestos.REFERENCIA = '') then
|
|
|
|
|
|
if (Application.MessageBox('<27>Desea crear un montaje asociado a este presupuesto?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
|
|
|
|
|
dmMontajes.NuevoMontaje(Nil, Presupuestos);
|
|
|
|
|
|
end;
|
|
|
|
|
|
finally
|
|
|
|
|
|
Presupuestos.DataTable.EnableControls;
|
|
|
|
|
|
HideHourglassCursor;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2009-03-05 18:57:06 +00:00
|
|
|
|
procedure TfEditorPresupuestos.OnListaAnosChange(Sender: TObject; const Text: string);
|
2010-01-04 18:48:47 +00:00
|
|
|
|
var
|
|
|
|
|
|
aAux : ISelectedRowList;
|
2009-03-05 18:57:06 +00:00
|
|
|
|
begin
|
|
|
|
|
|
dmPresupuestos.FiltrarAno(Presupuestos, WhereDataTable, Text);
|
|
|
|
|
|
if Presupuestos.DataTable.Active then
|
|
|
|
|
|
actRefrescar.Execute;
|
2010-01-04 18:48:47 +00:00
|
|
|
|
|
|
|
|
|
|
// Quitar las selecciones que hubiera anteriormente porque ya no valen
|
|
|
|
|
|
if Supports(Presupuestos, ISelectedRowList, aAux) then
|
|
|
|
|
|
if (aAux.SelectedRows.Count > 0) then
|
|
|
|
|
|
aAux.SelectedRows.Clear;
|
2009-03-05 18:57:06 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorPresupuestos.FormShow(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
ListaAnos := dmPresupuestos.DarListaAnosPresupuestos;
|
|
|
|
|
|
cbxListaAnos.OnChange := OnListaAnosChange; //OJO SIEMPRE ANTES DEL INHERITED
|
|
|
|
|
|
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2016-02-23 16:36:40 +00:00
|
|
|
|
|
2007-06-21 16:02:50 +00:00
|
|
|
|
initialization
|
|
|
|
|
|
RegisterEditor(IBizPresupuestos, ShowEditorPresupuestos, etItems);
|
|
|
|
|
|
RegisterEditor(IBizPresupuestos, ShowSelectEditorPresupuestos, etSelectItems);
|
|
|
|
|
|
|
|
|
|
|
|
finalization
|
|
|
|
|
|
|
|
|
|
|
|
end.
|
|
|
|
|
|
|