{
===============================================================================
  Copyright (©) 2007. Rodax Software.
===============================================================================
  Los contenidos de este fichero son propiedad de Rodax Software titular del
  copyright. Este fichero sólo podrá ser copiado, distribuido y utilizado,
  en su totalidad o en parte, con el permiso escrito de Rodax Software, o de
  acuerdo con los términos y condiciones establecidas en el acuerdo/contrato
  bajo el que se suministra.
  -----------------------------------------------------------------------------
  Web:  www.rodax-software.com
===============================================================================
  Fecha primera versión: 
  Versión actual: 1.0.0
  Fecha versión actual: 
===============================================================================
  Modificaciones:

    Fecha         Comentarios
    ---------------------------------------------------------------------------
===============================================================================
}

unit uBizOscManufacturers;

interface

uses
  uDAInterfaces, uDADataTable, uDBSelectionListUtils, schTiendaWebClient_Intf;

const
  BIZ_CLIENT_OSC_MANUFACTURER = 'Client.OscManufacturer';

type
  IBizOscManufacturer = interface(Iosc_Manufacturers)
  	['{1426504F-8DBA-46C2-BC7B-A841503CA53E}']    
    function EsNuevo : Boolean;
  end;

  TBizOscManufacturer = class(Tosc_ManufacturersDataTableRules, IBizOscManufacturer, ISeleccionable)
  protected
  	FSeleccionableInterface : ISeleccionable;

    procedure OnNewRecord(Sender: TDADataTable); override;
  public
    procedure IniciarValoresNuevo;
    function EsNuevo : Boolean;
    constructor Create(aDataTable: TDADataTable); override;
    destructor Destroy; override;

    property SeleccionableInterface : ISeleccionable
    					read FSeleccionableInterface
    					write FSeleccionableInterface
    					implements ISeleccionable;
  end;

implementation

{ TBizOscManufacturer }

uses
  SysUtils, uDataTableUtils;

constructor TBizOscManufacturer.Create(aDataTable: TDADataTable);
begin
  inherited;
  
	FSeleccionableInterface := TSeleccionable.Create(aDataTable);  
end;

destructor TBizOscManufacturer.Destroy;
begin
  
  FSeleccionableInterface := NIL;
  inherited;
end;

function TBizOscManufacturer.EsNuevo: Boolean;
begin
  Result := (manufacturers_id < 0)
end;

procedure TBizOscManufacturer.IniciarValoresNuevo;
begin
  date_added := Now;
end;

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

initialization
  RegisterDataTableRules(BIZ_CLIENT_OSC_MANUFACTURER, TBizOscManufacturer);

finalization

end.

