Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Coloboración Paypal con ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 08-03-2007
Avatar de BlackDaemon
BlackDaemon BlackDaemon is offline
Miembro
 
Registrado: dic 2006
Ubicación: Bolivia - Santa Cruz
Posts: 206
Poder: 20
BlackDaemon Va por buen camino
Bueno yo mismo me respondo
recuerdan mi código :

Código Delphi [-]
procedure TFrmAgregarItems.SBAgregarClick(Sender: TObject);
var i : integer;
    SubTotal : double;
begin
    FrmVentas.SGListaProductos.Cells[1,FrmVentas.SGListaProductos.RowCount-1] := ECantidad.Text;
    FrmVentas.SGListaProductos.Cells[2,FrmVentas.SGListaProductos.RowCount-1] := DBTUnidad.Caption;
    FrmVentas.SGListaProductos.Cells[3,FrmVentas.SGListaProductos.RowCount-1] := DBTCodigo.Caption;
    FrmVentas.SGListaProductos.Cells[4,FrmVentas.SGListaProductos.RowCount-1] := DBTCodigoBarra.Caption;
    FrmVentas.SGListaProductos.Cells[5,FrmVentas.SGListaProductos.RowCount-1] := DBTDescripcion.Caption;
    FrmVentas.SGListaProductos.Cells[6,FrmVentas.SGListaProductos.RowCount-1] := DBTUnidadPrecio.Caption;
    FrmVentas.SGListaProductos.Cells[7,FrmVentas.SGListaProductos.RowCount-1] := DM.ZQAgregarItems.FieldByName('precio1').AsString;

    FrmVentas.SGListaProductos.RowCount := FrmVentas.SGListaProductos.RowCount+1;

    SubTotal := 0;
   // Calcula el SubTotal
   For i:=1 to FrmVentas.SGListaProductos.RowCount-1 do
      SubTotal := SubTotal + StrToFloat(FrmVentas.SGListaProductos.Cells[8,i]);
      FrmVentas.LSubTotal.Caption := FormatFloat('%8.2n',SubTotal);
      //FrmVentas.LSubTotal.Caption := FloatToStr(SubTotal);
  Close;
end;

y me salía ese puñetero error ??
Pues ahora está así y no me sale ese error

Código Delphi [-]
procedure TFrmAgregarItems.SBAgregarClick(Sender: TObject);
var i : integer;
    SubTotal : double;
begin
    FrmVentas.SGListaProductos.Cells[1,FrmVentas.SGListaProductos.RowCount-1] := ECantidad.Text;
    FrmVentas.SGListaProductos.Cells[2,FrmVentas.SGListaProductos.RowCount-1] := DBTUnidad.Caption;
    FrmVentas.SGListaProductos.Cells[3,FrmVentas.SGListaProductos.RowCount-1] := DBTCodigo.Caption;
    FrmVentas.SGListaProductos.Cells[4,FrmVentas.SGListaProductos.RowCount-1] := DBTCodigoBarra.Caption;
    FrmVentas.SGListaProductos.Cells[5,FrmVentas.SGListaProductos.RowCount-1] := DBTDescripcion.Caption;
    FrmVentas.SGListaProductos.Cells[6,FrmVentas.SGListaProductos.RowCount-1] := DBTUnidadPrecio.Caption;
    FrmVentas.SGListaProductos.Cells[7,FrmVentas.SGListaProductos.RowCount-1] := DM.ZQAgregarItems.FieldByName('precio1').AsString;

    //FrmVentas.SGListaProductos.RowCount := FrmVentas.SGListaProductos.RowCount+1;

    SubTotal := 0;
   // Calcula el SubTotal
   For i:=1 to FrmVentas.SGListaProductos.RowCount-1 do
      SubTotal := SubTotal + StrToFloat(FrmVentas.SGListaProductos.Cells[7,i]);
      FrmVentas.SGSubTotal.Cells[1,0] := Format('%8.2n',[SubTotal]);

  
  Close;
end;

ya ahora decidí mostrar el resultado en un StringGrid pequeñito Pero ese no es el problema por que podría haberlo mostrado en el mismo Label que tenía
Ya ahora esta línea :

Código Delphi [-]
//FrmVentas.SGListaProductos.RowCount := FrmVentas.SGListaProductos.RowCount+1;

la comenté y puedo agregar ahora los Items al StringGrid que contiene los Items sin problema y me da el resultado del precio1 que lo saco con :

Código Delphi [-]
FrmVentas.SGListaProductos.Cells[7,FrmVentas.SGListaProductos.RowCount-1] := DM.ZQAgregarItems.FieldByName('precio1').AsString;

y ya todo bién peroooooo!!! ahora un problema.. como es de suponerse esa línea que comenté lo que hace es cada vés que pasa por ahí aumenta 1 al StringGrid y ahora no aumenta nada y pues si agrego otro Item me sobreescribe al que tengo en el StringGrid pero vamos.. eso es lógico por que no hay que aumente a +1 el StringGrid ahora la pregunta.

Por que esa línea me da problemas con el error que tengo en el anterior mensaje ????
Que otra forma tengo de sumar columnas en un StringGrid ??

saludos
Responder Con Cita
  #2  
Antiguo 09-03-2007
Avatar de Lepe
[Lepe] Lepe is offline
Miembro Premium
 
Registrado: may 2003
Posts: 7.424
Poder: 31
Lepe Va por buen camino
Al hacer el bucle, tambien coge la última fila que acabas de añadir en blanco, y al intentar pasar esa celda vacía a Float, es cuando obtienes el error.

Código Delphi [-]
 FrmVentas.SGListaProductos.RowCount := FrmVentas.SGListaProductos.RowCount+1;

    SubTotal := 0;
   // Calcula el SubTotal
   For i:=1 to FrmVentas.SGListaProductos.RowCount-2 do
añade la línea al StringGrid, pero el bucle, hazlo 1 vez menos (ya que sabes que la última línea siempre estará vacía).

Saludos
__________________
Si usted entendió mi comentario, contácteme y gustosamente,
se lo volveré a explicar hasta que no lo entienda, Gracias.
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

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
convertir string jsanchez Varios 3 31-07-2006 22:23:19
Problema al convertir a string Fita Varios 3 24-12-2005 16:43:55
conversion de double a string y viceversa mainau Varios 2 03-08-2004 21:11:30
convertir de boolean a string ??? chele Varios 2 10-06-2004 12:18:35
pasar double a string ???? chele Varios 2 01-06-2004 16:54:06


La franja horaria es GMT +2. Ahora son las 05:44:45.


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