private int verificalista(Entidades.TabelaPacotes tab, List <Entidades.TabelaPacotes> lista)
 {
     for (int i = 0; i < lista.Count; i++)
     {
         if (tab.Descr == lista.ElementAt(i).Descr&& lista.ElementAt(i).Tipo == "Adcional")
         {
             return(i);
         }
     }
     return(-1);
 }
        private void btnIncluirServico_Click(object sender, EventArgs e)
        {
            try
            {
                Entidades.TabelaPacotes      tab  = new Entidades.TabelaPacotes();
                Controller.ServicoController sc   = new Controller.ServicoController();
                Entidades.Servico            serv = new Entidades.Servico();
                tab.Codigo = Convert.ToInt32(cbbServico.SelectedValue);
                tab.Descr  = cbbServico.Text.ToString();
                DataTable dtserv = sc.retornaObjServico(Convert.ToInt32(cbbServico.SelectedValue));
                DataRow   drServ = dtserv.Rows[0];
                serv.carregaServico(Convert.ToInt32(drServ["codtiposervico"].ToString()),
                                    drServ["tiposerv_descricao"].ToString(),
                                    drServ["tiposerv_obs"].ToString(),
                                    Convert.ToDouble(drServ["tiposerv_valor"].ToString()),
                                    drServ["tiposerv_temposervico"].ToString());

                if (string.IsNullOrWhiteSpace(ttbQtde.Text))
                {
                    MessageBox.Show("Informe a quantidade do serviço.");
                }
                else
                {
                    tab.Qtde = Convert.ToInt32(ttbQtde.Text.ToString());
                    tab.Tipo = "Adcional";
                    int index = verificalista(tab, listaTabela);
                    if (index > 0)
                    {
                        listaTabela.ElementAt(index).Qtde += tab.Qtde;
                    }
                    else
                    {
                        listaTabela.Add(tab);
                    }
                    ttbTotal.Text = (Convert.ToDouble(ttbTotal.Text.ToString()) + (tab.Qtde * serv.Valor)).ToString();
                    carregaDgvPacotesAdcinais(listaTabela);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex);
                throw;
            }
        }
        private void addListaTabela(List <Entidades.PacoteServico> lista)
        {
            for (int i = 0; i < lista.Count; i++)
            {
                Entidades.TabelaPacotes tab = new Entidades.TabelaPacotes();
                tab.Codigo = lista.ElementAt(i).Servico.Codigo;
                tab.Descr  = lista.ElementAt(i).Servico.ServicoNome;
                tab.Qtde   = lista.ElementAt(i).Quantidade;
                if (lista.ElementAt(i).Pacote.PaccoteNome != "")
                {
                    tab.Tipo = lista.ElementAt(i).Pacote.PaccoteNome;
                }
                else
                {
                    tab.Tipo = "Adcional";
                }
                tab.Valor = lista.ElementAt(i).Pacote.Valor;
                listaTabela.Add(tab);

                carregaDgvPacotesAdcinais(listaTabela);
            }
        }