Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Conexión con bases de datos
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Conexión con bases de datos

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 14-10-2008
sargento elias sargento elias is offline
Miembro
 
Registrado: mar 2008
Posts: 109
Poder: 17
sargento elias Va por buen camino
Smile Orientación al report Builder

Buenas tardes.

Necesito información o una orientación para un informe complicado.
Tengo una pantalla en delphi7 donde introduce el usuario los datos desde/hasta (fecha,codigo1,codigo2,codigo3, ect) y le doy la opción de que seleccione los campos que quiere mostrar en el informe y en que orden.

es decir por ejemplo elige cod1 y fecha(cod---- fecha) saldrán en esa línea y en ese orden, si eligiera primero la fecha saldrían primero la fecha en la línea y después el cod. (fecha---- cod) y si elige sólo la fecha pues sólo sale en el informe la fecha. Si alguien ha hecho algo parecido agradecería una orientación.

El segundo problema que se me plantea es que los campos tienen un número fijo de caracteres, y si por ejemplo eligiera todos , en la linea del informe podría tener algo así:

Pedro------Ramón--------calle el cid 17 ,35-----------------matalas
cañas

Es decir que quiero controlar la longitud de la hoja que no me corte el dato, que en ese caso el campo aparezca entero abajo en otra línea.

Perdonad por el rollo. Gracias
Responder Con Cita
  #2  
Antiguo 16-10-2008
JosepGA JosepGA is offline
Miembro
 
Registrado: jun 2007
Ubicación: Tarragona
Posts: 166
Poder: 17
JosepGA Va por buen camino
hola, yo me he creado una Dll de generación de reports a la cual le paso arrays con las configuraciones de los campos a motrar en el orden de añadido.
Le paso la conexión de la base de datos, los campos, las longitudes ( no puede ser en caracteres ya que con fuentes de windows no funciona, no es lo mismo una "i" que una "w", a no ser que uses courier y apliques una formula), le paso el formato, las agrupaciones, los campos con formula, etc.. Luego en la Dll creo los componentes en el report, que lo unico que tiene creado son los datos de cabecera del report.
Responder Con Cita
  #3  
Antiguo 16-10-2008
JosepGA JosepGA is offline
Miembro
 
Registrado: jun 2007
Ubicación: Tarragona
Posts: 166
Poder: 17
JosepGA Va por buen camino
Por cierto, cuando tenga un momento te paso el código (lo tengo en el trabajo)
Responder Con Cita
  #4  
Antiguo 16-10-2008
JosepGA JosepGA is offline
Miembro
 
Registrado: jun 2007
Ubicación: Tarragona
Posts: 166
Poder: 17
JosepGA Va por buen camino
Espero que te sirva, te lo envio por partes:

unit RptConsultaMantRB;

interface

uses
Forms, SysUtils, Dialogs, Graphics, Provider, SqlExpr, DBXpress, SimpleDS, DB, TXComp, ppDB, ppDBPipe, DBClient, DBLocal, DBLocalS,
ppParameter, ppVar, ppBands, ppMemo, ppStrtch, ppRegion, ppCtrls, ppPrnabl, ppClass, ppCache, Classes, ppComm, ppRelatv, ppProd,
ppReport, ppTypes, Printers, ppRichTx, Parser10, ppWWRichEd,
//ppVar, ppBands, ppMemo, ppStrtch, ppRegion, ppCtrls, ppPrnabl, ppClass, ppCache, Classes, ppComm, ppRelatv, ppProd, ppReport, Printers,
//ppRichTx, ppWWRichEd, Parser10, ppChrt, ppTypes, ppParameter,

TXRB;

type
TFormRptConsultaMantenimientos = class(TForm)
ppReportConsultaMant: TppReport;
DSTablaConsulta: TDataSource;
ppCabecera: TppHeaderBand;
ppDetalle: TppDetailBand;
ppPiePagina: TppFooterBand;
ppLabelTituloListado: TppLabel;
ppSystemVariable1: TppSystemVariable;
ppSystemVariable2: TppSystemVariable;
ppLine1: TppLine;
ppLine2: TppLine;
ppLabel2: TppLabel;
ppVariable1: TppVariable;
Calculadora: TParser;
tContabilidades: TSQLClientDataSet;
tEmpresasContables: TSQLClientDataSet;
tLogoClientes: TSQLClientDataSet;
tEmpresasComercial: TSQLClientDataSet;
tParamClientes: TSQLClientDataSet;
ppDBPipeline1: TppDBPipeline;
ppLabel1: TppLabel;
ppVariable2: TppVariable;
ExtraOptions1: TExtraOptions;
tSQLConexionGeneral: TSQLConnection;
tSQLConexionGestion: TSQLConnection;
tSQLConexionContabilidad: TSQLConnection;
tTablaConsulta: TSimpleDataSet;
tTablaRelacionada: TSimpleDataSet;
ppParameterList1: TppParameterList;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure DarDeAltaCamposEnReport( TamanyoFuente : Double );
procedure ppVariable1GetText(Sender: TObject; var Text: String);
procedure ppReportConsultaMantPreviewFormCreate(Sender: TObject);
procedure ppVariable2GetText(Sender: TObject; var Text: String);
private
{ Private declarations }
TituloDelReport : String;
ListaCampos : tStringList;
ListaTitulos : tStringList;
ListaFormulas : tStringList;
ListaFormulasExpresion : tStringList;
ListaLongitud : tStringList;
ListaAlineacion : tStringList;
ListaFormatoCampos : tStringList;
ListaSumados : tStringList;
ListaCamposConRango : tStringList;
ListaRangosDesde : tStringList;
ListaRangosHasta : tStringList;
ListaValoresSustituir : tStringList;
//ListaBDTablasRelacionadasSQL : tStringList;
ListaTablasRelacionadasSQL : tStringList;

ListaTotalesSumados : tStringList;

MostratPiePagina : Boolean;

NombreEmpresa, NombreEmpresaCtb : String;
CamposMaestroAux : String;
CamposRelacionadoAux : String;

ListaTablasRelacionadas : Array[ 0..10 ] Of TSimpleDataSet;
ListaTablasRelacionadasCamposMaestro : Array[ 0..10 ] Of String;
ListaTablasRelacionadasCamposRelacionado : Array[ 0..10 ] Of String;
ListaTablasRelacionadasCampoDevolver : Array[ 0..10 ] Of String;

function CalcularExpresion( Expresion : String ) : String;

Procedure ActivarConexionesModuloDeDatos( Const tSQLConexionGeneralOrigen, tSQLConexionGestionOrigen, tSQLConexionContabilidadOrigen : tSQLConnection );
Procedure DesactivarConexionesModuloDeDatos( Const tSQLConexionGeneralOrigen, tSQLConexionGestionOrigen, tSQLConexionContabilidadOrigen : tSQLConnection );

Procedure ActivarConexionGeneral;
Procedure ActivarConexionGestion;
Procedure ActivarConexionContabilidad;

Procedure DesactivarConexionGeneral;
Procedure DesactivarConexionGestion;
Procedure DesactivarConexionContabilidad;
protected
procedure tCalculoFormulas( sender: TObject; Var Value: String );
procedure tCalculoFormulasSumatorio( sender: TObject; Var Value: String );
procedure tFormateadoCampo(sender: TObject; var Value: String);
procedure tBuscarDatoCampoRelacionado(Sender: TObject; var Text: String);
procedure ppEtiquetaCampoClick(Sender, aDrawCommand: TObject);
public
{ Public declarations }
end;

procedure EjecutarRptConsultaMantenimientos(
vGlobales : tVariablesGlobales;
Const auxSQLConexionGestion: TSQLConnection;
Const auxSQLConexionGeneral: TSQLConnection;
Const auxSQLConexionContabilidad: TSQLConnection;
Titulo : String;
BaseDeDatos : Integer;
ConsultaTablaSQL : String;
Apaisado : Boolean;
TamanyoFuente : Double;
LstCampos : tStringList;
LstTitulos : tStringList;
LstFormulas : tStringList;
LstFormulasExpresion : tStringList;
LstLongitud : tStringList;
LstAlineacion : tStringList;
LstFormatoCampos : tStringList;
LstSumados : tStringList;
LstCamposConRango : tStringList;
LstRangosDesde : tStringList;
LstRangosHasta : tStringList;
LstValoresSustituir : tStringList;
//LstBDTablasRelacionadasSQL : tStringList;
LstTablasRelacionadasSQL : tStringList;
EmpresaActual, EmpresaCtb, CtbActual : String;
NombreEmpresaActual, NombreEmpresaCtbActual : String ); far; Export;
var
FormRptConsultaMantenimientos: TFormRptConsultaMantenimientos;
FilaTitulos : Integer;

implementation

procedure EjecutarRptConsultaMantenimientos(
vGlobales : tVariablesGlobales;
Const auxSQLConexionGestion: TSQLConnection;
Const auxSQLConexionGeneral: TSQLConnection;
Const auxSQLConexionContabilidad: TSQLConnection;
Titulo : String;
BaseDeDatos : Integer;
ConsultaTablaSQL : String;
Apaisado : Boolean;
TamanyoFuente : Double;
LstCampos : tStringList;
LstTitulos : tStringList;
LstFormulas : tStringList;
LstFormulasExpresion : tStringList;
LstLongitud : tStringList;
LstAlineacion : tStringList;
LstFormatoCampos : tStringList;
LstSumados : tStringList;
LstCamposConRango : tStringList;
LstRangosDesde : tStringList;
LstRangosHasta : tStringList;
LstValoresSustituir : tStringList;
//LstBDTablasRelacionadasSQL : tStringList;
LstTablasRelacionadasSQL : tStringList;
EmpresaActual, EmpresaCtb, CtbActual : String;
NombreEmpresaActual, NombreEmpresaCtbActual : String ); far; Export;
Var
i : LongInt;
TieneFiltros : Boolean;
PosicionNombreEmpresa : LongInt;

