public void BorrarCursoRealizado()
        {
            SQLSERVERDB miBD      = new SQLSERVERDB(BD_SERVER, BD_NAME);
            string      sentencia = "DELETE FROM CursosRealizados "
                                    + "WHERE idCurso = " + idCurso + " AND correo = '" + correo + "';";

            miBD.Delete(sentencia);

            idCurso = -1;
            correo  = null;
        }
Beispiel #2
0
        public MaterialCurso(int idCurso, String nombre)
        {
            //Select
            SQLSERVERDB miBD      = new SQLSERVERDB(BD_SERVER, BD_NAME);
            string      sentencia = "SELECT * FROM MaterialCurso WHERE  idCurso = " + idCurso + "  AND nombre = '" + nombre + "';";

            object[] tupla = miBD.Select(sentencia)[0];

            this.idCurso = idCurso;
            this.nombre  = nombre;
            this.enlace  = (string)tupla[2];
        }
Beispiel #3
0
        public MaterialActividad(string nombre, string enlace, Actividad actividad)
        {
            //Insert
            SQLSERVERDB miBD      = new SQLSERVERDB(BD_SERVER, BD_NAME);
            string      sentencia = "INSERT INTO MaterialActividad VALUES (" + actividad.IdActividad + ",'" + nombre + "','" + enlace + "');";

            miBD.Insert(sentencia);

            this.nombre      = nombre;
            this.enlace      = enlace;
            this.idActividad = actividad.IdActividad;
        }
Beispiel #4
0
        public MaterialActividad(string nombre, int idActividad)
        {
            //Select
            SQLSERVERDB miBD      = new SQLSERVERDB(BD_SERVER, BD_NAME);
            string      sentencia = "SELECT * FROM MaterialActividad WHERE nombre = '" + nombre + "' AND idActividad = " + idActividad + ";";

            object[] tupla = miBD.Select(sentencia)[0];

            this.idActividad = (int)tupla[0];
            this.nombre      = (string)tupla[1];
            this.enlace      = (string)tupla[2];
        }
Beispiel #5
0
        public void BorrarDebate()
        {
            SQLSERVERDB miBD      = new SQLSERVERDB(BD_SERVER, BD_NAME);
            string      sentencia = "DELETE FROM Debate WHERE id = " + id + ";";

            miBD.Delete(sentencia);
            id               = -1;
            creadorDebate    = null;
            asuntoDebate     = null;
            mensajeDebate    = null;
            fechaPublicacion = null;
        }
Beispiel #6
0
        public static List <Rol> ListaRoles()
        {
            List <Rol>  lista = new List <Rol>();
            SQLSERVERDB miBD  = new SQLSERVERDB(BD_SERVER, BD_NAME);

            foreach (object[] tupla in miBD.Select("SELECT rolName FROM Rol;"))
            {
                string r = (string)tupla[0];
                lista.Add(new Rol(r));
            }
            return(lista);
        }
Beispiel #7
0
        public Rol(string name)
        {
            SQLSERVERDB miBD      = new SQLSERVERDB(BD_SERVER, BD_NAME);
            string      sentencia = "SELECT * FROM Rol WHERE rolName = '" + name + "';";

            object[] tupla = miBD.Select(sentencia)[0];

            rolName = (string)tupla[0];
            rolDes  = (string)tupla[1];
            admin   = (int)tupla[2] == 1 ? true : false;
            //admin = (bool)tupla[2];
        }
Beispiel #8
0
        public Debate(string creador, string asunto, string mensaje, string fecha)
        {
            SQLSERVERDB miBD      = new SQLSERVERDB(BD_SERVER, BD_NAME);
            string      sentencia = "INSERT INTO Debate VALUES (" + 0 + ",'" + creador + "', '" + asunto + "','" + mensaje + "','" + fecha + "');";

            miBD.Insert(sentencia);
            this.id               = (int)miBD.SelectScalar("SELECT MAX(id) FROM Debate");
            this.creadorDebate    = creador;
            this.asuntoDebate     = asunto;
            this.mensajeDebate    = mensaje;
            this.fechaPublicacion = fecha;
        }
