private void comboFichaAluno_SelectedIndexChanged(object sender, EventArgs e) { try { int n = Convert.ToInt16(comboFichaAluno.SelectedValue); if (n > 0) { // MessageBox.Show("" + comboFichaAluno.SelectedValue); FichaDetalhe fichaDet = new FichaDetalhe(); dataGridExercicios.DataSource = fichaDet.select(" where f.idFichaTreino=" + comboFichaAluno.SelectedValue); FichaTreino fichaTreino = new FichaTreino(); foreach (FichaTreino ficha1 in fichaTreino.selectArray("where id_fichaTreino = " + comboFichaAluno.SelectedValue)) { //maskedNomeFicha.Text = ""+ficha.NomeFicha; textNumeroTreinosR.Text = "" + ficha1.NumeroTreinosRealizados; } } else { } } catch (Exception ex) { } }
private void FrmCadTreino_FormClosing(object sender, FormClosingEventArgs e) { if (verificaClose == 0) { try { FichaTreino fichas = new FichaTreino(); int id; id = fichas.getIdPlanoTreino(); if (id > 0) { PlanoTreino plano = new PlanoTreino(); plano.Id = Convert.ToInt16(id); plano.updateDelete(); FichaTreino ficha = new FichaTreino(); ficha.IdPlanoTreino = Convert.ToInt16(id); ficha.updateDelete(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } //this.Close(); }
public ArrayList selectArrayback(string options = "") { ArrayList dados = new ArrayList(); MySqlConnection cn = new MySqlConnection(dbConnection.Conecta); cn.Open(); MySqlCommand cmd = new MySqlCommand("select * from fichaTreino " + options, cn); MySqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { FichaTreino ficha = new FichaTreino(); ficha.Id = Convert.ToInt16(dr["id_fichaTreino"]); ficha.IdPlanoTreino = Convert.ToInt16(dr["idPlanoTreino"]); ficha.NomeFicha = Convert.ToChar(dr["nomeFicha"]); ficha.NumeroTreinosRealizados = Convert.ToInt16(dr["numeroTreinosRealizados"]); ficha.Situacao = Convert.ToBoolean(dr["situacao"]); dados.Add(ficha); } dr.Close(); cn.Close(); return(dados); }
private void btCancelar_Click(object sender, EventArgs e) { try { FichaTreino fichas = new FichaTreino(); int id; id = fichas.getIdPlanoTreino(); if (id > 0) { PlanoTreino plano = new PlanoTreino(); plano.Id = Convert.ToInt16(id); plano.updateDelete(); FichaTreino ficha = new FichaTreino(); ficha.IdPlanoTreino = Convert.ToInt16(id); ficha.updateDelete(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } this.Close(); }
public void Remover(FichaTreino ficha) { using (var context = new SoftnessContext()) { context.FichaTreinos.Remove(ficha); context.SaveChanges(); } }
public void Atualiza(FichaTreino FichaTreinos) { using (var contexto = new SoftnessContext()) { contexto.Entry(FichaTreinos).State = EntityState.Modified; contexto.SaveChanges(); } }
public void Adiciona(FichaTreino ficha) { using (var context = new SoftnessContext()) { context.FichaTreinos.Add(ficha); context.SaveChanges(); } }
private void btAdicionar_Click(object sender, EventArgs e) { //Verifica se componente esta vazio if (maskedVezesSemana.Text.Trim().Length < 1) { MessageBox.Show("Digite uma quantidade de vezes na semana válido.", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Information); maskedVezesSemana.Focus(); return; } //Verifica se componente esta vazio if (comboNomeFicha.SelectedIndex == -1) { MessageBox.Show("Digite um nome para ficha válido.", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Information); comboNomeFicha.Focus(); return; } #region Verifica se o nome da ficha de treino ja esta sendo utilizada //Verifica se o nome da ficha de treino ja esta sendo utilizada PlanoTreino planos = new PlanoTreino(); DataTable dt = new DataTable(); dt = planos.verificacaoNomeTreino(" where p.idAluno = " + comboAluno.SelectedValue + " and f.nomeFicha = '" + comboNomeFicha.SelectedItem.ToString() + "' and p.situacao = 1 and f.situacao = 1;"); if (dt.Rows.Count >= 1) { MessageBox.Show("Este nome da ficha já esta sendo utilizado.", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Information); comboNomeFicha.Focus(); //comboNomeFicha.SelectedIndex = -1; return; } #endregion FichaTreino ficha = new FichaTreino(); int id; id = ficha.getIdPlanoTreino(); ficha.IdPlanoTreino = id; ficha.NomeFicha = Convert.ToChar(comboNomeFicha.SelectedItem.ToString()); ficha.NumeroTreinosRealizados = 0; ficha.Situacao = true; //MessageBox.Show("" + id); ficha.insert(); groupBoxFichasAluno.Enabled = true; groupBoxListaExercicios.Enabled = true; groupBoxFichaDetalhe.Enabled = true; comboNomeFicha.SelectedIndex = -1; carregarFichas(); }
public ActionResult AdicionaFicha(FichaTreino ficha) { FichaTreinoDAO dao = new FichaTreinoDAO(); if (ficha != null) { dao.Adiciona(ficha); return(RedirectToAction("Index", "Home")); } else { return(RedirectToAction("Nova")); } }
private void carregarFichas() { #region Carregar as Fichas no comboBox try { FichaTreino ficha = new FichaTreino(); ArrayList array = ficha.selectArray1(Convert.ToString(idPlanoTreino) + " order by nomeFicha"); comboFichaAluno.DataSource = array; comboFichaAluno.DisplayMember = "nomeFicha"; comboFichaAluno.ValueMember = "id"; } catch { } #endregion }
//Metodo para retornar os dados do aluno public ArrayList selectArray1(string options = "") { ArrayList dados = new ArrayList(); MySqlConnection cn = new MySqlConnection(dbConnection.Conecta); cn.Open(); MySqlCommand cmd = new MySqlCommand("select * from fichaTreino where idPlanoTreino=" + options, cn); MySqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { FichaTreino ficha = new FichaTreino(); ficha.Id = Convert.ToInt16(dr["id_fichaTreino"]); ficha.NomeFicha = Convert.ToChar(dr["nomeFicha"].ToString()); //alunos.IdUsuario = Convert.ToInt16(dr["idUsuario"]); dados.Add(ficha); } dr.Close(); cn.Close(); return(dados); }
public void insert() { MySqlConnection cn = new MySqlConnection(); FichaTreino fichaTreino = new FichaTreino(); cn.ConnectionString = dbConnection.Conecta; MySqlCommand cmd = new MySqlCommand(); cmd.Connection = cn; cmd.CommandText = "insert into fichaDetalhe(idFichaTreino, idExercicio, series, repeticoes, carga) values(@idFichaTreino, @idExercicio, @series, @repeticoes, @carga); select @@IDENTITY;"; //cmd.Parameters.AddWithValue("@idFichaTreino", fichaTreino.getIdFichaTreino()); cmd.Parameters.AddWithValue("@idFichaTreino", this.IdFichaTreino); //cmd.Parameters.AddWithValue("@idFichaTreino", this.IdFichaTreino); cmd.Parameters.AddWithValue("@idExercicio", this.IdExercicio); cmd.Parameters.AddWithValue("@series", this.Series); cmd.Parameters.AddWithValue("@repeticoes", this.Repeticoes); cmd.Parameters.AddWithValue("@carga", this.Carga); cn.Open(); this.Id = Convert.ToInt16(cmd.ExecuteScalar()); cn.Close(); }
public FrmAltTreino(int idPlanoTreino, int idFichaTreino, int idExercicio) { InitializeComponent(); deletaExercicio = new ArrayList(); this.idPlanoTreino = idPlanoTreino; this.idFichaTreino = idFichaTreino; comboGrupoMuscular.SelectedIndex = -1; comboExercicio.SelectedIndex = -1; FichaDetalhe ficha = new FichaDetalhe(); count = ficha.getIdFichaDetalhe() + 1; PlanoTreino planoTreino = new PlanoTreino(); foreach (PlanoTreino plano in planoTreino.selectArray("where id_planoTreino = " + idPlanoTreino)) { dateInicio.Text = plano.DataInicio; maskedVezesSemana.Text = "" + plano.VezesSemana; idAluno = plano.IdAluno; idTreinador = plano.IdTreinador; idObjetivo = plano.IdObjetivo; } FichaTreino fichaTreino = new FichaTreino(); foreach (FichaTreino fichaDet in fichaTreino.selectArray("where idPlanoTreino = " + idPlanoTreino)) { //maskedNomeFicha.Text = ""+ficha.NomeFicha; //comboFichaAluno.SelectedItem = "" + fichaDet.NomeFicha; //textNumeroTreinosR.Text = "" + fichaDet.NumeroTreinosRealizados; } try { int n = Convert.ToInt16(comboFichaAluno.SelectedValue); if (n > 0) { // MessageBox.Show("" + comboFichaAluno.SelectedValue); FichaDetalhe fichaDet = new FichaDetalhe(); dataGridExercicios.DataSource = fichaDet.select(" where f.idFichaTreino=" + comboFichaAluno.SelectedValue); } else { } } catch (Exception ex) { } //carregarExercicios(idFichaTreino); try { FichaTreino ficha1 = new FichaTreino(); ArrayList array = ficha1.selectArray1(Convert.ToString(idPlanoTreino) + " order by nomeFicha"); comboFichaAluno.DataSource = array; comboFichaAluno.DisplayMember = "nomeFicha"; comboFichaAluno.ValueMember = "id"; } catch { } }
private void btSalvar_Click(object sender, EventArgs e) { #region Validação dos componentes do cadastro if (comboAluno.SelectedIndex == -1) { MessageBox.Show("Selecione um aluno.", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Information); comboAluno.Focus(); return; } if (comboTreinador.SelectedIndex == -1) { MessageBox.Show("Selecione um Treinador.", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Information); comboTreinador.Focus(); return; } if (comboObjetivo.SelectedIndex == -1) { MessageBox.Show("Selecione um objetivo.", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Information); comboObjetivo.Focus(); return; } if (dateInicio.Text.Trim().Length < 10) { MessageBox.Show("Digite uma data válida.", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Information); dateInicio.Focus(); return; } if (maskedVezesSemana.Text.Trim().Length < 1) { MessageBox.Show("Digite uma quantidade de vezes na semana válido.", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Information); maskedVezesSemana.Focus(); return; } if (comboFichaAluno.SelectedIndex == -1) { MessageBox.Show("Digite um nome para ficha válido.", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Information); comboFichaAluno.Focus(); return; } if (dataGridExercicios.RowCount == 0) { MessageBox.Show("Insira algum exercício no treino.", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Information); comboGrupoMuscular.Focus(); return; } #endregion #region Alterar os dados PlanoTreino plano = new PlanoTreino(); plano.Id = idPlanoTreino; plano.IdAluno = Convert.ToInt16(comboAluno.SelectedValue); plano.IdTreinador = Convert.ToInt16(comboTreinador.SelectedValue); plano.IdObjetivo = Convert.ToInt16(comboObjetivo.SelectedValue); plano.DataInicio = dateInicio.Text.Trim(); plano.VezesSemana = Convert.ToInt16(maskedVezesSemana.Text.Trim()); plano.Situacao = true; plano.update(); FichaTreino ficha = new FichaTreino(); ficha.Id = idFichaTreino; //ficha.NomeFicha = Convert.ToChar(comboFichaAluno.SelectedItem.ToString()); ficha.Situacao = true; ficha.update(); //ficha.insertIdPlanoTreino(); FichaDetalhe detalhe = new FichaDetalhe(); for (int i = 0; i < dataGridExercicios.RowCount; i++) { //MessageBox.Show("6- " + dataGridExercicios.Rows[i].Cells["ColumnIdExercicio"].Value.ToString()); //MessageBox.Show("4- " + Convert.ToInt16(dataGridExercicios.Rows[i].Cells[""].Value.ToString())); //MessageBox.Show("5- " + Convert.ToInt16(dataGridExercicios.Rows[i].Cells[5].Value.ToString())); ////MessageBox.Show("3- " + Convert.ToInt16(dataGridExercicios.Rows[i].Cells[3].Value.ToString())); detalhe.IdExercicio = Convert.ToInt16(dataGridExercicios.Rows[i].Cells["ColumnIdExercicios"].Value.ToString()); detalhe.Series = Convert.ToInt16(dataGridExercicios.Rows[i].Cells["ColumnSeries"].Value.ToString()); detalhe.Repeticoes = Convert.ToInt16(dataGridExercicios.Rows[i].Cells["ColumnRepeticoes"].Value.ToString()); detalhe.Carga = Convert.ToInt16(dataGridExercicios.Rows[i].Cells["ColumnCarga"].Value.ToString()); detalhe.update(); } MessageBox.Show("Treino Alterado com Sucesso."); #endregion #region Gravar o log //Geracao do log Logs logs = new Logs(); string linha; using (StreamReader reader = new StreamReader("user.txt")) { linha = reader.ReadLine(); } logs.IdUsuario = Convert.ToInt16(linha.ToString()); logs.IdAcao = 16; logs.Data = DateTime.Today.ToString("dd/MM/yyyy"); logs.Hora = DateTime.Now.ToString("HH:mm"); logs.insert(); #endregion this.Close(); }