unit srvCitas_Impl;

{----------------------------------------------------------------------------}
{ This unit was automatically generated by the RemObjects SDK after reading  }
{ the RODL file associated with this project .                               }
{                                                                            }
{ This is where you are supposed to code the implementation of your objects. }
{----------------------------------------------------------------------------}

interface

uses
  {vcl:} Classes, SysUtils, 
  {RemObjects:} uROClientIntf, uROTypes, uROServer, uROServerIntf, uROSessions,
  {Ancestor Implementation:} DARemoteService_Impl,
  {Used RODLs:} DataAbstract_Intf,
  {Generated:} FactuGES_Intf, uDAClasses, uDAInterfaces, uDADataTable,
  uDABINAdapter;

type
  { TsrvCitas }
  TsrvCitas = class(TDARemoteService, IsrvCitas)
    schCitas: TDASchema;
    DABINAdapter: TDABINAdapter;
  private
  protected
    function getCodigo(const Generador: String): Integer;
  end;

implementation

{$R *.dfm}
uses
  {Generated:} FactuGES_Invk, uDataModuleServer;

procedure Create_srvCitas(out anInstance : IUnknown);
begin
  anInstance := TsrvCitas.Create(NIL);
end;

{ srvCitas }
{ TsrvCitas }

function TsrvCitas.getCodigo(const Generador: String): Integer;
var
  ds: IDADataset;
begin
  ds := Connection.NewDataset(Format('SELECT Gen_id("%s",1) FROM RDB$DataBase', [Generador]));
  ds.Open;
  Result := ds.Fields[0].Value;
  ds.Close;
end;

initialization
  TROClassFactory.Create('srvCitas', Create_srvCitas, TsrvCitas_Invoker);

finalization

end.
