151 lines
4.2 KiB
ObjectPascal
151 lines
4.2 KiB
ObjectPascal
|
|
unit uEditorAlmacen;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
|
Dialogs, uEditorDBItem, ToolWin, ComCtrls, JvExControls, JvComponent,
|
|||
|
|
uViewAlmacen, uBizAlmacenes, 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, uViewMensaje,
|
|||
|
|
JvAppStorage, JvAppRegistryStorage, JvFormPlacement,
|
|||
|
|
|
|||
|
|
uViewAlmacenes;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
IEditorAlmacen = interface(IEditorDBItem)
|
|||
|
|
['{BADE8E8B-B0BC-4759-B2EE-4B4082827BE0}']
|
|||
|
|
function GetAlmacen: IBizAlmacen;
|
|||
|
|
procedure SetAlmacen(const Value: IBizAlmacen);
|
|||
|
|
property Almacen: IBizAlmacen read GetAlmacen write SetAlmacen;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
TfEditorAlmacen = class(TfEditorDBItem, IEditorAlmacen)
|
|||
|
|
|
|||
|
|
procedure FormShow(Sender: TObject);
|
|||
|
|
procedure dsDataTableDataChange(Sender: TObject; Field: TField);
|
|||
|
|
procedure actEliminarExecute(Sender: TObject);
|
|||
|
|
private
|
|||
|
|
FAlmacen: IBizAlmacen;
|
|||
|
|
FViewAlmacen : IViewAlmacen;
|
|||
|
|
protected
|
|||
|
|
function GetAlmacen: IBizAlmacen; virtual;
|
|||
|
|
procedure SetAlmacen(const Value: IBizAlmacen); virtual;
|
|||
|
|
|
|||
|
|
function GetViewAlmacen: IViewAlmacen;
|
|||
|
|
procedure SetViewAlmacen(const Value: IViewAlmacen);
|
|||
|
|
property ViewAlmacen: IViewAlmacen read GetViewAlmacen write
|
|||
|
|
SetViewAlmacen;
|
|||
|
|
public
|
|||
|
|
property Almacen: IBizAlmacen read GetAlmacen write SetAlmacen;
|
|||
|
|
constructor Create(AOwner: TComponent); override;
|
|||
|
|
destructor Destroy; override;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
{$R *.dfm}
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
uCustomEditor, uDataModuleAlmacenes, uDataModuleBase, uEditorUtils;
|
|||
|
|
|
|||
|
|
function ShowEditorAlmacen (ABizObject : TDADataTableRules): TModalResult;
|
|||
|
|
var
|
|||
|
|
AEditor: TfEditorAlmacen;
|
|||
|
|
begin
|
|||
|
|
AEditor := TfEditorAlmacen.Create(Application);
|
|||
|
|
try
|
|||
|
|
AEditor.Almacen := (ABizObject as IBizAlmacen);
|
|||
|
|
Result := AEditor.ShowModal;
|
|||
|
|
finally
|
|||
|
|
AEditor.Release;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
{
|
|||
|
|
******************************* TfEditorAlmacen *******************************
|
|||
|
|
}
|
|||
|
|
function TfEditorAlmacen.GetAlmacen: IBizAlmacen;
|
|||
|
|
begin
|
|||
|
|
Result := FAlmacen;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfEditorAlmacen.GetViewAlmacen: IViewAlmacen;
|
|||
|
|
begin
|
|||
|
|
Result := FViewAlmacen;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorAlmacen.SetAlmacen(const Value: IBizAlmacen);
|
|||
|
|
begin
|
|||
|
|
FAlmacen := Value;
|
|||
|
|
dsDataTable.DataTable := FAlmacen.DataTable;
|
|||
|
|
|
|||
|
|
if Assigned(FViewAlmacen) and Assigned(Almacen) then
|
|||
|
|
FViewAlmacen.Almacen := Almacen;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorAlmacen.SetViewAlmacen(const Value: IViewAlmacen);
|
|||
|
|
begin
|
|||
|
|
FViewAlmacen := Value;
|
|||
|
|
|
|||
|
|
if Assigned(FViewAlmacen) and Assigned(Almacen) then
|
|||
|
|
FViewAlmacen.Almacen := Almacen;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorAlmacen.FormShow(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
|
|||
|
|
if not Assigned(FViewAlmacen) then
|
|||
|
|
raise Exception.Create('No hay ninguna vista asignada');
|
|||
|
|
|
|||
|
|
if not Assigned(Almacen) then
|
|||
|
|
raise Exception.Create('No hay ning<6E>n almac<61>n asignado');
|
|||
|
|
|
|||
|
|
Almacen.DataTable.Active := True;
|
|||
|
|
FViewAlmacen.ShowEmbedded(pagGeneral);
|
|||
|
|
FViewAlmacen.SetFocus;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
destructor TfEditorAlmacen.Destroy;
|
|||
|
|
begin
|
|||
|
|
FViewAlmacen := NIL;
|
|||
|
|
FAlmacen := NIL;
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
constructor TfEditorAlmacen.Create(AOwner: TComponent);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
ViewAlmacen := CreateView(TfrViewAlmacen) as IViewAlmacen;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorAlmacen.dsDataTableDataChange(Sender: TObject;
|
|||
|
|
Field: TField);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
if Assigned(FAlmacen) and (not (FAlmacen.DataTable.Fetching) or
|
|||
|
|
not (FAlmacen.DataTable.Opening) or not (FAlmacen.DataTable.Closing)) then
|
|||
|
|
begin
|
|||
|
|
if Length(FAlmacen.NOMBRE) = 0 then
|
|||
|
|
JvNavPanelHeader.Caption := 'Nuevo almac<61>n'
|
|||
|
|
else
|
|||
|
|
JvNavPanelHeader.Caption := 'Almac<61>n - ' + FAlmacen.Nombre;
|
|||
|
|
Caption := JvNavPanelHeader.Caption;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorAlmacen.actEliminarExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if (Application.MessageBox('<27>Desea borrar este almac<61>n?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
initialization
|
|||
|
|
RegisterEditor(IBizAlmacen, ShowEditorAlmacen, etItem);
|
|||
|
|
|
|||
|
|
end.
|
|||
|
|
|