PosicionArray : LongInt;
Parametros : String;
auxBaseDeDatos : String;
TablaRelacionada : String;
IndiceRango : String;
CamposMaestro : String;
CamposRelacionado : String;
CampoDevolver : String;
PosicionCorchete : LongInt;
PosicionPuntoComa : LongInt;
CampoRangoMaestro : String;
CampoRangoRelacionado : String;
TipoBaseDatos : LongInt;

Begin
AsignacionValoresGlobales( vGlobales );

FilaTitulos := 60;

If ( Pos( '( ' + NombreEmpresaActual + ' )', Titulo ) <> 0 ) Then
Delete( Titulo, Pos( '( ' + NombreEmpresaActual + ' )', Titulo ), Length( '( ' + NombreEmpresaActual + ' )' ) );

AsignarLaConfiguracionDeLasAplicaciones;

setEmpresaActual := EmpresaActual;
setEmpresaContable := EmpresaCtb;
Try
setContabilidad := StrToInt( CtbActual );
Except
setContabilidad := -1;
End;

Application.CreateForm( tFormRptConsultaMantenimientos, FormRptConsultaMantenimientos );

With FormRptConsultaMantenimientos Do
Try
ActivarConexionesModuloDeDatos( auxSQLConexionGeneral, auxSQLConexionGestion, auxSQLConexionContabilidad );

tContabilidades.DBConnection := tSQLConexionGeneral;
tEmpresasContables.DBConnection := tSQLConexionGeneral;
tLogoClientes.DBConnection := tSQLConexionGeneral;
tEmpresasComercial.DBConnection := tSQLConexionGeneral;
tParamClientes.DBConnection := tSQLConexionGeneral;

tContabilidades.Active := TRUE;
tEmpresasContables.Active := TRUE;
tLogoClientes.Active := TRUE;
tEmpresasComercial.Active := TRUE;
tParamClientes.Active := TRUE;

ppReportConsultaMant.BeginUpdate;

TituloDelReport := Titulo;
ppLabelTituloListado.Caption := TituloDelReport;
ppReportConsultaMant.PrinterSetup.DocumentName := TituloDelReport;
ppReportConsultaMant.ShowAutoSearchDialog := FALSE;
ppReportConsultaMant.Units := utScreenPixels;

If Apaisado Then
Begin
ppReportConsultaMant.PrinterSetup.Orientation := poLandscape;
ppLabelTituloListado.Width := ppReportConsultaMant.PrinterSetup.PaperWidth - 50;
ppLine2.Width := ppLabelTituloListado.Width;
ppSystemVariable2.Left := ppLabelTituloListado.Width - ppSystemVariable2.Width;
End;

ListaCampos.AddStrings( LstCampos );
ListaTitulos.AddStrings( LstTitulos );
ListaFormulas.AddStrings( LstFormulas );
ListaFormulasExpresion.AddStrings( LstFormulasExpresion );
ListaLongitud.AddStrings( LstLongitud );
ListaAlineacion.AddStrings( LstAlineacion );
ListaFormatoCampos.AddStrings( LstFormatoCampos );
ListaSumados.AddStrings( LstSumados );
ListaCamposConRango.AddStrings( LstCamposConRango );
ListaRangosDesde.AddStrings( LstRangosDesde );
ListaRangosHasta.AddStrings( LstRangosHasta );
ListaValoresSustituir.AddStrings( LstValoresSustituir );
//ListaBDTablasRelacionadasSQL.AddStrings( LstBDTablasRelacionadasSQL );
ListaTablasRelacionadasSQL.AddStrings( LstTablasRelacionadasSQL );

For i := 0 To ( ListaCampos.Count - 1 ) Do
Begin
ListaFormulas.Strings[ i ] := UpperCase( Trim( ListaFormulas.Strings[ i ] ) );
ListaAlineacion.Strings[ i ] := UpperCase( Trim( ListaAlineacion.Strings[ i ] ) );
ListaSumados.Strings[ i ] := UpperCase( Trim( ListaSumados.Strings[ i ] ) );
ListaCamposConRango.Strings[ i ] := UpperCase( Trim( ListaCamposConRango.Strings[ i ] ) );
ListaTotalesSumados.Add( '0' );
End;

For i := 0 To ( ListaTablasRelacionadasSQL.Count - 1 ) Do
Begin
Parametros := ListaTablasRelacionadasSQL.Strings[ i ];
If Parametros <> '' Then
Begin
PosicionCorchete := Pos( ']', Parametros );
auxBaseDeDatos := Copy( Parametros, 2, ( PosicionCorchete - 2 ) );
Delete( Parametros, 1, PosicionCorchete );
Try
TipoBaseDatos := StrToInt( auxBaseDeDatos );
Except
TipoBaseDatos := 1; { 0=General, 1=Producción, 2=Facturacion, 3=Contabilidad }
End;

PosicionCorchete := Pos( '[', Parametros );
Delete( Parametros, 1, ( PosicionCorchete - 1 ) );

PosicionCorchete := Pos( ']', Parametros );
TablaRelacionada := Copy( Parametros, 2, ( PosicionCorchete - 2 ) );
Delete( Parametros, 1, PosicionCorchete );

PosicionCorchete := Pos( '[', Parametros );
Delete( Parametros, 1, ( PosicionCorchete - 1 ) );

PosicionCorchete := Pos( ']', Parametros );
IndiceRango := Copy( Parametros, 2, ( PosicionCorchete - 2 ) );
Delete( Parametros, 1, PosicionCorchete );

PosicionCorchete := Pos( '[', Parametros );
Delete( Parametros, 1, ( PosicionCorchete - 1 ) );

PosicionCorchete := Pos( ']', Parametros );
CamposMaestro := Copy( Parametros, 2, ( PosicionCorchete - 2 ) );
Delete( Parametros, 1, PosicionCorchete );

PosicionCorchete := Pos( '[', Parametros );
Delete( Parametros, 1, ( PosicionCorchete - 1 ) );

PosicionCorchete := Pos( ']', Parametros );
CamposRelacionado := Copy( Parametros, 2, ( PosicionCorchete - 2 ) );
Delete( Parametros, 1, PosicionCorchete );

PosicionCorchete := Pos( '[', Parametros );
Delete( Parametros, 1, ( PosicionCorchete - 1 ) );

PosicionCorchete := Pos( ']', Parametros );
CampoDevolver := Copy( Parametros, 2, ( PosicionCorchete - 2 ) );
Delete( Parametros, 1, PosicionCorchete );

ListaTablasRelacionadas[ i ] := TSimpleDataSet.Create( FormRptConsultaMantenimientos );
ListaTablasRelacionadasCamposMaestro[ i ] := CamposMaestro;
ListaTablasRelacionadasCamposRelacionado[ i ] := CamposRelacionado;
ListaTablasRelacionadasCampoDevolver[ i ] := CampoDevolver;

Case TipoBaseDatos Of
0 : { General }
Begin
ListaTablasRelacionadas[ i ].Connection := tSQLConexionGeneral;
End;
1 : { Producción }
Begin
ListaTablasRelacionadas[ i ].Connection := tSQLConexionGestion;
End;
2 : { Facturación }
Begin
ListaTablasRelacionadas[ i ].Connection := tSQLConexionGestion;
End;
3 : { Contabilidad }
Begin
ListaTablasRelacionadas[ i ].Connection := tSQLConexionContabilidad;
End;
End;

ListaTablasRelacionadas[ i ].DataSet.CommandText := TablaRelacionada;
ListaTablasRelacionadas[ i ].Open;
End;
End;

MostratPiePagina := FALSE;
For i := 0 To ( ListaSumados.Count - 1 ) Do
If ( ListaSumados.Strings[ i ] = 'S' ) Then
MostratPiePagina := TRUE;

TieneFiltros := FALSE;
For i := 0 To ( LstCamposConRango.Count - 1 ) Do
If ( LstCamposConRango.Strings[ i ] = 'S' ) Then
TieneFiltros := TRUE;

With tTablaConsulta Do
Begin
Case BaseDeDatos Of
0 : { General }
Connection := tSQLConexionGeneral;
1 : { Producción }
Connection := tSQLConexionGestion;
2 : { Facturación }
Connection := tSQLConexionGestion;
3 : { Contabilidad }
Connection := tSQLConexionContabilidad;
End;

DataSet.CommandText := ConsultaTablaSQL;

Try
If Not Active Then
Open;
Except
on E: Exception do ShowMessage( E.Message );
End;
End;

If BaseDeDatos = 3 Then { Contabilidad }
Begin
FilaTitulos := FilaTitulos + 20;
ppCabecera.Height := ppCabecera.Height + 20;
End;

Try
DarDeAltaCamposEnReport( TamanyoFuente );
Finally
ppReportConsultaMant.EndUpdate;
tTablaConsulta.EnableControls;
End;

With tTablaConsulta Do
Try
If Not Active Then
Open;
Except
on E: Exception do ShowMessage( E.Message );
End;

Case BaseDeDatos Of
0, 1, 2 : { General, Producción, Facturación }
Begin
With tEmpresasComercial Do
If FindKey( [ EmpresaActual ] ) Then
NombreEmpresa := FieldByName( 'Nombre' ).AsString
Else
NombreEmpresa := NombreEmpresaActual;
NombreEmpresaCtb := '';
ppLabel1.Visible := FALSE;
ppVariable2.Visible := FALSE;
End;
3 : { Contabilidad }
Begin
With tEmpresasContables Do
If FindKey( [ EmpresaCtb ] ) Then
NombreEmpresa := FieldByName( 'DESCRIPCION' ).AsString
Else
NombreEmpresa := NombreEmpresaActual;

With tContabilidades Do
If FindKey( [ EmpresaCtb, CtbActual ] ) Then
NombreEmpresaCtb := FieldByName( 'DESCRIPCION' ).AsString
Else
NombreEmpresaCtb := NombreEmpresaCtbActual;
End;
End;

(*Application.CreateForm( tFormPrevisualizacionRts, FormPrevisualizacionRts );
With FormPrevisualizacionRts Do
Try
ppVisualizador.Hint := 'Pulse en un Título para ordenar por el campo';
ppVisualizadorSegundaPagina.Hint := 'Pulse en un Título para ordenar por el campo';
ppVisualizador.Report := ppReportConsultaMant;

FormPrevisualizacionRts.ShowModal;
Finally
Free;
End;*)

