unit uDataModuleAsientos; interface uses {vcl:} SysUtils, Classes, DB, DBClient, {RemObjects:} uDAClientDataModule, uDADataTable, uDABINAdapter, uROServiceComponent, uRORemoteService, uROClient, uROBinMessage, uROWinInetHttpChannel, uDAScriptingProvider, uDACDSDataTable, uBizAsientos; type TdmAsientos = class(TDAClientDataModule) DABINAdapter: TDABINAdapter; RORemoteService: TRORemoteService; tbl_Asientos: TDACDSDataTable; ds_Asientos: TDADataSource; procedure DAClientDataModuleCreate(Sender: TObject); private public function GetItems: IBizAsiento; function GetItem(Codigo:Integer): IBizAsiento; procedure Preview; function AsignarPunteado(const CodigoCuenta: Integer; const FechaIni: DateTime; const FechaFin: TDateTime; const ValorPunteado: Integer): boolean; function darPenultimoCierre(const CodigoCuenta: Integer): TDateTime; function darSumaAcumulada(const CodigoCuenta: Integer; const FechaIni: DateTime; const FechaFin: DateTime): Currency; procedure anadirAsiento(pDatos: TDatosAsiento); end; var dmAsientos: TdmAsientos; implementation {$R *.DFM} uses Controls, Forms, uDAInterfaces, DataAbstract_Intf, FactuGES_Intf, uDataTableUtils, uROTypes, uEditorPreview, Dialogs, schAsientosClient_Intf, uDataModuleBase, uDBSelectionList, uDataModuleCuentas; procedure TdmAsientos.anadirAsiento(pDatos: TDatosAsiento); var AAsiento: IBizAsiento; begin try AAsiento := GetItem(-1); AAsiento.Cuenta.OnCuentaChanged := Nil; AAsiento.Cuenta.LocalizarCuenta(pDatos.CodigoCuenta); with AAsiento do begin DataTable.Active := True; Insert; CODIGOCUENTA := pDatos.CodigoCuenta; FECHAASIENTO := pDatos.FechaAsiento; CODIGOPAGO := pDatos.CodigoPago; DESCRIPCION := pDatos.Descripcion; IMPORTE := pDatos.Importe; Post; DataTable.ApplyUpdates; AAsiento := NIL; end; except on E:Exception do begin AAsiento.DataTable.CancelUpdates; AAsiento := NIL; raise; end; end; end; function TdmAsientos.AsignarPunteado(const CodigoCuenta: Integer; const FechaIni: TDateTime; const FechaFin: TDateTime; const ValorPunteado: Integer): boolean; begin Result := (RORemoteService as IsrvAsientos).AsignarPunteo(CodigoCuenta, FechaIni, FechaFin, ValorPunteado); end; procedure TdmAsientos.DAClientDataModuleCreate(Sender: TObject); begin RORemoteService.Channel := dmBase.Channel; RORemoteService.Message := dmBase.Message; end; function TdmAsientos.darPenultimoCierre(const CodigoCuenta: Integer): TDateTime; begin Result := (RORemoteService as IsrvAsientos).darPenultimoCierre(CodigoCuenta); end; function TdmAsientos.darSumaAcumulada(const CodigoCuenta: Integer; const FechaIni, FechaFin: DateTime): Currency; begin Result := (RORemoteService as IsrvAsientos).darSumaAcumulada(CodigoCuenta, FechaIni, FechaFin); end; function TdmAsientos.GetItem(Codigo: Integer): IBizAsiento; var AAsiento : IBizAsiento; begin AAsiento:= GetItems; with AAsiento.DataTable.Where do AddText(fld_AsientosCODIGO + ' = ' + IntToStr(Codigo)); Result := AAsiento; end; function TdmAsientos.GetItems: IBizAsiento; var dtAsientos: TDACDSDataTable; ACursor: TCursor; begin ACursor := Screen.Cursor; Screen.Cursor := crHourGlass; try dtAsientos := TDACDSDataTable.Create(NIL); CloneDataTable(tbl_Asientos, dtAsientos); dtAsientos.BusinessRulesID := 'BizAsiento'; Result := (dtAsientos as IBizAsiento); finally Screen.Cursor := ACursor; end; end; procedure TdmAsientos.Preview; var AStream: TMemoryStream; AEditorPreview : TfEditorPreview; begin { AStream := Binary.Create; AEditorPreview := TfEditorPreview.Create(Application); try AStream := (RemoteService as ISrvContactos).GenerateReport; AEditorPreview.Report.PreviewPages.LoadFromStream(AStream); AEditorPreview.ShowModal; finally AEditorPreview.Release; AStream.Free; end; } end; {function TdmCuentas.GetCliente(Codigo: Integer): IBizCliente; var // dtContactos: TDACDSDataTable; // dtCategorias: TDACDSDataTable; // ACursor: TCursor; begin { ACursor := Screen.Cursor; Screen.Cursor := crHourGlass; try dtContactos := TDACDSDataTable.Create(NIL); CloneDataTable(tbl_Contactos, dtContactos); dtContactos.BusinessRulesID := 'BizCliente'; dtCategorias := TDACDSDataTable.Create(NIL); CloneDataTable(tbl_CategoriasContacto, dtCategorias); dtCategorias.BusinessRulesID := 'BizCategoria'; (dtContactos as IBizContacto).Categorias := (dtCategorias as IBizCategoriasContacto); Result := (dtContactos as IBizCliente); GetCliente(Result, Codigo); finally Screen.Cursor := ACursor; end; end; } {function TdmAsientos.GetItem(Codigo: Integer): IBizCuenta; var ACuenta: IBizCuenta; begin ACuenta := GetItems; with ACuenta.DataTable do begin if Active then Active := False; Where.Clear; Where.AddCondition(fld_CuentasCODIGO, cEqual, Codigo); Active := True; end; Result := ACuenta; end; {function TdmAsientos.PuedoEliminarCuenta(Codigo: Integer): Boolean; begin Result := (RORemoteService as IsrvCuentas).PuedoEliminarCuenta(Codigo); end; } initialization dmAsientos := TdmAsientos.Create(nil); finalization FreeAndNil(dmAsientos); end.