unit schArticulosClient_Intf;

interface

uses
  Classes, DB, schBase_Intf, SysUtils, uROClasses, uDAInterfaces, uDADataTable, FmtBCD, uROXMLIntf;

const
  { Data table rules ids
       Feel free to change them to something more human readable
       but make sure they are unique in the context of your application }
  RID_Articulos = '{FEECF05F-3ABB-4A2F-92C5-AA54F1925D9A}';

  { Data table names }
  nme_Articulos = 'Articulos';

  { Articulos fields }
  fld_ArticulosID = 'ID';
  fld_ArticulosREFERENCIA = 'REFERENCIA';
  fld_ArticulosDESCRIPCION = 'DESCRIPCION';
  fld_ArticulosFAMILIA = 'FAMILIA';

  { Articulos field indexes }
  idx_ArticulosID = 0;
  idx_ArticulosREFERENCIA = 1;
  idx_ArticulosDESCRIPCION = 2;
  idx_ArticulosFAMILIA = 3;

type
  { IArticulos }
  IArticulos = interface(IDAStronglyTypedDataTable)
  ['{34D9BA45-CF94-4F26-A4C3-585D3A06B86C}']
    { Property getters and setters }
    function GetIDValue: Integer;
    procedure SetIDValue(const aValue: Integer);
    function GetIDIsNull: Boolean;
    procedure SetIDIsNull(const aValue: Boolean);
    function GetREFERENCIAValue: String;
    procedure SetREFERENCIAValue(const aValue: String);
    function GetREFERENCIAIsNull: Boolean;
    procedure SetREFERENCIAIsNull(const aValue: Boolean);
    function GetDESCRIPCIONValue: String;
    procedure SetDESCRIPCIONValue(const aValue: String);
    function GetDESCRIPCIONIsNull: Boolean;
    procedure SetDESCRIPCIONIsNull(const aValue: Boolean);
    function GetFAMILIAValue: String;
    procedure SetFAMILIAValue(const aValue: String);
    function GetFAMILIAIsNull: Boolean;
    procedure SetFAMILIAIsNull(const aValue: Boolean);


    { Properties }
    property ID: Integer read GetIDValue write SetIDValue;
    property IDIsNull: Boolean read GetIDIsNull write SetIDIsNull;
    property REFERENCIA: String read GetREFERENCIAValue write SetREFERENCIAValue;
    property REFERENCIAIsNull: Boolean read GetREFERENCIAIsNull write SetREFERENCIAIsNull;
    property DESCRIPCION: String read GetDESCRIPCIONValue write SetDESCRIPCIONValue;
    property DESCRIPCIONIsNull: Boolean read GetDESCRIPCIONIsNull write SetDESCRIPCIONIsNull;
    property FAMILIA: String read GetFAMILIAValue write SetFAMILIAValue;
    property FAMILIAIsNull: Boolean read GetFAMILIAIsNull write SetFAMILIAIsNull;
  end;

  { TArticulosDataTableRules }
  TArticulosDataTableRules = class(TIntfObjectDADataTableRules, IArticulos)
  private
  protected
    { Property getters and setters }
    function GetIDValue: Integer; virtual;
    procedure SetIDValue(const aValue: Integer); virtual;
    function GetIDIsNull: Boolean; virtual;
    procedure SetIDIsNull(const aValue: Boolean); virtual;
    function GetREFERENCIAValue: String; virtual;
    procedure SetREFERENCIAValue(const aValue: String); virtual;
    function GetREFERENCIAIsNull: Boolean; virtual;
    procedure SetREFERENCIAIsNull(const aValue: Boolean); virtual;
    function GetDESCRIPCIONValue: String; virtual;
    procedure SetDESCRIPCIONValue(const aValue: String); virtual;
    function GetDESCRIPCIONIsNull: Boolean; virtual;
    procedure SetDESCRIPCIONIsNull(const aValue: Boolean); virtual;
    function GetFAMILIAValue: String; virtual;
    procedure SetFAMILIAValue(const aValue: String); virtual;
    function GetFAMILIAIsNull: Boolean; virtual;
    procedure SetFAMILIAIsNull(const aValue: Boolean); virtual;

    { Properties }
    property ID: Integer read GetIDValue write SetIDValue;
    property IDIsNull: Boolean read GetIDIsNull write SetIDIsNull;
    property REFERENCIA: String read GetREFERENCIAValue write SetREFERENCIAValue;
    property REFERENCIAIsNull: Boolean read GetREFERENCIAIsNull write SetREFERENCIAIsNull;
    property DESCRIPCION: String read GetDESCRIPCIONValue write SetDESCRIPCIONValue;
    property DESCRIPCIONIsNull: Boolean read GetDESCRIPCIONIsNull write SetDESCRIPCIONIsNull;
    property FAMILIA: String read GetFAMILIAValue write SetFAMILIAValue;
    property FAMILIAIsNull: Boolean read GetFAMILIAIsNull write SetFAMILIAIsNull;

  public
    constructor Create(aDataTable: TDADataTable); override;
    destructor Destroy; override;

  end;

