unit uBizEmpresasTiendas;

interface

uses
  uDAInterfaces, uDADataTable,
  schEmpresasClient_Intf;

const
  BIZ_CLIENT_EMPRESAS_TIENDAS = 'Client.EmpresaTienda';
  CTE_ID_TODAS = 0;
  CTE_TODAS = 'Todas';

type
  IBizEmpresaTienda = interface(IEmpresasTiendas)
  ['{564205A6-82A6-45E1-9523-6751BB5A8708}']
    function EsNuevo : Boolean;
  end;

  TBizEmpresaTienda = class(TEmpresasTiendasDataTableRules, IBizEmpresaTienda)
  protected
    procedure BeforeInsert(Sender: TDADataTable); override;
  public
    function EsNuevo : Boolean;
  end;

implementation

uses
  Dialogs,uDataTableUtils, DB;

{ TBizEmpresasTiendas }

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

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

initialization
  RegisterDataTableRules(BIZ_CLIENT_EMPRESAS_TIENDAS, TBizEmpresaTienda);


end.
