Пример #1
0
        public AnexGRIDResponde ListarGrilla(AnexGRID grilla)
        {
            try
            {
                using (var db = new ModeloDatos())
                {
                    grilla.Inicializar();

                    var query = db.PlanEstudio.Include("Semestre").Where(x => x.plan_id > 0);

                    if (grilla.columna == "plan_id")
                    {
                        query = grilla.columna_orden == "DESC" ? query.OrderByDescending(x => x.plan_id)
                                                               : query.OrderBy(x => x.plan_id);
                    }

                    if (grilla.columna == "semestre_id")
                    {
                        query = grilla.columna_orden == "DESC" ? query.OrderByDescending(x => x.semestre_id)
                                                               : query.OrderBy(x => x.semestre_id);
                    }

                    if (grilla.columna == "nombre")
                    {
                        query = grilla.columna_orden == "DESC" ? query.OrderByDescending(x => x.nombre)
                                                               : query.OrderBy(x => x.nombre);
                    }

                    // Filtrar
                    foreach (var f in grilla.filtros)
                    {
                        if (f.columna == "nombre" && f.valor != "")
                        {
                            query = query.Where(x => x.semestre_id.ToString() == f.valor);
                        }
                    }


                    var planestudio = query.Skip(grilla.pagina)
                                      .Take(grilla.limite)
                                      .ToList();

                    var total = query.Count();

                    grilla.SetData(from s in planestudio
                                   select new
                    {
                        s.plan_id,
                        s.Semestre.nombre,
                        nombreplan = s.nombre
                    }, total);
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return(grilla.responde());
        }
Пример #2
0
 //METODO GUARDAR
 public void Guardar(string SiDocente, string siSemestre, bool docente)
 {
     try
     {
         using (var db = new ModeloDatos())
         {
             if (this.persona_id > 0)
             {
                 db.Entry(this).State = EntityState.Modified;
                 Directory.Move(
                     HttpContext.Current.Server.MapPath("~/Server/EPIS/Portafolio/Portafolio_" + siSemestre + "/" + SiDocente),
                     HttpContext.Current.Server.MapPath("~/Server/EPIS/Portafolio/Portafolio_" + siSemestre + "/" + this.dni + "_" + this.nombre + " " + this.apellido));
             }
             else
             {
                 db.Entry(this).State = EntityState.Added;
                 if (docente)
                 {
                     string path = Path.Combine(HttpContext.Current.Server.MapPath("~/Server/EPIS/Portafolio/Portafolio_" + siSemestre),
                                                this.dni + "_" + this.nombre + " " + this.apellido);
                     Directory.CreateDirectory(path);
                 }
             }
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Пример #3
0
        //metodo buscar
        public List <Usuario> Buscar(string criterio)//retornar un objeto
        {
            var    usuario = new List <Usuario>();
            String estado  = "";

            if (criterio == "Activo")
            {
                estado = "Activo";
            }
            if (criterio == "Inactivo")
            {
                estado = "Inactivo";
            }
            try
            {
                using (var db = new ModeloDatos())
                {
                    usuario = db.Usuario
                              .Where(x => x.nombre.Contains(criterio) || x.estado == estado)
                              .ToList();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(usuario);
        }
Пример #4
0
        //metodo guardar
        public void Guardar(string sem_ant)
        {
            try
            {
                using (var db = new ModeloDatos())//si existe solo modifica si no existe solo agrega
                {
                    if (this.semestre_id > 0)
                    {
                        db.Entry(this).State = EntityState.Modified; //si el valor es mayor que cero solo modifica
                        Directory.Move(
                            HttpContext.Current.Server.MapPath("~/Server/EPIS/Portafolio/Portafolio_" + sem_ant),
                            HttpContext.Current.Server.MapPath("~/Server/EPIS/Portafolio/Portafolio_" + this.nombre));
                    }
                    else
                    {
                        db.Entry(this).State = EntityState.Added; //si el valor es  cero va a agregar
                        string path = Path.Combine(HttpContext.Current.Server.MapPath("~/Server/EPIS/Portafolio/"), "Portafolio_" + this.nombre);
                        Directory.CreateDirectory(path);
                    }
                    db.SaveChanges();
                }
            }

            catch (Exception ex)
            {
                throw;
            }
        }
Пример #5
0
 public void cambiarleido(int id)
 {
     using (var db = new ModeloDatos())
     {
         db.Database.ExecuteSqlCommand(
             "update Notificacion set estado = @estado where notificacion_id = @notificacion_id",
             new SqlParameter("estado", "Leido"),
             new SqlParameter("notificacion_id", id)
             );
     }
 }
Пример #6
0
        //para la anexgrid
        public AnexGRIDResponde ListarGrilla(AnexGRID grilla)
        {
            try
            {
                using (var db = new ModeloDatos())
                {
                    grilla.Inicializar();
                    var query = db.HojaVida.Where(x => x.hojavida_id > 0);
                    //obtener los campos y que permita ordenar
                    if (grilla.columna == "hojavida_id")
                    {
                        query = grilla.columna_orden == "DESC" ? query.OrderByDescending(x => x.hojavida_id)
                                                    : query.OrderBy(x => x.hojavida_id);
                    }
                    if (grilla.columna == "persona_id")
                    {
                        query = grilla.columna_orden == "DESC" ? query.OrderByDescending(x => x.persona_id)
                                                    : query.OrderBy(x => x.persona_id);
                    }
                    // Filtrar
                    foreach (var f in grilla.filtros)
                    {
                        if (f.columna == "hojavida_id")
                        {
                            query = query.Where(x => x.hojavida_id.ToString().StartsWith(f.valor));
                        }
                    }

                    var rango = query.Skip(grilla.pagina)
                                .Take(grilla.limite)
                                .ToList();
                    var total = query.Count();//cantidad de registros

                    grilla.SetData(
                        from m in rango
                        select new
                    {
                        m.hojavida_id,
                        m.persona_id,
                    },
                        total
                        );
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(grilla.responde());
        }
Пример #7
0
        public void Guardar()
        {
            System.DateTime dt;
            dt = Convert.ToDateTime(this.fecha_inicio);

            string fecha_inicio;

            fecha_inicio = dt.ToString("yyyyMMdd");

            System.DateTime dtt;
            dtt = Convert.ToDateTime(this.fecha_fin);

            string fecha_fin;

            fecha_fin = dtt.ToString("yyyyMMdd");

            try
            {
                using (var db = new ModeloDatos())
                {
                    if (this.configentrega_id > 0)
                    {
                        db.Database.ExecuteSqlCommand(
                            "update ConfigEntrega set id_unidad = @id_unidad, nombre = @nombre, fecha_inicio = cast(@fecha_inicio as smalldatetime), fecha_fin = cast(@fecha_fin as smalldatetime), estado = @estado where configentrega_id = @id",
                            new SqlParameter("id_unidad", this.id_unidad),
                            new SqlParameter("nombre", this.nombre),
                            new SqlParameter("fecha_inicio", this.fecha_inicio),
                            new SqlParameter("fecha_fin", this.fecha_fin),
                            new SqlParameter("estado", this.estado),
                            new SqlParameter("id", this.configentrega_id)
                            );
                    }
                    else
                    {
                        db.Database.ExecuteSqlCommand(
                            "insert into ConfigEntrega values(@id_unidad,@nombre,cast(@fecha_inicio as smalldatetime),cast(@fecha_fin as smalldatetime),@estado)",
                            new SqlParameter("id_unidad", this.id_unidad),
                            new SqlParameter("nombre", this.nombre),
                            new SqlParameter("fecha_inicio", this.fecha_inicio),
                            new SqlParameter("fecha_fin", this.fecha_fin),
                            new SqlParameter("estado", this.estado)
                            );
                    }
                }
            }
            catch (Exception e)
            {
                throw;
            }
        }
Пример #8
0
 public void Eliminar()
 {
     try
     {
         using (var db = new ModeloDatos())
         {
             db.Entry(this).State = EntityState.Deleted;
             db.SaveChanges();
         }
     }
     catch (Exception e)
     {
         throw;
     }
 }
Пример #9
0
        //Consulta 05

        public List <Semestre> listarsemestre()
        {
            var semestre = new List <Semestre>();

            try
            {
                using (ModeloDatos db = new ModeloDatos())
                {
                    semestre = db.Semestre.ToList();
                }
            }
            catch (Exception e)
            {
            }
            return(semestre);
        }
Пример #10
0
        public List <TipoDocumento> listartipodocumento()
        {
            var tipodoc = new List <TipoDocumento>();

            try
            {
                using (ModeloDatos db = new ModeloDatos())
                {
                    tipodoc = db.TipoDocumento.Include("TipoPersona").Where(x => x.TipoPersona.nombre.Equals("Docente")).ToList();
                }
            }
            catch (Exception e)
            {
            }
            return(tipodoc);
        }
Пример #11
0
        public MetadataDocumento listarmetadatareciente(string semestre, string tipodoc, string persona)
        {
            var meta = new MetadataDocumento();

            try
            {
                using (ModeloDatos db = new ModeloDatos())
                {
                    meta = db.MetadataDocumento.Include("Persona").Include("TipoDocumento").Include(x => x.Persona.TipoPersona).Where(x => x.Persona.codigo.Equals(persona.Trim()) || x.Persona.dni.Equals(persona.Trim())).Where(x => x.Persona.TipoPersona.nombre.Equals("Docente")).Where(x => x.semestre_id.ToString().Equals(semestre) && x.tipodocumento_id.ToString().Equals(tipodoc)).OrderByDescending(x => x.metadata_id).First();
                }
            }
            catch (Exception e)
            {
            }
            return(meta);
        }
Пример #12
0
        public Persona ObtenerPersona(string codigo)
        {
            var persona = new Persona();

            try
            {
                using (var db = new ModeloDatos())
                {
                    persona = db.Persona.Where(x => x.codigo.Equals(codigo.Trim()) || x.dni.Equals(codigo.Trim())).SingleOrDefault();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(persona);
        }
Пример #13
0
        public List <Persona> Listar()
        {
            var persona = new List <Persona>();

            try
            {
                using (var db = new ModeloDatos())
                {
                    persona = db.Persona.ToList();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(persona);
        }
Пример #14
0
        //consulta04

        public List <Notificacion> Listar()//retornar es un Collection
        {
            var notificacion = new List <Notificacion>();

            try
            {
                using (var db = new ModeloDatos())
                {
                    notificacion = db.Notificacion.ToList();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(notificacion);
        }
Пример #15
0
        public List <Semestre> Listar()  //retorna un collection
        {
            var semestre = new List <Semestre>();

            try
            {
                using (var db = new ModeloDatos())
                {
                    semestre = db.Semestre.ToList();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(semestre);
        }
Пример #16
0
 public void eliminarcurso(int id)
 {
     try
     {
         using (var db = new ModeloDatos())
         {
             db.Database.ExecuteSqlCommand(
                 "delete from CursoDocente where cursodocente_id = @id",
                 new SqlParameter("id", id)
                 );
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Пример #17
0
        public List <HojaVidaDocenteFC> Listar(int codigo)
        {
            var persona = new List <HojaVidaDocenteFC>();

            try
            {
                using (var db = new ModeloDatos())
                {
                    persona = db.HojaVidaDocenteFC.Where(x => x.HojaVida.persona_id == codigo).ToList();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(persona);
        }
Пример #18
0
        public List <HojaVida> Listar()
        {
            var rango = new List <HojaVida>();

            try
            {
                using (var db = new ModeloDatos())
                {
                    rango = db.HojaVida.Include("Persona").ToList();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(rango);
        }
Пример #19
0
        public List <HojaVidaDocenteCRP> Listar(int codigo)
        {
            var rango = new List <HojaVidaDocenteCRP>();

            try
            {
                using (var db = new ModeloDatos())
                {
                    rango = db.HojaVidaDocenteCRP.Where(x => x.HojaVida.persona_id == codigo).ToList();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(rango);
        }
Пример #20
0
        public Notificacion obtener(int id)
        {
            var notificacion = new Notificacion();

            try
            {
                using (var db = new ModeloDatos())
                {
                    notificacion = db.Notificacion.Include("Persona").Include("Persona1").Where(x => x.notificacion_id == id).SingleOrDefault();
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return(notificacion);
        }
Пример #21
0
        public List <TipoPersona> listartipopersona()
        {
            var tipopersona = new List <TipoPersona>();

            try
            {
                using (var db = new ModeloDatos())
                {
                    tipopersona = db.TipoPersona.ToList();
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return(tipopersona);
        }
Пример #22
0
        public List <Unidad> listarunidad()
        {
            var unidad = new List <Unidad>();

            try
            {
                using (var db = new ModeloDatos())
                {
                    unidad = db.Unidad.Include("Semestre").ToList();
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return(unidad);
        }
Пример #23
0
        public List <Usuario> listarusuarios()
        {
            var usuario = new List <Usuario>();

            try
            {
                using (var db = new ModeloDatos())
                {
                    usuario = db.Usuario.Include("Persona").Include("TipoUsuario1").ToList();
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return(usuario);
        }
Пример #24
0
        public List <Notificacion> Buscar(string criterio) //collection
        {
            var notificacion = new List <Notificacion>();


            try
            {
                using (var db = new ModeloDatos())
                {
                    notificacion = db.Notificacion.Include("Persona").Where(x => x.Persona.codigo.Contains(criterio.Trim()) || x.Persona.dni.Contains(criterio.Trim())).ToList();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(notificacion);
        }
Пример #25
0
        public CursoDocente listardocente(string id)
        {
            var cursodocente = new CursoDocente();

            try
            {
                using (var db = new ModeloDatos())
                {
                    cursodocente = db.CursoDocente.Include("Persona").Where(x => x.curso_cod.Contains(id)).SingleOrDefault();
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return(cursodocente);
        }
Пример #26
0
        public List <Curso> listarcursoplan(int id)
        {
            var curso = new List <Curso>();

            try
            {
                using (var db = new ModeloDatos())
                {
                    curso = db.Curso.Where(x => x.plan_id == id).ToList();
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return(curso);
        }
Пример #27
0
        public List <PlanEstudio> listar() //retornar es un Collection
        {
            var planestudio = new List <PlanEstudio>();

            try
            {
                using (var db = new ModeloDatos())
                {
                    planestudio = db.PlanEstudio.ToList();
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return(planestudio);
        }
Пример #28
0
        public List <Persona> listartododocente()
        {
            var docente = new List <Persona>();

            try
            {
                using (var db = new ModeloDatos())
                {
                    docente = db.Persona.Include("TipoPersona").Where(x => x.TipoPersona.nombre.Contains("Docente") || x.TipoPersona.nombre.Contains("Administrador")).ToList();
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return(docente);
        }
Пример #29
0
        public HojaVida ObtenerByPersona(int persona_id)//retornar un objeto
        {
            var rango = new HojaVida();

            try
            {
                using (var db = new ModeloDatos())
                {
                    rango = db.HojaVida.Include("persona")
                            .Where(x => x.persona_id == persona_id)
                            .SingleOrDefault();
                }
            }
            catch (Exception ex)
            {
            }
            return(rango);
        }
Пример #30
0
        public List <TipoPersona> listartipo() //retornar es un Collection
        {
            var tipo = new List <TipoPersona>();

            try
            {
                using (var db = new ModeloDatos())
                {
                    tipo = db.TipoPersona.ToList();
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return(tipo);
        }