Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 21-10-2013
monfa monfa is offline
Registrado
 
Registrado: ene 2012
Posts: 3
Poder: 0
monfa Va por buen camino
Problema Al Llenar Sort

AYUDA LLENADO DE GRILLA
Hola buenos dias me pueden ayudar,
Estoy haciendo una agenda de citas con un SortGrid
Tengo un error por que me muestra asi

7:00 1 53456765 OSCAR PALACIOS
7:45 1
7:45 2
7:45 3
8:30 1
8:30 2
8:30 3

y deberia mostar


7:00 1 53456765 OSCAR PALACIOS
7:00 2
7:00 3
7:45 1
7:45 2
7:45 3
8:30 1
8:30 2
8:30 3
9:15 1
9:15 2
9:15 3

Donde el interval = intervalo del dia que en este caso son 45

Código Delphi [-]
procedure TF_ag.llena;
var
  hora : TTime;
  fila, interval, cam : Integer;
  mensaje : String;
  i, j, k, l: Integer;
begin
  fila        := 1;
  interval    := intervalo(MC1.Date);
  if not(Pro.fieldValues['HORA_INICIAL'] = NULL) then
  begin
      hora    := Pro.fieldValues['HORA_INICIAL'];
        cam     := Pro.fieldValues['CAMILLA'];
        Spro.RowCount  := 2;
        if intervalo(MC1.Date) > 0 then
         begin
                ZQagenda.Close;
                  ZQagenda.SQL.Clear;
                  ZQagenda.SQL.Add('SELECT P.NOMBRE,. A* FROM PACIENTES P, AGENDA A  WHERE P.CEDULA = A.CEDULA AND 
                                                                 A.COD_P ='+QuotedStr(Pro.fieldValues['COD_P'])  AND A.FECHA = '+QuotedStr(DateToStr(MC1.Date)) ORDER BY A.HORA ASC');
                 ZQagenda.Open;
                 If not(Pro.fieldValues['HORA_INICIAL'] = Pro.fieldValues['HORA_FINAL']) then
        begin
                     while (CompareTime(hora, Pro.fieldValues['HORA_INI']) >= 0) and
                                                             (CompareTime(hora, Pro.fieldValues['HORA_FIN']) < 0) do  //
                      begin
                          if ZQagenda.RecordCount > 0 then
                            begin
                    ZQagenda.First;
                                  with SGag do
                                  begin
                                        for j:= 0 to ZQagenda.RecordCount - 1 do
                        begin
                            if ((CompareTime(ZQagenda.FieldValues['HORA'],hora) < 0) and
                                                                (CompareTime(ZQagenda.FieldValues['HORA'],hora-(interval)) > 0)) or
                                                                (CompareTime(ZQagenda.FieldValues['HORA'],hora) = 0)  then
                                              begin
                                                Cells[0, fila]  := FormatDateTime('hh:nn am/pm',ZQagenda.FieldValues['HORA_INI']);
                                                 if not(ZQagenda.FieldValues['CEDULA']= NULL) then
                                                begin
                                                      if not(ZQagenda.FieldValues['CEDULA'] = '0') then
                                                            Cells[2, fila]  := ZQagenda.FieldValues['CEDULA']
                                                      else
                                                            Cells[2, fila]  := '';
                                                end;
                                                if not(ZQagenda.FieldValues['NOMBRE'] = NULL) then
                                                begin
                                                      if not(ZQagenda.FieldValues['CEDULA'] = '0') then
                                                            Cells[3, fila]  := ZQagenda.FieldValues['NOMBRE']
                                                      else
                                                            Cells[3, fila]  := '';
                                               end;
                                                SGag .RowCount  := SGag .RowCount + 1;
                                                fila := fila + 1;
                                          end else
                                          begin
                                              for l := 1 to cam do 
                                            begin
                                                  SGag .Cells[0, fila]  := FormatDateTime('hh:nn am/pm',hora);
                                                  SGag .Cells[1, fila]  := IntToStr(l);
                                                  SGag .Cells[2, fila]  := '';
                                                  SGag .Cells[3, fila]  := '';
                                SGag .RowCount        := SGag .RowCount + 1;
                                                  fila := fila + 1;
                                            end; 
                                          end; 
                                          ZQagenda.Next;
                                    end; 
                            end else
                            begin
                               for i := 1 to cam 
                                 begin
                                     SGag .Cells[0, fila]  := FormatDateTime('hh:nn am/pm',hora);
                                      SGag .Cells[1, fila]  := IntToStr(i);
                                      SGag .Cells[2, fila]  := '';
                                      SGag .Cells[3, fila]  := '';
                                     SGag .RowCount        := SGag .RowCount + 1;
                                      fila  := fila + 1;
                                 end;
                            end;  
                            hora:= hora+(interval);
                      end; 
                 end; 
          end;
 end;
end;

Última edición por ecfisa fecha: 22-10-2013 a las 00:54:46. Razón: Agregar etiquetas [DELPHI] [/DELPHI]
Responder Con Cita
  #2  
Antiguo 22-10-2013
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola monfa y bienvenido a Club Delphi

Como a todos los que se inician te invitamos a que leas nuestra guía de estilo.

Por favor cuando incluyas código en tus mensaje utiliza TAG's para darle más legibilidad, como explica la imágen:


(Esta vez ya las agregué en tu mensaje )

Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita
  #3  
Antiguo 22-10-2013
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 18.271
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Es difícil seguir el código que has colocado, pues faltan muchos componentes para poder reproducirlo.
Lo que se me ocurre es que tal vez estés "machacando" algunos valores. Es decir, que los estés pintando todos, pero unos encima de otros, por lo tanto quedan los últimos.

Lo más sencillo es que coloques unos breakpoints y ejecutes "paso a paso".
Uno en el FOR, para asegurarte de cuantas veces pasa, y otro el los diferentes lugares donde rellenas celdas, para ver lo que estás escribiendo.

Otra opción si con eso no te aclaras es utilizar un pequeño LOG. Coloca un Memo en el formulario (de forma temporal) y cada vez que pintas una celda añade una línea como esta:

Código Delphi [-]
  // ATexto lo que se rellena en la celda y fila y columna enteros
  Memo1.Lines.Add(Format('(%d,%d) = %s',[ATexto, fila, columna]));

De esta forma al acabar tendrás una lista de lo que has guardado en cada celda.
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
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
Sort en campo lookup? Mystery Varios 0 08-04-2010 19:50:45
Bubble Sort en StringGrid Gothic_Indhy Varios 2 08-04-2009 13:54:11
Ordenar (sort) en rave reports raudelink Impresión 3 24-01-2006 17:33:11
Vistas sort/index StartKill Firebird e Interbase 6 16-01-2006 16:15:46
TObjectList.Sort duda Lepe Varios 3 21-03-2004 21:43:35


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


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