Beispiel #9
0
        public void BorrarRol()
        {
            SQLSERVERDB miBD      = new SQLSERVERDB(BD_SERVER, BD_NAME);
            string      sentencia = "DELETE FROM Rol "
                                    + "WHERE rolName='" + rolName + "';";

            miBD.Delete(sentencia);

            rolName = null;
            rolDes  = null;
            admin   = false;
        }
Beispiel #10
0
        public static List <Usuario> listaProfesores()
        {
            List <Usuario> lista = new List <Usuario>();
            SQLSERVERDB    miBD  = new SQLSERVERDB(BD_SERVER, BD_NAME);

            foreach (object[] tupla in miBD.Select("SELECT correoUsuario FROM Usuario WHERE rolUsuario = 'PROFESOR';"))
            {
                string r = (string)tupla[0];
                lista.Add(new Usuario(r));
            }
            return(lista);
        }
Beispiel #11
0
        private static List <string> listaCorreos()
        {
            List <string> lista = new List <string>();
            SQLSERVERDB   miBD  = new SQLSERVERDB(BD_SERVER, BD_NAME);

            foreach (object[] tupla in miBD.Select("SELECT correoUsuario FROM Usuario;"))
            {
                string r = (string)tupla[0];
                lista.Add(r);
            }
            return(lista);
        }
Beispiel #12
0
        public void BorrarUsuario()
        {
            SQLSERVERDB miBD = new SQLSERVERDB(BD_SERVER, BD_NAME);

            miBD.Delete("DELETE FROM Usuario WHERE correoUsuario ='" + this.correoUsuario + "';");
            this.correoUsuario      = null;
            this.nombreUsuario      = null;
            this.contraseniaUsuario = null;
            this.cif = null;
            this.niu = null;
            this.rol = null;
        }
Beispiel #13
0
        public static List <Actividad> listaActividadesValoradas(Usuario u)
        {
            List <Actividad> res  = new List <Actividad>();
            SQLSERVERDB      miBD = new SQLSERVERDB(BD_SERVER, BD_NAME);

            foreach (Object[] tupla in miBD.Select("SELECT idActividad FROM ValoracionActividad WHERE correoUsuario = '" + u.CorreoUsuario + "';"))
            {
                int id = (int)tupla[0];
                res.Add(new Actividad(id));
            }

            return(res);
        }
Beispiel #14
0
        //Select
        public Mensaje(int id)
        {
            SQLSERVERDB miBD      = new SQLSERVERDB(BD_SERVER, BD_NAME);
            string      sentencia = "SELECT * FROM Mensaje WHERE idMensaje = " + id + ";";

            object[] tupla = miBD.Select(sentencia)[0];
            this.emisor    = (string)tupla[0];
            this.receptor  = (string)tupla[1];
            this.idMensaje = (int)tupla[2];
            this.asunto    = (string)tupla[3];
            this.cuerpo    = (string)tupla[4];
            this.fecha     = (string)tupla[5];
        }
Beispiel #15
0
        public Rol(string name, string des, bool adm)
        {
            SQLSERVERDB miBD      = new SQLSERVERDB(BD_SERVER, BD_NAME);
            string      sentencia = "INSERT INTO Rol VALUES("
                                    + "'" + name + "',"
                                    + "'" + des + "',"
                                    + (adm ? 1 : 0) + ");";

            miBD.Insert(sentencia);
            rolName = name;
            rolDes  = des;
            admin   = adm;
        }
Beispiel #16
0
        public MaterialCurso(string enlace, Curso curso, String nombre)
        {
            //Insert
            SQLSERVERDB miBD      = new SQLSERVERDB(BD_SERVER, BD_NAME);
            string      sentencia = "INSERT INTO MaterialCurso VALUES (" + curso.CursoID + ", '" + nombre + "' ,'" + enlace + "');";

            miBD.Insert(sentencia);


            this.enlace  = enlace;
            this.idCurso = curso.CursoID;
            this.nombre  = nombre;
        }
