Beispiel #1
0
        protected void ButtonSignupSubmit_Click(object sender, EventArgs e)
        {
            if (TextboxSignupPassword.Text == TextboxSignupConfirmPassword.Text)
            {
                string fName    = this.TextboxSignupFirstname.Text;
                string lName    = this.TextboxSignupLastname.Text;
                string email    = this.TextboxSignupEmail.Text;
                string password = this.TextboxSignupPassword.Text;
                string phone    = this.TextboxSignupMobile.Text;
                WebApplication1.scripts.AccountCredentials acc = new scripts.AccountCredentials();
                acc.setFName(fName);
                acc.setLName(lName);
                acc.setEmail(email);
                acc.setPassword(password);
                acc.setPhoneNumber(phone);
                WebApplication1.scripts.AccountDAO dao = new scripts.AccountDAO();
                if (dao.getIdByPhoneNumber(phone) == -1)
                {
                    dao.insertAccount(acc);

                    ClientScriptManager cs = Page.ClientScript;
                    Type cstype            = this.GetType();

                    String alert = "alert('registeration completed');";
                    cs.RegisterStartupScript(cstype, "PopupScript", alert, true);
                    Response.Redirect(Page.ResolveClientUrl("login.aspx"));
                }
                else
                {
                    ClientScriptManager cs = Page.ClientScript;
                    Type cstype            = this.GetType();

                    String alert = "alert('this phone number is already registered ');";
                    cs.RegisterStartupScript(cstype, "PopupScript", alert, true);
                }
            }
            else
            {
                Response.Write("<script language=javascript>alert('password and confirm password does not match');</script>");
            }
        }
Beispiel #2
0
        protected void ButtonLoginSubmit_Click(object sender, EventArgs e)
        {
            string phone    = this.TextboxLoginMobile.Text;
            string password = this.TextboxLoginPassword.Text;

            WebApplication1.scripts.AccountDAO         dao = new scripts.AccountDAO();
            WebApplication1.scripts.AccountCredentials acc = new scripts.AccountCredentials();
            int id = dao.getIdByPhoneNumber(phone);

            if (id == -1)
            {
                //not regestierd
                ClientScriptManager cs = Page.ClientScript;
                Type cstype            = this.GetType();

                String alert = "alert('this phone number is not registered');";
                cs.RegisterStartupScript(cstype, "PopupScript", alert, true);
            }
            else
            {
                //phone number exist
                acc = dao.getAccountById(id);
                if (acc.getPassword() != password)
                {
                    //wrong password
                    ClientScriptManager cs = Page.ClientScript;
                    Type cstype            = this.GetType();

                    String alert = "alert('wrong password');";
                    cs.RegisterStartupScript(cstype, "PopupScript", alert, true);
                }
                else
                {
                    //access granted
                    Session["id"] = id;
                    Response.Redirect(Page.ResolveClientUrl("../users/book/book.aspx"));
                }
            }
        }