Example #1
0
        private void cmdRegister_Click(object sender, EventArgs e)
        {
            // Extract details from the form
            String first_name = txtFirstName.Text;
            String last_name = txtLastName.Text;
            String email = txtEmail.Text;
            String username = txtUsername.Text;
            String password = txtPassword.Text;
            String confirmPassword = txtConfirmPassword.Text;

            // Create a user object
            User newUser = new User(username, password, first_name, last_name, email, "Enter your bio here...");

            // Create a registerModel
            RegisterModel registerModel = new RegisterModel();

            //Validate the data
            Validation validation = registerModel.validateData(newUser, confirmPassword);

            // Output the state of the Login
            MessageBox.Show(validation.getError());

            // If it was valid, add the user
            if (validation.getValidity())
            {
                // Convert username to lower case - for storage
                String lowerCaseUsername = newUser.getUsername().ToLower();
                newUser.setUsername(lowerCaseUsername);

                // Attempt to add the user to the database
                bool success = registerModel.doRegister(newUser);

                // If it succeeded, close the current form
                if (success)
                {
                    this.Close();

                    //Set the parent to be login
                   // Login parent = (Login)this.Parent;

                    //Call the method to show
                    //parent.showForm();

                }
            }
        }
Example #2
0
        private void txtUsername_Leave(object sender, EventArgs e)
        {
            if (txtUsername.Text == "")
            {
                txtUsername.Text = "Username...";
            }
            else
            {
                picUsernameStatus.Image = Properties.Resources.spinningWheel;

                RegisterModel registerModel = new RegisterModel();
                bool taken = registerModel.checkUsername(txtUsername.Text);

                picUsernameStatus.Visible = true;

                if (!taken) {
                    picUsernameStatus.Image = Properties.Resources.small_tick;
                }
                else
                {
                    picUsernameStatus.Image = Properties.Resources.small_cross;
                    lblUsernameTaken.Visible = true;
                }

            }
        }