示例#1
0
        public ActionResult ExportarUbicaciones()
        {
            EmpresaDTO objEmpresa = (new EmpresaBL()).getEmpresa(getCurrentUser().IdEmpresa);

            UbicacionBL objBL = new UbicacionBL();
            List<UbicacionDTO> lista = objBL.getUbicacionsEnEmpresa(getCurrentUser().IdEmpresa);

            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Clear();

            dt.Columns.Add("Nombre");
            dt.Columns.Add("Estado");

            foreach (var item in lista)
            {
                DataRow row = dt.NewRow();
                row["Nombre"] = item.Nombre;
                row["Estado"] = item.Estado ? "Activo" : "Inactivo";
                dt.Rows.Add(row);
            }

            GenerarPdf5(dt, "Detalle de Ubicaciones", "Detalle_de_Ubicaciones", objEmpresa, Response);

            createResponseMessage(CONSTANTES.SUCCESS, CONSTANTES.SUCCESS_FILE);
            return RedirectToAction("Items", "Admin");
        }
示例#2
0
        public ActionResult Ubicacion(int? id = null)
        {
            if (!this.currentUser()) { return RedirectToAction("Ingresar"); }
            if (!this.isAdministrator()) { return RedirectToAction("Index"); }
            ViewBag.Title = "Ubicacion";
            MenuNavBarSelected(10, 2);

            UsuarioDTO currentUser = getCurrentUser();

            UbicacionBL objBL = new UbicacionBL();

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

            UbicacionDTO obj;
            if (id != null && id != 0)
            {
                obj = objBL.getUbicacionEnEmpresa((int)currentUser.IdEmpresa, (int)id);
                if (obj == null) return RedirectToAction("Ubicaciones");
                if (obj.IdEmpresa != currentUser.IdEmpresa) return RedirectToAction("Ubicaciones");
                return View(obj);
            }
            obj = new UbicacionDTO();
            obj.IdEmpresa = currentUser.IdEmpresa;

            return View(obj);
        }
示例#3
0
        public ActionResult AddUbicacion(UbicacionDTO dto)
        {
            if (!this.currentUser()) { return RedirectToAction("Ingresar"); }
            if (!this.isAdministrator()) { return RedirectToAction("Index"); }
            try
            {
                UbicacionBL objBL = new UbicacionBL();
                if (dto.IdUbicacion == 0)
                {
                    if (objBL.add(dto))
                    {
                        createResponseMessage(CONSTANTES.SUCCESS);
                        return RedirectToAction("Ubicaciones");
                    }
                }
                else if (dto.IdUbicacion != 0)
                {
                    if (objBL.update(dto))
                    {
                        createResponseMessage(CONSTANTES.SUCCESS);
                        return RedirectToAction("Ubicaciones");
                    }
                    else
                    {
                        createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_UPDATE_MESSAGE);
                    }

                }
                else
                {
                    createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_INSERT_MESSAGE);
                }
            }
            catch (Exception e)
            {
                if (dto.IdUbicacion != 0)
                    createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_UPDATE_MESSAGE);
                else createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_INSERT_MESSAGE);
            }
            TempData["Ubicacion"] = dto;
            return RedirectToAction("Ubicacion");
        }
示例#4
0
        public ActionResult Ubicaciones(bool inactivos = false)
        {
            if (!this.currentUser()) { return RedirectToAction("Ingresar"); }
            if (!isAdministrator()) { return RedirectToAction("Index"); }
            ViewBag.Title = "Ubicaciones";
            MenuNavBarSelected(10, 2);
            UsuarioDTO user = getCurrentUser();

            UbicacionBL objBL = new UbicacionBL();
            List<UbicacionDTO> listaUbicacions = new List<UbicacionDTO>();
            ViewBag.vbInactivos = inactivos;

            if (user.IdEmpresa > 0)
            {
                listaUbicacions = objBL.getUbicacionsEnEmpresa(user.IdEmpresa);
                if (!inactivos)
                { listaUbicacions = objBL.getUbicacionsActivasEnEmpresa(user.IdEmpresa); }
                else
                { listaUbicacions = objBL.getUbicacionsEnEmpresa(user.IdEmpresa); }
            }
            return View(listaUbicacions);
        }