public List <Matricula> misAlumnos(Int64 pId) { List <Matricula> lista = new List <Matricula>(); using (SqlConnection con = ConexionBD.Conectar()) { con.Open(); string ssql = "select a.*,b.Id, b.ProfesorId, c.Id from Matriculas as a inner join Grupos as b on a.GrupoId=b.Id inner join Profesores as c on b.ProfesorId=c.Id where c.Id={0}"; string sentencia = string.Format(ssql, pId); SqlCommand comando = new SqlCommand(sentencia, con); comando.CommandType = CommandType.Text; IDataReader lector = comando.ExecuteReader(); while (lector.Read()) { lista.Add(new Matricula(lector.GetInt64(0), lector.GetString(1), lector.GetString(2), CarreraDAL.ObtenerPorId(lector.GetInt64(3)), EstudianteDAL.ObtenerPorId(lector.GetInt64(4)), GrupoDAL.ObtenerPorId(lector.GetInt64(5)))); } con.Close(); } return(lista); }
public List <Matricula> CodigoAlumnos(string pBuscar) { List <Matricula> lista = new List <Matricula>(); using (SqlConnection con = ConexionBD.Conectar()) { con.Open(); string ssql = " select a.*, b.* from Matriculas as a inner join Estudiantes as b on a.EstudianteId=b.Id where b.Codigo like '%{0}%'"; string sentencia = string.Format(ssql, pBuscar); SqlCommand comando = new SqlCommand(sentencia, con); comando.CommandType = CommandType.Text; IDataReader lector = comando.ExecuteReader(); while (lector.Read()) { lista.Add(new Matricula(lector.GetInt64(0), lector.GetString(1), lector.GetString(2), CarreraDAL.ObtenerPorId(lector.GetInt64(3)), EstudianteDAL.ObtenerPorId(lector.GetInt64(4)), GrupoDAL.ObtenerPorId(lector.GetInt64(5)))); } con.Close(); } return(lista); }
public static Matricula ObtenerPorId(Int64 pId) { Matricula matricula = new Matricula(); using (SqlConnection con = ConexionBD.Conectar()) { con.Open(); string ssql = "select * from Matriculas where Id={0}"; string sentencia = string.Format(ssql, pId); SqlCommand comando = new SqlCommand(sentencia, con); comando.CommandType = CommandType.Text; IDataReader lector = comando.ExecuteReader(); if (lector.Read()) { matricula.Id = lector.GetInt64(0); matricula.Año = lector.GetString(1); matricula.Ciclo = lector.GetString(2); matricula.CarreraId = CarreraDAL.ObtenerPorId(lector.GetInt64(3)); matricula.EstudianteId = EstudianteDAL.ObtenerPorId(lector.GetInt64(4)); matricula.GrupoId = GrupoDAL.ObtenerPorId(lector.GetInt64(5)); } con.Close(); } return(matricula); }
public List <Matricula> ListarMatricula() { List <Matricula> lista = new List <Matricula>(); using (SqlConnection con = ConexionBD.Conectar()) { con.Open(); string ssql = "select * from Matriculas"; SqlCommand comando = new SqlCommand(ssql, con); comando.CommandType = CommandType.Text; IDataReader lector = comando.ExecuteReader(); while (lector.Read()) { lista.Add(new Matricula(lector.GetInt64(0), lector.GetString(1), lector.GetString(2), CarreraDAL.ObtenerPorId(lector.GetInt64(3)), EstudianteDAL.ObtenerPorId(lector.GetInt64(4)), GrupoDAL.ObtenerPorId(lector.GetInt64(5)))); } con.Close(); } return(lista); }