public void cadastraAluno(Aluno aluno) { AlunoRepositorio.AbreConexaoBanco(); AlunoRepositorio.comando.CommandText = "insert into aluno (nome, data_nascimento, id_curso) " + "values ('" + aluno.Nome + "', '" + aluno.Data_nascimento.ToString("yyyy-MM-dd") + "', '" + aluno.Curso.Id_curso + "' )"; AlunoRepositorio.executaComandoInsertDeleteUpdate(AlunoRepositorio.comando); AlunoRepositorio.FechaConexaoBanco(); }
public List <Aluno> listaAlunoPorCurso(Curso curso) { AlunoRepositorio.AbreConexaoBanco(); AlunoRepositorio.comando.CommandText = "select aluno.matricula, aluno.nome, aluno.data_nascimento, curso.nome as nomeCurso from aluno " + "inner join curso where curso.nome = '" + curso.Nome + "'" + " and curso.id_curso = aluno.id_curso"; MySqlDataReader dadosRetornados = AlunoRepositorio.executaComandoSelect(comando); return(criaListaParaRetornar(dadosRetornados)); }
public int excluiAluno(string matricula) { AlunoRepositorio.AbreConexaoBanco(); AlunoRepositorio.comando.CommandText = "delete from aluno where aluno.matricula = '" + matricula + "'"; int x = AlunoRepositorio.executaComandoInsertDeleteUpdate(comando); AlunoRepositorio.FechaConexaoBanco(); return(x); }
public int editaAluno(Aluno aluno) { AlunoRepositorio.AbreConexaoBanco(); AlunoRepositorio.comando.CommandText = "update aluno set nome = '" + aluno.Nome + "', data_nascimento = '" + aluno.Data_nascimento.ToString("yyyy-MM-dd") + "'," + "id_curso = '" + aluno.Curso.Id_curso + "' where (matricula = '" + aluno.Matricula + "')"; int x = AlunoRepositorio.executaComandoInsertDeleteUpdate(comando); AlunoRepositorio.FechaConexaoBanco(); return(x); }
public void cadastraAluno(int matricula) { if (matricula < 1) { throw new Exception("É necessário informar a matricula do aluno"); } AlunoRepositorio.AbreConexaoBanco(); AlunoRepositorio.comando.CommandText = "insert into aluno (matricula) " + "values ('" + matricula + "')"; AlunoRepositorio.executaComandoInsertDeleteUpdate(AlunoRepositorio.comando); AlunoRepositorio.FechaConexaoBanco(); }