Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["ssnLoggedUserID"] == null)
            {
                Response.Redirect("~/Account/Login.aspx");
            }

            if (!IsPostBack)
            {
                //Page.ClientScript.RegisterStartupScript(this.GetType(), "onLoad", "DisplaySessionTimeout();", true);

                using (UnitOfWork oUnitOfWork = new UnitOfWork())
                {
                    if (System.IO.Path.GetFileName(Request.Url.AbsolutePath).ToUpper() != "HOME.ASPX" &&
                        System.IO.Path.GetFileName(Request.Url.AbsolutePath).ToUpper() != "ACESSONEGADO.ASPX" &&
                        System.IO.Path.GetFileName(Request.Url.AbsolutePath).ToUpper() != "ERRO.ASPX")
                    {
                        if (!oUnitOfWork.UsuarioREP.EhAutorizado(int.Parse(Session["ssnLoggedUserID"].ToString()), System.IO.Path.GetFileName(Request.Url.AbsolutePath)))
                        {
                            Response.Redirect("~/AcessoNegado.aspx");
                        }
                    }

                    if (string.IsNullOrEmpty(btnUsuario.Text))
                    {
                        Sigmeh.Model.Usuario usuario = oUnitOfWork.UsuarioREP.BuscarTodos(usu => usu.UsuarioID.Equals(int.Parse(Session["ssnLoggedUserID"].ToString()))).FirstOrDefault();
                        btnUsuario.Text = usuario.Entidade.Nome;
                    }
                }

                CarregarEmpresas(int.Parse(Session["ssnLoggedUserID"].ToString()));

                if (Session["ssnLstEmpresaMaeID"] != null)
                {
                    if (!string.IsNullOrEmpty(Session["ssnLstEmpresaMaeID"].ToString()))
                    {
                        SelecionarEmpresasMae((List <int>)Session["ssnLstEmpresaMaeID"]);
                    }
                }
            }

            if (Request.Params["__EVENTTARGET"] != null)
            {
                if (Request.Params["__EVENTTARGET"].ToString().Contains("ddlEmpresa"))
                {
                    AtualizarListaEmpresasMaeID();
                }
            }

            if (ddlEmpresa.CheckedItems.Count <= 0)
            {
                SelecionarPrimeiraEmpresaMae();
            }
        }
Exemplo n.º 2
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            using (UnitOfWork oUnitOfWork = new UnitOfWork())
            {
                Sigmeh.Model.Usuario usuario = oUnitOfWork.UsuarioREP.Autenticar(((TextBox)pnlLogin.FindControl("UserName")).Text, ((TextBox)pnlLogin.FindControl("Password")).Text);

                if (usuario != null)
                {
                    Session.Add("ssnLoggedUserID", usuario.UsuarioID);
                    Response.Redirect("../Home.aspx");
                }
            }
        }