ppReportConsultaMant.Print;

ChDir( setRutaEjecutable );
Finally
DesactivarConexionesModuloDeDatos( auxSQLConexionGeneral, auxSQLConexionGestion, auxSQLConexionContabilidad );

Free;
End;
End;
Responder Con Cita
  #5  
Antiguo 16-10-2008
JosepGA JosepGA is offline
Miembro
 
Registrado: jun 2007
Ubicación: Tarragona
Posts: 166
Poder: 17
JosepGA Va por buen camino
lo siento en la vista previa se veia diferente, lo vuelvo a intentar:

Código Delphi [-]
unit RptConsultaMantRB;

interface

uses
  Forms, SysUtils, Dialogs, Graphics, Provider, SqlExpr, DBXpress, SimpleDS, DB, TXComp, ppDB, ppDBPipe, DBClient, DBLocal, DBLocalS,
  ppParameter, ppVar, ppBands, ppMemo, ppStrtch, ppRegion, ppCtrls, ppPrnabl, ppClass, ppCache, Classes, ppComm, ppRelatv, ppProd,
  ppReport, ppTypes, Printers, ppRichTx, Parser10, ppWWRichEd, 
  //ppVar, ppBands, ppMemo, ppStrtch, ppRegion, ppCtrls, ppPrnabl, ppClass, ppCache, Classes, ppComm, ppRelatv, ppProd, ppReport, Printers,
  //ppRichTx, ppWWRichEd, Parser10, ppChrt, ppTypes, ppParameter,

  TXRB;

type
  TFormRptConsultaMantenimientos = class(TForm)
    ppReportConsultaMant: TppReport;
    DSTablaConsulta: TDataSource;
    ppCabecera: TppHeaderBand;
    ppDetalle: TppDetailBand;
    ppPiePagina: TppFooterBand;
    ppLabelTituloListado: TppLabel;
    ppSystemVariable1: TppSystemVariable;
    ppSystemVariable2: TppSystemVariable;
    ppLine1: TppLine;
    ppLine2: TppLine;
    ppLabel2: TppLabel;
    ppVariable1: TppVariable;
    Calculadora: TParser;
    tContabilidades: TSQLClientDataSet;
    tEmpresasContables: TSQLClientDataSet;
    tLogoClientes: TSQLClientDataSet;
    tEmpresasComercial: TSQLClientDataSet;
    tParamClientes: TSQLClientDataSet;
    ppDBPipeline1: TppDBPipeline;
    ppLabel1: TppLabel;
    ppVariable2: TppVariable;
    ExtraOptions1: TExtraOptions;
    tSQLConexionGeneral: TSQLConnection;
    tSQLConexionGestion: TSQLConnection;
    tSQLConexionContabilidad: TSQLConnection;
    tTablaConsulta: TSimpleDataSet;
    tTablaRelacionada: TSimpleDataSet;
    ppParameterList1: TppParameterList;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure DarDeAltaCamposEnReport( TamanyoFuente : Double );
    procedure ppVariable1GetText(Sender: TObject; var Text: String);
    procedure ppReportConsultaMantPreviewFormCreate(Sender: TObject);
    procedure ppVariable2GetText(Sender: TObject; var Text: String);
  private
    { Private declarations }
    TituloDelReport : String;
    ListaCampos : tStringList;
    ListaTitulos : tStringList;
    ListaFormulas : tStringList;
    ListaFormulasExpresion : tStringList;
      ListaLongitud : tStringList;
      ListaAlineacion : tStringList;
    ListaFormatoCampos : tStringList;
    ListaSumados : tStringList;
    ListaCamposConRango : tStringList;
    ListaRangosDesde : tStringList;
    ListaRangosHasta : tStringList;
    ListaValoresSustituir : tStringList;
    //ListaBDTablasRelacionadasSQL : tStringList;
    ListaTablasRelacionadasSQL : tStringList;

    ListaTotalesSumados : tStringList;

    MostratPiePagina : Boolean;

    NombreEmpresa, NombreEmpresaCtb : String;
    CamposMaestroAux : String;
    CamposRelacionadoAux : String;

    ListaTablasRelacionadas : Array[ 0..10 ] Of TSimpleDataSet;
    ListaTablasRelacionadasCamposMaestro : Array[ 0..10 ] Of String;
    ListaTablasRelacionadasCamposRelacionado : Array[ 0..10 ] Of String;
    ListaTablasRelacionadasCampoDevolver : Array[ 0..10 ] Of String;

    function CalcularExpresion( Expresion : String ) : String;

    Procedure ActivarConexionesModuloDeDatos( Const tSQLConexionGeneralOrigen, tSQLConexionGestionOrigen, tSQLConexionContabilidadOrigen : tSQLConnection );
    Procedure DesactivarConexionesModuloDeDatos( Const tSQLConexionGeneralOrigen, tSQLConexionGestionOrigen, tSQLConexionContabilidadOrigen : tSQLConnection );

    Procedure ActivarConexionGeneral;
    Procedure ActivarConexionGestion;
    Procedure ActivarConexionContabilidad;

    Procedure DesactivarConexionGeneral;
    Procedure DesactivarConexionGestion;
    Procedure DesactivarConexionContabilidad;
    protected
    procedure tCalculoFormulas( sender: TObject; Var Value: String );
    procedure tCalculoFormulasSumatorio( sender: TObject; Var Value: String );
        procedure tFormateadoCampo(sender: TObject; var Value: String);
    procedure tBuscarDatoCampoRelacionado(Sender: TObject; var Text: String);
    procedure ppEtiquetaCampoClick(Sender, aDrawCommand: TObject);
  public
    { Public declarations }
  end;

procedure EjecutarRptConsultaMantenimientos(
            vGlobales : tVariablesGlobales;
            Const auxSQLConexionGestion: TSQLConnection;
            Const auxSQLConexionGeneral: TSQLConnection;
            Const auxSQLConexionContabilidad: TSQLConnection;
            Titulo : String;
            BaseDeDatos : Integer;
            ConsultaTablaSQL : String;
            Apaisado : Boolean;
            TamanyoFuente : Double;
            LstCampos : tStringList;
            LstTitulos : tStringList;
            LstFormulas : tStringList;
            LstFormulasExpresion : tStringList;
            LstLongitud : tStringList;
            LstAlineacion : tStringList;
            LstFormatoCampos : tStringList;
            LstSumados : tStringList;
            LstCamposConRango : tStringList;
                  LstRangosDesde : tStringList;
                  LstRangosHasta : tStringList;
            LstValoresSustituir : tStringList;
            //LstBDTablasRelacionadasSQL : tStringList;
            LstTablasRelacionadasSQL : tStringList;
                        EmpresaActual, EmpresaCtb, CtbActual : String;
            NombreEmpresaActual, NombreEmpresaCtbActual : String ); far; Export;
var
  FormRptConsultaMantenimientos: TFormRptConsultaMantenimientos;
  FilaTitulos : Integer;

implementation

procedure EjecutarRptConsultaMantenimientos(
            vGlobales : tVariablesGlobales;
            Const auxSQLConexionGestion: TSQLConnection;
            Const auxSQLConexionGeneral: TSQLConnection;
            Const auxSQLConexionContabilidad: TSQLConnection;
                        Titulo : String;
            BaseDeDatos : Integer;
            ConsultaTablaSQL : String;
            Apaisado : Boolean;
            TamanyoFuente : Double;
            LstCampos : tStringList;
            LstTitulos : tStringList;
            LstFormulas : tStringList;
            LstFormulasExpresion : tStringList;
            LstLongitud : tStringList;
            LstAlineacion : tStringList;
            LstFormatoCampos : tStringList;
            LstSumados : tStringList;
            LstCamposConRango : tStringList;
                  LstRangosDesde : tStringList;
                  LstRangosHasta : tStringList;
            LstValoresSustituir : tStringList;
            //LstBDTablasRelacionadasSQL : tStringList;
            LstTablasRelacionadasSQL : tStringList;
            EmpresaActual, EmpresaCtb, CtbActual : String;
            NombreEmpresaActual, NombreEmpresaCtbActual : String ); far; Export;
Var
  i : LongInt;
  TieneFiltros : Boolean;
  PosicionNombreEmpresa : LongInt;

  PosicionArray : LongInt;
  Parametros : String;
  auxBaseDeDatos : String;
  TablaRelacionada : String;
  IndiceRango : String;
  CamposMaestro : String;
  CamposRelacionado : String;
  CampoDevolver : String;
  PosicionCorchete : LongInt;
  PosicionPuntoComa : LongInt;
  CampoRangoMaestro : String;
  CampoRangoRelacionado : String;
  TipoBaseDatos : LongInt;

