예제 #1
0
        public List<Aluno> ListarTodos()
        {
            var lista = new List<Aluno>();
            sql = "SELECT * FROM ALUNOS";
            SqlDataReader alunos = new Contexto().ExecutaComandoComRetorno(sql);
            return TranformaReaderEmLista(alunos);

        }
예제 #2
0
 public void Excluir(int id)
 {
     using ( contexto = new Contexto())
     {
         sql = String.Format(" DELETE FROM ALUNOS WHERE ALUNOID = {0}", id);
         contexto.ExecutaComando(sql);
     }
 }
예제 #3
0
        public void Inserir(Aluno aluno)
        {
            
            sql = string.Format(@"INSERT INTO ALUNOS (NOME, CARGO, DATANASCIMENTO) VALUES ('{0}','{1}','{2}')",
                aluno.Nome, aluno.Cargo, aluno.DataNasc);

            using (contexto = new Contexto())
            {
                contexto.ExecutaComando(sql);
            }
        }
예제 #4
0
        public void Alterar(Aluno aluno)
        {
            StringBuilder _sql = new StringBuilder();

            _sql.Append("UPDATE ALUNOS SET ");
            _sql.Append(String.Format(" NOME = '{0}', ", aluno.Nome));
            _sql.Append(String.Format(" CARGO = '{0}', ", aluno.Cargo));
            _sql.Append(String.Format(" DATANASCIMENTO = '{0}' ", aluno.DataNasc));
            _sql.Append(String.Format(" WHERE ALUNOID  = {0}", aluno.Id));

            using (contexto = new Contexto())
            {
                contexto.ExecutaComando(_sql.ToString());
            }
        }