public FrmTreinamentoAlterar(ExerciciosTreinamento exerciciosTreinamento) { InitializeComponent(); this.txtCodigoTreinamento.Text = exerciciosTreinamento.Treinamento.IDTreinamento.ToString(); this.txtCadastrarSeries.Text = exerciciosTreinamento.Series.ToString(); this.txtCadastrarRepeticoes.Text = exerciciosTreinamento.Repeticoes.ToString(); this.mskCadastrarIntervalo.Text = exerciciosTreinamento.Intervalo; using (ExercicioNegocio exercicioNegocio = new ExercicioNegocio()) { try { ListaExercicio listaExercicio = exercicioNegocio.PesquisarExercicioCodigoNome(null, "%"); cbxCadastrarExercicio.DataSource = listaExercicio; cbxCadastrarExercicio.DisplayMember = "Nome"; cbxCadastrarExercicio.ValueMember = "IDExercicio"; this.cbxCadastrarExercicio.Text = exerciciosTreinamento.Exercicio.Nome; } catch (Exception ex) { MessageBox.Show("Não foi possível carregar a lista de exercício. Detalhes: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } }
public ActionResult MostrarExercicio(int codigo, string treino) { ExercicioNegocio exercicioNegocio = new ExercicioNegocio(); ListaExercicio listaExercicio = exercicioNegocio.PesquisarExercicioCodigoNome(codigo, null); ViewBag.ExercicioNome = listaExercicio.Select(c => c.Nome).First(); ViewBag.IDTreinamento = Request.Cookies["IDTreinamento"].Value; ViewBag.Treino = treino; ViewBag.Url = "localhost"; return(View(listaExercicio.First())); }
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; } } } }
public FrmTreinamentoCadastrar(AcaoNaTela acaoNaTela, Treinamento treinamento) { acaoNaTelaInformada = acaoNaTela; InitializeComponent(); this.dgwTreinamentoExercicios.AutoGenerateColumns = false; using (ExercicioNegocio exercicioNegocio = new ExercicioNegocio()) { try { ListaExercicio listaExercicio = exercicioNegocio.PesquisarExercicioCodigoNome(null, "%"); cbxCadastrarExercicio.DataSource = listaExercicio; cbxCadastrarExercicio.DisplayMember = "Nome"; cbxCadastrarExercicio.ValueMember = "IDExercicio"; } catch (Exception ex) { MessageBox.Show("Não foi possível carregar a lista de exercício. Detalhes: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } using (TipoTreinamentoNegocio tipoTreinamentoNegocio = new TipoTreinamentoNegocio()) { try { ListaTipoTreinamento listaTipoTreinamento = tipoTreinamentoNegocio.PesquisarTreinamentoCodigoNome(null, "%"); cbxCadastrarTipoTreinamento.DataSource = listaTipoTreinamento; cbxCadastrarTipoTreinamento.DisplayMember = "Descricao"; cbxCadastrarTipoTreinamento.ValueMember = "IDTipoTreinamento"; } catch (Exception ex) { MessageBox.Show("Não foi possível carregar a lista de tipo de treinamento. Detalhes: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } cbxCadastrarExercicio.SelectedItem = null; cbxCadastrarTipoTreinamento.SelectedItem = null; if (acaoNaTelaInformada == AcaoNaTela.Inserir) { this.Text = "Cadastrar Treinamento Físico"; this.lblCadastrarTitulo.Text = "Cadastrar Treinamento Físico"; grpTreinamentoFisico.Enabled = true; grpFichaTreinamento.Enabled = false; pbxCadastrarTreinamento.Image = global::Apresentacao.Properties.Resources._1440663403_add_property; txtCodigoAluno.Text = treinamento.Aluno.Pessoa.IDPessoa.ToString(); txtCadastrarAluno.Text = treinamento.Aluno.Pessoa.Nome; txtMostrarObjetivo.Text = treinamento.Aluno.Objetivo.Descricao; btnCadastrarTreinamento.Text = "Cadastrar"; txtCadastrarQuantidadeExercicios.Text = "0"; cbxCadastrarTipoTreinamento.Select(); } else if (acaoNaTelaInformada == AcaoNaTela.Alterar) { this.Text = "Alterar Treinamento Físico"; this.lblCadastrarTitulo.Text = "Alterar Treinamento Físico"; // grpTreinamentoFisico.Enabled = false; grpFichaTreinamento.Enabled = true; pbxCadastrarTreinamento.Image = global::Apresentacao.Properties.Resources._1440663068_edit_property; txtCodigoAluno.Text = treinamento.Aluno.Pessoa.IDPessoa.ToString(); txtCadastrarAluno.Text = treinamento.Aluno.Pessoa.Nome; txtMostrarObjetivo.Text = treinamento.Aluno.Objetivo.Descricao; cbxCadastrarTipoTreinamento.Text = treinamento.TipoTreinamento.Descricao; btnCadastrarTreinamento.Text = "Alterar"; txtCadastrarTreinamentoCodigo.Text = treinamento.IDTreinamento.ToString(); AtualizarGridTreinamentos(DialogResult.Yes, treinamento.IDTreinamento); cbxCadastrarExercicio.Select(); grpBoxAtivo.Enabled = true; btnCadastrarTreinamento.Enabled = true; dtpCadastrarDataTreinamento.Enabled = false; cbxCadastrarTipoTreinamento.Enabled = false; rbtCadastrarAtivoSim.Checked = treinamento.Ativo == true ? true : false; rbtCadastrarAtivoNao.Checked = treinamento.Ativo == false ? true : false; dtpCadastrarDataTreinamento.Value = treinamento.DataCadastro; } }
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; } } } }