public ArrayList selectArray(string options = "") { ArrayList dados = new ArrayList(); MySqlConnection cn = new MySqlConnection(dbConnection.Conecta); cn.Open(); MySqlCommand cmd = new MySqlCommand("select * from fichaDetalhe " + options, cn); MySqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { FichaDetalhe ficha = new FichaDetalhe(); ficha.Id = Convert.ToInt16(dr["id_fichaDetalhe"]); ficha.IdFichaTreino = Convert.ToInt16(dr["idFichaTreino"]); ficha.IdExercicio = Convert.ToInt16(dr["idExercicio"]); ficha.Series = Convert.ToInt16(dr["series"]); ficha.Repeticoes = Convert.ToInt16(dr["repeticoes"]); ficha.Carga = Convert.ToInt16(dr["carga"]); dados.Add(ficha); } dr.Close(); cn.Close(); return(dados); }
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) { } }
public FrmCadTreino() { InitializeComponent(); comboAluno.SelectedIndex = -1; comboTreinador.SelectedIndex = -1; comboObjetivo.SelectedIndex = -1; comboGrupoMuscular.SelectedIndex = -1; comboExercicio.SelectedIndex = -1; comboNomeFicha.SelectedIndex = -1; FichaDetalhe ficha = new FichaDetalhe(); count = ficha.getIdFichaDetalhe() + 1; }
private void deletar_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in dataGridExercicios.SelectedRows) { try { FichaDetalhe fichaDet = new FichaDetalhe(); fichaDet.Id = Convert.ToInt16(dataGridExercicios.CurrentRow.Cells[0].Value); fichaDet.delete(); dataGridExercicios.Rows.Remove(row); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
public void CriarFicha(Ficha ficha) { _appGestaoContext.Fichas.Add(ficha); _appGestaoContext.SaveChanges(); var fichaFuncionarios = _carrinhoFicha.CarrinhoFichaItens; foreach (var funcionario in fichaFuncionarios) { var fichaDetalhe = new FichaDetalhe() { FichaId = ficha.FichaId, FuncionarioId = funcionario.Funcionario.FuncionarioId }; _appGestaoContext.FichaDetalhes.Add(fichaDetalhe); } _appGestaoContext.SaveChanges(); }
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); } else { } } catch (Exception ex) { } }
private void adicionar_Click(object sender, EventArgs e) { #region Validação dos componentes do cadastro if (comboGrupoMuscular.SelectedIndex == -1) { MessageBox.Show("Selecione um grupo muscular.", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Information); comboObjetivo.Focus(); return; } if (comboExercicio.SelectedIndex == -1) { MessageBox.Show("Selecione um exercício.", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Information); comboObjetivo.Focus(); return; } if (numericSeries.Value.Equals("") || numericSeries.Value == 0) { MessageBox.Show("Digite um número de série válido.", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Information); numericSeries.Focus(); return; } if (numericRepeticoes.Value.Equals("") || numericRepeticoes.Value == 0) { MessageBox.Show("Digite um número de repetições válido.", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Information); numericRepeticoes.Focus(); return; } if (numericCarga.Value.Equals("")) { MessageBox.Show("Digite um número de carga válido.", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Information); numericCarga.Focus(); return; } #endregion #region Salva o exercicio #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 FichaDetalhe fichaD = new FichaDetalhe(); DataTable dt = new DataTable(); dt = fichaD.verificaTreino(" where d.idExercicio = " + comboExercicio.SelectedValue + " and f.nomeFicha = '" + comboFichaAluno.Text.ToString() + "' and p.idAluno = " + comboAluno.SelectedValue + " and f.situacao = 1 and p.situacao = 1;"); //MessageBox.Show("" + comboExercicio.SelectedValue + "" + comboFichaAluno.Text.ToString() + "" + comboAluno.SelectedValue); if (dt.Rows.Count >= 1) { MessageBox.Show("Esta ficha de treino já possui este exercício.", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Information); comboGrupoMuscular.Focus(); //comboNomeFicha.SelectedIndex = -1; return; } #endregion #region Adiciona na dataGrid //dataGridExercicios.Rows.Add(count, comboGrupoMuscular.Text, comboExercicio.Text, numericSeries.Value, numericRepeticoes.Value, numericCarga.Value, comboExercicio.SelectedValue, comboFichaAluno.SelectedValue); //count++; FichaDetalhe detalhe = new FichaDetalhe(); detalhe.IdFichaTreino = Convert.ToInt16(comboFichaAluno.SelectedValue); detalhe.IdExercicio = Convert.ToInt16(comboExercicio.SelectedValue); detalhe.Series = Convert.ToInt16(numericSeries.Value); detalhe.Repeticoes = Convert.ToInt16(numericRepeticoes.Value); detalhe.Carga = Convert.ToInt16(numericCarga.Value); detalhe.insert(); #endregion #region Limpar os componentes comboGrupoMuscular.SelectedIndex = -1; comboExercicio.SelectedIndex = -1; numericSeries.Value = 0; numericRepeticoes.Value = 0; numericCarga.Value = 0; comboGrupoMuscular.Focus(); #endregion 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) { } #endregion //#region Adiciona o exercicio na dataGrid //FichaDetalhe fichaDet = new FichaDetalhe(); //dataGridExercicios.Rows.Add(count, comboGrupoMuscular.Text, comboExercicio.Text, numericSeries.Value, numericRepeticoes.Value, numericCarga.Value, comboExercicio.SelectedValue); //count++; //#endregion #region Limpa os componentes comboGrupoMuscular.SelectedIndex = -1; comboExercicio.SelectedIndex = -1; numericSeries.Value = 0; numericRepeticoes.Value = 0; numericCarga.Value = 0; comboGrupoMuscular.Focus(); #endregion }
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(); }