Beispiel #17
0
        //Insert
        public Mensaje(string emisor, string receptor, int idMensaje, string asunto, string cuerpo, string fecha)
        {
            SQLSERVERDB miBD      = new SQLSERVERDB(BD_SERVER, BD_NAME);
            string      sentencia = "INSERT INTO Mensaje VALUES('" + emisor + "','" + receptor + "'," + idMensaje + ",'" + asunto + "','" + cuerpo + "','" + fecha + "');";

            miBD.Insert(sentencia);
            this.emisor    = emisor;
            this.receptor  = receptor;
            this.idMensaje = idMensaje;
            this.asunto    = asunto;
            this.cuerpo    = cuerpo;
            this.fecha     = fecha;
        }
        public static List <Curso> listaCursos(string correo)
        {
            List <Curso> lista = new List <Curso>();
            SQLSERVERDB  miBD  = new SQLSERVERDB(BD_SERVER, BD_NAME);

            foreach (object[] tupla in miBD.Select("SELECT idCurso FROM CursosRealizados WHERE correo = '" + correo + "';"))
            {
                int cursoId = (int)tupla[0];
                lista.Add(new Curso(cursoId));
            }

            return(lista);
        }
Beispiel #19
0
        public static List <Curso> listaCursosValorados(Usuario u)
        {
            List <Curso> lista = new List <Curso>();
            SQLSERVERDB  miBD  = new SQLSERVERDB(BD_SERVER, BD_NAME);

            foreach (object[] tupla in miBD.Select("SELECT idCurso FROM ValoracionCurso WHERE correoUsuario = '" + u.CorreoUsuario + "';"))
            {
                int idCurso = (int)tupla[0];
                lista.Add(new Curso(idCurso));
            }

            return(lista);
        }
Beispiel #20
0
        public Debate(int id)
        {
            SQLSERVERDB miBD      = new SQLSERVERDB(BD_SERVER, BD_NAME);
            string      sentencia = "SELECT * FROM Debate WHERE id = " + id + ";";

            object[] tupla = miBD.Select(sentencia)[0];

            this.id               = (int)tupla[0];
            this.creadorDebate    = (string)tupla[1];
            this.asuntoDebate     = (string)tupla[2];
            this.mensajeDebate    = (string)tupla[3];
            this.fechaPublicacion = (string)tupla[4];
        }
        public static List <string> usuariosQueHanRellenadoPrueba(Curso curso)
        {
            List <string> lista = new List <string>();
            SQLSERVERDB   miBD  = new SQLSERVERDB(BD_SERVER, BD_NAME);

            foreach (object[] tupla in miBD.Select("SELECT correoUsuario FROM RespuestaPrueba WHERE idPrueba = " + curso.CursoID + ";"))
            {
                string correo = (string)tupla[0];
                lista.Add(correo);
            }

            return(lista);
        }
Beispiel #22
0
        public void setAdmin(Rol other, bool value)
        {
            if (!admin)
            {
                throw new Error("Rol sin permiso para establecer administradores.");
            }
            SQLSERVERDB miBD      = new SQLSERVERDB(BD_SERVER, BD_NAME);
            string      sentencia = "UPDATE Rol SET admin = " + (value?1:0) + " "
                                    + "WHERE rolName='" + other.RolName + "';";

            miBD.Update(sentencia);
            other.admin = value;
        }
Beispiel #23
0
        public static List <Mensaje> listaMensajesRecibidos(string correo)
        {
            List <Mensaje> lista = new List <Mensaje>();
            SQLSERVERDB    miBD  = new SQLSERVERDB(BD_SERVER, BD_NAME);

            foreach (object[] tupla in miBD.Select("SELECT idMensaje FROM Mensaje WHERE receptor = '" + correo + "';"))
            {
                int idMensaje = (int)tupla[0];
                lista.Add(new Mensaje(idMensaje));
            }

            return(lista);
        }
