Example #1
0
        private void addPlayerButton_Click(object sender, EventArgs e)
        {
            errorLabel.Text = "";

            try
            {
                if (playerUsernameBox.Text.Contains(" "))
                {
                    errorLabel.Text     = "Usernames cannot contain a space! Use _ instead";
                    errorLabel.Location = new Point((ActiveForm.Width - errorLabel.Width) / 2, 390);
                }
                else
                {
                    int count = sql.count("players", "username", "");
                    sql.addPlayer(playerUsernameBox.Text, count, (int)EloBox.Value);

                    errorLabel.Text     = "Player successfully added";
                    errorLabel.Location = new Point((ActiveForm.Width - errorLabel.Width) / 2, 390);
                }
            }
            catch
            {
                errorLabel.Text     = "Player already exists in database";
                errorLabel.Location = new Point((ActiveForm.Width - errorLabel.Width) / 2, 390);
            }
        }