CreateUser() public method

Creates a new Gamespy Account
Only used in the Gamespy Account Creation Form
public CreateUser ( int Pid, string Nick, string Pass, string Email, string Country ) : bool
Pid int The Profile Id to assign this account
Nick string The Account Name
Pass string The UN-HASHED Account Password
Email string The Account Email Address
Country string The Country Code for this Account
return bool
        private void CreateBtn_Click(object sender, EventArgs e)
        {
            int Pid = (int)PidBox.Value;

            using (GamespyDatabase Database = new GamespyDatabase())
            {
                // Make sure there is no empty fields!
                if (AccountName.Text.Trim().Length < 3)
                {
                    MessageBox.Show("Please enter a valid account name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                else if (AccountPass.Text.Trim().Length < 3)
                {
                    MessageBox.Show("Please enter a valid account password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                else if (!Validator.IsValidEmail(AccountEmail.Text))
                {
                    MessageBox.Show("Please enter a valid account email", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                // Check if PID exists (for changing PID)
                if (PidSelect.SelectedIndex == 1)
                {
                    if (!Validator.IsValidPID(Pid.ToString()))
                    {
                        MessageBox.Show("Invalid PID Format. A PID must be 8 or 9 digits in length", "Error",
                            MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    else if (Database.UserExists(Pid))
                    {
                        MessageBox.Show("PID is already in use. Please enter a different PID.", "Error",
                            MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }

                // Check if the user exists
                if (Database.UserExists(AccountName.Text))
                {
                    MessageBox.Show("Account name is already in use. Please select a different Account Name.", "Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                try
                {
                    // Attempt to create the account
                    if (PidSelect.SelectedIndex == 1)
                        Database.CreateUser(Pid, AccountName.Text, AccountPass.Text, AccountEmail.Text, "00");
                    else
                        Database.CreateUser(AccountName.Text, AccountPass.Text, AccountEmail.Text, "00");

                    Notify.Show("Account Created Successfully!", AccountName.Text, AlertType.Success);
                }
                catch (Exception E)
                {
                    MessageBox.Show(E.Message, "Account Create Error");
                }
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
        /// <summary>
        /// Whenever the "newuser" command is recieved, this method is called to
        /// add the new users information into the database
        /// </summary>
        /// <param name="Recv">Array of parms sent by the server</param>
        private void CreateNewUser(Dictionary<string, string> Recv)
        {
            // Make sure the user doesnt exist already
            try
            {
                using (GamespyDatabase Database = new GamespyDatabase())
                {
                    // Check to see if user exists
                    if (Database.UserExists(Recv["nick"]))
                    {
                        Stream.SendAsync(@"\error\\err\516\fatal\\errmsg\This account name is already in use!\id\1\final\");
                        Disconnect(5);
                        return;
                    }

                    // We need to decode the Gamespy specific encoding for the password
                    string Password = GamespyUtils.DecodePassword(Recv["passwordenc"]);
                    string Cc = (RemoteEndPoint.AddressFamily == AddressFamily.InterNetwork)
                        ? Ip2nation.GetCountryCode(RemoteEndPoint.Address)
                        : Program.Config.ASP_LocalIpCountryCode;

                    // Attempt to create account. If Pid is 0, then we couldnt create the account
                    if ((PlayerId = Database.CreateUser(Recv["nick"], Password, Recv["email"], Cc)) == 0)
                    {
                        Stream.SendAsync(@"\error\\err\516\fatal\\errmsg\Error creating account!\id\1\final\");
                        Disconnect(6);
                        return;
                    }

                    Stream.SendAsync(@"\nur\\userid\{0}\profileid\{0}\id\1\final\", PlayerId);
                }
            }
            catch(Exception e)
            {
                // Check for invalid query params
                if (e is KeyNotFoundException)
                {
                    Stream.SendAsync(@"\error\\err\0\fatal\\errmsg\Invalid Query!\id\1\final\");
                }
                else
                {
                    Stream.SendAsync(@"\error\\err\516\fatal\\errmsg\Error creating account!\id\1\final\");
                    GpcmServer.Log("ERROR: [Gpcm.CreateNewUser] An error occured while trying to create a new User account :: " + e.Message);
                }

                Disconnect(7);
                return;
            }
        }