unit uBizContactosDatosBancarios;

interface

uses
  uDAInterfaces, uDADataTable,
  schContactosClient_Intf;

const
  BIZ_CLIENT_CONTACTOS_DATOS_BANCARIOS = 'Client.ContactosDatosBancarios';

type
  IBizContactosDatosBancarios = interface(IDatosBancarios)
    ['{87EC6EA3-7DAE-446F-A968-6DA3C716A113}']
    function EsNuevo : Boolean;
  end;

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

implementation

uses
  Dialogs,uDataTableUtils, DB;

{ TBizDatosBancarios }

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

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

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

initialization
  RegisterDataTableRules(BIZ_CLIENT_CONTACTOS_DATOS_BANCARIOS, TBizContactosDatosBancarios);


end.
