public void Guardar(profesores profesores)
 {
     //if (var != dtg.CurrentRow.Cells["numerocontrol"].Value.ToString())
     //{
     if (profesores.Idprofesor == 0)
     {
         //insertar
         string consulta = string.Format("insert into profesores values(null,'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')",
                                         nuevonumero, profesores.Nombre, profesores.Apellidopaterno, profesores.Apellidomaterno, profesores.Domicilio,
                                         profesores.Estado, profesores.Ciudad, profesores.Numerocedula, profesores.Titulo, profesores.Fechanacimiento, profesores.Materia, profesores.Grupo);
         conexion.Ejecutarconsulta(consulta);
     }
     else
     {
         //update o que lo modifique
         string consulta = string.Format("Update profesores set numerocontrol = '{0}', nombre = '{1}', apellidopaterno = '{2}', apellidomaterno = '{3}', domicilio = '{4}', estado = '{5}', ciudad = '{6}', numerocedula = '{7}', titulo = '{8}', fechanacimiento = '{9}', materia ='{10}', grupo ='{11}'  where Idprofesor = {12}",
                                         nuevonumero, profesores.Nombre, profesores.Apellidopaterno, profesores.Apellidomaterno, profesores.Domicilio,
                                         profesores.Estado, profesores.Ciudad, profesores.Numerocedula, profesores.Titulo, profesores.Fechanacimiento, profesores.Materia, profesores.Grupo, profesores.Idprofesor);
         conexion.Ejecutarconsulta(consulta);
     }
     //  i++;
     //}
     //else if(var == dtg.CurrentRow.Cells["numerocontrol"].Value.ToString())
     //i++;
 }
        public List <profesores> GetProfesores(ComboBox combo)
        {
            var    listprofesores = new List <profesores>(); //la variable var es generica
            var    ds             = new DataSet();
            string consulta       = "Select * from profesores";

            ds = conexion.Obtenerdatos(consulta, "profesores");
            combo.DataSource    = ds.Tables[0];
            combo.DisplayMember = "nombre";
            //combo.ValueMember = "Idestudio";
            //combo.DataSource = dt;
            var dt = new DataTable();

            dt = ds.Tables[0];
            //combo.DataSource = dt;
            foreach (DataRow row in dt.Rows)
            {
                //string datos = string.Format("{0}", row.ItemArray[0]);
                //combo.Items.Add(datos);
                var profesores = new profesores
                {
                    Nombre = row["nombre"].ToString(),
                };
                listprofesores.Add(profesores);
            }
            //lenar lista
            return(listprofesores);
        }
        public List <profesores> GetProfesores(string filtro)
        {
            //List<Usuario> listusuario = new List<Usuario>();
            var    listprofesores = new List <profesores>(); //la variable var es generica
            var    ds             = new DataSet();
            string consulta       = "Select * from profesores where nombre like '%" + filtro + "%'";

            ds = conexion.Obtenerdatos(consulta, "profesores");
            var dt = new DataTable();

            dt = ds.Tables[0];
            foreach (DataRow row in dt.Rows)
            {
                var profesores = new profesores
                {
                    Idprofesor      = Convert.ToInt32(row["Idprofesor"]),
                    Numerocontrol   = row["numerocontrol"].ToString(),
                    Nombre          = row["nombre"].ToString(),
                    Apellidopaterno = row["apellidopaterno"].ToString(),
                    Apellidomaterno = row["apellidomaterno"].ToString(),
                    Domicilio       = row["domicilio"].ToString(),
                    Estado          = row["estado"].ToString(),
                    Ciudad          = row["ciudad"].ToString(),
                    Numerocedula    = row["numerocedula"].ToString(),
                    Titulo          = row["titulo"].ToString(),
                    Fechanacimiento = row["fechanacimiento"].ToString(),
                    Materia         = row["materia"].ToString(),
                    Grupo           = row["grupo"].ToString()
                };
                listprofesores.Add(profesores);
            }
            //HardCodear
            //lenar lista
            return(listprofesores);
        }
        public async Task <ActionResult <profesores> > Postprofesores(profesores profesores)
        {
            _context.profesores.Add(profesores);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("Getprofesores", new { id = profesores.id_profesor }, profesores));
        }
        public async Task <IActionResult> Putprofesores(int id, profesores profesores)
        {
            if (id != profesores.id_profesor)
            {
                return(BadRequest());
            }

            _context.Entry(profesores).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();

                return(CreatedAtAction("Getprofesores", new { id = profesores.id_profesor }, profesores));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!profesoresExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #6
0
 public ProfesorVM(usuarios usuarioLogueado)
 {
     if (usuarioLogueado.roles.Contains("ROLE_ADMIN"))
     {
         CursosImpartidos        = BBDDService.getCursos();
         ProfesorLogueado        = new profesores();
         ProfesorLogueado.nombre = usuarioLogueado.username;
     }
     else
     {
         ProfesorLogueado = BBDDService.getProfesorByUsername(usuarioLogueado.username);
         CursosImpartidos = BBDDService.getCursosByProfesor(ProfesorLogueado.id);
     }
 }
Example #7
0
 public void Guardar(profesores profesor)
 {
     _profesorAccesoDatos.Guardar(profesor);
 }
Example #8
0
        public IHttpActionResult Postlogin(loginDTO login)
        {
            login log = db.login.Find(login.Usuario);


            if (log != null)
            {
                if (log.Usuario == login.Usuario && log.Password == login.Password)
                {
                    estudiantes estu = db.estudiantes.Where(t => t.Login_Usuario == log.Usuario).FirstOrDefault();
                    if (estu == null)
                    {
                        profesores pro = db.profesores.Where(t => t.Login_Usuario == log.Usuario).FirstOrDefault();
                        if (pro != null)
                        {
                            HorarioProfDTO prof = new HorarioProfDTO();
                            profesoresDTO  pr   = new profesoresDTO();
                            Mapper.CreateMap <profesores, profesoresDTO>();
                            Mapper.Map(pro, pr);
                            List <AsignaturaProDTO>    lista  = new List <AsignaturaProDTO>();
                            List <estudiantesListaDTO> listaE = new List <estudiantesListaDTO>();

                            Mapper.CreateMap <asignaturas, AsignaturaProDTO>();
                            Mapper.Map(db.asignaturas.Where(t => t.Profesores_CeduProf == pr.CeduProf).ToList(), lista);


                            foreach (AsignaturaProDTO Asp in lista)
                            {
                                List <estudiantes> ls = db.asignaturas.Where(t => t.CodiAsig == Asp.CodiAsig && t.Grupo == Asp.Grupo).SelectMany(b => b.calificaciones.Select(p => p.estudiantes)).ToList();
                                Mapper.CreateMap <estudiantes, estudiantesListaDTO>();
                                Mapper.Map(ls, listaE);

                                Asp.Listado = listaE;
                            }
                            foreach (estudiantesListaDTO edt in listaE)
                            {
                                edt.Nota1        = 3;
                                edt.Nota2        = 3;
                                edt.Nota3        = 3;
                                edt.Habilitacion = 3;
                            }

                            prof.profesor = pr;
                            prof.materias = lista;
                            return(Ok(prof));
                        }
                    }

                    else
                    {
                        HorarioDTO     est = new HorarioDTO();
                        estudiantesDTO e   = new estudiantesDTO();
                        Mapper.CreateMap <estudiantes, estudiantesDTO>();
                        Mapper.Map(estu, e);
                        est.estudiante = e;
                        List <AsignaturaEstDTO> lista = new List <AsignaturaEstDTO>();

                        Mapper.CreateMap <asignaturas, AsignaturaEstDTO>();
                        Mapper.Map(db.calificaciones.Where(t => t.Estudiantes_CeduEstu == estu.CeduEstu).Select(k => k.asignaturas).ToList(), lista);

                        List <calificaciones> cl = db.calificaciones.Where(t => t.Estudiantes_CeduEstu == estu.CeduEstu).ToList();
                        for (int i = 0; i < cl.Count; i++)
                        {
                            lista[i].Nota1        = cl[i].Nota1;
                            lista[i].Nota2        = cl[i].Nota2;
                            lista[i].Nota3        = cl[i].Nota3;
                            lista[i].Habilitacion = cl[i].Habilitacion;
                        }

                        est.materias = lista;

                        return(Ok(est));
                    }
                }
                else
                {
                    return(Ok("Contraseña incorrecta"));
                }
            }
            else
            {
                return(Ok("Usuario no registrado"));
            }



            return(CreatedAtRoute("DefaultApi", new { id = login.Usuario }, login));
        }