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(); }