Пример #1
0
        public static List <Resumenes> TraerResumenesXPuntYEsc(int idEsc)
        {
            List <Resumenes> ListaDeResumenes = new List <Resumenes>();

            Conectar();
            SqlCommand command = SQL.CreateCommand();

            command.CommandType = System.Data.CommandType.Text;
            command.CommandText = " SELECT TOP 8 * FROM Resumenes where FkEscuela = " + idEsc + " ORDER BY Puntuacion DESC"; //Consulta
            SqlDataReader dataReader = command.ExecuteReader();

            while (dataReader.Read())
            {
                int       idres = Convert.ToInt32(dataReader["IdResumen"]);
                string    Nom   = dataReader["Nombre"].ToString();
                int       fkMat = Convert.ToInt32(dataReader["FkMateria"]);
                int       fkUsu = Convert.ToInt32(dataReader["FkUsuario"]);
                int       punt  = Convert.ToInt32(dataReader["Puntuacion"]);
                int       ano   = Convert.ToInt32(dataReader["Anio"]);
                string    ft    = dataReader["Archivo"].ToString();
                int       fkesc = Convert.ToInt32(dataReader["FkEscuela"]);
                Resumenes resu  = new Resumenes(idres, Nom, fkMat, fkUsu, punt, ano, ft, fkesc);
                ListaDeResumenes.Add(resu);
            }
            dataReader.Close();
            Desconectar();
            return(ListaDeResumenes);
        }
Пример #2
0
        public static void ModificarResumen(Resumenes resu)
        {
            Conectar();
            SqlCommand command = SQL.CreateCommand();

            command.CommandType = System.Data.CommandType.Text;
            command.CommandText = "UPDATE Resumenes SET Nombre = '" + resu.Nombre + "', FkMateria =" + resu.FkMateria + ", FkUsuario = " + resu.FkUsuario + ", Puntuacion = " + resu.Puntuacion + "' WHERE IdResumen = " + resu.IdResumen; //Consulta
            SqlDataReader dataReader = command.ExecuteReader();

            Desconectar();
        }
Пример #3
0
        public static void InsertarResumen(Resumenes res)
        {
            Conectar();
            SqlCommand command = SQL.CreateCommand();

            command.CommandType = System.Data.CommandType.Text;
            command.CommandText = "INSERT into Resumenes(Nombre, FkMateria ,FkUsuario,Puntuacion,Anio,Archivo,FkEscuela ) values ('" + res.Nombre + "'," + res.FkMateria + "," + res.FkUsuario + "," + res.Puntuacion + "," + res.Ano + ",'" + res.Archivo + "'," + res.FkEscuela + ")"; //Consulta
            SqlDataReader dataReader = command.ExecuteReader();

            Desconectar();
        }
Пример #4
0
        public static List <Resumenes> TraerResumenes(int idRes)//Cuando es -1 trae todo, sino trae esa
        {
            List <Resumenes> ListaDeResumenes = new List <Resumenes>();

            Conectar();
            SqlCommand command = SQL.CreateCommand();

            command.CommandType = System.Data.CommandType.Text;
            if (idRes != -1)
            {
                command.CommandText = "SELECT* FROM Resumenes where IdResumen =" + idRes;  //Consulta
            }
            else
            {
                command.CommandText = "SELECT* FROM Resumenes"; //Consulta
            }
            SqlDataReader dataReader = command.ExecuteReader();

            while (dataReader.Read())
            {
                int       idres = Convert.ToInt32(dataReader["IdResumen"]);
                string    Nom   = dataReader["Nombre"].ToString();
                int       fkMat = Convert.ToInt32(dataReader["FkMateria"]);
                int       fkUsu = Convert.ToInt32(dataReader["FkUsuario"]);
                int       punt  = Convert.ToInt32(dataReader["Puntuacion"]);
                int       ano   = Convert.ToInt32(dataReader["Anio"]);
                string    ft    = dataReader["Archivo"].ToString();
                int       fkesc = Convert.ToInt32(dataReader["FkEscuela"]);
                Resumenes resu  = new Resumenes(idres, Nom, fkMat, fkUsu, punt, ano, ft, fkesc);
                ListaDeResumenes.Add(resu);
            }
            dataReader.Close();
            Desconectar();

            return(ListaDeResumenes);
        }