Ver Mensaje Individual
  #1  
Antiguo 18-12-2007
whatson whatson is offline
Miembro
 
Registrado: dic 2007
Posts: 19
Reputación: 0
whatson Va por buen camino
Question Problemas para sumar en TDBGrid

Buenos dias a Todos. Les pido su colaboracion para resolver este problema que tengo con la suma en las columnas de cantidad de articulos e Importe.
No he podido colocar estos valores en sus respectivos LabelImporte y LabelCantArticulos, ademas de ponerme un error "incompatible types" en la linea del While.

Cualquier comentario al respecto Me sera de mucha Utilidad
De antemano Muchas gracias.

Código:
procedure TFormPrincipal.DBGrid11KeyPress(Sender: TObject; var Key: Char);
begin
  If Key = #13 then  //  Si se pulsa la tecla ENTER en el Grid
      begin
          if DBGrid11.Fields[1].Value = Null then
                  DBGrid11.Fields[1].AsFloat := 1; // CANTIDAD
                  if DBGrid11.Fields[1].Value = Null  then
                     DBGrid11.Fields[4].AsFloat := 0; // PRECIO UNITARIO
                     DBGrid11.Fields[5].AsFloat := DBGrid11.Fields[1].AsFloat * DBGrid11.Fields[4].AsFloat; // IMPORTE
                     LabelImporte.Caption := '0';
                     LabelCantArticulos.Caption := '0';
                     DataSourcePartVta.DataSet.First; // primer registro
                    While DataSourcePartVta.DataSet.EnableControls = False do
                      begin
                          DBGrid11.Fields[5].AsFloat:= DBGrid11.Fields[1].AsFloat * DBGrid11.Fields[4].AsFloat;
                          LabelImporte.Caption:=FloatToStr(DBGrid11.Fields[5].AsFloat + StrToFloat(LabelImporte.Caption));
                          LabelCantArticulos.Caption:=FloatToStr(DBGrid11.Fields[1].AsFloat + StrToFloat(LabelCantArticulos.Caption));
                          DataSourcePartVta.DataSet.Next; // siguiente registro
                      end;
                  end;
      end;
end.
Responder Con Cita