Beispiel #1
0
        //revisada
        //**************************************Funciones para las listas****************************************
        public static Materias GetMaterias(int idProfesor)
        {
            string scriptname = "ObtenerMaterias.php?";
            //Se crea la cadena para hacer el request
            string query = baseURL + scriptname;

            query += "idProfesor=" + idProfesor;

            //se hace el request
            string json = HacerRequest(query);

            //deserialización de json a c# object
            Materias x = new Materias();

            Newtonsoft.Json.JsonConvert.PopulateObject(json, x);
            //reconvertir colores
            if (x.materias != null)
            {
                for (int cont = 0; cont < x.materias.Count; cont++)
                {
                    materia obj = x.materias[cont];
                    obj.Color = ConvertirColor(obj.Color);
                }
            }
            return(x);
        }
Beispiel #2
0
        public static bool modificarMateria(materia mat)
        {
            string scriptname = "modificarMateria.php?";
            //Se crea la cadena para hacer el request
            string query = baseURL + scriptname;

            query += "idMateria=" + mat.IdMateria;
            query += "&nombre=" + mat.Nombre;
            query += "&matricula=" + mat.Matricula;
            query += "&idProfesor=" + mat.IdProfesor;
            query += "&color=" + PrepararColor(mat.Color);
            query += "&nick=" + mat.Nick;

            //se hace el request
            string json = HacerRequest(query);

            //deserialización de json a c# object
            materia x = new materia();

            Newtonsoft.Json.JsonConvert.PopulateObject(json, x);
            //reconvertir color
            x.Color = ConvertirColor(x.Color);
            if (x.Nombre.Length > 0)
            {
                return(true);
            }
            return(false);
        }
Beispiel #3
0
        //**************************************Funciones para las materias****************************************
        public static materia InsertarMateria(materia mat)
        {
            //insertarMateria.php?nombre=Sistemas%20embebidos&matricula=818323&idProfesor=2&color=%23009688&nick=SE
            string scriptname = "insertarMateria.php?";
            //Se crea la cadena para hacer el request
            string query = baseURL + scriptname;

            query += "nombre=" + mat.Nombre;
            query += "&matricula=" + mat.Matricula;
            query += "&idProfesor=" + mat.IdProfesor;
            query += "&color=" + PrepararColor(mat.Color);
            query += "&nick=" + mat.Nick;
            Console.WriteLine(query);

            //se hace el request
            string json = HacerRequest(query);

            //deserialización de json a c# object
            materia x = new materia();

            try { Newtonsoft.Json.JsonConvert.PopulateObject(json, x); }
            catch { }
            //reconvertir color
            x.Color = ConvertirColor(x.Color);
            return(x);
        }
Beispiel #4
0
        public static materia consultarMateria(materia mat)
        {
            string scriptname = "consultarMateria.php?";
            //Se crea la cadena para hacer el request
            string query = baseURL + scriptname;

            query += "idMateria=" + mat.IdMateria;
            //se hace el request
            string json = HacerRequest(query);
            //deserialización de json a c# object
            materia x = new materia();

            Newtonsoft.Json.JsonConvert.PopulateObject(json, x);
            //reconvertir color
            x.Color = ConvertirColor(x.Color);
            return(x);
        }
Beispiel #5
0
        public static bool eliminarMateria(materia mat)
        {
            string scriptname = "eliminarMateria.php?";
            //Se crea la cadena para hacer el request
            string query = baseURL + scriptname;

            query += "idMateria=" + mat.IdMateria;
            //se hace el request
            string json = HacerRequest(query);
            //deserialización de json a c# object
            materia x = new materia();

            Newtonsoft.Json.JsonConvert.PopulateObject(json, x);
            if (x.Nombre != null)
            {
                return(false);
            }
            return(true);
        }
Beispiel #6
0
        public static materia ObtenerMateriasAlumno(grupo gpo)
        {
            string scriptname = "ObtenerMateriasAlumno.php?";
            //Se crea la cadena para hacer el request
            string query = baseURL + scriptname;

            query += "IdGrupo=" + gpo.IdGrupo;
            //se hace el request
            string json = HacerRequest(query);
            //deserialización de json a c# object
            materia x = new materia();

            try { Newtonsoft.Json.JsonConvert.PopulateObject(json, x); }
            catch { }
            //reconvertir colores
            if (x.Color != null)
            {
                x.Color = ConvertirColor(x.Color);
            }
            return(x);
        }