171 lines
5.0 KiB
ObjectPascal
171 lines
5.0 KiB
ObjectPascal
|
|
unit uEditorAlmacenes;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
|
Dialogs, uEditorBase, uEditorGrid, ToolWin, ComCtrls, JvExControls, JvComponent,
|
|||
|
|
JvNavigationPane, uViewAlmacenes, uBizAlmacenes, 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, JvComponentBase;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
IEditorAlmacenes = interface(IEditorGrid)
|
|||
|
|
['{D757531B-1392-46E9-9EDA-2B0A2AFE5DCC}']
|
|||
|
|
function GetAlmacenes: IBizAlmacen;
|
|||
|
|
procedure SetAlmacenes(const Value: IBizAlmacen);
|
|||
|
|
property Almacenes: IBizAlmacen read GetAlmacenes write SetAlmacenes;
|
|||
|
|
|
|||
|
|
function GetSelectionBarVisible: Boolean;
|
|||
|
|
procedure SetSelectionBarVisible(const Value: Boolean);
|
|||
|
|
property SelectionBarVisible : Boolean read GetSelectionBarVisible write
|
|||
|
|
SetSelectionBarVisible;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
TfEditorAlmacenes = class(TfEditorGrid, IEditorAlmacenes)
|
|||
|
|
frViewBarraSeleccion: TfrViewBarraSeleccion;
|
|||
|
|
procedure FormShow(Sender: TObject);
|
|||
|
|
procedure actNuevoExecute(Sender: TObject);
|
|||
|
|
procedure actModificarExecute(Sender: TObject);
|
|||
|
|
procedure actEliminarExecute(Sender: TObject);
|
|||
|
|
procedure frViewBarraSeleccionactSeleccionarExecute(Sender: TObject);
|
|||
|
|
private
|
|||
|
|
FAlmacenes: IBizAlmacen;
|
|||
|
|
protected
|
|||
|
|
function GetAlmacenes: IBizAlmacen; virtual;
|
|||
|
|
procedure SetAlmacenes(const Value: IBizAlmacen); 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 Almacenes: IBizAlmacen read GetAlmacenes write SetAlmacenes;
|
|||
|
|
constructor Create(AOwner: TComponent); override;
|
|||
|
|
destructor Destroy; override;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
uCustomEditor, uDataModuleAlmacenes,
|
|||
|
|
uEditorAlmacen, uEditorDBBase, uEditorUtils,
|
|||
|
|
cxGrid, cxGridCustomTableView, uDBSelectionList, uListaAlmacenes;
|
|||
|
|
|
|||
|
|
{$R *.dfm}
|
|||
|
|
|
|||
|
|
function ShowEditorAlmacenes (ABizObject : TDADataTableRules): TModalResult;
|
|||
|
|
var
|
|||
|
|
AEditor: TfListaAlmacenes;
|
|||
|
|
begin
|
|||
|
|
AEditor := TfListaAlmacenes.Create(Application);
|
|||
|
|
try
|
|||
|
|
AEditor.Almacenes := (ABizObject as IBizAlmacen);
|
|||
|
|
Result := AEditor.ShowModal;
|
|||
|
|
finally
|
|||
|
|
AEditor.Release;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
{
|
|||
|
|
****************************** TfEditorAlmacenes *******************************
|
|||
|
|
}
|
|||
|
|
procedure TfEditorAlmacenes.FormShow(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
|
|||
|
|
if not Assigned(ViewGrid) then
|
|||
|
|
raise Exception.Create('No hay ninguna vista asignada');
|
|||
|
|
|
|||
|
|
if not Assigned(Almacenes) then
|
|||
|
|
raise Exception.Create('No hay ning<6E>n Almacen asignado');
|
|||
|
|
|
|||
|
|
Almacenes.DataTable.Active := True;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfEditorAlmacenes.GetAlmacenes: IBizAlmacen;
|
|||
|
|
begin
|
|||
|
|
Result := FAlmacenes;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorAlmacenes.SetAlmacenes(const Value: IBizAlmacen);
|
|||
|
|
begin
|
|||
|
|
FAlmacenes := Value;
|
|||
|
|
dsDataTable.DataTable := FAlmacenes.DataTable;
|
|||
|
|
if Assigned(ViewGrid) then
|
|||
|
|
(ViewGrid as IViewAlmacenes).Almacenes := Almacenes;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorAlmacenes.actNuevoExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
Almacenes.Insert;
|
|||
|
|
Almacenes.Show;
|
|||
|
|
ViewGrid.RefreshGrid;
|
|||
|
|
ViewGrid.SyncFocusedRecordsFromDataSet;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorAlmacenes.actModificarExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
Almacenes.Show;
|
|||
|
|
ViewGrid.RefreshGrid;
|
|||
|
|
ViewGrid.SyncFocusedRecordsFromDataSet;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorAlmacenes.SetViewGrid(const Value: IViewGrid);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
if Assigned(ViewGrid) and Assigned(Almacenes) then
|
|||
|
|
(ViewGrid as IViewAlmacenes).Almacenes := Almacenes;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
destructor TfEditorAlmacenes.Destroy;
|
|||
|
|
begin
|
|||
|
|
FAlmacenes := NIL;
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfEditorAlmacenes.GetSelectionBarVisible: Boolean;
|
|||
|
|
begin
|
|||
|
|
Result := frViewBarraSeleccion.Visible
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorAlmacenes.SetSelectionBarVisible(const Value: Boolean);
|
|||
|
|
begin
|
|||
|
|
frViewBarraSeleccion.Visible := True;
|
|||
|
|
ViewGrid.OnDblClick := frViewBarraSeleccion.actSeleccionar.OnExecute;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorAlmacenes.frViewBarraSeleccionactSeleccionarExecute(
|
|||
|
|
Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
ViewGrid.SyncFocusedRecordsFromGrid;
|
|||
|
|
ModalResult := mrOK;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
constructor TfEditorAlmacenes.Create(AOwner: TComponent);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
ViewGrid := CreateView(TfrViewAlmacenes) as IViewAlmacenes;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorAlmacenes.actEliminarExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if (Application.MessageBox('<27>Desea borrar este almac<61>n?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
ViewGrid.RefreshGrid;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
initialization
|
|||
|
|
RegisterEditor(IBizAlmacen, ShowEditorAlmacenes, etItems);
|
|||
|
|
|
|||
|
|
end.
|
|||
|
|
|