ActiveDelphi - Índice do Fórum ActiveDelphi
.: O site do programador Delphi! :.
 
 FAQFAQ   PesquisarPesquisar   MembrosMembros   GruposGrupos   RegistrarRegistrar 
 PerfilPerfil   Entrar e ver Mensagens ParticularesEntrar e ver Mensagens Particulares   EntrarEntrar 

Seleção de duas informações em um stringgrid

 
Novo Tópico   Responder Mensagem    ActiveDelphi - Índice do Fórum -> Delphi
Exibir mensagem anterior :: Exibir próxima mensagem  
Autor Mensagem
fdsilva.desenv
Novato
Novato


Registrado: Quarta-Feira, 28 de Novembro de 2012
Mensagens: 68

MensagemEnviada: Sex Ago 30, 2019 11:02 am    Assunto: Seleção de duas informações em um stringgrid Responder com Citação

Prezados, bom dia.

Estou com uma dúvida de como realizar o processo abaixo.

Tenho uma grid onde eu tenho informações que são carregadas de uma tabela, e preciso, a cada double click nas linhas da grid, trazer o numero de cada titulo selecionado + quantidade total de clientes selecionadas.

sendo assim, criei uma função chamada "AchaNaLista" e dois StringLista LSTBloco e LSTCliente, onde o LSTBloco vai somar a quantidade de titulos, e o outro a quantidade de Clientes.

Para a stringlist da quantidade de títulos, funciona perfeitamente, o problema está para capturar a quantidade clientes corretamente, pois eu posso ter a seguinte situação:

linha 1 - titulo100 cliente50
linha 2 - titulo200 cliente50
linha 3 - titulo300 cliente25
linha 4 - titulo400 cliente35
linha 5 - titulo500 cliente40

Nessa situação, o numero do titulo nunca se repete, pois o numero do titulo é uma chave primaria, já o cliente, pode ter mais de um titulo, o que está me gerando a dificuldade.

Preciso que, quando selecionado a linha 1, 2 e 3, me apareça 3 títulos e 2 clientes selecionados.

Alguém pode me ajudar?

segue abaixo o meu código:
Código:
function TfrmGerarNovoReceber.AchaNaLista(Chave : String; Cliente : String; Grid : Boolean) : Boolean;
{Chave : Valor a ser procurada na lista
 Grid : Para saber se foi chamada pelo Duplo clique no grid.}
var
  n,c1,c2 :Word;
  ResultClie : Boolean;
  i, cont : integer;
begin
  n := 0;
  c1 := 0;
  c2 := 0;
  cont := 0;
  Result := False;
  ResultClie := False;
  if (LstBloco.Count > 0) then
  begin
    for n := 0 to LstBloco.Count - 1 do
      if LstBloco[n] = Chave then
      begin
        Result := True;
        Break;
      end;
  end;

  if Grid then       {se foi chamada pelo Duplo clique no grid}
  begin
    if Result then {Se encontrar a lista}
    begin
      LstBloco.Delete(n);
      QValTitSel   := QValTitSel - ( StrtoNum(StringGrid1.Cells[8,StringGrid1.Row])+StrtoNum(StringGrid1.Cells[9,StringGrid1.Row]) );
    end
    else
    begin
      LstBloco.Add(Chave);
      QValTitSel   := QValTitSel + ( StrtoNum(StringGrid1.Cells[8,StringGrid1.Row]) +StrtoNum(StringGrid1.Cells[9,StringGrid1.Row]) );
    end;
  end;

  if LstBloco.Count > 0 then
  begin
    for n := 0 to LstBloco.Count -1 do
    begin
      cont := 0;
      for i:= 0 to StringGrid1.RowCount - 1 do
      begin
        if ((StringGrid1.Cells[4,i] = Cliente) and (StringGrid1.Cells[1,i] = LstBloco[n] )) then
        begin
          if LstCliente.Count > 0 then
          begin
            for c1 := 0 to LstCliente.Count - 1 do
            begin
              if LstCliente[c1] = Cliente then
              begin
                cont := cont + 1;
                c2 := c1;
              end;
            end;

            if cont = 0 then
              LstCliente.Add(Cliente)
            else if cont = 1 then
              LstCliente.Delete(c2);
          end
          else
          begin
            LstCliente.Add(Cliente);
            cont := 2;
          end;

        end;
      end;
    end;
  end;

  if (LstBloco.Count > 1) then
    spSkinLblStatus.Caption := IntToStr(LstBloco.Count) + ' ' + 'Seleções'
  else
  begin
    if (LstBloco.Count = 1) then
      spSkinLblStatus.Caption := IntToStr(LstBloco.Count) + ' ' + 'Seleção'
    else
      spSkinLblStatus.Caption := 'Nenhuma' + ' ' + 'Seleção';
  end;

  if (LstCliente.Count > 0) then
    LblClientes.Caption := 'Clientes Selecionados: '+IntToStr(LstCliente.Count)
  else
    LblClientes.Caption := 'Clientes Selecionados: ';

  LblValorSel.Caption  := FloattoStrF(QValTitSel, ffNumber, 12, 2);

end;
Voltar ao Topo
Ver o perfil de Usuários Enviar Mensagem Particular
fdsilva.desenv
Novato
Novato


Registrado: Quarta-Feira, 28 de Novembro de 2012
Mensagens: 68

MensagemEnviada: Ter Set 03, 2019 10:59 am    Assunto: Responder com Citação

como ninguem me ajudou, consegui aqui após uns dias apanhando kkkk

valeu ai galera... pode fechar o chamado...
Voltar ao Topo
Ver o perfil de Usuários Enviar Mensagem Particular
Mostrar os tópicos anteriores:   
Novo Tópico   Responder Mensagem    ActiveDelphi - Índice do Fórum -> Delphi Todos os horários são GMT - 3 Horas
Página 1 de 1

 
Ir para:  
Enviar Mensagens Novas: Proibido.
Responder Tópicos Proibido
Editar Mensagens: Proibido.
Excluir Mensagens: Proibido.
Votar em Enquetes: Proibido.


Powered by phpBB © 2001, 2005 phpBB Group
Traduzido por: Suporte phpBB