This repository has been archived on 2024-12-02. You can view files and clone it, but cannot push or open issues or pull requests.
AlonsoYSal_FactuGES/Modulos/Presupuestos/Servidor/srvPresupuestos_Impl.pas

129 lines
4.5 KiB
ObjectPascal
Raw Blame History

unit srvPresupuestos_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, uDAScriptingProvider,
uDABusinessProcessor, uDADataTable, uDAInterfaces, uDAEngine,
uDAIBXDriver, frxClass, frxDBSet, DB, uDACDSDataTable, uDABINAdapter,
uDADriverManager;
type
{ TsrvPresupuestos }
TsrvPresupuestos = class(TDARemoteService, IsrvPresupuestos)
bpPresupuestos: TDABusinessProcessor;
DADataCabecera: TDADataSource;
DADataDetalles: TDADataSource;
frxDBCabecera: TfrxDBDataset;
frxDBDetalles: TfrxDBDataset;
tbl_Presupuesto: TDACDSDataTable;
tbl_DetallesPresupuesto: TDACDSDataTable;
DABINAdapter: TDABINAdapter;
schPresupuestos: TDASchema;
frxReport1: TfrxReport;
procedure DARemoteServiceActivate(const aClientID: TGUID;
aSession: TROSession; const aMessage: IROMessage);
private
protected
function GenerateReport(const Codigo: Integer; const TamLetra: Integer): Binary;
function GetNextAutoinc: Integer;
function PuedoEliminarPresupuesto(const CodigoPresupuesto: Integer): Boolean;
end;
implementation
{$R *.dfm}
uses
Dialogs,
{Generated:} FactuGES_Invk, uDataModuleServer, uRORemoteDataModule,
fServerForm, Variants, IB, schPresupuestosClient_Intf;
procedure Create_srvPresupuestos(out anInstance : IUnknown);
begin
anInstance := TsrvPresupuestos.Create(NIL);
end;
{ srvPresupuestos }
procedure TsrvPresupuestos.DARemoteServiceActivate(const aClientID: TGUID;
aSession: TROSession; const aMessage: IROMessage);
begin
((Connection as IDAConnectionObjectAccess).ConnectionObject as
TIBXConnection).Database.TraceFlags := [tfQPrepare, tfQExecute, tfQFetch, tfError, tfStmt, tfConnect, tfTransact, tfBlob, tfService, tfMisc];
end;
function TsrvPresupuestos.GenerateReport(const Codigo: Integer; const TamLetra: Integer): Binary;
var
dsMaster: IDADataset;
dsDetail: IDADataset;
AStream: TMemoryStream;
begin
AStream := TMemoryStream.Create;
Result := Binary.Create;
try
dsMaster := schPresupuestos.NewDataset(Connection, 'InformeCabeceraPresupuesto', ['CODIGO'], [Codigo]);
dsDetail := schPresupuestos.NewDataset(Connection, 'InformeDetallesPresupuesto', ['CODIGOPRESUPUESTO'], [Codigo], False);
dsDetail.Active := True;
AStream.Clear;
ServiceAdapter.WriteDataset(AStream, dsMaster, [woRows, woSchema], -1);
ServiceAdapter.ReadDataset(AStream, tbl_Presupuesto, TRUE, '', TRUE, TRUE);
AStream.Clear;
ServiceAdapter.WriteDataset(AStream, dsDetail, [woRows, woSchema], -1);
ServiceAdapter.ReadDataset(AStream, tbl_DetallesPresupuesto, TRUE, '', TRUE, TRUE);
if (dsMaster.Dataset.FieldByName(fld_DetallesPresupuestosTIPO).AsString = 'Inciencia') then
frxReport1.LoadFromFile(DarRutaInformes + 'InfIncidencia.fr3', True)
else
frxReport1.LoadFromFile(DarRutaInformes + 'InfPresupuesto.fr3', True);
//Tama<6D>o de letra
if TamLetra <> 0 then
frxReport1.Styles.Find('Concepto normal').Font.Size := TamLetra;
frxReport1.PrepareReport;
frxReport1.PreviewPages.SaveToStream(Result);
finally
AStream.Free;
end;
end;
function TsrvPresupuestos.GetNextAutoinc: Integer;
begin
Result := uDataModuleServer.GetNextAutoinc(Connection, 'GEN_PRESUPUESTOS');
end;
function TsrvPresupuestos.PuedoEliminarPresupuesto(
const CodigoPresupuesto: Integer): Boolean;
var
dsPresupuesto: IDASQLCommand;
begin
Result := True;
Connection.BeginTransaction;
try
dsPresupuesto := schPresupuestos.NewCommand(Connection, 'Delete_Presupuestos', ['OLD_CODIGO'], [CodigoPresupuesto]);
except
on E: Exception do
Result := False;
end;
Connection.RollbackTransaction;
end;
initialization
TROClassFactory.Create('srvPresupuestos', Create_srvPresupuestos, TsrvPresupuestos_Invoker);
finalization
end.