Begin
  AsignacionValoresGlobales( vGlobales );

  FilaTitulos := 60;

  If ( Pos( '( ' + NombreEmpresaActual + ' )', Titulo ) <> 0 ) Then
    Delete( Titulo, Pos( '( ' + NombreEmpresaActual + ' )', Titulo ), Length( '( ' + NombreEmpresaActual + ' )' ) );

  AsignarLaConfiguracionDeLasAplicaciones;

  setEmpresaActual := EmpresaActual;
  setEmpresaContable := EmpresaCtb;
  Try
    setContabilidad := StrToInt( CtbActual );
  Except
    setContabilidad := -1;
  End;

  Application.CreateForm( tFormRptConsultaMantenimientos, FormRptConsultaMantenimientos );

  With FormRptConsultaMantenimientos Do
    Try
      ActivarConexionesModuloDeDatos( auxSQLConexionGeneral, auxSQLConexionGestion, auxSQLConexionContabilidad );

      tContabilidades.DBConnection := tSQLConexionGeneral;
      tEmpresasContables.DBConnection := tSQLConexionGeneral;
      tLogoClientes.DBConnection := tSQLConexionGeneral;
      tEmpresasComercial.DBConnection := tSQLConexionGeneral;
      tParamClientes.DBConnection := tSQLConexionGeneral;

      tContabilidades.Active := TRUE;
      tEmpresasContables.Active := TRUE;
      tLogoClientes.Active := TRUE;
      tEmpresasComercial.Active := TRUE;
      tParamClientes.Active := TRUE;

      ppReportConsultaMant.BeginUpdate;

      TituloDelReport := Titulo;
      ppLabelTituloListado.Caption := TituloDelReport;
      ppReportConsultaMant.PrinterSetup.DocumentName := TituloDelReport;
      ppReportConsultaMant.ShowAutoSearchDialog := FALSE;
      ppReportConsultaMant.Units := utScreenPixels;

      If Apaisado Then
        Begin
          ppReportConsultaMant.PrinterSetup.Orientation := poLandscape;
          ppLabelTituloListado.Width := ppReportConsultaMant.PrinterSetup.PaperWidth - 50;
          ppLine2.Width := ppLabelTituloListado.Width;
          ppSystemVariable2.Left := ppLabelTituloListado.Width - ppSystemVariable2.Width;
        End;

      ListaCampos.AddStrings( LstCampos );
      ListaTitulos.AddStrings( LstTitulos );
      ListaFormulas.AddStrings( LstFormulas );
      ListaFormulasExpresion.AddStrings( LstFormulasExpresion );
      ListaLongitud.AddStrings( LstLongitud );
      ListaAlineacion.AddStrings( LstAlineacion );
      ListaFormatoCampos.AddStrings( LstFormatoCampos );
      ListaSumados.AddStrings( LstSumados );
      ListaCamposConRango.AddStrings( LstCamposConRango );
      ListaRangosDesde.AddStrings( LstRangosDesde );
      ListaRangosHasta.AddStrings( LstRangosHasta );
      ListaValoresSustituir.AddStrings( LstValoresSustituir );
      //ListaBDTablasRelacionadasSQL.AddStrings( LstBDTablasRelacionadasSQL );
      ListaTablasRelacionadasSQL.AddStrings( LstTablasRelacionadasSQL );

      For i := 0 To ( ListaCampos.Count - 1 ) Do
        Begin
          ListaFormulas.Strings[ i ] := UpperCase( Trim( ListaFormulas.Strings[ i ] ) );
          ListaAlineacion.Strings[ i ] := UpperCase( Trim( ListaAlineacion.Strings[ i ] ) );
          ListaSumados.Strings[ i ] := UpperCase( Trim( ListaSumados.Strings[ i ] ) );
          ListaCamposConRango.Strings[ i ] := UpperCase( Trim( ListaCamposConRango.Strings[ i ] ) );
          ListaTotalesSumados.Add( '0' );
        End;

      For i := 0 To ( ListaTablasRelacionadasSQL.Count - 1 ) Do
        Begin
          Parametros := ListaTablasRelacionadasSQL.Strings[ i ];
          If Parametros <> '' Then
            Begin
              PosicionCorchete := Pos( ']', Parametros );
              auxBaseDeDatos := Copy( Parametros, 2, ( PosicionCorchete - 2 ) );
              Delete( Parametros, 1, PosicionCorchete );
              Try
                TipoBaseDatos := StrToInt( auxBaseDeDatos );
              Except
                TipoBaseDatos := 1; { 0=General, 1=Producción, 2=Facturacion, 3=Contabilidad }
              End;

              PosicionCorchete := Pos( '[', Parametros );
              Delete( Parametros, 1, ( PosicionCorchete - 1 ) );

              PosicionCorchete := Pos( ']', Parametros );
              TablaRelacionada := Copy( Parametros, 2, ( PosicionCorchete - 2 ) );
              Delete( Parametros, 1, PosicionCorchete );

              PosicionCorchete := Pos( '[', Parametros );
              Delete( Parametros, 1, ( PosicionCorchete - 1 ) );

              PosicionCorchete := Pos( ']', Parametros );
              IndiceRango := Copy( Parametros, 2, ( PosicionCorchete - 2 ) );
              Delete( Parametros, 1, PosicionCorchete );

              PosicionCorchete := Pos( '[', Parametros );
              Delete( Parametros, 1, ( PosicionCorchete - 1 ) );

              PosicionCorchete := Pos( ']', Parametros );
              CamposMaestro := Copy( Parametros, 2, ( PosicionCorchete - 2 ) );
              Delete( Parametros, 1, PosicionCorchete );

              PosicionCorchete := Pos( '[', Parametros );
              Delete( Parametros, 1, ( PosicionCorchete - 1 ) );

              PosicionCorchete := Pos( ']', Parametros );
              CamposRelacionado := Copy( Parametros, 2, ( PosicionCorchete - 2 ) );
              Delete( Parametros, 1, PosicionCorchete );

              PosicionCorchete := Pos( '[', Parametros );
              Delete( Parametros, 1, ( PosicionCorchete - 1 ) );

              PosicionCorchete := Pos( ']', Parametros );
              CampoDevolver := Copy( Parametros, 2, ( PosicionCorchete - 2 ) );
              Delete( Parametros, 1, PosicionCorchete );

              ListaTablasRelacionadas[ i ] := TSimpleDataSet.Create( FormRptConsultaMantenimientos );
              ListaTablasRelacionadasCamposMaestro[ i ] := CamposMaestro;
              ListaTablasRelacionadasCamposRelacionado[ i ] := CamposRelacionado;
              ListaTablasRelacionadasCampoDevolver[ i ] := CampoDevolver;

              Case TipoBaseDatos Of
                0 : { General }
                  Begin
                    ListaTablasRelacionadas[ i ].Connection := tSQLConexionGeneral;
                  End;
                1 : { Producción }
                  Begin
                    ListaTablasRelacionadas[ i ].Connection := tSQLConexionGestion;
                  End;
                2 : { Facturación }
                  Begin
                    ListaTablasRelacionadas[ i ].Connection := tSQLConexionGestion;
                  End;
                3 : { Contabilidad }
                  Begin
                    ListaTablasRelacionadas[ i ].Connection := tSQLConexionContabilidad;
                  End;
              End;

              ListaTablasRelacionadas[ i ].DataSet.CommandText := TablaRelacionada;
              ListaTablasRelacionadas[ i ].Open;
            End;
        End;

      MostratPiePagina := FALSE;
      For i := 0 To ( ListaSumados.Count - 1 ) Do
        If ( ListaSumados.Strings[ i ] = 'S' ) Then
          MostratPiePagina := TRUE;

      TieneFiltros := FALSE;
      For i := 0 To ( LstCamposConRango.Count - 1 ) Do
        If ( LstCamposConRango.Strings[ i ] = 'S' ) Then
          TieneFiltros := TRUE;

      With tTablaConsulta Do
        Begin
          Case BaseDeDatos Of
            0 : { General }
              Connection := tSQLConexionGeneral;
            1 : { Producción }
              Connection := tSQLConexionGestion;
            2 : { Facturación }
              Connection := tSQLConexionGestion;
            3 : { Contabilidad }
              Connection := tSQLConexionContabilidad;
          End;

          DataSet.CommandText := ConsultaTablaSQL;

          Try
            If Not Active Then
              Open;
          Except
            on E: Exception do ShowMessage( E.Message );
          End;
        End;

      If BaseDeDatos = 3 Then { Contabilidad }
        Begin
          FilaTitulos := FilaTitulos + 20;
          ppCabecera.Height := ppCabecera.Height + 20;
        End;

      Try
        DarDeAltaCamposEnReport( TamanyoFuente );
      Finally
        ppReportConsultaMant.EndUpdate;
        tTablaConsulta.EnableControls;
      End;

      With tTablaConsulta Do
        Try
          If Not Active Then
            Open;
        Except
          on E: Exception do ShowMessage( E.Message );
        End;

      Case BaseDeDatos Of
        0, 1, 2 : { General, Producción, Facturación }
          Begin
            With tEmpresasComercial Do
              If FindKey( [ EmpresaActual ] ) Then
                NombreEmpresa := FieldByName( 'Nombre' ).AsString
              Else
                NombreEmpresa := NombreEmpresaActual;
            NombreEmpresaCtb := '';
            ppLabel1.Visible := FALSE;
            ppVariable2.Visible := FALSE;
          End;
        3 : { Contabilidad }
          Begin
            With tEmpresasContables Do
              If FindKey( [ EmpresaCtb ] ) Then
                NombreEmpresa := FieldByName( 'DESCRIPCION' ).AsString
              Else
                NombreEmpresa := NombreEmpresaActual;

            With tContabilidades Do
              If FindKey( [ EmpresaCtb, CtbActual ] ) Then
                NombreEmpresaCtb := FieldByName( 'DESCRIPCION' ).AsString
              Else
                NombreEmpresaCtb := NombreEmpresaCtbActual;
          End;
      End;

      (*Application.CreateForm( tFormPrevisualizacionRts, FormPrevisualizacionRts );
      With FormPrevisualizacionRts Do
        Try
          ppVisualizador.Hint := 'Pulse en un Título para ordenar por el campo';
          ppVisualizadorSegundaPagina.Hint := 'Pulse en un Título para ordenar por el campo';
          ppVisualizador.Report := ppReportConsultaMant;

          FormPrevisualizacionRts.ShowModal;
        Finally
          Free;
        End;*)

      ppReportConsultaMant.Print;

      ChDir( setRutaEjecutable );
    Finally
      DesactivarConexionesModuloDeDatos( auxSQLConexionGeneral, auxSQLConexionGestion, auxSQLConexionContabilidad );

      Free;
    End;
End;
Responder Con Cita
  #6  
Antiguo 16-10-2008
JosepGA JosepGA is offline
Miembro
 
Registrado: jun 2007
Ubicación: Tarragona
Posts: 166
Poder: 17
JosepGA Va por buen camino
segunda parte:

Código Delphi [-]
{$R *.dfm}

procedure TFormRptConsultaMantenimientos.ppVariable1GetText(
  Sender: TObject; var Text: String);
begin
  Text := NombreEmpresa;
end;

procedure TFormRptConsultaMantenimientos.ppReportConsultaMantPreviewFormCreate(
  Sender: TObject);
begin
  ppReportConsultaMant.PreviewForm.WindowState := wsMaximized;
end;

