Exemplo n.º 1
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            AccountServiceRef.Service1Client client = new AccountServiceRef.Service1Client();
            string email        = Email.Text;
            string password     = Password.Text;
            string firstName    = First.Text;
            string lastName     = Last.Text;
            string inputCaptcha = Capcha.Text;
            string rule         = "User";

            Boolean result  = false;
            string  captcha = (string)Session["Captcha"];

            if (captcha.Equals(inputCaptcha))
            {
                result = client.addUser1(firstName, lastName, email, password, rule);

                if (result == true)
                {
                    linkBtn.Visible = true;
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "<script>$('#remindModal').modal('show');</script>", false);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "<script>$('#remindCapchaModal').modal('show');</script>", false);
            }
        }
        protected void btnLogin_Click(Object sender, EventArgs e)
        {
            string email    = Email.Text;
            string password = Password.Text;
            int    result   = 0;

            AccountServiceRef.Service1Client client = new AccountServiceRef.Service1Client();
            result = client.verifyUser(email, password);

            if (result > 0)
            {
                FormsAuthentication.RedirectFromLoginPage(email, false);

                Session["Email"] = email;
                Session["Rule"]  = result;

                if (result == 1)
                {
                    Response.Redirect("~/Member/Home.aspx");
                }
                else if (result == 2)
                {
                    Response.Redirect("~/Staff/Home.aspx");
                }
                else
                {
                    Response.Redirect("~/Admin/Home.aspx");
                }
            }

            else
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "<script>$('#remindModal').modal('show');</script>", false);
            }
        }