Пример #1
0
        public ActionResult Create()
        {
            int ano      = DateTime.Now.Year;
            int semestre = DateTime.Now.Month;

            if (!InventarioDAO.CheckStatus())
            {
                if (InventarioDAO.Create())
                {
                    TempData["msg"]      = "Consolidado com sucesso!";
                    TempData["msg_type"] = "success";
                    return(RedirectToAction("Inventario", "Inventario"));
                }
                TempData["msg"]      = "Ocorreu um erro!";
                TempData["msg_type"] = "danger";
                return(RedirectToAction("Inventario", "Inventario"));
            }
            else
            {
                TempData["msg"]      = "Inventário já consolidado!";
                TempData["msg_type"] = "warning";
                return(RedirectToAction("Inventario", "Inventario"));
            }
        }
Пример #2
0
        public ActionResult Inventario()
        {
            // Início: Proteção de rota
            if (Session["usuario_nivel"] == null)
            {
                TempData["msg"]      = "Necessário estar logado!";
                TempData["msg_type"] = "warning";
                return(RedirectToAction("Index", "Home"));
            }

            if (Convert.ToInt32(Session["usuario_nivel"]) > 0)
            {
                TempData["msg"]      = "Você não tem autorização para acessar esta área!";
                TempData["msg_type"] = "danger";
                return(RedirectToAction("Index", "Home"));
            }
            // Fim: Proteção de Rota

            List <Inventario> list;

            if (!InventarioDAO.CheckStatus())
            {
                string semestre = "/1";
                if (DateTime.Now.Month > 6)
                {
                    semestre = "/2";
                }
                TempData["semestre_ano"] = DateTime.Now.Year.ToString() + semestre;
            }
            list = InventarioDAO.GetAll();
            if (list == null)
            {
                list = new List <Inventario>();
            }
            return(View(list));
        }