Ejemplo n.º 1
0
        public ActionResult MontarTelaUnidade()
        {
            // Verifica se tem usuario logado
            USUARIO usuario = new USUARIO();

            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            if ((USUARIO)Session["UserCredentials"] != null)
            {
                usuario = (USUARIO)Session["UserCredentials"];

                // Verfifica permissão
                if (usuario.PERFIL.PERF_SG_SIGLA != "ADM" || usuario.PERFIL.PERF_SG_SIGLA != "SIN" || usuario.PERFIL.PERF_SG_SIGLA != "CON")
                {
                    Session["MensUnidade"] = 2;
                    return(RedirectToAction("CarregarBase", "BaseAdmin"));
                }
            }
            else
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            Int32 idAss = (Int32)Session["IdAssinante"];

            // Carrega listas
            if ((List <UNIDADE>)Session["ListaUnidade"] == null)
            {
                listaMaster             = baseApp.GetAllItens(idAss);
                Session["ListaUnidade"] = listaMaster;
            }
            ViewBag.Listas = (List <UNIDADE>)Session["ListaUnidade"];
            ViewBag.Title  = "Unidades";
            ViewBag.Cats   = new SelectList(baseApp.GetAllTipos(idAss), "TIUN_CD_ID", "TIUN_NM_NOME");

            // Indicadores
            ViewBag.Ativos = listaMaster.Where(p => p.USUARIO.Count > 0).ToList().Count;
            ViewBag.Unids  = ((List <UNIDADE>)Session["ListaUnidade"]).Count;
            ViewBag.Perfil = usuario.PERFIL.PERF_SG_SIGLA;

            // Mensagem
            if ((Int32)Session["MensUnidade"] == 1)
            {
                ModelState.AddModelError("", ERP_Condominio_Resources.ResourceManager.GetString("M0016", CultureInfo.CurrentCulture));
            }
            if ((Int32)Session["MensUnidade"] == 2)
            {
                ModelState.AddModelError("", ERP_Condominio_Resources.ResourceManager.GetString("M0011", CultureInfo.CurrentCulture));
            }

            // Abre view
            Session["MensUnidade"] = 0;
            objeto = new UNIDADE();
            return(View(objeto));
        }
        public ActionResult CarregarBase()
        {
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }

            // Carrega listas
            Int32?idAss = (Int32)Session["IdAssinante"];

            if ((Int32)Session["Login"] == 1)
            {
                Session["Perfis"]             = baseApp.GetAllPerfis();
                Session["Cargos"]             = carApp.GetAllItens(idAss.Value);
                Session["Usuarios"]           = usuApp.GetAllUsuarios(idAss.Value);
                Session["Filiais"]            = filApp.GetAllItens(idAss.Value);
                Session["UFs"]                = usuApp.GetAllUF();
                Session["TiposContribuintes"] = tcoApp.GetAllItens(idAss.Value);
                Session["TiposPessoas"]       = tpApp.GetAllItens();
                Session["Regimes"]            = rtApp.GetAllItens(idAss.Value);
                Session["Unidades"]           = uniApp.GetAllItens(idAss.Value);
            }
            Session["MensTarefa"]       = 0;
            Session["MensNoticia"]      = 0;
            Session["MensNotificacao"]  = 0;
            Session["MensUsuario"]      = 0;
            Session["MensLog"]          = 0;
            Session["MensUsuarioAdm"]   = 0;
            Session["MensAgenda"]       = 0;
            Session["MensTemplate"]     = 0;
            Session["MensConfiguracao"] = 0;
            Session["MensTelefone"]     = 0;
            Session["MensEquipe"]       = 0;
            Session["MensConsumo"]      = 0;
            Session["MensCargo"]        = 0;
            Session["MensGrupo"]        = 0;
            Session["MensSubGrupo"]     = 0;
            Session["MensCC"]           = 0;
            Session["MensBanco"]        = 0;
            Session["MensFilial"]       = 0;
            Session["MensRemu"]         = 0;
            Session["MensDente"]        = 0;
            Session["MensProc"]         = 0;
            Session["MensPaciente"]     = 0;
            Session["MensFornecedor"]   = 0;
            Session["MensProduto"]      = 0;

            USUARIO          usu = (USUARIO)Session["Usuario"];
            UsuarioViewModel vm  = Mapper.Map <USUARIO, UsuarioViewModel>(usu);


            List <NOTIFICACAO> lista = usu.NOTIFICACAO.ToList();

            Session["Notificacoes"]      = lista;
            Session["ListaNovas"]        = lista.Where(p => p.NOTI_IN_VISTA == 0).ToList();
            SessionMocks.ListaNovas      = (List <NOTIFICACAO>)Session["ListaNovas"];
            Session["NovasNotificacoes"] = lista.Where(p => p.NOTI_IN_VISTA == 0).Count();
            Session["Nome"]             = usu.USUA_NM_NOME;
            ViewBag.NovasNotificacoes   = lista.Where(p => p.NOTI_IN_VISTA == 0).Count();
            ViewBag.ListaNovas          = (List <NOTIFICACAO>)Session["ListaNovas"];
            Session["VoltaNotificacao"] = 3;

            List <NOTICIA> lista1 = notiApp.GetAllItensValidos(idAss.Value);

            Session["Noticias"]       = lista1;
            Session["NoticiasNumero"] = lista1.Count;
            ViewBag.NoticiasNumero    = lista1.Count;
            ViewBag.Noticias          = lista1;

            List <TAREFA> lista2 = tarApp.GetTarefaStatus(usu.USUA_CD_ID, 1);

            Session["ListaPendentes"]   = lista2;
            Session["TarefasPendentes"] = lista2.Count;
            List <TAREFA> lista3 = tarApp.GetByUser(usu.USUA_CD_ID);

            Session["TarefasLista"] = lista3;
            Session["Tarefas"]      = lista3.Count;

            ViewBag.TarefasPendentes = lista2.Count;
            ViewBag.Tarefas          = lista3.Count;

            List <AGENDA> lista4 = usu.AGENDA.ToList();

            Session["Agendas"]        = lista4;
            Session["NumAgendas"]     = lista4.Count;
            Session["AgendasHoje"]    = lista4.Where(p => p.AGEN_DT_DATA == DateTime.Today.Date).ToList();
            Session["NumAgendasHoje"] = lista4.Where(p => p.AGEN_DT_DATA == DateTime.Today.Date).ToList().Count;

            ViewBag.NumAgendas     = lista4.Count;
            ViewBag.NumAgendasHoje = lista4.Where(p => p.AGEN_DT_DATA == DateTime.Today.Date).ToList().Count;

            Session["Logs"] = usu.LOG.Count;
            ViewBag.Logs    = usu.LOG.Count;

            String frase = String.Empty;
            String nome  = usu.USUA_NM_NOME.Substring(0, usu.USUA_NM_NOME.IndexOf(" "));

            if (DateTime.Now.Hour <= 12)
            {
                frase = "Bom dia, " + nome;
            }
            else if (DateTime.Now.Hour > 12 & DateTime.Now.Hour <= 18)
            {
                frase = "Boa tarde, " + nome;
            }
            else
            {
                frase = "Boa noite, " + nome;
            }
            Session["Greeting"] = frase;
            Session["Foto"]     = usu.USUA_AQ_FOTO;
            Session["ErroSoma"] = 0;
            ViewBag.Greeting    = frase;
            ViewBag.Foto        = usu.USUA_AQ_FOTO;

            // Mensagens
            if ((Int32)Session["MensNotificacao"] == 2)
            {
                ModelState.AddModelError("", OdontoWeb_Resources.ResourceManager.GetString("M0011", CultureInfo.CurrentCulture));
            }
            if ((Int32)Session["MensNoticia"] == 2)
            {
                ModelState.AddModelError("", OdontoWeb_Resources.ResourceManager.GetString("M0011", CultureInfo.CurrentCulture));
            }
            if ((Int32)Session["MensUsuario"] == 2)
            {
                ModelState.AddModelError("", OdontoWeb_Resources.ResourceManager.GetString("M0011", CultureInfo.CurrentCulture));
            }
            if ((Int32)Session["MensLog"] == 2)
            {
                ModelState.AddModelError("", OdontoWeb_Resources.ResourceManager.GetString("M0011", CultureInfo.CurrentCulture));
            }
            if ((Int32)Session["MensUsuarioAdm"] == 2)
            {
                ModelState.AddModelError("", OdontoWeb_Resources.ResourceManager.GetString("M0011", CultureInfo.CurrentCulture));
            }
            if ((Int32)Session["MensTemplate"] == 2)
            {
                ModelState.AddModelError("", OdontoWeb_Resources.ResourceManager.GetString("M0011", CultureInfo.CurrentCulture));
            }
            if ((Int32)Session["MensConfiguracao"] == 2)
            {
                ModelState.AddModelError("", OdontoWeb_Resources.ResourceManager.GetString("M0011", CultureInfo.CurrentCulture));
            }
            if ((Int32)Session["MensCargo"] == 2)
            {
                ModelState.AddModelError("", OdontoWeb_Resources.ResourceManager.GetString("M0011", CultureInfo.CurrentCulture));
            }
            if ((Int32)Session["MensGrupo"] == 2)
            {
                ModelState.AddModelError("", OdontoWeb_Resources.ResourceManager.GetString("M0011", CultureInfo.CurrentCulture));
            }
            if ((Int32)Session["MensSubGrupo"] == 2)
            {
                ModelState.AddModelError("", OdontoWeb_Resources.ResourceManager.GetString("M0011", CultureInfo.CurrentCulture));
            }
            if ((Int32)Session["MensCC"] == 2)
            {
                ModelState.AddModelError("", OdontoWeb_Resources.ResourceManager.GetString("M0011", CultureInfo.CurrentCulture));
            }
            if ((Int32)Session["MensBanco"] == 2)
            {
                ModelState.AddModelError("", OdontoWeb_Resources.ResourceManager.GetString("M0011", CultureInfo.CurrentCulture));
            }
            if ((Int32)Session["MensDente"] == 2)
            {
                ModelState.AddModelError("", OdontoWeb_Resources.ResourceManager.GetString("M0011", CultureInfo.CurrentCulture));
            }
            if ((Int32)Session["MensProc"] == 2)
            {
                ModelState.AddModelError("", OdontoWeb_Resources.ResourceManager.GetString("M0011", CultureInfo.CurrentCulture));
            }
            if ((Int32)Session["MensPaciente"] == 2)
            {
                ModelState.AddModelError("", OdontoWeb_Resources.ResourceManager.GetString("M0011", CultureInfo.CurrentCulture));
            }
            if ((Int32)Session["MensFornecedor"] == 2)
            {
                ModelState.AddModelError("", OdontoWeb_Resources.ResourceManager.GetString("M0011", CultureInfo.CurrentCulture));
            }
            if ((Int32)Session["MensProduto"] == 2)
            {
                ModelState.AddModelError("", OdontoWeb_Resources.ResourceManager.GetString("M0011", CultureInfo.CurrentCulture));
            }

            return(View(vm));
        }