procedure TFormRptConsultaMantenimientos.DarDeAltaCamposEnReport( TamanyoFuente : Double );
Var
  i : LongInt;
  PosicionCampo : LongInt;
  tTitulo : TppLabel;
  tCampo : TppDBText;
  tCampoDBMemo : TppDBMemo;
  tCampoDBMemoRT : TppDBRichText;
  //tCampoDBMemoRT : TppWWRichEdit;
  tCampoDBImagen : TppDBImage;
  tCampoFormula : TppVariable;
  tCampoSumado : TppVariable;
  tRelacionado : TppDBText; //TppLabel;
  tLineas : TppLine;
begin
  PosicionCampo := 0;
  With ListaCampos Do
    For i := 0 To ( Count - 1 ) Do
      If ( StrToInt( ListaLongitud.Strings[ i ] ) > 0 ) Then
        Begin
          With ppReportConsultaMant Do
            Begin
              tTitulo := TppLabel.Create( ppReportConsultaMant );
              With tTitulo Do
                Begin
                  //Parent := BandaCabeceraPagina;
                  Band := ppCabecera;
                  Left := PosicionCampo;
                  Top := FilaTitulos;
                  Width := StrToInt( ListaLongitud.Strings[ i ] );
                  Height := 15;
                  AutoSize := FALSE;
                  If ListaAlineacion.Strings[ i ] = 'I' Then
                    AlignMent := taLeftJustify
                  Else If ListaAlineacion.Strings[ i ] = 'C' Then
                    AlignMent := taCenter
                  Else If ListaAlineacion.Strings[ i ] = 'D' Then
                    AlignMent := taRightJustify;
                  Font.Style := [ fsBold ];
                  Caption := ListaTitulos.Strings[ i ];
                  tTitulo.Name := 'Tit_' + ListaCampos.Strings[ i ];
                  UserName := 'Titulo' + IntToStr( i );
                  If ( ListaTablasRelacionadasSQL.Strings[ i ] = '' ) Then { Campo de Base de Datos Relacionado }
                    If ( ListaFormulas.Strings[ i ] <> 'S' ) Then
                      If ( tTablaConsulta.FieldByName( ListaCampos.Strings[ i ] ).DataType <> ftMemo ) And
                         ( tTablaConsulta.FieldByName( ListaCampos.Strings[ i ] ).DataType <> ftFmtMemo ) And
                         ( tTablaConsulta.FieldByName( ListaCampos.Strings[ i ] ).DataType <> ftBlob ) And
                         ( tTablaConsulta.FieldByName( ListaCampos.Strings[ i ] ).DataType <> ftGraphic ) Then
                        OnDrawCommandClick := ppEtiquetaCampoClick;
                  Visible := TRUE;
                  Transparent := TRUE;
                  Font.Name := ppLabelTituloListado.Font.Name;
                  Font.Size := Trunc( TamanyoFuente );
                  Font.Style := [ fsBold ];
                End;

              tLineas := TppLine.Create( ppReportConsultaMant );
              With tLineas Do
                Begin
                  //Parent := BandaCabeceraPagina;
                  Band := ppCabecera;
                  Left := PosicionCampo;
                  Top := FilaTitulos + 17;
                  Width := StrToInt( ListaLongitud.Strings[ i ] );
                  Height := 2;
                  Visible := TRUE;
                  //Transparent := TRUE;
                End;

              If ( ListaTablasRelacionadasSQL.Strings[ i ] <> '' ) Then { Campo de Base de Datos Relacionado }
                Begin
                  tRelacionado := TppDBText.Create( ppReportConsultaMant );
                  With tRelacionado Do
                    Begin
                      //Parent := BandaDetalle;
                      Band := ppDetalle;
                      Left := PosicionCampo;
                      Top := 0;
                      Width := StrToInt( ListaLongitud.Strings[ i ] );
                      Height := 15;
                      AutoSize := FALSE;
                      WordWrap := TRUE;
                      If ListaAlineacion.Strings[ i ] = 'I' Then
                        AlignMent := taLeftJustify
                      Else If ListaAlineacion.Strings[ i ] = 'C' Then
                        AlignMent := taCenter
                      Else If ListaAlineacion.Strings[ i ] = 'D' Then
                        AlignMent := taRightJustify;
                      Tag := i;
                      DataPipeline := ppDBPipeline1;
                      DataField := ListaCampos.Strings[ i ];
                      OnGetText := tBuscarDatoCampoRelacionado;
                      Caption := ListaTitulos.Strings[ i ];
                      Name := 'ppRelac' + IntToStr( i );
                      //UserName := 'Relac' + IntToStr( i );
                      Visible := TRUE;
                      Transparent := TRUE;
                      Font.Name := ppLabelTituloListado.Font.Name;
                      Font.Size := Trunc( TamanyoFuente );
                      Font.Style := [ ];
                    End;
                End
              Else If ( ListaFormulas.Strings[ i ] = 'N' ) Then { Campo de Base de Datos }
                Begin
                  If ( tTablaConsulta.FieldByName( ListaCampos.Strings[ i ] ).DataType = ftFmtMemo ) Or
                     ( tTablaConsulta.FieldByName( ListaCampos.Strings[ i ] ).DataType = ftBlob ) Or
                     ( tTablaConsulta.FieldByName( ListaCampos.Strings[ i ] ).IsBlob ) Then
                    Begin
                      tCampoDBMemoRT := TppDBRichText.Create( ppReportConsultaMant );
                      //tCampoDBMemoRT := TppWWRichEdit.Create( ppDetalle );

                      ppDetalle.PrintHeight := phDynamic;

                      With tCampoDBMemoRT Do
                        Begin
                          Band := ppDetalle;
                          Left := PosicionCampo;
                          Top := 0;
                          Width := StrToInt( ListaLongitud.Strings[ i ] );
                          Height := 15;
                          AutoSize := FALSE;
                          WordWrap := TRUE;
                          If ListaAlineacion.Strings[ i ] = 'I' Then
                            AlignMent := taLeftJustify
                          Else If ListaAlineacion.Strings[ i ] = 'C' Then
                            AlignMent := taCenter
                          Else If ListaAlineacion.Strings[ i ] = 'D' Then
                            AlignMent := taRightJustify;
                          DataPipeline := ppDBPipeline1;
                          DataField := ListaCampos.Strings[ i ];
                          //OnGetMemo := tFormateadoCampoMemo;
                          Tag := i;
                          Name := 'Campo' + IntToStr( i );
                          UserName := 'Campo' + IntToStr( i );
                          Visible := TRUE;
                          Transparent := TRUE;
                          //Font.Name := ppLabelTituloListado.Font.Name;
                          //Font.Size := Trunc( TamanyoFuente );
                          //ShiftRelativeTo := tRegiones;
                          Stretch := TRUE;
                          Font.Style := [ ];
                          AutoDisplay := TRUE;
                        End;
                    End
                  Else If ( tTablaConsulta.FieldByName( ListaCampos.Strings[ i ] ).DataType = ftGraphic ) Then
                    Begin
                      tCampoDBImagen := TppDBImage.Create( ppReportConsultaMant );
                      With tCampoDBImagen Do
                        Begin
                          //Parent := BandaDetalle;
                          Band := ppDetalle;
                          Left := PosicionCampo;
                          Top := 0;
                          Width := StrToInt( ListaLongitud.Strings[ i ] );
                          Height := StrToInt( ListaLongitud.Strings[ i ] );
                          AutoSize := FALSE;
                          WordWrap := TRUE;
                          If ListaAlineacion.Strings[ i ] = 'I' Then
                            AlignMent := taLeftJustify
                          Else If ListaAlineacion.Strings[ i ] = 'C' Then
                            AlignMent := taCenter
                          Else If ListaAlineacion.Strings[ i ] = 'D' Then
                            AlignMent := taRightJustify;
                          DataPipeline := ppDBPipeline1;
                          DataField := ListaCampos.Strings[ i ];
                          //OnGetMemo := tFormateadoCampoMemo;
                          Tag := i;
                          Name := 'Campo' + IntToStr( i );
                          UserName := 'Campo' + IntToStr( i );
                          Visible := TRUE;
                          Transparent := TRUE;
                          Font.Name := ppLabelTituloListado.Font.Name;
                          Font.Size := Trunc( TamanyoFuente );
                          //ShiftRelativeTo := tRegiones;
                          Stretch := FALSE;
                          Font.Style := [ ];
                        End;
                    End
                  Else If tTablaConsulta.FieldByName( ListaCampos.Strings[ i ] ).DataType = ftMemo Then
                    Begin
                      tCampoDBMemo := TppDBMemo.Create( ppReportConsultaMant );
                      With tCampoDBMemo Do
                        Begin
                          //Parent := BandaDetalle;
                          Band := ppDetalle;
                          Left := PosicionCampo;
                          Top := 0;
                          Width := StrToInt( ListaLongitud.Strings[ i ] );
                          Height := 15;
                          AutoSize := FALSE;
                          WordWrap := TRUE;
                          If ListaAlineacion.Strings[ i ] = 'I' Then
                            AlignMent := taLeftJustify
                          Else If ListaAlineacion.Strings[ i ] = 'C' Then
                            AlignMent := taCenter
                          Else If ListaAlineacion.Strings[ i ] = 'D' Then
                            AlignMent := taRightJustify;
                          DataPipeline := ppDBPipeline1;
                          DataField := ListaCampos.Strings[ i ];
                          //OnGetMemo := tFormateadoCampoMemo;
                          Tag := i;
                          Name := 'Campo' + IntToStr( i );
                          UserName := 'Campo' + IntToStr( i );
                          Visible := TRUE;
                          Transparent := TRUE;
                          Font.Name := ppLabelTituloListado.Font.Name;
                          Font.Size := Trunc( TamanyoFuente );
                          //ShiftRelativeTo := tRegiones;
                          Stretch := TRUE;
                          Font.Style := [ ];
                        End;
                    End
                  Else
                    Begin
                      tCampo := TppDBText.Create( ppReportConsultaMant );
                      With tCampo Do
                        Begin
                          //Parent := BandaDetalle;
                          Band := ppDetalle;
                          Left := PosicionCampo;
                          Top := 0;
                          Width := StrToInt( ListaLongitud.Strings[ i ] );
                          Height := 15;
                          AutoSize := FALSE;
                          WordWrap := TRUE;
                          If ListaAlineacion.Strings[ i ] = 'I' Then
                            AlignMent := taLeftJustify
                          Else If ListaAlineacion.Strings[ i ] = 'C' Then
                            AlignMent := taCenter
                          Else If ListaAlineacion.Strings[ i ] = 'D' Then
                            AlignMent := taRightJustify;
                          DataPipeline := ppDBPipeline1;
                          DataField := ListaCampos.Strings[ i ];
                          OnGetText := tFormateadoCampo;
                          DisplayFormat := ListaFormatoCampos.Strings[ i ];
                          Tag := i;
                          Name := 'Campo' + IntToStr( i );
                          UserName := 'Campo' + IntToStr( i );
                          Visible := TRUE;
                          Transparent := TRUE;
                          Font.Name := ppLabelTituloListado.Font.Name;
                          Font.Size := Trunc( TamanyoFuente );
                          Font.Style := [ ];
                        End;
                    End;
                End
              Else
                Begin
                  tCampoFormula := TppVariable.Create( ppReportConsultaMant );
                  With tCampoFormula Do
                    Begin
                      //Parent := BandaDetalle;
                      Band := ppDetalle;
                      Left := PosicionCampo;
                      Top := 0;
                      Width := StrToInt( ListaLongitud.Strings[ i ] );
                      Height := 15;
                      AutoSize := FALSE;
                      WordWrap := TRUE;
                      If ListaAlineacion.Strings[ i ] = 'I' Then
                        AlignMent := taLeftJustify
                      Else If ListaAlineacion.Strings[ i ] = 'C' Then
                        AlignMent := taCenter
                      Else If ListaAlineacion.Strings[ i ] = 'D' Then
                        AlignMent := taRightJustify;
                      {Mask := ListaFormatoCampos.Strings[ i ];}
                      OnGetText := tCalculoFormulas;
                      Tag := i;
                      Name := 'Campo' + IntToStr( i );
                      UserName := 'Campo' + IntToStr( i );
                      Visible := TRUE;
                      Transparent := TRUE;
                      Font.Name := ppLabelTituloListado.Font.Name;
                      Font.Size := Trunc( TamanyoFuente );
                      Font.Style := [ ];
                    End;
                End;
            End;

          PosicionCampo := PosicionCampo + StrToInt( ListaLongitud.Strings[ i ] ) + 4;
        End;

  PosicionCampo := 0;
  With ListaSumados Do
    For i := 0 To ( Count - 1 ) Do
      If ( StrToInt( ListaLongitud.Strings[ i ] ) > 0 ) Then
        If ( Strings[ i ] = 'S' ) Then
          Begin
            tLineas := TppLine.Create( ppReportConsultaMant );
            With tLineas Do
              Begin
                //Parent := BandaCabeceraPagina;
                Band := ppPiePagina;
                Left := PosicionCampo;
                Top := 0;
                Width := StrToInt( ListaLongitud.Strings[ i ] );
                Height := 2;
                Visible := TRUE;
                //Transparent := TRUE;
              End;

            With ppReportConsultaMant Do
              Begin
                tCampoFormula := TppVariable.Create( ppReportConsultaMant );
                With tCampoFormula Do
                  Begin
                    //Parent := BandaPiePagina;
                    Band := ppPiePagina;
                    Left := PosicionCampo;
                    Top := 4;
                    Width := StrToInt( ListaLongitud.Strings[ i ] );
                    Height := 15;
                    AutoSize := FALSE;
                    WordWrap := TRUE;
                    If ListaAlineacion.Strings[ i ] = 'I' Then
                      AlignMent := taLeftJustify
                    Else If ListaAlineacion.Strings[ i ] = 'C' Then
                      AlignMent := taCenter
                    Else If ListaAlineacion.Strings[ i ] = 'D' Then
                      AlignMent := taRightJustify;
                    {Mask := ListaFormatoCampos.Strings[ i ];}
                    OnGetText := tCalculoFormulasSumatorio;
                    Tag := i;
                    Name := 'SumCampo' + IntToStr( i );
                    UserName := 'SumCampo' + IntToStr( i );
                    Visible := TRUE;
                    Transparent := TRUE;
                    Font.Name := ppLabelTituloListado.Font.Name;
                    Font.Size := Trunc( TamanyoFuente );
                    Font.Style := [ fsBold ];
                  End;
              End;

            PosicionCampo := PosicionCampo + StrToInt( ListaLongitud.Strings[ i ] ) + 4;
          End
        Else
          PosicionCampo := PosicionCampo + StrToInt( ListaLongitud.Strings[ i ] ) + 4;
