Ver Mensaje Individual
  #4  
Antiguo 06-03-2007
Avatar de CarlosHernandez
CarlosHernandez CarlosHernandez is offline
Miembro
 
Registrado: oct 2003
Posts: 139
Reputación: 21
CarlosHernandez Va por buen camino
codigo

la cuestion es la siguiente, yo con este codigo realizo la union de varios campos, de una tabla de personal, y otra de horas, validaqndo todo, y haciendo una validacion solo para que me tome 1 entrada y ultima salida por dia, todo el mes para imprimirlo en un reporte, y el union lo uso para pasar el registro que no este en la tabla hora ejmeplo, un sabado que no tenga asistencia, lo pone como registro vacio, para vizualizarlo en el reporte, y se vean los 31 dias del mes. ah tambien tengo fotos dentro de la bases de datos


Código Delphi [-]
var
op,b,boton:integer;
nombref:PChar;
begin


               if RadioButton1.Checked=true then op:=1;   //diario


                     case op of


                     1:begin


     b:=0;
with tabla.IBQuerypersonal do begin     //*-966222

SQL.Clear;
Close;                                 //                                    // and status='+QuotedStr('Activo')+'                                     //                           //
sql.Add('select * from personal where (  Ubicacion='+QuotedStr('CIRCUITO DE TRABAJO')+' or 
Ubicacion='+QuotedStr('DEPARTAMENTO1')+'  ) and status='+QuotedStr('Activo')+'  
and ( modcargo='+QuotedStr('Fijo')+'  or modcargo='+QuotedStr('Contratado')+'  or 
modcargo='+QuotedStr('TITULAR')+'  or modcargo='+QuotedStr('CONTRATADO')+') 
order by nombre asc');
Prepare;
open;


 while not eof do      begin// e aqui el problema cuando pongo esto y se hace en un ciclo de 120 registro aproximado







 ////////////////
 DataSource1.DataSet:=tabla.IBQHorasrep2;
dINI := DateTimePicker1.Date;
Dfin := DateTimePicker2.Date;
nDATO := (dINI + strtofloat('20'));
nDIAS := Trunc(dFIN - dINI);

 with Tabla.IBQHorasrep2 do begin
   sql.Clear;
   Close;

   FOR I := 0 TO nDIAS DO
     BEGIN
       nDATO  := (dINI + STRTOFLOAT(INTTOSTR(I)));
       dFECHA := FLOATTODATETIME(nDATO);
       cFECHA := FormatDateTime('mm/dd/yyyy', dFECHA);
      // SHOWMESSAGE(cFECHA);
//       S := FormatDateTime('dddd, mmmm, yyyy, hh:mm AM/PM');

       SQL.Add('select min(h.he),max(h.hs),CAST('+QuotedStr(cFECHA)+' AS DATE) 
      F1,p.nombre,p.apellido,p.cedula,h.fecha');
       SQL.Add('from personal p left join horas h on h.cedula=p.cedula and h.fecha='+QuotedStr(cFECHA)+'');
       SQL.Add('where p.cedula = arcedula and p.status ='+QuotedStr('Activo')+'');
       SQL.Add('group by p.cedula, p.nombre, p.apellido,h.fecha,3'); //
       IF I < nDIAS THEN
       BEGIN
          SQL.Add(' UNION ');
       END
       ELSE
        BEGIN
          SQL.Add(' order by 3,1 ');
       END


     END;


   Prepare;

   ParamByName('parcedula').AsString:=tabla.IBQuerypersonalCEDULA.AsString;

   
     Open;
 end;




////////////////   end;


//*****ver foto

if tabla.IBQuerypersonalFOTO.IsNull then begin
Image1.Picture:=nil;
end else  begin
  if tabla.IBQuerypersonalFORMATOFOTO.AsString ='BMP' then
  image1.Picture.Graphic:=TBitmap.Create

  else if tabla.IBQuerypersonalFORMATOFOTO.AsString ='JPG' then
 Image1.Picture.Graphic:=TJpegImage.Create


  else

  exit;
  m:=tabla.IBQuerypersonal.CreateBlobStream(tabla.IBQuerypersonalFOTO,bmread);
  Image1.Picture.Graphic.LoadFromStream(m);
  m.Free;

    end;
          //********* ver foto





     b:=b+1;
        label4.Caption:= inttostr(b);



   Boton := Application.MessageBox ('¿Está Seguro que Desea Imprimir este registro?',
                              'Print',MB_YESNO+MB_ICONQUESTION);
   If Boton = ID_YES Then   begin
   //impresion

       form20.QRLabel19.Caption:=DBEdit4.Text;  //ubicacion

form20.QRLabel2.Caption:=DBEdit1.Text;//nombre
form20.QRLabel3.Caption:=DBEdit3.Text;  //apellido
form20.QRLabel5.Caption:=DBEdit2.Text; //cargo

form20.QRLabel4.Caption:=tabla.IBQuerypersonalCEDULA.AsString;    //cedula
Form20.QuickRep1.Prepare;


 
      form20.QuickRep1.Print;
      //impresion


 
 
 end
   Else  begin
   end;




     tabla.IBQuerypersonal.next;
      end;
      tabla.IBQuerypersonal.first;


     end; //*-966222






             end;//del case


    end;
    end;/////////////////////

este codigo da perfecto, pero cuando lo ejecuto en un while do para que se haga 120 veces obvio que consume mucha memoria
__________________
begin
Elverdugo79@hotmail.com
end;

Última edición por CarlosHernandez fecha: 06-03-2007 a las 20:56:59.
Responder Con Cita