Esempio n. 1
0
 /// <summary>
 /// Updates the Users Country code when sent by the client
 /// </summary>
 /// <param name="recv">Array of information sent by the server</param>
 private void UpdateUser(Dictionary <string, string> Recv)
 {
     // Set clients country code
     try
     {
         using (GamespyDatabase Conn = new GamespyDatabase())
             Conn.UpdateUser(PlayerId, Recv["countrycode"]);
     }
     catch (Exception e)
     {
         Program.ErrorLog.Write("ERROR: [GpcmClient.UpdateUser] " + e.Message);
     }
 }
        /// <summary>
        /// Event fired when the Submit button is pushed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UpdateBtn_Click(object sender, EventArgs e)
        {
            int Pid = (int)PlayerID.Value;

            using (GamespyDatabase Database = new GamespyDatabase())
            {
                // Make sure there is no empty fields!
                if (AccountNick.Text.Trim().Length < 3)
                {
                    MessageBox.Show("Please enter a valid account name", "Error");
                    return;
                }
                else if (!Validator.IsValidEmail(AccountEmail.Text))
                {
                    MessageBox.Show("Please enter a valid account email", "Error");
                    return;
                }
                else if (Pid != AccountId)
                {
                    if (!Validator.IsValidPID(Pid.ToString()))
                    {
                        MessageBox.Show("Invalid PID Format. A PID must be 8 or 9 digits in length", "Error");
                        return;
                    }
                    // Make sure the PID doesnt exist!
                    else if (Database.UserExists(Pid))
                    {
                        MessageBox.Show("Battlefield 2 PID is already taken. Please try a different PID.", "Error");
                        return;
                    }
                }

                Database.UpdateUser(AccountId, Pid, AccountNick.Text, AccountPass.Text, AccountEmail.Text);
            }
            this.Close();
        }