public ActionResult Index(int IDAluno)
        {
            var temaSite = "menuAluno";

            listaTreinamento = treinamentoNegocio.PesquisarTreinamentoCodigoNomeAluno(IDAluno, null);
            ViewBag.IDAluno  = Request.Cookies["IDAluno"].Value;
            return(View(listaTreinamento));
        }
 public void Dispose()
 {
     acessoDadosSqlServer = null;
     listaTreinamento     = null;
 }
        public void AtualizarGridTreinamento(DialogResult dialogResult)
        {
            using (TreinamentoNegocio treinamentoNegocio = new TreinamentoNegocio())
            {
                ValidacaoInterfaces validarInterfaces = new ValidacaoInterfaces();
                if (dialogResult == DialogResult.Yes)
                {
                    try
                    {
                        ListaTreinamento listaTreinamento = treinamentoNegocio.PesquisarTreinamentoCodigoNomeAluno(null, txtSelecionarCodAluno.Text);
                        this.dgwSelecionarTreinamentoFísico.DataSource = null;
                        this.dgwSelecionarTreinamentoFísico.DataSource = listaTreinamento;
                        this.dgwSelecionarTreinamentoFísico.Update();
                        this.dgwSelecionarTreinamentoFísico.Refresh();
                        txtSelecionarCodAluno.Focus();

                        return;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Não foi possível atualizar, após ter inserido ou alterado treinamento. Detalhes: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }
                else if (validarInterfaces.ValidarCampoPesquisar(txtSelecionarCodAluno, "nome do aluno") == true)
                {
                    return;
                }
                else if (txtSelecionarCodAluno.Text.Where(c => char.IsNumber(c)).Count() > 0)
                {
                    try
                    {
                        ListaTreinamento listaTreinamento = treinamentoNegocio.PesquisarTreinamentoCodigoNomeAluno(Convert.ToInt32(txtSelecionarCodAluno.Text), null);
                        if (listaTreinamento.Count() > 0)
                        {
                            this.dgwSelecionarTreinamentoFísico.DataSource = null;
                            this.dgwSelecionarTreinamentoFísico.DataSource = listaTreinamento;
                            this.dgwSelecionarTreinamentoFísico.Update();
                            this.dgwSelecionarTreinamentoFísico.Refresh();
                            txtSelecionarCodAluno.Focus();
                            return;
                        }
                        else
                        {
                            MessageBox.Show("Não existe nenhum aluno com este código: " + txtSelecionarCodAluno.Text, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            txtSelecionarCodAluno.Focus();
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Não foi possível pesquisar aluno por código. Detalhes: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtSelecionarCodAluno.Focus();
                        return;
                    }
                }
                else
                {
                    try
                    {
                        ListaTreinamento listaTreinamento = treinamentoNegocio.PesquisarTreinamentoCodigoNomeAluno(null, txtSelecionarCodAluno.Text);
                        if (listaTreinamento.Count() > 0)
                        {
                            this.dgwSelecionarTreinamentoFísico.DataSource = null;
                            this.dgwSelecionarTreinamentoFísico.DataSource = listaTreinamento;
                            this.dgwSelecionarTreinamentoFísico.Update();
                            this.dgwSelecionarTreinamentoFísico.Refresh();
                            txtSelecionarCodAluno.Focus();
                            return;
                        }
                        else
                        {
                            MessageBox.Show("Não existe nenhum aluno com esse nome: " + txtSelecionarCodAluno.Text, "Avso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            txtSelecionarCodAluno.Focus();
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Não foi possível pesquisar aluno por nome. Detalhes: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtSelecionarCodAluno.Focus();
                        return;
                    }
                }
            }
        }