unit uDatosBancariosContactoController;

interface

uses
  Windows, Forms, Classes, Controls, Contnrs, SysUtils, uDADataTable,
  uBizContactos, uBizContactosDatosBancarios, uIDataModuleContactos,
  uControllerBase;

type
  IDatosBancariosContactoController = interface(IControllerBase)
  ['{2E1C410A-B11D-4E1C-A7DF-9321BAEA5952}']
    procedure Ver(ADatoBancario : IBizContactosDatosBancarios);
    function Localizar(ADatosBancarios: IBizContactosDatosBancarios; const ID : Integer): Boolean;
  end;

  TDatosBancariosContactoController = class(TControllerBase, IDatosBancariosContactoController)
  private
    FDataModule : IDataModuleContactos;
  public
    procedure Ver(ADatoBancario : IBizContactosDatosBancarios);
    function Localizar(ADatosBancarios: IBizContactosDatosBancarios; const ID : Integer): Boolean;
    constructor Create; override;
    destructor Destroy; override;
  end;

implementation

{ TDatosBancariosContactoController }

uses
  uDataModuleContactos, schContactosClient_Intf, 
  uEditorRegistryUtils, cxControls, uIEditorDatoBancarioContacto;


constructor TDatosBancariosContactoController.Create;
begin
  inherited;
  FDataModule := TDataModuleContactos.Create(Nil);
end;

destructor TDatosBancariosContactoController.Destroy;
begin
  FDataModule := Nil;
  inherited;
end;

function TDatosBancariosContactoController.Localizar(
  ADatosBancarios: IBizContactosDatosBancarios; const ID : Integer): Boolean;
begin
  Result := True;
  ShowHourglassCursor;
  try
    with ADatosBancarios.DataTable do
    begin
      DisableControls;
      First;
      if not Locate(fld_DatosBancariosID, ID, []) then
         Result := False;
      EnableControls;
    end;
  finally
    HideHourglassCursor;
  end;
end;

procedure TDatosBancariosContactoController.Ver(
  ADatoBancario : IBizContactosDatosBancarios);
var
  AEditor : IEditorDatoBancarioContacto;
begin
  AEditor := NIL;

  CreateEditor('EditorDatoBancarioContacto', IEditorDatoBancarioContacto, AEditor);
  if Assigned(AEditor) then
    try
      AEditor.DatoBancario := ADatoBancario;
      AEditor.Controller := Self;
      AEditor.ShowModal;
    finally
      AEditor.Release;
      AEditor := NIL;
    end;
end;

end.