implementation

uses Variants, uROBinaryHelpers;

{ TArticulosDataTableRules }
constructor TArticulosDataTableRules.Create(aDataTable: TDADataTable);
begin
  inherited;
end;

destructor TArticulosDataTableRules.Destroy;
begin
  inherited;
end;

function TArticulosDataTableRules.GetIDValue: Integer;
begin
  result := DataTable.Fields[idx_ArticulosID].AsInteger;
end;

procedure TArticulosDataTableRules.SetIDValue(const aValue: Integer);
begin
  DataTable.Fields[idx_ArticulosID].AsInteger := aValue;
end;

function TArticulosDataTableRules.GetIDIsNull: boolean;
begin
  result := DataTable.Fields[idx_ArticulosID].IsNull;
end;

procedure TArticulosDataTableRules.SetIDIsNull(const aValue: Boolean);
begin
  if aValue then
    DataTable.Fields[idx_ArticulosID].AsVariant := Null;
end;

function TArticulosDataTableRules.GetREFERENCIAValue: String;
begin
  result := DataTable.Fields[idx_ArticulosREFERENCIA].AsString;
end;

procedure TArticulosDataTableRules.SetREFERENCIAValue(const aValue: String);
begin
  DataTable.Fields[idx_ArticulosREFERENCIA].AsString := aValue;
end;

function TArticulosDataTableRules.GetREFERENCIAIsNull: boolean;
begin
  result := DataTable.Fields[idx_ArticulosREFERENCIA].IsNull;
end;

procedure TArticulosDataTableRules.SetREFERENCIAIsNull(const aValue: Boolean);
begin
  if aValue then
    DataTable.Fields[idx_ArticulosREFERENCIA].AsVariant := Null;
end;

function TArticulosDataTableRules.GetDESCRIPCIONValue: String;
begin
  result := DataTable.Fields[idx_ArticulosDESCRIPCION].AsString;
end;

procedure TArticulosDataTableRules.SetDESCRIPCIONValue(const aValue: String);
begin
  DataTable.Fields[idx_ArticulosDESCRIPCION].AsString := aValue;
end;

function TArticulosDataTableRules.GetDESCRIPCIONIsNull: boolean;
begin
  result := DataTable.Fields[idx_ArticulosDESCRIPCION].IsNull;
end;

procedure TArticulosDataTableRules.SetDESCRIPCIONIsNull(const aValue: Boolean);
begin
  if aValue then
    DataTable.Fields[idx_ArticulosDESCRIPCION].AsVariant := Null;
end;

function TArticulosDataTableRules.GetFAMILIAValue: String;
begin
  result := DataTable.Fields[idx_ArticulosFAMILIA].AsString;
end;

procedure TArticulosDataTableRules.SetFAMILIAValue(const aValue: String);
begin
  DataTable.Fields[idx_ArticulosFAMILIA].AsString := aValue;
end;

function TArticulosDataTableRules.GetFAMILIAIsNull: boolean;
begin
  result := DataTable.Fields[idx_ArticulosFAMILIA].IsNull;
end;

procedure TArticulosDataTableRules.SetFAMILIAIsNull(const aValue: Boolean);
begin
  if aValue then
    DataTable.Fields[idx_ArticulosFAMILIA].AsVariant := Null;
end;


initialization
  RegisterDataTableRules(RID_Articulos, TArticulosDataTableRules);

end.
