Beispiel #1
0
        public static bool esAutorizador()
        {
            var responsable              = new responsable();
            int idResponsable            = responsable.obtenerResponsableporIdusuario(SessionHelper.GetIdUser()).IdResponsable;
            AutorizadorTarea autorizador = new AutorizadorTarea();

            try
            {
                using (var ctx = new inventarioContext())
                {
                    autorizador = ctx.AutorizadorTarea.Where(x => x.estado == 1)
                                  .Where(x => x.IdResponsable == idResponsable)
                                  .Include(x => x.responsable.usuariosSistema)
                                  .FirstOrDefault();
                }
                if (autorizador != null)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                throw;
            }
        }
Beispiel #2
0
        public ResponseModel Listar()
        {
            List <usuariosSistema> usuarios = new List <usuariosSistema>();

            var rm = new ResponseModel();

            try
            {
                using (var ctx = new inventarioContext())
                {
                    ctx.Configuration.LazyLoadingEnabled   = true;
                    ctx.Configuration.ProxyCreationEnabled = false;
                    usuarios = ctx.usuariosSistema.Include(x => x.responsable)
                               .Include("responsable.areas")
                               .ToList();
                }
                rm.response = true;
                rm.message  = "";
                rm.function = "mostrarTablaUsuarios";
                rm.result   = usuarios;
            }
            catch (Exception e)
            {
                throw;
            }
            return(rm);
        }
Beispiel #3
0
        public ResponseModel Guardar()
        {
            var rm = new ResponseModel();

            try
            {
                using (var ctx = new inventarioContext())
                {
                    if (this.IdTarea > 0)
                    {
                        ctx.Entry(this).State = EntityState.Modified;
                    }
                    else
                    {
                        this.Nro = this.ObtenerCorrelativo();
                        ctx.Entry(this).State = EntityState.Added;
                    }
                    if (this.editardatos(this.IdTarea))//se puede editar?
                    {
                        ctx.SaveChanges();
                        rm.SetResponse(true);
                    }
                    else
                    {
                        rm.message = "No se puede editar esta tarea finalizada";
                    }
                }
            }
            catch (Exception e)
            {
                throw;
            }
            return(rm);
        }