end;

procedure TFormRptConsultaMantenimientos.tCalculoFormulas( sender: TObject; Var Value: String );
begin
  Value := CalcularExpresion( ListaFormulasExpresion.Strings[ ( Sender As TppVariable ).Tag ] );

  If ( ListaSumados.Strings[ ( Sender As TppVariable ).Tag ] = 'S' ) Then
    ListaTotalesSumados.Strings[ ( Sender As TppVariable ).Tag ] := FloatToStr(
      StrToFloat( ListaTotalesSumados.Strings[ ( Sender As TppVariable ).Tag ] ) + StrToFloat( Value ) );

  If ListaFormatoCampos.Strings[ ( Sender As TppVariable ).Tag ] <> '' Then
    Value := FormatFloat( ListaFormatoCampos.Strings[ ( Sender As TppVariable ).Tag ],
                                                 StrToFloat( Value ) );
end;
Responder Con Cita
  #7  
Antiguo 16-10-2008
JosepGA JosepGA is offline
Miembro
 
Registrado: jun 2007
Ubicación: Tarragona
Posts: 166
Poder: 17
JosepGA Va por buen camino
tercera parte:

Código Delphi [-]
procedure TFormRptConsultaMantenimientos.tCalculoFormulasSumatorio( sender: TObject; Var Value: String );
begin
  If ListaFormatoCampos.Strings[ ( Sender As TppVariable ).Tag ] <> '' Then
    Value := FormatFloat( ListaFormatoCampos.Strings[ ( Sender As TppVariable ).Tag ],
                                               StrToFloat( ListaTotalesSumados.Strings[ ( Sender As TppVariable ).Tag ] ) )
  Else
    Value := ListaTotalesSumados.Strings[ ( Sender As TppVariable ).Tag ];
end;

procedure TFormRptConsultaMantenimientos.tFormateadoCampo( sender: TObject; Var Value: String );
Var
  Valor : String;
  ValoresFormato : String;
  PosicionComa : LongInt;
  ValorFinal : String;
  EncontradoComa : Boolean;
  PosicionValor : LongInt;
  i : LongInt;
begin
  Valor := Value; //( Sender As TppDBText ).DataPipeline.FieldByName( ( Sender As TppDBText ).DataField ).AsString;
  ValoresFormato := ListaValoresSustituir.Strings[ ( Sender As TppDBText ).Tag ];

  If ( ValoresFormato <> '' ) Then
    Begin
      ValorFinal := Value;
      EncontradoComa := FALSE;
      PosicionValor := Pos( Valor, ValoresFormato );
      If PosicionValor <> 0 Then
        For i := PosicionValor To Length( ValoresFormato ) Do
          If ( Copy( ValoresFormato, i, 1 ) = ']' ) Then
            Break
          Else If ( Copy( ValoresFormato, i, 1 ) <> ',' ) And EncontradoComa Then
            ValorFinal := ValorFinal + Copy( ValoresFormato, i, 1 )
          Else If ( Copy( ValoresFormato, i, 1 ) = ',' ) Then
            Begin
              EncontradoComa := TRUE;
              ValorFinal := '';
            End;

      Value := Trim( ValorFinal );
    End;
  {Else
    Value := Valor;}
end;

function TFormRptConsultaMantenimientos.CalcularExpresion( Expresion : String ) : String;
var
  i, j : LongInt;
  Posicion : LongInt;
  Operandos : String;
  CampoTabla : String;
  Variable : Char;
  ExpresionObtenida : String;
  SubExpresion : String;
  SubValor : String;
  Caracter : String;
