Exemple #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);
            }
        }
Exemple #2
0
        private void removeEloFromCheckBoxString()
        {
            int countTeam = sql.count("teams5v5", "id", "");

            try
            {
                string p1 = "";
                string p2 = "";
                string p3 = "";
                string p4 = "";
                string p5 = "";

                foreach (string s in playerListBox.CheckedItems)
                {
                    string removedElo = "";

                    if (s.Contains("   "))
                    {
                        removedElo = s.Substring(s.IndexOf("   ") + 3);
                    }
                    else
                    {
                        removedElo = s.Substring(s.IndexOf(" ") + 1);
                    }
                    if (p1 == "")
                    {
                        p1 = removedElo;
                    }
                    else if (p2 == "")
                    {
                        p2 = removedElo;
                    }
                    else if (p3 == "")
                    {
                        p3 = removedElo;
                    }
                    else if (p4 == "")
                    {
                        p4 = removedElo;
                    }
                    else if (p5 == "")
                    {
                        p5 = removedElo;
                    }
                }

                sql.add5v5Team(countTeam, teamNameBox.Text, coachNameBox.Text, p1, p2, p3, p4, p5);
            }
            catch
            {
                errorLabel.Text     = "Team name already exists";
                errorLabel.Location = new Point((ActiveForm.Width - errorLabel.Width) / 2, 465);
                addingLabel.Text    = "";
            }

            errorLabel.Text     = "Team successfully added";
            errorLabel.Location = new Point((ActiveForm.Width - errorLabel.Width) / 2, 465);
            addingLabel.Text    = "";
        }