git-svn-id: https://192.168.0.254/svn/Proyectos.AlonsoYSal_FactuGES/trunk@5 9a1d36f3-7752-2d40-8ccb-50eb49674c68
150 lines
4.0 KiB
ObjectPascal
150 lines
4.0 KiB
ObjectPascal
unit uEditorCuenta;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, uEditorDBItem, ToolWin, ComCtrls, JvExControls, JvComponent,
|
||
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, JvAppStorage, JvAppRegistryStorage, JvFormPlacement,
|
||
|
||
uViewCuenta, uBizCuentas;
|
||
|
||
type
|
||
IEditorCuenta = interface(IEditorDBItem)
|
||
['{BADE8E8B-B0BC-4759-B2EE-4B4082827BE0}']
|
||
function GetCuenta: IBizCuenta;
|
||
procedure SetCuenta(const Value: IBizCuenta);
|
||
property Cuenta: IBizCuenta read GetCuenta write SetCuenta;
|
||
end;
|
||
|
||
TfEditorCuenta = class(TfEditorDBItem, IEditorCuenta)
|
||
|
||
procedure FormShow(Sender: TObject);
|
||
procedure dsDataTableDataChange(Sender: TObject; Field: TField);
|
||
procedure actEliminarExecute(Sender: TObject);
|
||
private
|
||
FCuenta: IBizCuenta;
|
||
FViewCuenta : IViewCuenta;
|
||
protected
|
||
function GetCuenta: IBizCuenta; virtual;
|
||
procedure SetCuenta(const Value: IBizCuenta); virtual;
|
||
|
||
function GetViewCuenta: IViewCuenta;
|
||
procedure SetViewCuenta(const Value: IViewCuenta);
|
||
property ViewCuenta: IViewCuenta read GetViewCuenta write
|
||
SetViewCuenta;
|
||
public
|
||
property Cuenta: IBizCuenta read GetCuenta write SetCuenta;
|
||
constructor Create(AOwner: TComponent); override;
|
||
destructor Destroy; override;
|
||
end;
|
||
|
||
implementation
|
||
|
||
{$R *.dfm}
|
||
|
||
uses
|
||
uEditorUtils;
|
||
|
||
function ShowEditorCuenta (ABizObject : TDADataTableRules): TModalResult;
|
||
var
|
||
AEditor: TfEditorCuenta;
|
||
begin
|
||
AEditor := TfEditorCuenta.Create(Application);
|
||
try
|
||
AEditor.Cuenta := (ABizObject as IBizCuenta);
|
||
Result := AEditor.ShowModal;
|
||
finally
|
||
AEditor.Release;
|
||
end;
|
||
end;
|
||
|
||
{
|
||
******************************* TfEditorCuenta *******************************
|
||
}
|
||
function TfEditorCuenta.GetCuenta: IBizCuenta;
|
||
begin
|
||
Result := FCuenta;
|
||
end;
|
||
|
||
function TfEditorCuenta.GetViewCuenta: IViewCuenta;
|
||
begin
|
||
Result := FViewCuenta;
|
||
end;
|
||
|
||
procedure TfEditorCuenta.SetCuenta(const Value: IBizCuenta);
|
||
begin
|
||
FCuenta := Value;
|
||
dsDataTable.DataTable := FCuenta.DataTable;
|
||
|
||
if Assigned(FViewCuenta) and Assigned(Cuenta) then
|
||
FViewCuenta.Cuenta := Cuenta;
|
||
end;
|
||
|
||
procedure TfEditorCuenta.SetViewCuenta(const Value: IViewCuenta);
|
||
begin
|
||
FViewCuenta := Value;
|
||
|
||
if Assigned(FViewCuenta) and Assigned(Cuenta) then
|
||
FViewCuenta.Cuenta := Cuenta;
|
||
end;
|
||
|
||
procedure TfEditorCuenta.FormShow(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
|
||
if not Assigned(FViewCuenta) then
|
||
raise Exception.Create('No hay ninguna vista asignada');
|
||
|
||
if not Assigned(Cuenta) then
|
||
raise Exception.Create('No hay ninguna cuenta asignado');
|
||
|
||
Cuenta.DataTable.Active := True;
|
||
FViewCuenta.ShowEmbedded(pagGeneral);
|
||
FViewCuenta.SetFocus;
|
||
end;
|
||
|
||
destructor TfEditorCuenta.Destroy;
|
||
begin
|
||
FViewCuenta := NIL;
|
||
FCuenta := NIL;
|
||
inherited;
|
||
end;
|
||
|
||
constructor TfEditorCuenta.Create(AOwner: TComponent);
|
||
begin
|
||
inherited;
|
||
ViewCuenta := CreateView(TfrViewCuenta) as IViewCuenta;
|
||
end;
|
||
|
||
procedure TfEditorCuenta.dsDataTableDataChange(Sender: TObject;
|
||
Field: TField);
|
||
begin
|
||
inherited;
|
||
if Assigned(FCuenta) and (not (FCuenta.DataTable.Fetching) or
|
||
not (FCuenta.DataTable.Opening) or not (FCuenta.DataTable.Closing)) then
|
||
begin
|
||
if Length(FCuenta.NOMBRE) = 0 then
|
||
JvNavPanelHeader.Caption := 'Nueva cuenta'
|
||
else
|
||
JvNavPanelHeader.Caption := 'Cuenta - ' + FCuenta.Nombre;
|
||
Caption := JvNavPanelHeader.Caption;
|
||
end;
|
||
end;
|
||
|
||
procedure TfEditorCuenta.actEliminarExecute(Sender: TObject);
|
||
begin
|
||
if (Application.MessageBox('<27>Est<73> seguro que desea borrar esta cuenta?, se borrar<61>n todos sus asientos.', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
||
inherited;
|
||
end;
|
||
|
||
initialization
|
||
RegisterEditor(IBizCuenta, ShowEditorCuenta, etItem);
|
||
|
||
end.
|
||
|