Ejemplo n.º 1
0
        private void signUpButton_Click(object sender, EventArgs e)
        {
            // add validations here, emailFormat, Minimum Password Length, all text boxes checked

            string format = "^([0-9a-zA-Z]([-\\.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$";

            if (firstNameTextBox.Text == "" || lastNameTextBox.Text == "" || emailTextBox.Text == "" || mobileTextBox.Text == "" || passwordTextBox.Text == "" || confirmPasswordTextBox.Text == "" || (memebrRadio.Checked != true && adminRadio.Checked != true))

            {
                if (firstNameTextBox.Text == "")
                {
                    errorProvider1.SetError(this.firstNameTextBox, "Please provide first name");
                    firstNameTextBox.Focus();
                }
                else
                {
                    errorProvider1.Clear();
                }
            }
            {
                if (lastNameTextBox.Text == "")
                {
                    errorProvider2.SetError(this.lastNameTextBox, "Please provide last name");
                }
                else
                {
                    errorProvider2.Clear();
                }

                if (firstNameTextBox.Text != "" && lastNameTextBox.Text == "")
                {
                    lastNameTextBox.Focus();
                }
            }
            {
                if (emailTextBox.Text == "")
                {
                    errorProvider3.SetError(this.emailTextBox, "Please provide email");
                }
                else
                {
                    errorProvider3.Clear();
                }

                if (firstNameTextBox.Text != "" && lastNameTextBox.Text != "" && emailTextBox.Text == "")
                {
                    emailTextBox.Focus();
                }
            }
            {
                if (mobileTextBox.Text == "" || mobileTextBox.Text.Length != 11)
                {
                    errorProvider4.SetError(this.mobileTextBox, "Please provide mobie number");
                }
                else
                {
                    errorProvider4.Clear();
                }

                if (firstNameTextBox.Text != "" && lastNameTextBox.Text != "" && emailTextBox.Text != "" && mobileTextBox.Text == "")
                {
                    mobileTextBox.Focus();
                }
            }
            {
                if (passwordTextBox.Text == "")
                {
                    errorProvider6.SetError(this.passwordTextBox, "Please set password");
                }
                else
                {
                    errorProvider6.Clear();
                }

                if (firstNameTextBox.Text != "" && lastNameTextBox.Text != "" && emailTextBox.Text != "" && mobileTextBox.Text != "" && passwordTextBox.Text == "")
                {
                    passwordTextBox.Focus();
                }
            }
            {
                if (confirmPasswordTextBox.Text == "")
                {
                    errorProvider7.SetError(this.confirmPasswordTextBox, "Please confirm your password");
                }
                else
                {
                    errorProvider7.Clear();
                }

                if (firstNameTextBox.Text != "" && lastNameTextBox.Text != "" && emailTextBox.Text != "" && mobileTextBox.Text != "" && passwordTextBox.Text != "" && confirmPasswordTextBox.Text == "")
                {
                    confirmPasswordTextBox.Focus();
                }
            }
            {
                if (adminRadio.Checked != true && memebrRadio.Checked != true)
                {
                    errorProvider5.SetError(this.memebrRadio, "Please select one");
                }
                else
                {
                    errorProvider5.Clear();
                }

                if (firstNameTextBox.Text != "" && lastNameTextBox.Text != "" && emailTextBox.Text != "" && mobileTextBox.Text != "" && passwordTextBox.Text != "" && confirmPasswordTextBox.Text != "" && (adminRadio.Checked != true && memebrRadio.Checked != true))
                {
                    memebrRadio.Focus();
                }
            }

            if (Regex.IsMatch(emailTextBox.Text, format))
            {
                errorProvider1.Clear();
                emailTextBox.Focus();
            }
            else
            {
                errorProvider1.SetError(this.emailTextBox, "Please provide valid email");
                return;
            }

            if (mobileTextBox.Text.Length <= 10 || mobileTextBox.Text.Length >= 12)
            {
                //errorProvider1.Clear();
                errorProvider4.SetError(this.mobileTextBox, "Please provide valid mobile number");
                // mobileTextBox.Focus();
            }
            else
            {
                errorProvider4.Clear();
            }



            if (passwordTextBox.Text != confirmPasswordTextBox.Text)
            {
                confirmPasswordError.Visible = true;
                confirmPasswordTextBox.Text  = "";
                confirmPasswordTextBox.Focus();
            }

            else
            {
                controller = new Controller.AuthorizationModule(Util.CONNECTION_DETAILS.CONNECITION_STRING, usersTableName);
                user       = new User(firstNameTextBox.Text, lastNameTextBox.Text, emailTextBox.Text, passwordTextBox.Text, adminRadio.Checked, mobileTextBox.Text);
                controller.signUp(user, this);
            }
        }