private void btnTipoExercicioCadastrar_Click(object sender, EventArgs e)
        {
            using (TipoExercicioNegocio tipoExercicioNegocio = new TipoExercicioNegocio())
            {
                ValidacaoInterfaces validarInterface = new ValidacaoInterfaces();
                if (validarInterface.validarCampoCadastrar(this.grpTipoExercicio.Controls) == true)
                {
                    return;
                }
                else if (validarInterface.ValidarRadioButton(this.rbtnAlunoAtivoSim, this.rbtnAlunoAtivoNao) == true)
                {
                    return;
                }

                if (acaoNaTelaInformada == AcaoNaTela.Inserir)
                {
                    TipoExercicio tipoExercicioInserir = new TipoExercicio()
                    {
                        Descricao = this.txtCadastrarDescricao.Text,
                        Ativo     = this.rbtnAlunoAtivoSim.Checked == true? true: false
                    };

                    string retorno = tipoExercicioNegocio.Inserir(tipoExercicioInserir);

                    try
                    {
                        int codigo = Convert.ToInt32(retorno);
                        MessageBox.Show("Tipo de exercício cadastrado com sucesso. Código: " + codigo.ToString(), "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.DialogResult = System.Windows.Forms.DialogResult.Yes;
                    }
                    catch
                    {
                        MessageBox.Show("Não foi possível cadastrar tipo de exercício. Detalhes: " + retorno, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                else if (acaoNaTelaInformada == AcaoNaTela.Alterar)
                {
                    TipoExercicio tipoExercicioAlterar = new TipoExercicio()
                    {
                        IDTipoExercicio = Convert.ToInt32(this.txtCadastrarCodigo.Text),
                        Descricao       = this.txtCadastrarDescricao.Text,
                        Ativo           = this.rbtnAlunoAtivoSim.Checked == true ? true : false
                    };

                    string retorno = tipoExercicioNegocio.Alterar(tipoExercicioAlterar);
                    try
                    {
                        int codigo = Convert.ToInt32(retorno);
                        MessageBox.Show("Tipo de exercício alterado com sucesso. Código: " + codigo.ToString(), "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.DialogResult = System.Windows.Forms.DialogResult.Yes;
                    }
                    catch
                    {
                        MessageBox.Show("Não foi possível alterar tipo de exercício. Detalhes: " + retorno, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
            }
        }
        private void btnAlterar_Click(object sender, EventArgs e)
        {
            using (MedidaCorporalNegocio medidaCorporalNegocio = new MedidaCorporalNegocio())
            {
                ValidacaoInterfaces validarInterfaces = new ValidacaoInterfaces();
                if (validarInterfaces.validarCampoCadastrar(grpMedidaCorporalAlterar.Controls) == true)
                {
                    return;
                }
                MedidaCorporal medidaCorporalAlterar = new MedidaCorporal()
                {
                    IDMedidaCorporal = Convert.ToInt32(txtCodigo.Text),
                    MedidaCm         = Convert.ToDecimal(mtxtCadastrarCentimetro.Text)
                };

                string retorno = medidaCorporalNegocio.Alterar(medidaCorporalAlterar);
                try
                {
                    int codigo = Convert.ToInt32(retorno);
                    MessageBox.Show("Medida corporal alterada com sucesso. Detalhes: " + codigo.ToString(), "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.DialogResult = DialogResult.Yes;
                }
                catch
                {
                    MessageBox.Show("Não foi possível Alterar Medida Corporal");
                    return;
                }
            }
        }
예제 #3
0
        private void btnTipoTreinamentoCadastrar_Click(object sender, EventArgs e)
        {
            using (TipoTreinamentoNegocio tipoTreinamentoNegocio = new TipoTreinamentoNegocio())
            {
                ValidacaoInterfaces validarInterfaces = new ValidacaoInterfaces();
                if (validarInterfaces.validarCampoCadastrar(grpTipoTreinamentoFisico.Controls) == true)
                {
                    return;
                }
                else if (validarInterfaces.ValidarRadioButton(rbtCadastrarAtivoSim, rbtCadastrarAtivoNao) == true)
                {
                    return;
                }

                if (acaoNaTelaInformada == AcaoNaTela.Inserir)
                {
                    TipoTreinamento tipoTreinamentoInserir = new TipoTreinamento()
                    {
                        Descricao = txtCadastrarTipoTreinamentoDescricao.Text,
                        Ativo     = rbtCadastrarAtivoSim.Checked == true? true: false
                    };

                    string retornoInserir = tipoTreinamentoNegocio.Inserir(tipoTreinamentoInserir);
                    try
                    {
                        int codigo = Convert.ToInt32(retornoInserir);
                        MessageBox.Show("Tipo de treinamento cadastrado com sucesso. Código: " + retornoInserir, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.DialogResult = DialogResult.Yes;
                    }
                    catch
                    {
                        MessageBox.Show("Não foi possível cadastrar o tipo de treinamento. Detalhes: " + retornoInserir, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }
                if (acaoNaTelaInformada == AcaoNaTela.Alterar)
                {
                    TipoTreinamento tipoTreinamentoAlterar = new TipoTreinamento()
                    {
                        IDTipoTreinamento = Convert.ToInt32(txtCadastrarCodigo.Text),
                        Descricao         = txtCadastrarTipoTreinamentoDescricao.Text,
                        Ativo             = rbtCadastrarAtivoSim.Checked == true ? true : false
                    };

                    string retornoAlterar = tipoTreinamentoNegocio.Alterar(tipoTreinamentoAlterar);
                    try
                    {
                        int codigo = Convert.ToInt32(retornoAlterar);
                        MessageBox.Show("Tipo de treinamento alterado com sucesso. Código: " + retornoAlterar, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.DialogResult = DialogResult.Yes;
                    }
                    catch
                    {
                        MessageBox.Show("Não foi possível alterar o tipo de treinamento. Detalhes: " + retornoAlterar, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }
            }
        }
예제 #4
0
        private void btnInserir_Click(object sender, EventArgs e)
        {
            using (MedidaCorporalNegocio medidaCorporalNegocio = new MedidaCorporalNegocio())
            {
                ValidacaoInterfaces validarInterfaces = new ValidacaoInterfaces();
                if (validarInterfaces.validarCampoCadastrar(grpFichaMedidaCorporal.Controls) == true)
                {
                    return;
                }
                if (cbxCadastrarTipoMedida.SelectedValue == null)
                {
                    MessageBox.Show(" Tipo de medida não existe", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    cbxCadastrarTipoMedida.Focus();
                    return;
                }


                MedidaCorporal medidaCorporal = new MedidaCorporal()
                {
                    DataMedida = dtpCadastrarDataMedida.Value,
                    MedidaCm   = Convert.ToDecimal(mtxtCadastrarCentimetro.Text)
                };

                medidaCorporal.Aluno        = new Aluno();
                medidaCorporal.Aluno.Pessoa = new Pessoa()
                {
                    IDPessoa = Convert.ToInt32(this.txtCodigoAluno.Text)
                };

                medidaCorporal.TipoMedidaCorporal = new TipoMedidaCorporal()
                {
                    IDTipoMedidaCorporal = Convert.ToInt32(cbxCadastrarTipoMedida.SelectedValue)
                };


                string idMedidaCorporal = medidaCorporalNegocio.Inserir(medidaCorporal);

                try
                {
                    int codigo = Convert.ToInt32(idMedidaCorporal);
                    mtxtCadastrarCentimetro.Clear();
                    cbxCadastrarTipoMedida.SelectedItem = null;
                    AtualizarGridMedidas(DialogResult.Yes, Convert.ToInt32(txtCodigoAluno.Text), dtpCadastrarDataMedida.Value.Date);
                    cbxCadastrarTipoMedida.Focus();
                }
                catch
                {
                    MessageBox.Show("Não foi possível cadastrar medida corporal. Detalhes: " + idMedidaCorporal, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    mtxtCadastrarCentimetro.Clear();
                    cbxCadastrarTipoMedida.SelectedItem = null;
                    return;
                }
            }
        }
        private void btnObjetivoCadastrar_Click_1(object sender, EventArgs e)
        {
            using (ObjetivoNegocio objetivoNegocio = new ObjetivoNegocio())
            {
                ValidacaoInterfaces validarInterfaces = new ValidacaoInterfaces();
                if (validarInterfaces.validarCampoCadastrar(this.grpObjetivo.Controls) == true)
                {
                    return;
                }

                if (acaoNaTelaInformada == AcaoNaTela.Inserir)
                {
                    Objetivo objetivoInserir = new Objetivo()
                    {
                        Descricao = txtCadastrarDescricao.Text
                    };

                    string retorno = objetivoNegocio.Inserir(objetivoInserir);
                    try
                    {
                        int codigo = Convert.ToInt32(retorno);
                        MessageBox.Show("Objetivo cadastrado com sucesso. Código: " + codigo.ToString(), "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.DialogResult = System.Windows.Forms.DialogResult.Yes;
                    }
                    catch
                    {
                        MessageBox.Show("Não foi possível cadastrar o objetivo. Detalhes: " + retorno, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }
                else if (acaoNaTelaInformada == AcaoNaTela.Alterar)
                {
                    Objetivo objetivoAlterar = new Objetivo()
                    {
                        IDObjetivo = Convert.ToInt32(this.txtCadastrarCodigo.Text),
                        Descricao  = this.txtCadastrarDescricao.Text
                    };

                    string retorno = objetivoNegocio.Alterar(objetivoAlterar);

                    try
                    {
                        int codigo = Convert.ToInt32(retorno);
                        MessageBox.Show("Objetivo alterado com sucesso. Código: " + codigo.ToString(), "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.DialogResult = System.Windows.Forms.DialogResult.Yes;
                    }
                    catch
                    {
                        MessageBox.Show("Não foi possível alterar o objetivo. Detalhes: " + retorno, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
            }
        }
        private void btnInserir_Click(object sender, EventArgs e)
        {
            using (ExerciciosTreinamentoNegocio exerciciosTreinamentoNegocio = new ExerciciosTreinamentoNegocio())
            {
                ValidacaoInterfaces validarInterfaces = new ValidacaoInterfaces();
                if (validarInterfaces.validarCampoCadastrar(grpFichaTreinamento.Controls) == true)
                {
                    return;
                }

                ExerciciosTreinamento exerciciosTreinamentoInserir = new ExerciciosTreinamento()
                {
                    Series     = Convert.ToInt32(txtCadastrarSeries.Text),
                    Repeticoes = Convert.ToInt32(txtCadastrarRepeticoes.Text),
                    Intervalo  = mskCadastrarIntervalo.Text
                };

                exerciciosTreinamentoInserir.Treinamento = new Treinamento()
                {
                    IDTreinamento = Convert.ToInt32(txtCadastrarTreinamentoCodigo.Text)
                };

                exerciciosTreinamentoInserir.Exercicio = new Exercicio()
                {
                    IDExercicio = Convert.ToInt32(cbxCadastrarExercicio.SelectedValue)
                };

                string retorno = exerciciosTreinamentoNegocio.Inserir(exerciciosTreinamentoInserir);
                try
                {
                    int codigo = Convert.ToInt32(retorno);
                    cbxCadastrarExercicio.Select();
                    AtualizarGridTreinamentos(DialogResult.Yes, codigo);
                }
                catch
                {
                    MessageBox.Show("Não foi possível cadastrar o exercício no treinamento. Detalhes: " + retorno, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    cbxCadastrarExercicio.SelectedItem = null;
                    mskCadastrarIntervalo.Text         = "00:00:00";
                    return;
                }
            }
        }
        private void btnRelatorioExecutar_Click(object sender, EventArgs e)
        {
            ValidacaoInterfaces validarInterfaces = new ValidacaoInterfaces();

            // if(validarInterfaces.ValidarCampoPesquisar(txtRelatorioFiltroCodigoNome, "nome") == true)
            // {
            //    return;
            //}


            if (txtRelatorioFiltroCodigoNome.Text.Where(c => char.IsNumber(c)).Count() > 0)
            {
                this.rpvRelatorioPorAluno.Enabled = false;
                this.rpvRelatorioPorAluno.Visible = false;
                this.uspAlunoPesquisarNomeOuCodigoTableAdapter1.Fill(this.tCCSF2015DataSet.uspAlunoPesquisarNomeOuCodigo, Convert.ToInt32(txtRelatorioFiltroCodigoNome.Text), null);
                this.rpvRelatorioAluno.RefreshReport();
                this.txtRelatorioFiltroCodigoNome.Clear();
            }
            else if (txtRelatorioFiltroCodigoNome.Text.Where(c => char.IsLetter(c)).Count() > 0)
            {
                // this.rpvRelatorioAluno.Visible = false;
                // this.rpvRelatorioAluno.Enabled = false;
                // this.rpvRelatorioPorAluno.Visible = true;
                //this.rpvRelatorioPorAluno.Enabled = true;
                //this.uspTreinamentoPesquisarIDAlunoNomeAlunoTableAdapter.Fill(this.tCCSF2015PC1DataSet1.uspTreinamentoPesquisarIDAlunoNomeAluno, null, txtRelatorioFiltroCodigoNome.Text);

                // this.uspMedidaCorporalPesquisarCodigoAlunoOuNomeAlunoTableAdapter.Fill(this.tCCSF2015PC1DataSet1.uspMedidaCorporalPesquisarCodigoAlunoOuNomeAluno, null, txtRelatorioFiltroCodigoNome.Text);
                this.rpvRelatorioPorAluno.Enabled = false;
                this.rpvRelatorioPorAluno.Visible = false;
                this.uspAlunoPesquisarNomeOuCodigoTableAdapter1.Fill(this.tCCSF2015DataSet.uspAlunoPesquisarNomeOuCodigo, null, txtRelatorioFiltroCodigoNome.Text);
                this.rpvRelatorioAluno.RefreshReport();
            }
            else if (txtRelatorioFiltroCodigoNome.Text == "")
            {
                this.rpvRelatorioPorAluno.Enabled = false;
                this.rpvRelatorioPorAluno.Visible = false;
                this.rpvRelatorioAluno.Visible    = true;
                this.rpvRelatorioAluno.Enabled    = true;
                this.uspAlunoPesquisarNomeOuCodigoTableAdapter1.Fill(this.tCCSF2015DataSet.uspAlunoPesquisarNomeOuCodigo, null, "%");
                this.rpvRelatorioAluno.RefreshReport();
                this.txtRelatorioFiltroCodigoNome.Clear();
            }
        }
예제 #8
0
        private void btnAlterar_Click(object sender, EventArgs e)
        {
            using (ExerciciosTreinamentoNegocio exercicioTreinamentoNegocio = new ExerciciosTreinamentoNegocio())
            {
                ValidacaoInterfaces validarInterfaces = new ValidacaoInterfaces();
                if (validarInterfaces.validarCampoCadastrar(grpTreinamentoAlterar.Controls) == true)
                {
                    return;
                }
                ExerciciosTreinamento exerciciosTreinamentoAlterar = new ExerciciosTreinamento()
                {
                    Series     = Convert.ToInt32(txtCadastrarSeries.Text),
                    Repeticoes = Convert.ToInt32(txtCadastrarRepeticoes.Text),
                    Intervalo  = mskCadastrarIntervalo.Text
                };

                exerciciosTreinamentoAlterar.Treinamento = new Treinamento()
                {
                    IDTreinamento = Convert.ToInt32(txtCodigoTreinamento.Text)
                };
                exerciciosTreinamentoAlterar.Exercicio = new Exercicio()
                {
                    IDExercicio = Convert.ToInt32(cbxCadastrarExercicio.SelectedValue)
                };

                string retorno = exercicioTreinamentoNegocio.Alterar(exerciciosTreinamentoAlterar);
                try
                {
                    int codigo = Convert.ToInt32(retorno);
                    MessageBox.Show("Exercício alterado com sucesso. Código: " + retorno, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.DialogResult = DialogResult.Yes;
                }
                catch
                {
                    MessageBox.Show("Não foi possível alterar exercício. Detalhes: " + retorno, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
        }
예제 #9
0
 public void AtualizarGridNoticia(DialogResult dialogResult)
 {
     using (NoticiaNegocio noticiaNegocio = new NoticiaNegocio())
     {
         ValidacaoInterfaces validarInterfaces = new ValidacaoInterfaces();
         if (dialogResult == DialogResult.Yes)
         {
             try
             {
                 ListaNoticia listaNoticia = noticiaNegocio.ConsultarNoticia(null, "%");
                 this.dgwSelecionarNoticia.DataSource = null;
                 this.dgwSelecionarNoticia.DataSource = listaNoticia;
                 this.dgwSelecionarNoticia.Update();
                 txtSelecionarCodTitulo.Focus();
                 txtSelecionarCodTitulo.Clear();
                 return;
             }
             catch (Exception ex)
             {
                 MessageBox.Show("Não foi possível atualizar, após ter inserido ou alterado notícia. Detalhes: " + ex.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 return;
             }
         }
         else if (validarInterfaces.ValidarCampoPesquisar(this.txtSelecionarCodTitulo, "título") == true)
         {
             return;
         }
         else if (this.txtSelecionarCodTitulo.Text.Where(c => char.IsNumber(c)).Count() > 0)
         {
             try
             {
                 ListaNoticia listaNoticia = noticiaNegocio.ConsultarNoticia(Convert.ToInt32(this.txtSelecionarCodTitulo.Text), null);
                 if (listaNoticia.Count() > 0)
                 {
                     this.dgwSelecionarNoticia.DataSource = null;
                     this.dgwSelecionarNoticia.DataSource = listaNoticia;
                     this.dgwSelecionarNoticia.Update();
                     this.dgwSelecionarNoticia.Refresh();
                     txtSelecionarCodTitulo.Focus();
                     return;
                 }
                 else
                 {
                     MessageBox.Show("Não existe nenhuma notícia com esse código: " + txtSelecionarCodTitulo.Text, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     txtSelecionarCodTitulo.Focus();
                     return;
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show("Não foi possível pesquisar notícia por código. Detalhes: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 txtSelecionarCodTitulo.Focus();
                 return;
             }
         }
         else
         {
             try
             {
                 ListaNoticia listaNoticia = noticiaNegocio.ConsultarNoticia(null, txtSelecionarCodTitulo.Text);
                 if (listaNoticia.Count() > 0)
                 {
                     this.dgwSelecionarNoticia.DataSource = null;
                     this.dgwSelecionarNoticia.DataSource = listaNoticia;
                     this.dgwSelecionarNoticia.Update();
                     this.dgwSelecionarNoticia.Refresh();
                     txtSelecionarCodTitulo.Focus();
                     return;
                 }
                 else
                 {
                     MessageBox.Show("Não existe nenhuma notícia com esse título: " + txtSelecionarCodTitulo.Text, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     txtSelecionarCodTitulo.Focus();
                     return;
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show("Não foi possível pesquisar notícia por título. Detalhes: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 txtSelecionarCodTitulo.Focus();
                 return;
             }
         }
     }
 }
예제 #10
0
        private void btnExercicioCadastrar_Click(object sender, EventArgs e)
        {
            using (ExercicioNegocio exercicioNegocio = new ExercicioNegocio())
            {
                ValidacaoInterfaces validarInterface = new ValidacaoInterfaces();
                if (validarInterface.validarCampoCadastrar(this.grpExercicio.Controls) == true)
                {
                    return;
                }
                if (validarInterface.validarCampoCadastrar(this.grpDemonstracao.Controls) == true)
                {
                    return;
                }


                if (acaoNaTelaInformada == AcaoNaTela.Inserir)
                {
                    var       bytes            = Encoding.UTF8.GetBytes(txtCadastrarUrlImagem.Text);
                    var       base64           = Convert.ToBase64String(bytes);
                    Exercicio exercicioInserir = new Exercicio()
                    {
                        Nome                  = this.txtCadastrarNome.Text,
                        Descricao             = this.rckCadastrarDescricao.Text,
                        DemonstracaoUrlImagem = txtCadastrarUrlImagem.Text,
                        DemonstracaoUrlVideo  = this.txtCadastrarUrlVideo.Text
                    };

                    exercicioInserir.TipoExercicio = new TipoExercicio()
                    {
                        IDTipoExercicio = Convert.ToInt32(cmbCadastrarTipo.SelectedValue)
                    };

                    string retorno = exercicioNegocio.Inserir(exercicioInserir);
                    try
                    {
                        int codigo = Convert.ToInt32(retorno);
                        MessageBox.Show("Exercicio cadastrado com sucesso. Código: " + codigo.ToString(), "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.DialogResult = System.Windows.Forms.DialogResult.Yes;
                    }
                    catch
                    {
                        MessageBox.Show("Não foi possível cadastrar o exercício. Detalhes: " + retorno, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }

                else if (acaoNaTelaInformada == AcaoNaTela.Alterar)
                {
                    Exercicio exercicioAlterar = new Exercicio()
                    {
                        IDExercicio           = Convert.ToInt32(this.txtCadastrarCodigo.Text),
                        Nome                  = this.txtCadastrarNome.Text,
                        Descricao             = this.rckCadastrarDescricao.Text,
                        DemonstracaoUrlImagem = this.txtCadastrarUrlImagem.Text,
                        DemonstracaoUrlVideo  = txtCadastrarUrlVideo.Text
                    };

                    exercicioAlterar.TipoExercicio = new TipoExercicio()
                    {
                        IDTipoExercicio = Convert.ToInt32(cmbCadastrarTipo.SelectedValue)
                    };

                    string retorno = exercicioNegocio.Alterar(exercicioAlterar);
                    try
                    {
                        int codigo = Convert.ToInt32(retorno);
                        MessageBox.Show("Exercício alterado com sucesso. Código: " + codigo.ToString(), "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.DialogResult = System.Windows.Forms.DialogResult.Yes;
                    }
                    catch
                    {
                        MessageBox.Show("Não foi possível alterar o exercício. Detalhes: " + retorno, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }
            }
        }
        private void btnCadastrarTreinamento_Click(object sender, EventArgs e)
        {
            using (TreinamentoNegocio treinamentoNegocio = new TreinamentoNegocio())
            {
                ValidacaoInterfaces validarInterfaces = new ValidacaoInterfaces();
                if (acaoNaTelaInformada == AcaoNaTela.Inserir)
                {
                    if (validarInterfaces.ValidarRadioButton(rbtCadastrarAtivoSim, rbtCadastrarAtivoNao) == true)
                    {
                        return;
                    }
                    if (cbxCadastrarTipoTreinamento.Text == "")
                    {
                        MessageBox.Show("Campo obrigatório nulo: Treinamento", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        cbxCadastrarTipoTreinamento.Focus();
                        return;
                    }
                    if (cbxCadastrarTipoTreinamento.SelectedValue == null)
                    {
                        MessageBox.Show("Tipo de treinamento físico não existe", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        cbxCadastrarTipoTreinamento.Focus();
                        return;
                    }
                    Treinamento treinamentoInserir = new Treinamento()
                    {
                        Ativo = rbtCadastrarAtivoSim.Checked == true ? true : false
                    };
                    treinamentoInserir.TipoTreinamento = new TipoTreinamento()
                    {
                        IDTipoTreinamento = Convert.ToInt32(cbxCadastrarTipoTreinamento.SelectedValue)
                    };

                    treinamentoInserir.Aluno        = new Aluno();
                    treinamentoInserir.Aluno.Pessoa = new Pessoa()
                    {
                        IDPessoa = Convert.ToInt32(txtCodigoAluno.Text)
                    };

                    string retorno = treinamentoNegocio.Inserir(treinamentoInserir);

                    try
                    {
                        int IDTreinamento = Convert.ToInt32(retorno);
                        grpFichaTreinamento.Enabled        = true;
                        grpTreinamentoFisico.Enabled       = false;
                        btnCadastrarTreinamento.Text       = "";
                        txtCadastrarTreinamentoCodigo.Text = IDTreinamento.ToString();
                        cbxCadastrarExercicio.Focus();
                    }
                    catch
                    {
                        MessageBox.Show("Não foi possível cadastrar as informações do treinamento. Detalhes: " + retorno, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        cbxCadastrarTipoTreinamento.Focus();
                        return;
                    }
                }

                else if (acaoNaTelaInformada == AcaoNaTela.Alterar)
                {
                    if (validarInterfaces.ValidarRadioButton(rbtCadastrarAtivoSim, rbtCadastrarAtivoNao) == true)
                    {
                        return;
                    }

                    Treinamento treinamentoAlterar = new Treinamento()
                    {
                        IDTreinamento = Convert.ToInt32(txtCadastrarTreinamentoCodigo.Text),
                        Ativo         = rbtCadastrarAtivoSim.Checked == true? true: false
                    };
                    treinamentoAlterar.TipoTreinamento = new TipoTreinamento()
                    {
                        IDTipoTreinamento = Convert.ToInt32(cbxCadastrarTipoTreinamento.SelectedValue)
                    };

                    treinamentoAlterar.Aluno        = new Aluno();
                    treinamentoAlterar.Aluno.Pessoa = new Pessoa()
                    {
                        IDPessoa = Convert.ToInt32(txtCodigoAluno.Text)
                    };

                    string retorno = treinamentoNegocio.Alterar(treinamentoAlterar);
                    try
                    {
                        int IDTreinamento = Convert.ToInt32(retorno);
                        grpFichaTreinamento.Enabled  = true;
                        grpTreinamentoFisico.Enabled = false;
                        cbxCadastrarExercicio.Focus();
                    }
                    catch
                    {
                        MessageBox.Show("Não foi possível alterar as informações do treinamento. Detalhes: " + retorno, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        cbxCadastrarTipoTreinamento.Focus();
                        return;
                    }
                }
            }
        }
        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;
                    }
                }
            }
        }
        public void AtualizarGridExercicio(DialogResult dialogResult)
        {
            using (ExercicioNegocio exercicioNegocio = new ExercicioNegocio())
            {
                ValidacaoInterfaces validarInterfaces = new ValidacaoInterfaces();
                if (dialogResult == DialogResult.Yes)
                {
                    try
                    {
                        ListaExercicio listaExercicio = exercicioNegocio.PesquisarExercicioCodigoNome(null, "%");
                        this.dgwSelecionarExercicio.DataSource = null;
                        this.dgwSelecionarExercicio.DataSource = listaExercicio;
                        this.dgwSelecionarExercicio.Update();
                        this.dgwSelecionarExercicio.Refresh();
                        txtSelecionarCodNome.Focus();
                        txtSelecionarCodNome.Clear();
                        return;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Não foi possível atualizar, após ter inserido ou alterado exercício. Detalhes: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtSelecionarCodNome.Focus();
                        return;
                    }
                }



                else if (validarInterfaces.ValidarCampoPesquisar(txtSelecionarCodNome, "nome") == true)
                {
                    return;
                }

                else if (this.txtSelecionarCodNome.Text.Where(c => char.IsNumber(c)).Count() > 0)
                {
                    try
                    {
                        ListaExercicio listaExercicio = exercicioNegocio.PesquisarExercicioCodigoNome(Convert.ToInt32(this.txtSelecionarCodNome.Text), null);
                        if (listaExercicio.Count() > 0)
                        {
                            this.dgwSelecionarExercicio.DataSource = null;
                            this.dgwSelecionarExercicio.DataSource = listaExercicio;
                            this.dgwSelecionarExercicio.Update();
                            this.dgwSelecionarExercicio.Refresh();
                            txtSelecionarCodNome.Focus();
                            return;
                        }
                        else
                        {
                            MessageBox.Show("Não existe nenhum exercício com esse código: " + txtSelecionarCodNome.Text, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            txtSelecionarCodNome.Focus();
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Não foi possível pesquisar exercício por código. Detalhes: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtSelecionarCodNome.Focus();
                        return;
                    }
                }
                else
                {
                    try
                    {
                        ListaExercicio listaExercicio = exercicioNegocio.PesquisarExercicioCodigoNome(null, this.txtSelecionarCodNome.Text);
                        if (listaExercicio.Count() > 0)
                        {
                            this.dgwSelecionarExercicio.DataSource = null;
                            this.dgwSelecionarExercicio.DataSource = listaExercicio;
                            this.dgwSelecionarExercicio.Update();
                            this.dgwSelecionarExercicio.Refresh();
                            txtSelecionarCodNome.Focus();
                            return;
                        }
                        else
                        {
                            MessageBox.Show("Não existe nenhum exercício com esse nome: " + txtSelecionarCodNome.Text, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            txtSelecionarCodNome.Focus();
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Não foi possível pesquisar exercício por nome. Detalhes: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtSelecionarCodNome.Focus();
                        return;
                    }
                }
            }
        }
예제 #14
0
 public void AtualizarGridTipoMedidaCorporal(DialogResult dialogResult)
 {
     using (TipoMedidaCorporalNegocio tipoMedidaNegocio = new TipoMedidaCorporalNegocio())
     {
         ValidacaoInterfaces validarInterfaces = new ValidacaoInterfaces();
         if (dialogResult == DialogResult.Yes)
         {
             try
             {
                 ListaTipoMedidaCorporal listaTipoMedidaCorporal = tipoMedidaNegocio.PesquisarTipoMedidaCorporal(null, "%");
                 this.dgwSelecionarTipoMedidaCorporal.DataSource = null;
                 this.dgwSelecionarTipoMedidaCorporal.DataSource = listaTipoMedidaCorporal;
                 this.dgwSelecionarTipoMedidaCorporal.Update();
                 this.dgwSelecionarTipoMedidaCorporal.Refresh();
                 txtSelecionarCodDescricao.Focus();
                 txtSelecionarCodDescricao.Clear();
                 return;
             }
             catch (Exception ex)
             {
                 MessageBox.Show("Não foi possível atualizar, após ter inserido ou alterado tipo de medida corporal. Detalhes: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 return;
             }
         }
         else if (validarInterfaces.ValidarCampoPesquisar(txtSelecionarCodDescricao, "descrição") == true)
         {
             return;
         }
         else if (txtSelecionarCodDescricao.Text.Where(c => char.IsNumber(c)).Count() > 0)
         {
             try
             {
                 ListaTipoMedidaCorporal listaTipoMedidaCorporal = tipoMedidaNegocio.PesquisarTipoMedidaCorporal(Convert.ToInt32(txtSelecionarCodDescricao.Text), null);
                 if (listaTipoMedidaCorporal.Count() > 0)
                 {
                     this.dgwSelecionarTipoMedidaCorporal.DataSource = null;
                     this.dgwSelecionarTipoMedidaCorporal.DataSource = listaTipoMedidaCorporal;
                     this.dgwSelecionarTipoMedidaCorporal.Update();
                     this.dgwSelecionarTipoMedidaCorporal.Refresh();
                     txtSelecionarCodDescricao.Focus();
                     return;
                 }
                 else
                 {
                     MessageBox.Show("Não existe nenhum tipo de medida corporal com esse código: " + txtSelecionarCodDescricao.Text, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     txtSelecionarCodDescricao.Focus();
                     return;
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show("Não foi possível pesquisar tipo de medida corporal por código. Detalhes: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 txtSelecionarCodDescricao.Focus();
                 return;
             }
         }
         else
         {
             try
             {
                 ListaTipoMedidaCorporal listaTipoMedidaCorporal = tipoMedidaNegocio.PesquisarTipoMedidaCorporal(null, txtSelecionarCodDescricao.Text);
                 if (listaTipoMedidaCorporal.Count() > 0)
                 {
                     this.dgwSelecionarTipoMedidaCorporal.DataSource = null;
                     this.dgwSelecionarTipoMedidaCorporal.DataSource = listaTipoMedidaCorporal;
                     this.dgwSelecionarTipoMedidaCorporal.Update();
                     this.dgwSelecionarTipoMedidaCorporal.Refresh();
                     txtSelecionarCodDescricao.Focus();
                     return;
                 }
                 else
                 {
                     MessageBox.Show("Não existe nenhum tipo de medida corporal com essa descrição: " + txtSelecionarCodDescricao.Text, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     txtSelecionarCodDescricao.Focus();
                     return;
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show("Não foi possível pesquisar tipo de medida corporal por descrição. Detalhes: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 txtSelecionarCodDescricao.Focus();
                 return;
             }
         }
     }
 }
예제 #15
0
        public void AtualizarGrid(DialogResult dialogResult)
        {
            using (TipoTreinamentoNegocio tipoTreinamentoNegocio = new TipoTreinamentoNegocio())
            {
                ValidacaoInterfaces  validar = new ValidacaoInterfaces();
                ListaTipoTreinamento listaTipoTreinamento = new ListaTipoTreinamento();
                if (dialogResult == DialogResult.Yes)
                {
                    try
                    {
                        listaTipoTreinamento = tipoTreinamentoNegocio.PesquisarTreinamentoCodigoNome(null, "%");
                        this.dgwSelecionarTipoTreinamento.DataSource = null;
                        this.dgwSelecionarTipoTreinamento.DataSource = listaTipoTreinamento;
                        this.dgwSelecionarTipoTreinamento.Update();
                        this.dgwSelecionarTipoTreinamento.Refresh();
                        this.txtSelecionarCodDescricao.Clear();
                        this.txtSelecionarCodDescricao.Focus();
                        return;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Não foi possível atualizar, após ter inserido ou alterado o tipo de treinamento. Detalhes: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtSelecionarCodDescricao.Clear();
                        txtSelecionarCodDescricao.Focus();
                        return;
                    }
                }

                if (validar.ValidarCampoPesquisar(txtSelecionarCodDescricao, "descrição") == true)
                {
                    return;
                }

                if (txtSelecionarCodDescricao.Text.Where(c => char.IsNumber(c)).Count() > 0)
                {
                    try
                    {
                        listaTipoTreinamento = tipoTreinamentoNegocio.PesquisarTreinamentoCodigoNome(Convert.ToInt32(txtSelecionarCodDescricao.Text), null);
                        if (listaTipoTreinamento.Count > 0)
                        {
                            this.dgwSelecionarTipoTreinamento.DataSource = null;
                            this.dgwSelecionarTipoTreinamento.DataSource = listaTipoTreinamento;
                            this.dgwSelecionarTipoTreinamento.Update();
                            this.dgwSelecionarTipoTreinamento.Refresh();
                            this.txtSelecionarCodDescricao.Focus();
                            return;
                        }
                        else
                        {
                            MessageBox.Show("Não possui nenhum tipo de treinamento com esse código: " + txtSelecionarCodDescricao.Text, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            txtSelecionarCodDescricao.Clear();
                            txtSelecionarCodDescricao.Focus();
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Não foi possível pesquisar por código. Detalhes: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtSelecionarCodDescricao.Focus();
                        txtSelecionarCodDescricao.Clear();
                        return;
                    }
                }
                else if (txtSelecionarCodDescricao.Text.Where(c => char.IsLetter(c)).Count() > 0)
                {
                    try
                    {
                        listaTipoTreinamento = tipoTreinamentoNegocio.PesquisarTreinamentoCodigoNome(null, txtSelecionarCodDescricao.Text);
                        if (listaTipoTreinamento.Count > 0)
                        {
                            this.dgwSelecionarTipoTreinamento.DataSource = null;
                            this.dgwSelecionarTipoTreinamento.DataSource = listaTipoTreinamento;
                            this.dgwSelecionarTipoTreinamento.Update();
                            this.dgwSelecionarTipoTreinamento.Refresh();
                            this.txtSelecionarCodDescricao.Focus();
                            return;
                        }
                        else
                        {
                            MessageBox.Show("Não possui nenhum tipo de treinamento com essa descrição: " + txtSelecionarCodDescricao.Text, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            txtSelecionarCodDescricao.Clear();
                            txtSelecionarCodDescricao.Focus();
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Não foi possível pesquisar o tipo de treinamento por descrição. Detalhes: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtSelecionarCodDescricao.Clear();
                        txtSelecionarCodDescricao.Focus();
                        return;
                    }
                }
            }
        }
예제 #16
0
        private void btnEquipamentoCadastrar_Click(object sender, EventArgs e)
        {
            using (EquipamentoNegocio equipamentoNegocio = new EquipamentoNegocio())
            {
                ValidacaoInterfaces validarInterfaces = new ValidacaoInterfaces();
                if (validarInterfaces.validarCampoCadastrar(this.grpEquipamento.Controls) == true)
                {
                    return;
                }
                else if (validarInterfaces.ValidarRadioButton(this.rbtCadastrarAtivoSim, this.rbtCadastrarAtivoNao) == true)
                {
                    return;
                }

                if (acaoNaTelaInformada == AcaoNaTela.Inserir)
                {
                    Equipamento equipamentoInserir = new Equipamento()
                    {
                        Nome       = this.txtCadastrarNomeEquipamento.Text,
                        Quantidade = Convert.ToInt32(this.txtCadastrarQuantidade.Text),
                        Ativo      = this.rbtCadastrarAtivoSim.Checked == true? true: false
                    };

                    string retorno = equipamentoNegocio.Inserir(equipamentoInserir);

                    try
                    {
                        int codigo = Convert.ToInt32(retorno);
                        MessageBox.Show("Equipamento cadastrado com sucesso. Código: " + codigo.ToString(), "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.DialogResult = System.Windows.Forms.DialogResult.Yes;
                    }
                    catch
                    {
                        MessageBox.Show("Não foi possível cadastrar o equipamento. Detalhes: " + retorno, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                else if (acaoNaTelaInformada == AcaoNaTela.Alterar)
                {
                    Equipamento equipamentoAlterar = new Equipamento()
                    {
                        IDEquipamento = Convert.ToInt32(this.txtCadastrarCodigo.Text),
                        Nome          = txtCadastrarNomeEquipamento.Text,
                        Quantidade    = Convert.ToInt32(this.txtCadastrarQuantidade.Text),
                        Ativo         = this.rbtCadastrarAtivoSim.Checked == true? true: false
                    };

                    string retorno = equipamentoNegocio.Alterar(equipamentoAlterar);

                    try
                    {
                        int codigo = Convert.ToInt32(retorno);
                        MessageBox.Show("Equipamento alterado com sucesso. Código: " + codigo.ToString(), "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.DialogResult = System.Windows.Forms.DialogResult.Yes;
                    }
                    catch
                    {
                        MessageBox.Show("Não foi possível alterar o equipamento. Detalhes: " + retorno, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
            }
        }
        private void btnNoticiaCadastrar_Click(object sender, EventArgs e)
        {
            using (NoticiaNegocio noticiaNegocio = new NoticiaNegocio())
            {
                ValidacaoInterfaces validarInterfaces = new ValidacaoInterfaces();
                if (validarInterfaces.validarCampoCadastrar(grpNoticia.Controls) == true)
                {
                    return;
                }
                else if (validarInterfaces.ValidarRadioButton(this.rbtCadastrarAtivoSim, rbtCadastrarAtivoNao) == true)
                {
                    return;
                }

                if (acaoNaTelaInformada == AcaoNaTela.Inserir)
                {
                    Noticia noticiaInserir = new Noticia()
                    {
                        Titulo    = txtCadastrarTitulo.Text.ToString(),
                        Descricao = rckCadastrarDescricao.Text,
                        Ativo     = rbtCadastrarAtivoSim.Checked == true? true: false
                    };

                    string retorno = noticiaNegocio.Inserir(noticiaInserir);
                    try
                    {
                        int codigo = Convert.ToInt32(retorno);
                        MessageBox.Show("Notícia cadastrada com sucesso. Código: " + codigo.ToString());
                        this.DialogResult = DialogResult.Yes;
                    }
                    catch
                    {
                        MessageBox.Show("Não foi possível cadastrar notícia. Detalhes: " + retorno, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                else if (acaoNaTelaInformada == AcaoNaTela.Alterar)
                {
                    Noticia noticiaAlterar = new Noticia()
                    {
                        IDNoticia = Convert.ToInt32(this.txtCadastrarCodigo.Text),
                        Titulo    = txtCadastrarTitulo.Text,
                        Descricao = rckCadastrarDescricao.Text,
                        Ativo     = rbtCadastrarAtivoSim.Checked == true? true: false
                    };

                    string retorno = noticiaNegocio.Alterar(noticiaAlterar);
                    try
                    {
                        int codigo = Convert.ToInt32(retorno);
                        MessageBox.Show("Notícia alterada com sucesso. Código: " + codigo.ToString(), "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.DialogResult = System.Windows.Forms.DialogResult.Yes;
                    }
                    catch
                    {
                        MessageBox.Show("Não foi possível alterar notícia. Detalhes: " + retorno, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
            }
        }
        public void  AtualizarGridObjetivo(DialogResult dialogResult)
        {
            using (ObjetivoNegocio objetivoNegocio = new ObjetivoNegocio())
            {
                ValidacaoInterfaces validarInterfaces = new ValidacaoInterfaces();
                if (dialogResult == DialogResult.Yes)
                {
                    try
                    {
                        ListaObjetivo listaObjetivo = objetivoNegocio.ConsultarObjetivoCodigoDescricao(null, "%");
                        dgwSelecionarObjetivo.DataSource = null;
                        dgwSelecionarObjetivo.DataSource = listaObjetivo;
                        dgwSelecionarObjetivo.Update();
                        dgwSelecionarObjetivo.Refresh();
                        txtSelecionarCodNome.Clear();
                        txtSelecionarCodNome.Focus();
                        return;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Não foi possível atualizar, após ter inserido ou alterado objetivo. Detalhes: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }


                else if (validarInterfaces.ValidarCampoPesquisar(this.txtSelecionarCodNome, "descrição") == true)
                {
                    return;
                }

                else if (this.txtSelecionarCodNome.Text.Where(c => char.IsNumber(c)).Count() > 0)
                {
                    try
                    {
                        ListaObjetivo listaObjetivo = objetivoNegocio.ConsultarObjetivoCodigoDescricao(Convert.ToInt32(this.txtSelecionarCodNome.Text), null);
                        if (listaObjetivo.Count() > 0)
                        {
                            dgwSelecionarObjetivo.DataSource = null;
                            dgwSelecionarObjetivo.DataSource = listaObjetivo;
                            dgwSelecionarObjetivo.Update();
                            dgwSelecionarObjetivo.Refresh();
                            txtSelecionarCodNome.Focus();
                            return;
                        }
                        else
                        {
                            MessageBox.Show("Não existe nenhum objetivo com esse código: " + txtSelecionarCodNome.Text, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            txtSelecionarCodNome.Focus();
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Não foi possível pesquisar objetivo por código. Detalhes: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtSelecionarCodNome.Focus();
                        return;
                    }
                }
                else
                {
                    try
                    {
                        ListaObjetivo listaObjetivo = objetivoNegocio.ConsultarObjetivoCodigoDescricao(null, this.txtSelecionarCodNome.Text);
                        if (listaObjetivo.Count() > 0)
                        {
                            dgwSelecionarObjetivo.DataSource = null;
                            dgwSelecionarObjetivo.DataSource = listaObjetivo;
                            dgwSelecionarObjetivo.Update();
                            dgwSelecionarObjetivo.Refresh();
                            txtSelecionarCodNome.Focus();
                            return;
                        }
                        else
                        {
                            MessageBox.Show("Não existe nenhum objetivo com essa descrição: " + txtSelecionarCodNome.Text, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            txtSelecionarCodNome.Focus();
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Não foi possível pesquisar objetivo por descrição. Detalhes: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtSelecionarCodNome.Focus();
                        return;
                    }
                }
            }
        }