Hola a todos, tengo este inconveniente.Hago una consulta y una suma de valores en donde los valores(la suma) los paso a un tchart y la consulta la paso a un stringgrid(me muestra las secciones y los valores correspondientes a cada una de ellas).Al final quiero insertar un registro que se llame resultado total y sumar todos los registros que me quedaron.Algo como lo siguiente quiero hacer:
Código Delphi
[-]
+--------+-------+
Imag.Per | 120 |
---------+-------+
Servicio | 36 |
---------+-------+
Resultado| 20 |
---------+-------+
Res.Total| 176 |
-----------------+
Este es mi codigo :
Código Delphi
[-]
procedure TForm1.BitBtnGraficarClick(Sender: TObject);
var
suma,i,x,y,val:integer;
secc,evalua:string;
begin
Chart2.Visible:=false;
randomize;
y:=0;
suma:=0;
i:=1; secc:=sgEvaluacion.cells[1,i];
for i := 2 to sgEvaluacion.RowCount - 1 do begin
if sgEvaluacion.cells[0,i]<> '' then
begin
suma := suma + StrToInt(sgEvaluacion.Cells[7,i]);
inc(y);
end
else
begin
sgGrafica.cells[1,sgGrafica.RowCount-1]:= IntToStr(suma) ;
sgGrafica.cells[0,sgGrafica.RowCount-1]:= secc;
sgGrafica2.cells[1,sgGrafica2.RowCount-1]:= IntToStr(suma) ; sgGrafica2.cells[0,sgGrafica2.RowCount-1]:= secc; x:=(suma div y)* 100;
sgGrafica.Cells[2,sgGrafica.RowCount-1]:=IntToStr(x);
sgGrafica2.Cells[2,sgGrafica2.RowCount-1]:=IntToStr(x); Series1.Add( suma ,secc, random(200) );
Series2.Add( suma ,secc, random(200) ); suma:=0;
secc:=sgEvaluacion.cells[1,i];
sgGrafica.RowCount:=sgGrafica.RowCount+1;
sgGrafica2.RowCount:=sgGrafica2.RowCount+1; end;
end;
sgGrafica2.cells[1,sgGrafica2.RowCount-1]:= inttostr (suma) ; sgGrafica2.cells[0,sgGrafica2.RowCount-1] := secc ; sgGrafica.cells[1,sgGrafica.RowCount-1]:= inttostr (suma) ;
sgGrafica.cells[0,sgGrafica.RowCount-1] := secc ;
x:=(suma div y)*100;
sgGrafica.Cells[2,sgGrafica.RowCount-1]:=IntToStr(x);
sgGrafica.RowCount:=sgGrafica.RowCount+1;
Series1.Add( suma ,secc, random(260) );
sgGrafica2.Cells[2,sgGrafica2.RowCount-1]:=IntToStr(x); sgGrafica2.RowCount:=sgGrafica2.RowCount+1; Series2.Add( suma ,secc, random(260) ); end;