Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #8  
Antiguo 26-09-2007
[FGarcia] FGarcia is offline
Miembro Premium
 
Registrado: sep 2005
Ubicación: Cordoba, Veracruz, México
Posts: 1.123
Poder: 22
FGarcia Va por buen camino
Cuando es la hora exacta se llama a este procedimiento el cual:

1. Ejecuta la consulta.
2. convierte la cadena iHora a un Datetime
3. Extrae los componentes de ese datetime y compara la hora
4. de acuerdo a la hora escribe en el stringgrid

Código Delphi [-]
procedure TfrmMain.ActualizaCadaHora(iHora: string; eHora: string) ;
var
  estaHora: Tdatetime;
  consultaVacia: Boolean;
  esteTotal: string ;
  etHora,etMin,etSeg,etMseg: word;
begin
  consultaVacia := False;
  with QyHora do
    begin
      Close ;
      SQL.Clear ;
      SQL.Add('SELECT COUNT(*) AS HSacos, ' +
              'SUM (Peso) AS [HTotal] ' +
              'FROM Captura WHERE (HoraFecha BETWEEN :FIni AND :FFin)');
      Parameters.ParamByName('FIni').Value := iHora;
      Parameters.ParamByName('FFin').Value := eHora;
      Open ;
      if (QyHora.RecordCount = 0) then
        consultaVacia := True;
    end;
 
  if not consultaVacia then
    begin
      //Convierto la cadena iHora a un formato de datetime
      estaHora := StrToDateTime(iHora);
      DecodeTime(estaHora, etHora,etMin,etSeg,etMseg);
      //Pruebo que este campo de la consulta no sea NULL
      if QyHora.Fields.FieldByName('HTotal').IsNull  then
        esteTotal := '0'
      else
        begin
          esteTotal := QyHora.FieldValues['HTotal'];
          esteTotal := Format('%.0n', [strtoFloat(esteTotal)]);
        end;
      case etHora of
      0:  begin
            StringGrid1.Cells[1,1] := QyHora.FieldValues['HSacos'];
            StringGrid1.Cells[2,1] := esteTotal;
          end;
      1:  begin
            StringGrid1.Cells[1,2] := QyHora.FieldValues['HSacos'];
            StringGrid1.Cells[2,2] := esteTotal;
          end;
      2:  begin
            StringGrid1.Cells[1,3] := QyHora.FieldValues['HSacos'];
            StringGrid1.Cells[2,3] := esteTotal;
          end;
      3:  begin
            StringGrid1.Cells[1,4] := QyHora.FieldValues['HSacos'];
            StringGrid1.Cells[2,4] := esteTotal;
          end;
      4:  begin
            StringGrid1.Cells[1,5] := QyHora.FieldValues['HSacos'];
            StringGrid1.Cells[2,5] := esteTotal;
          end;
      5:  begin
            StringGrid1.Cells[1,6] := QyHora.FieldValues['HSacos'];
            StringGrid1.Cells[2,6] := esteTotal;
          end;
      6:  begin
            StringGrid1.Cells[1,7] := QyHora.FieldValues['HSacos'];
            StringGrid1.Cells[2,7] := esteTotal;
            Stringgrid1.TopRow := 7;
          end;
      7:  begin
            StringGrid1.Cells[1,8] := QyHora.FieldValues['HSacos'];
            StringGrid1.Cells[2,8] := esteTotal;
          end;
      8:  begin
            StringGrid1.Cells[1,9] := QyHora.FieldValues['HSacos'];
            StringGrid1.Cells[2,9] := esteTotal;
          end;
      9:  begin
            StringGrid1.Cells[1,10] := QyHora.FieldValues['HSacos'];
            StringGrid1.Cells[2,10] := esteTotal;
          end;
      10: begin
            StringGrid1.Cells[1,11] := QyHora.FieldValues['HSacos'];
            StringGrid1.Cells[2,11] := esteTotal;
          end;
      11: begin
            StringGrid1.Cells[1,12] := QyHora.FieldValues['HSacos'];
            StringGrid1.Cells[2,12] := esteTotal;
          end;
      12: begin
            StringGrid1.Cells[1,13] := QyHora.FieldValues['HSacos'];
            StringGrid1.Cells[2,13] := esteTotal;
          end;
      13: begin
            StringGrid1.Cells[1,14] := QyHora.FieldValues['HSacos'];
            StringGrid1.Cells[2,14] := esteTotal;
          end;
      14: begin
            StringGrid1.Cells[1,15] := QyHora.FieldValues['HSacos'];
            StringGrid1.Cells[2,15] := esteTotal;
            Stringgrid1.TopRow := 15;
          end;
      15: begin
            StringGrid1.Cells[1,16] := QyHora.FieldValues['HSacos'];
            StringGrid1.Cells[2,16] := esteTotal;
          end;
      16: begin
            StringGrid1.Cells[1,17] := QyHora.FieldValues['HSacos'];
            StringGrid1.Cells[2,17] := esteTotal;
          end;
      17: begin
            StringGrid1.Cells[1,18] := QyHora.FieldValues['HSacos'];
            StringGrid1.Cells[2,18] := esteTotal;
          end;
      18: begin
            StringGrid1.Cells[1,19] := QyHora.FieldValues['HSacos'];
            StringGrid1.Cells[2,19] := esteTotal;
          end;
      19: begin
            StringGrid1.Cells[1,20] := QyHora.FieldValues['HSacos'];
            StringGrid1.Cells[2,20] := esteTotal;
          end;
      20: begin
            StringGrid1.Cells[1,21] := QyHora.FieldValues['HSacos'];
            StringGrid1.Cells[2,21] := esteTotal;
          end;
      21: begin
            StringGrid1.Cells[1,22] := QyHora.FieldValues['HSacos'];
            StringGrid1.Cells[2,22] := esteTotal;
          end;
      22: begin
            StringGrid1.Cells[1,23] := QyHora.FieldValues['HSacos'];
            StringGrid1.Cells[2,23] := esteTotal;
            Stringgrid1.TopRow := 23;
          end;
      23: begin
            StringGrid1.Cells[1,24] := QyHora.FieldValues['HSacos'];
            StringGrid1.Cells[2,24] := esteTotal;
          end;
      end;
    end;
end;

como dije al principio del mensaje si la hora de generar los reportes no coincide con la actualizacion de el stringgrid los reportes se generan perfectamente, solo es en la coincidencia de hora donde ya los reportes no se generan.

Por cierto ya cambie las variables a local para evitar dudas. Y si, esa idea se me ocurrio basti de que sea un problema con la actualizacion del timer.
Responder Con Cita
 



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
Ayuda con una consulta continua vaporlalibre Varios 15 05-12-2006 18:20:25
Lectura continua de Archivo friendspark API de Windows 2 02-02-2006 16:27:52
Ejecución de procedimiento almacenado jfgaliano SQL 4 12-12-2005 11:36:15
Reproduccion continua de un video avi alexmucho C++ Builder 1 09-09-2004 11:58:21
el problema continua! merlin Impresión 1 15-01-2004 15:01:18


La franja horaria es GMT +2. Ahora son las 10:01:19.


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