Exemple #1
0
        public List <Grupo> ListarGrupos()
        {
            List <Grupo> grupo = new List <Grupo>();

            using (SqlConnection con = ConexionBD.Conectar())
            {
                con.Open();
                string     ssql    = "select * from Grupos";
                SqlCommand comando = new SqlCommand(ssql, con);
                comando.CommandType = CommandType.Text;
                IDataReader lector = comando.ExecuteReader();
                while (lector.Read())
                {
                    grupo.Add(new Grupo(lector.GetInt64(0),
                                        lector.GetString(1),
                                        lector.GetString(2),
                                        CarreraDAL.ObtenerPorId(lector.GetInt64(3)),
                                        ProfesorDAL.ObtenerPorId(lector.GetInt64(4))));
                }
                con.Close();
            }
            return(grupo);
        }
Exemple #2
0
        public static Grupo ObtenerPorId(Int64 pId)
        {
            Grupo grupo = new Grupo();

            using (SqlConnection con = ConexionBD.Conectar())
            {
                con.Open();
                string     ssql      = "select * from Grupos 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())
                {
                    grupo.Id          = lector.GetInt64(0);
                    grupo.NombreGrupo = lector.GetString(1);
                    grupo.Turno       = lector.GetString(2);
                    grupo.CarreraId   = CarreraDAL.ObtenerPorId(lector.GetInt64(3));
                    grupo.ProfesorId  = ProfesorDAL.ObtenerPorId(lector.GetInt64(4));
                }
                con.Close();
            }
            return(grupo);
        }
Exemple #3
0
        public List <Grupo> ObtenerGrupos(string pBuscar)
        {
            List <Grupo> lista = new List <Grupo>();

            using (SqlConnection con = ConexionBD.Conectar())
            {
                con.Open();
                string     ssql      = "select * from Grupos where NombreGrupo 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 Grupo(lector.GetInt64(0),
                                        lector.GetString(1),
                                        lector.GetString(2),
                                        CarreraDAL.ObtenerPorId(lector.GetInt64(3)),
                                        ProfesorDAL.ObtenerPorId(lector.GetInt64(4))));
                }
                con.Close();
            }
            return(lista);
        }