begin
  Try
    Expresion := Trim( Expresion );
    i := 1;
    Calculadora.Expression := '';
    Variable := 'A';
    ExpresionObtenida := '';
    While i <= Length( Expresion ) Do
      Begin
        Expresion := Trim( Expresion );
        If ( Pos( '[', Expresion ) <> 0 ) Then
          Begin
            Posicion := Pos( '[', Expresion ) - 1;
            Operandos := Trim( Copy( Expresion, i , Posicion ) );
            Delete( Expresion, i, Posicion );
            If ( Operandos <> '' ) Then
              Begin
                SubExpresion := '';
                SubValor := '';
                j := 0;
                While j < Length( Operandos ) Do
                  Begin
                    Inc( j );

                    Caracter := Copy( Operandos, j, 1 );
                    If ( Caracter <> ' ' ) Then
                      If ( ( Caracter >= '0' ) And ( Caracter <= '9' ) ) Or
                        ( Caracter = '.' ) Then
                        SubValor := SubValor + Caracter
                      Else
                        Begin
                          If ( SubValor <> '' ) Then
                            Begin
                              Calculadora.SetVariable( Variable, StrToFloat( SubValor ) );
                              SubExpresion := SubExpresion + '(' + Variable + ')';

                              Variable := Chr( Ord( Variable ) + 1 );

                              SubValor := '';
                            End;

                          SubExpresion := SubExpresion + Caracter;
                        End;
                  End;

                If ( SubValor <> '' ) Then
                  Begin
                    Calculadora.SetVariable( Variable, StrToFloat( SubValor ) );
                    SubExpresion := SubExpresion + '(' + Variable + ')';

                    Variable := Chr( Ord( Variable ) + 1 );

                    SubValor := '';
                  End;

                ExpresionObtenida := ExpresionObtenida + SubExpresion;
              End;
            i := 1;
            Expresion := Trim( Expresion );

            If ( Copy( Expresion, i, 1 ) = '[' ) Then
              Begin
                Posicion := Pos( ']', Expresion );
                CampoTabla := Trim( Copy( Expresion, i+1 , Posicion-2 ) );
                Delete( Expresion, i, Posicion );
                i := 0;
                Calculadora.SetVariable( Variable, tTablaConsulta.FieldByName( CampoTabla ).AsFloat );
                ExpresionObtenida := ExpresionObtenida + '(' + Variable + ')';

                Variable := Chr( Ord( Variable ) + 1 );
              End
          End
        Else
          Begin
            If ( Expresion <> '' ) Then
              Begin
                SubExpresion := '';
                SubValor := '';
                j := 0;
                While j < Length( Expresion ) Do
                  Begin
                    Inc( j );

                    Caracter := Copy( Expresion, j, 1 );
                    If ( Caracter <> ' ' ) Then
                      If ( ( Caracter >= '0' ) And ( Caracter <= '9' ) ) Or
                        ( Caracter = '.' ) Then
                        SubValor := SubValor + Caracter
                      Else
                        Begin
                          If ( SubValor <> '' ) Then
                            Begin
                              Calculadora.SetVariable( Variable, StrToFloat( SubValor ) );
                              SubExpresion := SubExpresion + '(' + Variable + ')';

                              Variable := Chr( Ord( Variable ) + 1 );

                              SubValor := '';
                            End;

                          SubExpresion := SubExpresion + Caracter;
                        End;
                  End;

                If ( SubValor <> '' ) Then
                  Begin
                    Calculadora.SetVariable( Variable, StrToFloat( SubValor ) );
                    SubExpresion := SubExpresion + '(' + Variable + ')';

                    Variable := Chr( Ord( Variable ) + 1 );

                    SubValor := '';
                  End;

                ExpresionObtenida := ExpresionObtenida + SubExpresion;
                Expresion := '';
              End;

            i := 0;
          End;

        Inc( i );
      End;

    Calculadora.Expression := ExpresionObtenida;
    Result := FloatToStr( Calculadora.Value );
  Except
    Result := '0';
  End;
end;

procedure TFormRptConsultaMantenimientos.ppVariable2GetText(
  Sender: TObject; var Text: String);
begin
  Text := NombreEmpresaCtb;
end;

procedure TFormRptConsultaMantenimientos.tBuscarDatoCampoRelacionado(Sender: TObject; var Text: String);
Var
  PosicionArray : LongInt;
  TablaRelacionada : String;
  IndiceRango : String;
  CamposMaestro : String;
  CamposRelacionado : String;
  CampoDevolver : String;
  PosicionPuntoComa : LongInt;
  CampoRangoMaestro : String;
  CampoRangoRelacionado : String;
begin
  PosicionArray := ( Sender As TppDBText ).Tag;

  CamposMaestro := ListaTablasRelacionadasCamposMaestro[ PosicionArray ];
  CamposRelacionado := ListaTablasRelacionadasCamposRelacionado[ PosicionArray ];

  CampoDevolver := ListaTablasRelacionadasCampoDevolver[ PosicionArray ];

  Text := '';
  Try
    ListaTablasRelacionadas[ PosicionArray ].SetRangeStart;
    While Length( CamposRelacionado ) > 0 Do
      Begin
        PosicionPuntoComa := Pos( ';', CamposMaestro );
        If PosicionPuntoComa = 0 Then
          PosicionPuntoComa := Length( CamposMaestro ) + 1;
        CampoRangoMaestro := Trim( Copy( CamposMaestro, 1, PosicionPuntoComa - 1 ) );
        Delete( CamposMaestro, 1, PosicionPuntoComa );

        PosicionPuntoComa := Pos( ';', CamposRelacionado );
        If PosicionPuntoComa = 0 Then
          PosicionPuntoComa := Length( CamposRelacionado ) + 1;
        CampoRangoRelacionado := Trim( Copy( CamposRelacionado, 1, PosicionPuntoComa - 1 ) );
        Delete( CamposRelacionado, 1, PosicionPuntoComa );

        If tTablaConsulta.FieldByName( CampoRangoMaestro ).DataType = ftString Then
          ListaTablasRelacionadas[ PosicionArray ].FieldByName( CampoRangoRelacionado ).AsString :=
            tTablaConsulta.FieldByName( CampoRangoMaestro ).AsString
        Else If tTablaConsulta.FieldByName( CampoRangoMaestro ).DataType = ftInteger Then
          ListaTablasRelacionadas[ PosicionArray ].FieldByName( CampoRangoRelacionado ).AsInteger :=
            tTablaConsulta.FieldByName( CampoRangoMaestro ).AsInteger
        Else If tTablaConsulta.FieldByName( CampoRangoMaestro ).DataType = ftSmallInt Then
          ListaTablasRelacionadas[ PosicionArray ].FieldByName( CampoRangoRelacionado ).AsInteger :=
            tTablaConsulta.FieldByName( CampoRangoMaestro ).AsInteger
        Else If tTablaConsulta.FieldByName( CampoRangoMaestro ).DataType = ftFloat Then
          ListaTablasRelacionadas[ PosicionArray ].FieldByName( CampoRangoRelacionado ).AsFloat :=
            tTablaConsulta.FieldByName( CampoRangoMaestro ).AsFloat
        Else If tTablaConsulta.FieldByName( CampoRangoMaestro ).DataType = ftDateTime Then
          ListaTablasRelacionadas[ PosicionArray ].FieldByName( CampoRangoRelacionado ).AsDateTime :=
            tTablaConsulta.FieldByName( CampoRangoMaestro ).AsDateTime
        Else If tTablaConsulta.FieldByName( CampoRangoMaestro ).DataType = ftDate Then
          ListaTablasRelacionadas[ PosicionArray ].FieldByName( CampoRangoRelacionado ).AsDateTime :=
            tTablaConsulta.FieldByName( CampoRangoMaestro ).AsDateTime
        Else If tTablaConsulta.FieldByName( CampoRangoMaestro ).DataType = ftTime Then
          ListaTablasRelacionadas[ PosicionArray ].FieldByName( CampoRangoRelacionado ).AsDateTime :=
            tTablaConsulta.FieldByName( CampoRangoMaestro ).AsDateTime;
      End;

    CamposMaestro := ListaTablasRelacionadasCamposMaestro[ PosicionArray ];
    CamposRelacionado := ListaTablasRelacionadasCamposRelacionado[ PosicionArray ];

    ListaTablasRelacionadas[ PosicionArray ].SetRangeEnd;
    While Length( CamposRelacionado ) > 0 Do
      Begin
        PosicionPuntoComa := Pos( ';', CamposMaestro );
        If PosicionPuntoComa = 0 Then
          PosicionPuntoComa := Length( CamposMaestro ) + 1;
        CampoRangoMaestro := Trim( Copy( CamposMaestro, 1, PosicionPuntoComa - 1 ) );
        Delete( CamposMaestro, 1, PosicionPuntoComa );

        PosicionPuntoComa := Pos( ';', CamposRelacionado );
        If PosicionPuntoComa = 0 Then
          PosicionPuntoComa := Length( CamposRelacionado ) + 1;
        CampoRangoRelacionado := Trim( Copy( CamposRelacionado, 1, PosicionPuntoComa - 1 ) );
        Delete( CamposRelacionado, 1, PosicionPuntoComa );

        If tTablaConsulta.FieldByName( CampoRangoMaestro ).DataType = ftString Then
          ListaTablasRelacionadas[ PosicionArray ].FieldByName( CampoRangoRelacionado ).AsString :=
            tTablaConsulta.FieldByName( CampoRangoMaestro ).AsString
        Else If tTablaConsulta.FieldByName( CampoRangoMaestro ).DataType = ftInteger Then
          ListaTablasRelacionadas[ PosicionArray ].FieldByName( CampoRangoRelacionado ).AsInteger :=
            tTablaConsulta.FieldByName( CampoRangoMaestro ).AsInteger
        Else If tTablaConsulta.FieldByName( CampoRangoMaestro ).DataType = ftSmallInt Then
          ListaTablasRelacionadas[ PosicionArray ].FieldByName( CampoRangoRelacionado ).AsInteger :=
            tTablaConsulta.FieldByName( CampoRangoMaestro ).AsInteger
        Else If tTablaConsulta.FieldByName( CampoRangoMaestro ).DataType = ftFloat Then
          ListaTablasRelacionadas[ PosicionArray ].FieldByName( CampoRangoRelacionado ).AsFloat :=
            tTablaConsulta.FieldByName( CampoRangoMaestro ).AsFloat
        Else If tTablaConsulta.FieldByName( CampoRangoMaestro ).DataType = ftDateTime Then
          ListaTablasRelacionadas[ PosicionArray ].FieldByName( CampoRangoRelacionado ).AsDateTime :=
            tTablaConsulta.FieldByName( CampoRangoMaestro ).AsDateTime
        Else If tTablaConsulta.FieldByName( CampoRangoMaestro ).DataType = ftDate Then
          ListaTablasRelacionadas[ PosicionArray ].FieldByName( CampoRangoRelacionado ).AsDateTime :=
            tTablaConsulta.FieldByName( CampoRangoMaestro ).AsDateTime
        Else If tTablaConsulta.FieldByName( CampoRangoMaestro ).DataType = ftTime Then
          ListaTablasRelacionadas[ PosicionArray ].FieldByName( CampoRangoRelacionado ).AsDateTime :=
            tTablaConsulta.FieldByName( CampoRangoMaestro ).AsDateTime;
      End;

    ListaTablasRelacionadas[ PosicionArray ].ApplyRange;
    If ( ListaTablasRelacionadas[ PosicionArray ].RecordCount <> 0 ) Then
      If ListaFormatoCampos.Strings[ PosicionArray ] <> '' Then
        Text := FormatFloat( ListaFormatoCampos.Strings[ PosicionArray ],
                              ListaTablasRelacionadas[ PosicionArray ].FieldByName( CampoDevolver ).AsFloat )
      Else
        Text := ListaTablasRelacionadas[ PosicionArray ].FieldByName( CampoDevolver ).AsString;
  Finally
  End;