Beispiel #4
0
        public DateTime retornarFechaComprometida(int idTarea)
        {
            DateTime comprometida = new DateTime();
            string   sql;

            try
            {
                /* using (var ctx = new inventarioContext())
                 * {
                 *
                 *   sql = "Select FechaComprometida From dbo.tareas Where idTarea=" + this.IdTarea;
                 *   var xxx=ctx.Database.ExecuteSqlCommand(sql);
                 * }*/
                using (var ctx = new inventarioContext())
                {
                    sql          = "Select FechaComprometida From dbo.tareas Where idTarea=" + idTarea;
                    comprometida = ctx.Database.SqlQuery <DateTime>(sql).FirstOrDefault <DateTime>();
                }
            }
            catch (Exception e)
            {
                throw;
            }
            return(comprometida);
        }
        public static int ObtenerArea(int IdUsuario)
        {
            int area;
            var modelResponsable = new responsable();

            try
            {
                using (var ctx = new inventarioContext())
                {
                    modelResponsable = ctx.responsable
                                       .Where(x => x.IdUsuario == IdUsuario)
                                       .SingleOrDefault();
                }
                if (modelResponsable != null)
                {
                    area = (int)modelResponsable.IdArea;
                }
                else
                {
                    area = -100;
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(area);
        }
Beispiel #6
0
        public bool editardatos(int idTarea)//se puede editar los datos???
        {
            bool   editar = false;
            string sql;
            int    estadoTarea;

            try
            {
                /* using (var ctx = new inventarioContext())
                 * {
                 *
                 *   sql = "Select FechaComprometida From dbo.tareas Where idTarea=" + this.IdTarea;
                 *   var xxx=ctx.Database.ExecuteSqlCommand(sql);
                 * }*/
                using (var ctx = new inventarioContext())
                {
                    sql         = "Select IdEstadoTarea From dbo.tareas Where idTarea=" + idTarea;
                    estadoTarea = ctx.Database.SqlQuery <int>(sql).FirstOrDefault <int>();
                    if (estadoTarea == 2) //2 finalizado
                    {
                        editar = false;
                    }
                    else
                    {
                        editar = true;
                    }
                }
            }
            catch (Exception e)
            {
                throw;
            }
            return(editar);
        }
        public ResponseModel Guardar()
        {
            var rm = new ResponseModel();

            try
            {
                using (var ctx = new inventarioContext())
                {
                    if (this.IdResponsable > 0)
                    {
                        ctx.Entry(this).State = EntityState.Modified;
                    }
                    else
                    {
                        ctx.Entry(this).State = EntityState.Added;
                    }
                    ctx.SaveChanges();
                    rm.SetResponse(true);
                }
            }
            catch (Exception e)
            {
                throw;
            }
            return(rm);
        }
Beispiel #8
0
        public enlaces Obtener(int id)
        {
            enlaces enlace = new enlaces();

            try
            {
                using (var ctx = new inventarioContext())
                {
                    //para retornar solo de la tabla alumno
                    // alumno = ctx.Alumno.Where(x => x.id == id)
                    //                   .SingleOrDefault();
                    //para retornar la relacion

                    enlace = ctx.enlaces.Include("proveedores")
                             .Include("oficinas")
                             .Include("oficinas.ciudades")
                             .Include("oficinas.tipoOficina")
                             .Include("oficinas.ciudades.departamentos")
                             .Include("enlacesTipo")
                             .Include("enlacesTecnologia")
                             .Include("enlacesServicios")
                             .Include("enlacesInternet")
                             .Include(x => x.contratos)
                             .Where(x => x.enlaceID == id)
                             .SingleOrDefault();
                    enlace.contratos = enlace.contratos.OrderByDescending(x => x.contratoID).ToList();
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(enlace);
        }
Beispiel #9
0
        public ResponseModel ListarBandejaAutorizador(DateTime ini, DateTime fin)
        {
            List <TareasIng> tareasing = new List <TareasIng>();
            var rm = new ResponseModel();

            try
            {
                using (var ctx = new inventarioContext())
                {
                    ctx.Configuration.LazyLoadingEnabled   = true;
                    ctx.Configuration.ProxyCreationEnabled = false;
                    tareasing = ctx.TareasIng
                                .Include("responsable")
                                .Include("responsable.areas")
                                .Include("responsable.usuariosSistema")
                                .Include("TipoTareaIng")
                                .Include("EstadoTareasIng")
                                .Include(x => x.AutorizadorTarea.responsable.usuariosSistema)
                                .Where(x => x.IdEstadoTareaIng == 1)
                                .Where(x => x.fecha >= ini)
                                .Where(x => x.fecha <= fin)
                                .ToList();
                }
                rm.response = true;
                rm.message  = "";
                rm.result   = tareasing;
            }
            catch (Exception e)
            {
                throw;
            }
            return(rm);
        }
        public static int ObtenerIdResponsableUsuario(int IdUsuario)
        {
            int _IdUsuario;
            var modelResponsable = new responsable();

            try
            {
                using (var ctx = new inventarioContext())
                {
                    modelResponsable = ctx.responsable
                                       .Where(x => x.IdUsuario == IdUsuario)
                                       //.Where(x => x.Encargado == 1)
                                       .FirstOrDefault();
                }
                if (modelResponsable != null)
                {
                    _IdUsuario = (int)modelResponsable.IdResponsable;
                }
                else
                {
                    _IdUsuario = -1;
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(_IdUsuario);
        }
Beispiel #11
0
        /*********************************/
        public List <enlaces> Listar(int tipo)
        {
            List <enlaces> enlaces = new List <enlaces>();

            try
            {
                using (var ctx = new inventarioContext())
                {
                    //enlaces = ctx.enlaces.ToList();
                    enlaces = ctx.enlaces.Include("proveedores")
                              .Include("oficinas")
                              .Include("oficinas.ciudades")
                              .Include("oficinas.tipoOficina")
                              .Include("oficinas.ciudades.departamentos")
                              .Include("enlacesTipo")
                              .Include("enlacesTecnologia")
                              .Where(x => x.enlaceTipoID == tipo)
                              .ToList();
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(enlaces);
        }
Beispiel #12
0
        public ResponseModel ListarAjax()
        {
            var areas = new List <areas>();
            var rm    = new ResponseModel();

            try
            {
                using (var ctx = new inventarioContext())
                {
                    ctx.Configuration.ProxyCreationEnabled = false;
                    areas = ctx.areas.ToList();
                }
                rm.response = true;
                rm.message  = "";
                /****SERIALIZAR A JSON CON JSON.NET*****/
                rm.result = JsonConvert.SerializeObject(areas, Formatting.Indented,
                                                        new JsonSerializerSettings()
                {
                    ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
                }
                                                        );
                /****FIN SERIALIZAR A JSON CON JSON.NET*****/
            }
            catch (Exception e)
            {
                throw;
            }
            return(rm);
        }
        public bool SeEditoArea(int idArea, int IdTarea) //consulta si el area se edito
        {
            bool ret = true;

            if (IdTarea > 0)
            {
                var modelTarea = new tareas();
                try
                {
                    using (var ctx = new inventarioContext())
                    {
                        //enlaces = ctx.enlaces.ToList();
                        modelTarea = ctx.tareas
                                     .Where(x => x.IdTarea == IdTarea)
                                     .SingleOrDefault();
                    }
                    if (modelTarea.IdArea == idArea)
                    {
                        ret = false;
                    }
                    else
                    {
                        ret = true;
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }

            return(ret);
        }
        public static bool esResponsable(int _IdTarea)

        {
            int _IdResponsable = SessionHelper.GetIdUser();

            _IdResponsable = responsable.ObtenerIdResponsableUsuario(_IdResponsable);
            tareaResponsable aux = new tareaResponsable();

            try
            {
                using (var ctx = new inventarioContext())
                {
                    aux = ctx.tareaResponsable.Where(x => x.IdTarea == _IdTarea)
                          .Where(x => x.IdResponsable == _IdResponsable)
                          .SingleOrDefault();
                }
                if (aux == null)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #15
0
        public ResponseModel finalizarTarea()
        {
            DateTime hoy          = DateTime.Now;
            var      rm           = new ResponseModel();
            DateTime comprometida = retornarFechaComprometida(this.IdTarea);
            int      eficiencia   = 0;
            TimeSpan ts;

            if (hoy >= comprometida)
            {
                ts = hoy - comprometida;
                // Diferencia dias.
                eficiencia = ts.Days;
            }
            string sql;

            try
            {
                using (var ctx = new inventarioContext())
                {
                    sql = "UPDATE dbo.tareas SET IdEstadoTarea=2,Eficiencia=" + eficiencia + ", FechaCierre='" + hoy.ToString("s") + "' Where idTarea=" + this.IdTarea;
                    ctx.Database.ExecuteSqlCommand(sql);
                    rm.SetResponse(true);
                }
            }
            catch (Exception e)
            {
                throw;
            }
            return(rm);
        }
        public static bool esEncargado()
        {
            int IdUsuario    = SessionHelper.GetIdUser();
            var _responsable = new responsable();

            try
            {
                using (var ctx = new inventarioContext())
                {
                    _responsable = ctx.responsable
                                   .Where(x => x.IdUsuario == IdUsuario)
                                   .Where(x => x.Encargado == 1)
                                   .SingleOrDefault();
                }
                if (_responsable != null)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #17
0
        public ResponseModel ObtenerAjax(int id)
        {
            enlaces enlaceAjax = new enlaces();
            var     rm         = new ResponseModel();

            try
            {
                using (var ctx = new inventarioContext())
                {
                    // ctx.Configuration.LazyLoadingEnabled = false;
                    //ctx.Configuration.ProxyCreationEnabled = false;// para retornar Json
                    ctx.Configuration.ProxyCreationEnabled = false;


                    enlaceAjax = ctx.enlaces.Include("proveedores")
                                 .Include("oficinas")
                                 .Include("oficinas.ciudades")
                                 .Include("oficinas.tipoOficina")
                                 .Include("oficinas.ciudades.departamentos")
                                 .Include("enlacesTipo")      //aqui esta el problema
                                 .Include("enlacesTecnologia")
                                 .Include("enlacesServicios")
                                 .Include("enlacesInternet")
                                 .Include(x => x.contratos)
                                 .Where(x => x.enlaceID == id)

                                 .SingleOrDefault();


                    enlaceAjax.contratos = enlaceAjax.contratos.OrderByDescending(x => x.contratoID).ToList();
                }
                rm.response = true;
                rm.message  = "";
                /****SERIALIZAR A JSON CON JSON.NET*****/
                rm.result = JsonConvert.SerializeObject(enlaceAjax, Formatting.Indented,
                                                        new JsonSerializerSettings()
                {
                    ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
                }
                                                        );
                /****FIN SERIALIZAR A JSON CON JSON.NET*****/
            }
            catch (Exception)
            {
                throw;
            }

            return(rm);
            // return this.Json
        }
Beispiel #18
0
        public List <tipoTareas> Listar()
        {
            var tipoTareas = new List <tipoTareas>();

            try
            {
                using (var ctx = new inventarioContext())
                {
                    tipoTareas = ctx.tipoTareas.ToList();
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(tipoTareas);
        }
Beispiel #19
0
        public List <areas> Listar()
        {
            var areas = new List <areas>();

            try
            {
                using (var ctx = new inventarioContext())
                {
                    areas = ctx.areas.ToList();
                }
            }
            catch (Exception e)
            {
                throw;
            }
            return(areas);
        }
        public List <enlacesTipo> Listar()
        {
            List <enlacesTipo> enlacesTipo = new List <enlacesTipo>();

            try
            {
                using (var ctx = new inventarioContext())
                {
                    enlacesTipo = ctx.enlacesTipo.ToList();
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(enlacesTipo);
        }
Beispiel #21
0
        public int ObtenerCorrelativo() //obtiene numero correlativo de acuerdo al año
        {
            // List<tareas> tareas = new List<tareas>();
            tareas   tareas1     = new tareas();
            DateTime hoy         = DateTime.Now;
            int      correlativo = 0;

            try
            {
                using (var ctx = new inventarioContext())
                {
                    //para retornar solo de la tabla alumno
                    // alumno = ctx.Alumno.Where(x => x.id == id)
                    //                   .SingleOrDefault();
                    //para retornar la relacion
                    //tareas = ctx.tareas.Where(x => x.FechaAsignacion.Value.Year == hoy.Year)
                    //                   .OrderByDescending(x => x.Nro)
                    //                   .ToList();
                    tareas1 = ctx.tareas.Where(x => x.FechaAsignacion.Value.Year == hoy.Year)
                              .OrderByDescending(x => x.Nro)
                              .FirstOrDefault();

                    correlativo = 0;
                }
            }
            catch (Exception e)
            {
                throw;
            }
            if (tareas1 != null)
            {
                if (tareas1.Nro == null)
                {
                    correlativo = 0;
                }
                else
                {
                    correlativo = (int)tareas1.Nro;
                }
            }
            else
            {
                correlativo = 0;
            }
            return(correlativo + 1);
        }
Beispiel #22
0
        public List <oficinas> Listar()
        {
            List <oficinas> oficinas = new List <oficinas>();

            try
            {
                using (var ctx = new inventarioContext())
                {
                    oficinas = ctx.oficinas.ToList();
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(oficinas);
        }
Beispiel #23
0
        public List <enlacesTecnologia> Listar()
        {
            List <enlacesTecnologia> enlacesTecnologia = new List <enlacesTecnologia>();

            try
            {
                using (var ctx = new inventarioContext())
                {
                    enlacesTecnologia = ctx.enlacesTecnologia.ToList();
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(enlacesTecnologia);
        }
Beispiel #24
0
        public List <prioridades> Listar()
        {
            var prioridades = new List <prioridades>();

            try
            {
                using (var ctx = new inventarioContext())
                {
                    prioridades = ctx.prioridades.ToList();
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(prioridades);
        }
Beispiel #25
0
        public TipoTareaIng Obtener(int id)
        {
            TipoTareaIng tarea = new TipoTareaIng();

            try
            {
                using (var ctx = new inventarioContext())
                {
                    tarea = ctx.TipoTareaIng
                            .SingleOrDefault();
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(tarea);
        }
Beispiel #26
0
        public List <TipoTareaIng> Listar()
        {
            List <TipoTareaIng> tareas = new List <TipoTareaIng>();

            try
            {
                using (var ctx = new inventarioContext())
                {
                    //enlaces = ctx.enlaces.ToList();
                    tareas = ctx.TipoTareaIng
                             .ToList();
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(tareas);
        }
Beispiel #27
0
        public AutorizadorTarea Obtener()
        {
            AutorizadorTarea autorizador = new AutorizadorTarea();

            try
            {
                using (var ctx = new inventarioContext())
                {
                    autorizador = ctx.AutorizadorTarea.Where(x => x.estado == 1)
                                  .Include(x => x.responsable.usuariosSistema)
                                  .FirstOrDefault();
                }
            }
            catch (Exception e)
            {
                throw;
            }
            return(autorizador);
        }
Beispiel #28
0
        public void EliminarResponsablesArea() //eliminar reponsables de area excepto el encargado
        {
            var responsable = new responsable();
            //int idResponsable = responsable.ObtenerIdResponsable(this.idarea);
            string sql;

            try
            {
                using (var ctx = new inventarioContext())
                {
                    sql = "DELETE FROM dbo.TareaResponsable WHERE idTarea = " + this.idtarea;
                    ctx.Database.ExecuteSqlCommand(sql);
                }
            }
            catch (Exception e)
            {
                throw;
            }
            //return rm;
        }
Beispiel #29
0
        public ResponseModel Observar(int idTareaing)
        {
            var    rm = new ResponseModel();
            string sql;

            try
            {
                using (var ctx = new inventarioContext())
                {
                    sql = "UPDATE dbo.TareasIng SET IdEstadoTareaIng=3 WHERE IdTareaIng=" + idTareaing;
                    ctx.Database.ExecuteSqlCommand(sql);
                    rm.SetResponse(true);
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(rm);
        }
        public responsable obtenerResponsableporIdusuario(int IdUsuario)
        {
            var modelResponsable = new responsable();

            try
            {
                using (var ctx = new inventarioContext())
                {
                    modelResponsable = ctx.responsable
                                       .Include(x => x.areas)
                                       .Where(x => x.IdUsuario == IdUsuario)

                                       .FirstOrDefault();
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(modelResponsable);
        }