This repository has been archived on 2024-12-02. You can view files and clone it, but cannot push or open issues or pull requests.
AlonsoYSal_FactuGES/Modulos/Montajes/Cliente/uEditorMontajes.pas
2007-06-21 16:02:50 +00:00

200 lines
5.8 KiB
ObjectPascal
Raw Blame History

unit uEditorMontajes;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uEditorBase, uEditorGrid, ToolWin, ComCtrls, JvExControls, JvComponent,
JvNavigationPane, uViewMontajes, uBizMontajes, 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, JvComponentBase, pngimage;
type
IEditorMontajes = interface(IEditorGrid)
['{607F821D-E790-4F80-B095-CE1C34B42E3A}']
function GetMontajes: IBizMontaje;
procedure SetMontajes(const Value: IBizMontaje);
property Montajes: IBizMontaje read GetMontajes write SetMontajes;
function GetSelectionBarVisible: Boolean;
procedure SetSelectionBarVisible(const Value: Boolean);
property SelectionBarVisible : Boolean read GetSelectionBarVisible write
SetSelectionBarVisible;
end;
TfEditorMontajes = class(TfEditorGrid, IEditorMontajes)
frViewBarraSeleccion: TfrViewBarraSeleccion;
procedure FormShow(Sender: TObject);
procedure actNuevoExecute(Sender: TObject);
procedure actModificarExecute(Sender: TObject);
procedure actEliminarExecute(Sender: TObject);
procedure frViewBarraSeleccionactSeleccionarExecute(Sender: TObject);
private
FMontajes: IBizMontaje;
protected
function GetMontajes: IBizMontaje; virtual;
procedure SetMontajes(const Value: IBizMontaje); virtual;
procedure SetViewGrid(const Value: IViewGrid); override;
function GetSelectionBarVisible: Boolean; virtual;
procedure SetSelectionBarVisible(const Value: Boolean); virtual;
public
property SelectionBarVisible : Boolean read GetSelectionBarVisible write
SetSelectionBarVisible;
property Montajes: IBizMontaje read GetMontajes write SetMontajes;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
implementation
uses
uCustomEditor, uDataModuleMontajes,
uEditorMontaje, uEditorDBBase, uEditorUtils,
cxGrid, cxGridCustomTableView, uDBSelectionList, uBizPresupuestosCliente,
uDataModulePresupuestos;
{$R *.dfm}
function ShowEditorMontajes (ABizObject : TDADataTableRules): TModalResult;
var
AEditor: TfEditorMontajes;
begin
AEditor := TfEditorMontajes.Create(Application);
try
AEditor.Montajes := (ABizObject as IBizMontaje);
Result := AEditor.ShowModal;
finally
AEditor.Release;
end;
end;
function ShowSelectEditorMontajes (ABizObject : TDADataTableRules) : TModalResult;
var
AEditor: TfEditorMontajes;
begin
AEditor := TfEditorMontajes.Create(Application);
try
AEditor.Montajes := (ABizObject as IBizMontaje);
AEditor.SelectionBarVisible := True;
Result := AEditor.ShowModal;
finally
AEditor.Release;
end;
end;
{
****************************** TfEditorMontajes *******************************
}
procedure TfEditorMontajes.FormShow(Sender: TObject);
begin
inherited;
if not Assigned(ViewGrid) then
raise Exception.Create('No hay ninguna vista asignada');
if not Assigned(Montajes) then
raise Exception.Create('No hay ning<6E>n Montaje asignado');
Montajes.DataTable.Active := True;
end;
function TfEditorMontajes.GetMontajes: IBizMontaje;
begin
Result := FMontajes;
end;
procedure TfEditorMontajes.SetMontajes(const Value: IBizMontaje);
begin
FMontajes := Value;
dsDataTable.DataTable := FMontajes.DataTable;
if Assigned(ViewGrid) then
(ViewGrid as IViewMontajes).Montajes := Montajes;
end;
procedure TfEditorMontajes.actNuevoExecute(Sender: TObject);
var
APresupuesto : IBizPresupuestos;
begin
inherited;
APresupuesto := dmPresupuestos.GetPresupuestosSinMontaje;
try
if APresupuesto.ShowForSelect = mrOK then
begin
APresupuesto := dmPresupuestos.GetItemsSeleccionados(APresupuesto);
APresupuesto.DataTable.Active := True;
dmMontajes.NuevoMontaje(Montajes, APresupuesto);
Montajes.Show;
end;
finally
APresupuesto := NIL;
ViewGrid.RefreshGrid;
ViewGrid.SyncFocusedRecordsFromDataSet;
end;
end;
procedure TfEditorMontajes.actModificarExecute(Sender: TObject);
begin
inherited;
Montajes.Show;
ViewGrid.RefreshGrid;
ViewGrid.SyncFocusedRecordsFromDataSet;
end;
procedure TfEditorMontajes.SetViewGrid(const Value: IViewGrid);
begin
inherited;
if Assigned(ViewGrid) and Assigned(Montajes) then
(ViewGrid as IViewMontajes).Montajes := Montajes;
end;
destructor TfEditorMontajes.Destroy;
begin
FMontajes := NIL;
inherited;
end;
function TfEditorMontajes.GetSelectionBarVisible: Boolean;
begin
Result := frViewBarraSeleccion.Visible
end;
procedure TfEditorMontajes.SetSelectionBarVisible(const Value: Boolean);
begin
frViewBarraSeleccion.Visible := True;
ViewGrid.OnDblClick := frViewBarraSeleccion.actSeleccionar.OnExecute;
end;
procedure TfEditorMontajes.frViewBarraSeleccionactSeleccionarExecute(
Sender: TObject);
begin
inherited;
ViewGrid.SyncFocusedRecordsFromGrid;
ModalResult := mrOK;
end;
constructor TfEditorMontajes.Create(AOwner: TComponent);
begin
inherited;
ViewGrid := CreateView(TfrViewMontajes) as IViewMontajes;
end;
procedure TfEditorMontajes.actEliminarExecute(Sender: TObject);
begin
if (MessageDlg('<27>Desea borrar este montaje?', mtConfirmation, [mbYes, mbNo], 0) = mrYes) then
begin
inherited;
ViewGrid.RefreshGrid;
end;
end;
initialization
RegisterEditor(IBizMontaje, ShowEditorMontajes, etItems);
RegisterEditor(IBizMontaje, ShowSelectEditorMontajes, etSelectItems);
end.