Carregar uma StringGrid ...

Delphi

03/11/2004

Tenho que carregar uma stringrid em execução , só que os dados que possuo vem de outra stringgrid ...
Essa stringgrid vai ser carregada com varios dados diferentes ...
tenho que agrupar varios dados diferentes nessa stringgrid, e somar qtos desses dados eu possuo ...
Eu até que tentei mas naum consigo ...
Se alguém tiver uma solução seje ela qual for , me ajudem .... Please !!!


Brigada ... bjos


Julianaleme

Julianaleme

Curtidas 0

Respostas

Reginaldo174

Reginaldo174

03/11/2004

Este é um procedimento que tenho em um sistema. Talvez possa servir como exemplo pra vc.

procedure TForm_ClientesRota.SpeedButton1Click(Sender: TObject);
var
  iQuant_Atendidos,
  iQuant_NAtendidos,
  iQuant_Clientes : integer;
begin
{  grid.Visible := true;
  Label2.Caption :=´Número de Clientes por Rota´;
  DBGrid1.Visible := False;
  dm.qry_rotas.Close;
  dm.qry_rotas.SQL.Clear;
  dm.qry_rotas.SQL.Add(´select distinct(rota) from Rota´);
  dm.qry_rotas.Open;

  dm.qry_clirota.Close;
  dm.qry_clirota.SQL.Clear;
  dm.qry_clirota.SQL.Add(´select count(*) as total´);
  dm.qry_clirota.SQL.Add(´from Clientes´);
  dm.qry_clirota.SQL.Add(´where Rota = :prota´);
  dm.qry_clirota.SQL.Add(´and´);
  dm.qry_clirota.SQL.Add(´Situacao =:ativo´);

  dm.Qvendas.Close;
  dm.QVendas.SQL.Clear;
  dm.Qvendas.SQL.Add(´select count(*)as total from Vendas´);
  dm.QVendas.SQL.Add(´where Rota = :prota´);
  dm.QVendas.SQL.Add(´and´);
  dm.QVendas.SQL.Add(´Data =:data1´);

  iQuant_Clientes := 0;
  iQuant_Atendidos := 0;
  iQuant_NAtendidos := 0;

  while not(dm.qry_rotas.Eof) do
  begin
    dm.qry_clirota.Parameters.ParamByName(´prota´).Value := DM.qry_rotas.fieldbyname(´rota´).AsString;
    dm.qry_clirota.Parameters.ParamByName(´ativo´).Value := ´Ativo´;

    if dm.qry_clirota.Active then
      dm.qry_clirota.Requery()
    else dm.qry_clirota.Open;

    dm.Qvendas.Parameters.ParamByName(´prota´).Value := DM.qry_rotas.fieldbyname(´rota´).AsString;
    dm.Qvendas.Parameters.ParamByName(´data1´).Value := FormatDateTime(´yyyy,mm,dd´,strtodate(MaskEdit1.Text));
    dm.Qvendas.open;
    iQuant_Atendidos := iQuant_Atendidos + dm.qvendas.fieldbyname(´total´).value;
    iQuant_NAtendidos:= iQuant_NAtendidos + (dm.qry_clirota.fieldbyname(´total´).value - dm.qvendas.fieldbyname(´total´).value);
    grid.Cells[2,grid.RowCount-1] := dm.qvendas.fieldbyname(´total´).AsString;
    grid.Cells[3,grid.RowCount-1] := inttostr(dm.qry_clirota.fieldbyname(´total´).value - dm.qvendas.fieldbyname(´total´).value) ;
    dm.Qvendas.close;

    grid.Cells[0,grid.RowCount-1] := DM.qry_rotas.fieldbyname(´rota´).AsString;
    grid.Cells[1,grid.RowCount-1] := dm.qry_clirota.fieldbyname(´total´).AsString;
    iQuant_Clientes := iQuant_Clientes + dm.qry_clirota.fieldbyname(´total´).Value;

    grid.RowCount := grid.RowCount + 1;
    dm.qry_rotas.Next;
  end;


  dm.qry_clirota.Close;
  dm.qry_rotas.Close;

  grid.Cells[0,grid.RowCount-1] := ´Totais´;
  grid.Cells[1,grid.RowCount-1] := formatfloat(´00´,iQuant_Clientes);
  grid.Cells[2,grid.RowCount-1] := formatfloat(´00´,iQuant_Atendidos);
  grid.Cells[3,grid.RowCount-1] := formatfloat(´00´,iQuant_NAtendidos);}
end;



GOSTEI 0
POSTAR