unit uBizDatosBancarios;

interface

uses
  uDAInterfaces, uDADataTable,
  schContactosClient_Intf;

const
  BIZ_CLIENT_DATOS_BANCARIOS = 'Client.DatosBancarios';

type
  IBizDatosBancarios = interface(IDatosBancarios)
    ['{B4752E6D-CC32-4425-9681-A124D9D26F09}']
    function EsNuevo : Boolean;
  end;

  TBizDatosBancarios = class(TDatosBancariosDataTableRules, IBizDatosBancarios)
  protected
    procedure BeforeInsert(Sender: TDADataTable); override;  
  public
    function EsNuevo : Boolean;
    procedure OnNewRecord(Sender: TDADataTable); override;
  end;

implementation

uses
  DB, uDataTableUtils;

{ TBizDatosBancarios }

procedure TBizDatosBancarios.BeforeInsert(Sender: TDADataTable);
var
  AMasterTable : TDADataTable;
begin
  inherited;
  AMasterTable := DataTable.GetMasterDataTable;
  if Assigned(AMasterTable) and (AMasterTable.State = dsInsert) then
     AMasterTable.Post;
end;

function TBizDatosBancarios.EsNuevo: Boolean;
begin
  Result := (ID < 0);
end;

procedure TBizDatosBancarios.OnNewRecord(Sender: TDADataTable);
begin
  inherited;
  ID := GetRecNo; // -1, -2, -3...
end;

initialization
  RegisterDataTableRules(BIZ_CLIENT_DATOS_BANCARIOS, TBizDatosBancarios);


end.
