Пример #1
0
        public void Insere(AvaliacaoModelo m)
        {
            SqlConnection conexao = new SqlConnection(Conexao.getConexao());
            try
            {
                //Comando de inserir:
                SqlCommand cmd = new SqlCommand("INSERT INTO Avaliacao (Aluno_idAluno, data_Avaliacao) VALUES (@idAluno, @data)", conexao);

                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add("@idAluno", m.getIdAluno());
                cmd.Parameters.Add("@data", m.getData());

                //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();
            }
        }
Пример #2
0
        public void update(AvaliacaoModelo m)
        {
            SqlConnection conexao = new SqlConnection(Conexao.getConexao());
            try
            {
                //Comando de deletar:
                SqlCommand cmd = new SqlCommand("UPDATE Avaliacao set Aluno_idAluno = @idAluno, data_Avaliacao = @data", conexao);

                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("@idAluno", m.getIdAluno());
                cmd.Parameters.AddWithValue("@data", m.getData());

                //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();
            }
        }
Пример #3
0
        public void delete(AvaliacaoModelo m)
        {
            SqlConnection conexao = new SqlConnection(Conexao.getConexao());
            try
            {
                //Comando de deletar:
                SqlCommand cmd = new SqlCommand("DELELTE Avaliacao where ID = @id_Avaliacao", conexao);

                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add("@idAluno", m.getIdAvaliacao());

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