Exemplo n.º 1
0
        private void btnRegister_Click(object sender, EventArgs e)
        {
            bool acceptedRequest = true;

            mail            = txtMail.Text;
            pseudo          = txtPseudo.Text;
            password        = txtPassword.Text;
            passwordComfirm = txtComfirmPassword.Text;

            if (password.Length < 6)
            {
                lblError.Text   = "You password is too weak";
                acceptedRequest = false;
            }
            if (password != passwordComfirm)
            {
                lblError.Text   = "You passwords does not match";
                acceptedRequest = false;
            }
            if (password == "")
            {
                lblError.Text   = "You must enter a password";
                acceptedRequest = false;
            }
            if (passwordComfirm == "")
            {
                lblError.Text   = "You must a password AND a comfirm password";
                acceptedRequest = false;
            }
            if (pseudo == "")
            {
                lblError.Text   = "You must enter a pseudo";
                acceptedRequest = false;
            }
            if (!IsValidEmail(mail))
            {
                lblError.Text   = "Your mail address is not valid";
                acceptedRequest = false;
            }
            if (mail == "")
            {
                lblError.Text   = "You must enter a mail address";
                acceptedRequest = false;
            }

            if (acceptedRequest == true)
            {
                if (Register.CreateUser(mail, pseudo, password))
                {
                    this.Hide();
                    GameForm newGameForm = new GameForm(mail);
                    newGameForm.ShowDialog();
                }
                else
                {
                    this.Hide();
                    RegisterForm newRegisterForm = new RegisterForm();
                    newRegisterForm.ShowDialog();
                }
            }
            else
            {
                lblError.Visible = true;
            }
        }