Beispiel #24
0
        public static List <Actividad> listaActividades(string correo)
        {
            List <Actividad> lista = new List <Actividad>();
            SQLSERVERDB      miBD  = new SQLSERVERDB(BD_SERVER, BD_NAME);

            foreach (object[] tupla in miBD.Select("SELECT idActividad FROM ActividadesRealizadas WHERE correo = '" + correo + "';"))
            {
                int actId = (int)tupla[0];
                lista.Add(new Actividad(actId));
            }

            return(lista);
        }
Beispiel #25
0
        public static List <Usuario> listaUsuarios(int actId)
        {
            List <Usuario> lista = new List <Usuario>();
            SQLSERVERDB    miBD  = new SQLSERVERDB(BD_SERVER, BD_NAME);

            foreach (object[] tupla in miBD.Select("SELECT correo FROM ActividadesRealizadas WHERE idActividad = " + actId + ";"))
            {
                string correo = (string)tupla[0];
                lista.Add(new Usuario(correo));
            }

            return(lista);
        }
Beispiel #26
0
        public static List <Respuesta> listaRespuestas(int idDebate)
        {
            List <Respuesta> lista = new List <Respuesta>();
            SQLSERVERDB      miBD  = new SQLSERVERDB(BD_SERVER, BD_NAME);

            foreach (object[] tupla in miBD.Select("SELECT idRespuesta FROM Respuesta WHERE idDebate = " + idDebate + ";"))
            {
                Console.WriteLine((int)tupla[0]);
                int idRespuesta = (int)tupla[0];
                lista.Add(new Respuesta(idRespuesta));
            }
            return(lista);
        }
Beispiel #27
0
        public void BorrarRespuesta()
        {
            SQLSERVERDB miBD = new SQLSERVERDB(BD_SERVER, BD_NAME);

            miBD.Delete("DELETE * FROM Respuesta WHERE idRespuesta = " + this.idRespuesta);
            this.idRespuesta = -1;

            this.debate = null;

            this.mensaje = null;
            this.creador = null;
            this.fecha   = null;
        }
        public PruebaConocimiento(int idCursoPrueba)
        {
            SQLSERVERDB miBD      = new SQLSERVERDB(BD_SERVER, BD_NAME);
            string      sentencia = "SELECT * FROM PruebaConocimiento WHERE idCursoPrueba = " + idCursoPrueba + ";";

            object[] tupla = miBD.Select(sentencia)[0];

            this.p1            = (string)tupla[0];
            this.p2            = (string)tupla[1];
            this.p3            = (string)tupla[2];
            this.p4            = (string)tupla[3];
            this.p5            = (string)tupla[4];
            this.idCursoPrueba = (int)tupla[5];
        }
Beispiel #29
0
        public Respuesta(Debate debate, Usuario creador, string mensaje, string fecha)
        {
            SQLSERVERDB miBD = new SQLSERVERDB(BD_SERVER, BD_NAME);

            string sentencia = "INSERT INTO Respuesta VALUES (" + 0 + "," + debate.ID + ",'" + creador.CorreoUsuario + "','" + mensaje + "','" + fecha + "');";

            miBD.Insert(sentencia);

            this.idRespuesta = (int)miBD.SelectScalar("SELECT MAX(idRespuesta) FROM Respuesta;");;
            this.debate      = debate;
            this.mensaje     = mensaje;
            this.creador     = creador;
            this.fecha       = fecha;
        }
        public PruebaConocimiento(string p1, string p2, string p3, string p4, string p5, int idCursoPrueba)
        {
            SQLSERVERDB miBD      = new SQLSERVERDB(BD_SERVER, BD_NAME);
            string      sentencia = "INSERT INTO PruebaConocimiento VALUES('" + p1 + "','" + p2 + "','" + p3 + "','" + p4 + "','" + p5 + "'," + idCursoPrueba + ");";

            miBD.Insert(sentencia);

            this.p1            = p1;
            this.p2            = p2;
            this.p3            = p3;
            this.p4            = p4;
            this.p5            = p5;
            this.idCursoPrueba = idCursoPrueba;
        }