示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                string email = txtEmail.Text.Trim();
                string password = txtPassword.Text.Trim();

                // Try to get this user
                using (usuarioBLL bll = new usuarioBLL())
                {
                    usuario user = bll.GetUserByLoginAndPassword(email, password);

                    if (user != null)
                    {
                        // We have a user
                        Session["loggedin"] = user.id_usuario;
                        Session["userPrivilege"] = user.valor_nivel_acesso;
                        Session["userName"] = user.nome;
                    }
                    else
                    {
                        // User not found
                        display = "display: block;";
                        txtEmail.BorderColor = System.Drawing.Color.Red;
                        txtPassword.BorderColor = System.Drawing.Color.Red;
                    }
                }
            }

            if (Session["loggedin"] != null)
            {
                Response.Redirect("contacts.aspx");
            }
        }
示例#2
0
        // Populate & bind the user dropdown list
        private void BindSellers(DropDownList ddl)
        {
            ddl.Items.Clear();
            ddl.Items.Add(new ListItem { Text = "All sellers", Value = "0" });
            ddl.AppendDataBoundItems = true;

            using (usuarioBLL bll = new usuarioBLL())
            {
                ddl.DataTextField = "nome";
                ddl.DataValueField = "id_usuario";
                ddl.DataSource = bll.GetUsersUpToAnAccessLevel(10);
                ddl.DataBind();
            }
        }