end;
Responder Con Cita
  #8  
Antiguo 16-10-2008
JosepGA JosepGA is offline
Miembro
 
Registrado: jun 2007
Ubicación: Tarragona
Posts: 166
Poder: 17
JosepGA Va por buen camino
ultima parte (un saludo):

Código Delphi [-]
procedure TFormRptConsultaMantenimientos.FormCreate(Sender: TObject);
begin
  TituloDelReport := '';

  ListaCampos := tStringList.Create;
  ListaTitulos := tStringList.Create;
  ListaFormulas := tStringList.Create;
  ListaFormulasExpresion := tStringList.Create;
  ListaLongitud := tStringList.Create;
  ListaAlineacion := tStringList.Create;
  ListaFormatoCampos := tStringList.Create;
  ListaSumados := tStringList.Create;
  ListaCamposConRango := tStringList.Create;
  ListaRangosDesde := tStringList.Create;
  ListaRangosHasta := tStringList.Create;
  ListaValoresSustituir := tStringList.Create;
  //ListaBDTablasRelacionadasSQL := tStringList.Create;
  ListaTablasRelacionadasSQL := tStringList.Create;

  ListaTotalesSumados := tStringList.Create;

  ListaCampos.Sorted := FALSE;
  ListaTitulos.Sorted := FALSE;
  ListaFormulas.Sorted := FALSE;
  ListaFormulasExpresion.Sorted := FALSE;
  ListaLongitud.Sorted := FALSE;
  ListaAlineacion.Sorted := FALSE;
  ListaFormatoCampos.Sorted := FALSE;
  ListaSumados.Sorted := FALSE;
  ListaCamposConRango.Sorted := FALSE;
  ListaRangosDesde.Sorted := FALSE;
  ListaRangosHasta.Sorted := FALSE;
  ListaValoresSustituir.Sorted := FALSE;
  //ListaBDTablasRelacionadasSQL.Sorted := FALSE;
  ListaTablasRelacionadasSQL.Sorted := FALSE;

  ListaTotalesSumados.Sorted := FALSE;
end;

procedure TFormRptConsultaMantenimientos.FormDestroy(Sender: TObject);
Var
  i : Integer;
begin
  For i := 0 To ListaTablasRelacionadasSQL.Count - 1 Do
    If ListaTablasRelacionadasSQL.Strings[ i ] <> '' Then
      ListaTablasRelacionadas[ i ].Close;

  ListaCampos.Free;
  ListaTitulos.Free;
  ListaFormulas.Free;
  ListaFormulasExpresion.Free;
  ListaLongitud.Free;
  ListaAlineacion.Free;
  ListaFormatoCampos.Free;
  ListaSumados.Free;
  ListaCamposConRango.Free;
  ListaRangosDesde.Free;
  ListaRangosHasta.Free;
  ListaValoresSustituir.Free;
  //ListaBDTablasRelacionadasSQL.Free;
  ListaTablasRelacionadasSQL.Free;

  ListaTotalesSumados.Free;

  tContabilidades.Active := FALSE;
  tEmpresasContables.Active := FALSE;
  tLogoClientes.Active := FALSE;
  tEmpresasComercial.Active := FALSE;
  tParamClientes.Active := FALSE;

  //Session.RemoveAllPasswords;
end;

procedure TFormRptConsultaMantenimientos.ppEtiquetaCampoClick(Sender, aDrawCommand: TObject);
begin
  Try
    If tTablaConsulta.IndexFieldNames <> Copy( ( Sender As TppLabel ).Name, 5, Length( ( Sender As TppLabel ).Name ) - 4 ) Then
      Try
        tTablaConsulta.IndexFieldNames := Copy( ( Sender As TppLabel ).Name, 5, Length( ( Sender As TppLabel ).Name ) - 4 );

        //FormPrevisualizacionRts.ppVisualizador.RegenerateReport;
        ppReportConsultaMant.Reset;
      Except
        tTablaConsulta.IndexFieldNames := '';

        Try
          //FormPrevisualizacionRts.ppVisualizador.RegenerateReport;
          ppReportConsultaMant.Reset;
        Except
        End;
      End;
  Except
  End;
end;

Procedure TFormRptConsultaMantenimientos.ActivarConexionesModuloDeDatos( Const tSQLConexionGeneralOrigen, tSQLConexionGestionOrigen, tSQLConexionContabilidadOrigen : tSQLConnection );
Begin
  If tSQLConexionGeneralOrigen <> Nil Then
    Begin
      //FormDMDatosEdiciones.tSQLConexionGeneral := tSQLConexionGeneralOrigen;
      FormRptConsultaMantenimientos.ActivarConexionGeneral;
    End;

  If tSQLConexionGestionOrigen <> Nil Then
    Begin
      //FormDMDatosEdiciones.tSQLConexionGestion := tSQLConexionGestionOrigen;
      FormRptConsultaMantenimientos.ActivarConexionGestion;
    End;

  If tSQLConexionContabilidadOrigen <> Nil Then
    Try
      //FormRptConsultaMantenimientos.tSQLConexionContabilidad := tSQLConexionContabilidadOrigen;
      FormRptConsultaMantenimientos.ActivarConexionContabilidad;
    Except
    End;
End;

Procedure TFormRptConsultaMantenimientos.DesactivarConexionesModuloDeDatos( Const tSQLConexionGeneralOrigen, tSQLConexionGestionOrigen, tSQLConexionContabilidadOrigen : tSQLConnection );
Begin
  If tSQLConexionGeneralOrigen <> Nil Then
    FormRptConsultaMantenimientos.DesactivarConexionGeneral;

  If tSQLConexionGestionOrigen <> Nil Then
    FormRptConsultaMantenimientos.DesactivarConexionGestion;

  If tSQLConexionContabilidadOrigen <> Nil Then
    Try
      FormRptConsultaMantenimientos.DesactivarConexionContabilidad;
    Except
    End;
End;

Procedure TFormRptConsultaMantenimientos.ActivarConexionGeneral;
Begin
  ChDir( setRutaEjecutable );
  tSQLConexionGeneral.ConnectionName := 'General';
  tSQLConexionGeneral.DriverName := setNombreDriverBD;
  tSQLConexionGeneral.LoadParamsFromIniFile( 'Cfgs.Ini' );
  tSQLConexionGeneral.Params.Values[ 'Password' ] := setPassword;
  tSQLConexionGeneral.LibraryName := setNombreLibrariaBD;
  tSQLConexionGeneral.VendorLib := setLibrariaVendedorBD;
  tSQLConexionGeneral.GetDriverFunc := setNombreFuncionBD;
  tSQLConexionGeneral.Connected := TRUE;
End;

Procedure TFormRptConsultaMantenimientos.ActivarConexionGestion;
Begin
  If ( setEmpresaActual <> '' ) Then
    Begin
      ChDir( setRutaEjecutable );
      tSQLConexionGestion.DriverName := setNombreDriverBD;
      tSQLConexionGestion.LoadParamsFromIniFile(  'Cfgs.Ini' );
      tSQLConexionGestion.Params.Values[ 'DataBase' ] := ExtractFileDir( tSQLConexionGeneral.Params.Values[ 'DataBase' ] ) + '\GESTION-' + setEmpresaActual + '.FDB';
      tSQLConexionGestion.Params.Values[ 'Password' ] := setPassword;
      tSQLConexionGestion.LibraryName :=  setNombreLibrariaBD;
      tSQLConexionGestion.VendorLib :=  setLibrariaVendedorBD;
      tSQLConexionGestion.GetDriverFunc := setNombreFuncionBD;
      tSQLConexionGestion.Connected := TRUE;
    End;
End;

Procedure TFormRptConsultaMantenimientos.ActivarConexionContabilidad;
Begin
  If ( setEmpresaContable <> '' ) Then
    Try
      ChDir( setRutaEjecutable );
      tSQLConexionContabilidad.DriverName := setNombreDriverBD;
      tSQLConexionContabilidad.LoadParamsFromIniFile(  'Cfgs.Ini' );
      tSQLConexionContabilidad.Params.Values[ 'DataBase' ] := ExtractFileDir( tSQLConexionGeneral.Params.Values[ 'DataBase' ] ) + '\CONTABILIDAD-' + setEmpresaContable + '.FDB';
      tSQLConexionContabilidad.Params.Values[ 'Password' ] := setPassword;
      tSQLConexionContabilidad.LibraryName :=  setNombreLibrariaBD;
      tSQLConexionContabilidad.VendorLib :=  setLibrariaVendedorBD;
      tSQLConexionContabilidad.GetDriverFunc := setNombreFuncionBD;
      tSQLConexionContabilidad.Connected := TRUE;
    Except
    End;
End;

Procedure TFormRptConsultaMantenimientos.DesactivarConexionGeneral;
Begin
  If tSQLConexionGeneral.Connected Then
    Begin

      tSQLConexionGeneral.Connected := FALSE;
    End;
End;

Procedure TFormRptConsultaMantenimientos.DesactivarConexionGestion;
Begin
  If tSQLConexionGestion.Connected Then
    Begin

      tSQLConexionGestion.Connected := FALSE;
    End;
End;

Procedure TFormRptConsultaMantenimientos.DesactivarConexionContabilidad;
Begin
  If tSQLConexionContabilidad.Connected Then
    Begin

      tSQLConexionContabilidad.Connected := FALSE;
    End;
End;

end.
Responder Con Cita
  #9  
Antiguo 16-10-2008
sargento elias sargento elias is offline
Miembro
 
Registrado: mar 2008
Posts: 109
Poder: 17
sargento elias Va por buen camino
Gracias, voy a probarlo, y a estudiarlo xD Gracias.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Report Builder yokey Impresión 3 10-06-2008 14:34:50
Report Builder 7 dmagui OOP 0 15-05-2007 01:53:06
Cabiar orientacion del informe en fast report fabitheking Impresión 2 25-01-2006 20:42:02
Report Builder 7.0 MarioATamborini Impresión 2 01-04-2004 00:58:40
report builder jsanchez Impresión 0 27-05-2003 01:08:47


La franja horaria es GMT +2. Ahora son las 13:36:13.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi