Example #1
0
        public ActionResult Proyecto(int? id = null, int? idEntidad = null)
        {
            if (!this.currentUser()) { return RedirectToAction("Ingresar"); }
            //if (!this.isAdministrator()) { return RedirectToAction("Index"); }
            ViewBag.Title = "Proyecto";
            MenuNavBarSelected(6);
            UsuarioDTO user = getCurrentUser();

            ProyectoBL objBL = new ProyectoBL();
            ViewBag.IdProyecto = id;
            ViewBag.lstComprobantes = objBL.getComprobantes_ConProyecto(user.IdEmpresa, id.GetValueOrDefault());

            ResponsableBL resBL = new ResponsableBL();
            ViewBag.lstResponsables = resBL.getResponsablesActivosEnEmpresa(user.IdEmpresa);

            EntidadResponsableBL objEntidadBL = new EntidadResponsableBL();
            EntidadResponsableDTO objEntidad = objEntidadBL.getEntidadResponsableEnEmpresa(user.IdEmpresa, idEntidad.GetValueOrDefault());
            if (objEntidad == null) { return RedirectToAction("EntidadesClientes", "Admin"); }

            var objSent = TempData["Proyecto"];
            if (objSent != null) { TempData["Proyecto"] = null; return View(objSent); }
            if (id == 0 && idEntidad != null)
            {
                ProyectoDTO nuevo = new ProyectoDTO();
                nuevo.IdEntidadResponsable = (int)idEntidad;
                nuevo.Estado = true;
                return View(nuevo);
            }
            else
            {
                if (id != null)
                {
                    ProyectoDTO obj = objBL.getProyecto((int)id);

                    if (obj == null) return RedirectToAction("Entidad", "Admin", new { id = objEntidad.IdEntidadResponsable });
                    if (obj.IdEntidadResponsable != objEntidad.IdEntidadResponsable) return RedirectToAction("Entidad", "Admin", new { id = objEntidad.IdEntidadResponsable });

                    EntidadResponsableDTO objEntidadProy = objEntidadBL.getEntidadResponsableEnEmpresa(user.IdEmpresa, obj.IdEntidadResponsable);
                    if (objEntidadProy == null) return RedirectToAction("Entidades", "Admin");
                    if (objEntidadProy.IdEmpresa != user.IdEmpresa) return RedirectToAction("Entidades", "Admin");

                    return View(obj);
                }
            }
            return View();
        }
Example #2
0
        public ActionResult AddResponsable(ResponsableDTO dto)
        {
            if (!this.currentUser()) { return RedirectToAction("Ingresar"); }
            try
            {
                ResponsableBL objBL = new ResponsableBL();
                if (dto.IdResponsable == 0)
                {
                    if (objBL.add(dto))
                    {
                        createResponseMessage(CONSTANTES.SUCCESS);
                        return RedirectToAction("Responsables");
                    }
                }
                else if (dto.IdResponsable != 0)
                {
                    if (objBL.update(dto))
                    {
                        createResponseMessage(CONSTANTES.SUCCESS);
                        return RedirectToAction("Responsables");
                    }
                    else
                    {
                        createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_UPDATE_MESSAGE);
                    }

                }
                else
                {
                    createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_INSERT_MESSAGE);
                }
            }
            catch (Exception e)
            {
                if (dto.IdResponsable != 0)
                    createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_UPDATE_MESSAGE);
                else createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_INSERT_MESSAGE);
            }
            TempData["Responsable"] = dto;
            return RedirectToAction("Responsable");
        }
Example #3
0
        public ActionResult Responsables(bool inactivos = false)
        {
            if (!this.currentUser()) { return RedirectToAction("Ingresar"); }
            if (!isAdministrator()) { return RedirectToAction("Index"); }
            ViewBag.Title = "Consultores";
            MenuNavBarSelected(5);

            UsuarioDTO currentUser = getCurrentUser();
            ResponsableBL objBL = new ResponsableBL();
            List<ResponsableDTO> listaResponsables = new List<ResponsableDTO>();

            ViewBag.vbInactivos = inactivos;

            if (currentUser.IdEmpresa > 0)
            {
                listaResponsables = objBL.getResponsablesEnEmpresa(currentUser.IdEmpresa);
                if (!inactivos)
                { listaResponsables = objBL.getResponsablesActivosEnEmpresa(currentUser.IdEmpresa); }
                else
                { listaResponsables = objBL.getResponsablesEnEmpresa(currentUser.IdEmpresa); }
            }
            return View(listaResponsables);
        }
Example #4
0
        public ActionResult Responsable(int? id = null)
        {
            if (!this.currentUser()) { return RedirectToAction("Ingresar"); }
            if (!this.isAdministrator()) { return RedirectToAction("Index"); }
            ViewBag.Title = "Responsable";
            MenuNavBarSelected(5);

            UsuarioDTO currentUser = getCurrentUser();

            ResponsableBL objBL = new ResponsableBL();
            ViewBag.lstComprobantes = objBL.getComprobantes_ConResponsable(currentUser.IdEmpresa, id.GetValueOrDefault());

            var objSent = TempData["Responsable"];
            if (objSent != null) { TempData["Responsable"] = null; return View(objSent); }

            ResponsableDTO obj;
            if (id != null)
            {
                obj = objBL.getResponsableEnEmpresa((int)currentUser.IdEmpresa, (int)id);
                if (obj == null) return RedirectToAction("Responsables");
                if (obj.IdEmpresa != currentUser.IdEmpresa) return RedirectToAction("Responsables");

                //ViewBag.lstComprobantes = objBL.getComprobantes_ConResponsable(currentUser.IdEmpresa, id.GetValueOrDefault());

                return View(obj);
            }
            obj = new ResponsableDTO();
            obj.IdEmpresa = currentUser.IdEmpresa;

            return View(obj);
        }
Example #5
0
        public ActionResult Entidad(int? id = null, int? idTipoEntidad = null, bool inactivosC = false, bool inactivosP = false)
        {
            if (!this.currentUser()) { return RedirectToAction("Ingresar"); }
            if (isUsuarioExterno()) { return RedirectToAction("Index"); }
            ViewBag.Title = "Entidad";

            int tipoEntidad = 1;
            if (idTipoEntidad != null) { tipoEntidad = idTipoEntidad.GetValueOrDefault(); }
            MenuNavBarSelected(6, tipoEntidad - 1);

            UsuarioDTO user = getCurrentUser();

            EntidadResponsableBL objBL = new EntidadResponsableBL();
            ViewBag.TipoIdentificacion = objBL.getTiposDeIdentificaciones();
            ViewBag.lstComprobantes = objBL.getComprobantes_ConEntidad(user.IdEmpresa, id.GetValueOrDefault());

            ResponsableBL resBL = new ResponsableBL();
            ViewBag.lstResponsables = resBL.getResponsablesActivosEnEmpresa(user.IdEmpresa);

            ViewBag.vbInactivosC = inactivosC;
            ViewBag.vbInactivosP = inactivosP;

            var objSent = TempData["Entidad"];
            if (objSent != null) { TempData["Entidad"] = null; return View(objSent); }

            EntidadResponsableDTO obj;
            if (id != null && id != 0)
            {
                //obj = objBL.getEntidadResponsableEnEmpresa((int)user.IdEmpresa, (int)id);
                obj = objBL.getEntidadResponsableEnEmpresa_Only((int)user.IdEmpresa, (int)id);
                if (obj == null) return RedirectToAction("Entidades");
                if (obj.IdEmpresa != user.IdEmpresa) return RedirectToAction("Entidades");
                //Contactos
                if (!inactivosC) { ViewBag.lstContactos = objBL.getContactosActivos_EnEntidadResponsable((int)obj.IdEntidadResponsable); }
                else { ViewBag.lstContactos = objBL.getContactos_EntidadResponsableEnEmpresa((int)obj.IdEntidadResponsable); }
                //Proyectos
                if (!inactivosP) { ViewBag.lstProyectos = objBL.getProyectosActivos_EntidadResponsableEnEmpresa((int)obj.IdEntidadResponsable); }
                else { ViewBag.lstProyectos = objBL.getProyectos_EntidadResponsableEnEmpresa((int)obj.IdEntidadResponsable); }

                return View(obj);
            }
            obj = new EntidadResponsableDTO();
            obj.IdEntidadResponsable = 0;
            obj.TipoPersona = 1;
            obj.IdEmpresa = user.IdEmpresa;
            if (idTipoEntidad != null && idTipoEntidad != 0) obj.IdTipoEntidad = idTipoEntidad;

            return View(obj);
        }