Ver Mensaje Individual
  #6  
Antiguo 16-10-2008
JosepGA JosepGA is offline
Miembro
 
Registrado: jun 2007
Ubicación: Tarragona
Posts: 166
Reputación: 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