Пример #1
0
        //falta
        public void update(TreinoExercicioModelo m)
        {

            SqlConnection conexao = new SqlConnection(Conexao.getConexao());
            try
            {
                //Comando de deletar:
                SqlCommand cmd = new SqlCommand("UPDATE Treino_has_Exercicio set Exercicio_idExercicio = @idExercicio, intervalo = @intervalo, repeticoes = @repeticoes, dia = @dia, posicao = @posicao, qtdSerie = @qtdSerie", conexao);

                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("@idExercicio", m.getIdExercicio());
                cmd.Parameters.AddWithValue("@intervalo", m.getIntervalo());
                cmd.Parameters.Add("@repeticoes", m.getRepeticoes());
                cmd.Parameters.Add("@dia", m.getDia());
                cmd.Parameters.Add("@qtdSerie", m.getQtdSeries());


                //Abre conexao
                conexao.Open();
                //Executa
                cmd.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                throw new Exception("Erro ao deletar no Banco de Dados: " + ex.Message);
            }
            catch (Exception ex)
            {
                throw new Exception("Erro: " + ex.Message);
            }
            finally
            {
                conexao.Close();
            }
        }
Пример #2
0
        public void Insere(TreinoExercicioModelo m)
        {
            SqlConnection conexao = new SqlConnection(Conexao.getConexao());
            try
            {
                //Comando de inserir:
                SqlCommand cmd = new SqlCommand("INSERT INTO Treino_has_Exercicio (Treino_idTreino, Exercicio_idExercicio, intervalo, repeticoes, dia, posicao, qtdSerie) VALUES (@idTreino, @idExercicio, @intervalo, @repeticoes, @dia, @posicao, @qtdSerie)", conexao);

                cmd.CommandType = CommandType.Text;

                cmd.Parameters.Add("@idTreino", m.getIdTreino());
                cmd.Parameters.Add("@idExercicio", m.getIdExercicio());
                cmd.Parameters.Add("@intervalo", m.getIntervalo());
                cmd.Parameters.Add("@repeticoes", m.getRepeticoes());
                cmd.Parameters.Add("@dia", m.getDia());
                cmd.Parameters.Add("@posicao", m.getPosicao());
                cmd.Parameters.Add("@qtdSerie", m.getQtdSeries());

                //Abre conexao
                conexao.Open();

                //Executa
                cmd.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                throw new Exception("Erro ao inserir no Banco de Dados: " + ex.Message);
            }
            catch (Exception ex)
            {
                throw new Exception("Erro: " + ex.Message);
            }
            finally
            {
                conexao.Close();
            }
        }
Пример #3
0
        public void delete(TreinoExercicioModelo m)
        {

            SqlConnection conexao = new SqlConnection(Conexao.getConexao());
            try
            {
                //Comando de deletar:
                SqlCommand cmd = new SqlCommand("DELETE Treino_has_Exercicio where Treino_idTreino = @idTreino AND Exercicio_idExercicio = @idExercicio", conexao);

                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("@idTreino", m.getIdTreino());
                cmd.Parameters.AddWithValue("@idExercicio", m.getIdExercicio());

                //Abre conexao
                conexao.Open();
                //Executa
                cmd.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                throw new Exception("Erro ao deletar no Banco de Dados: " + ex.Message);
            }
            catch (Exception ex)
            {
                throw new Exception("Erro: " + ex.Message);
            }
            finally
            {
                conexao.Close();
            }
        }