Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            var dt = ConnectionDB.ExecuteQuery("SELECT pl.name, sc.score " +
                                               "FROM PLAYER pl, SCOREBOARD sc " +
                                               "WHERE pl.idscore = sc.idscore order by sc.score desc " +
                                               "LIMIT 10");

            dataGridView1.DataSource = dt;
        }
Ejemplo n.º 2
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            Continue = true;
            try
            {
                var name   = txtName.Text;
                var player = txtName.Text;

                if (name.Length == 0)
                {
                    MessageBox.Show("you did not enter the name!", "Name Empty",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    //verificacion con la base de datos por si esta repetido
                    var dt = ConnectionDB.ExecuteQuery("SELECT Name FROM PLAYER ");

                    foreach (DataRow dr in dt.Rows)
                    {
                        if (dr[0].ToString().Equals(txtName.Text))
                        {
                            MessageBox.Show("The name already exist", "name repeated",
                                            MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                            Continue = false;
                            break;
                        }
                    }

                    //luego se inicia el juego
                    if (Continue == true)
                    {
                        ConnectionDB.ExecuteNonQuery("INSERT INTO PLAYER(Name) " +
                                                     $"VALUES('{txtName.Text}')");

                        player = txtName.Text;
                        GamePlatform game = new GamePlatform(player);
                        game.Show();
                    }
                    //Para un jugador previamente registrado
                    else
                    {
                        player = txtName.Text;
                        GamePlatform game = new GamePlatform(player);
                        game.Show();
                    }
                }
            }
            catch (Exception exceptionNoInfo)
            {
                MessageBox.Show("An error has ocurred :(");
            }
        }
Ejemplo n.º 3
0
        private void btnGameHistory_Click(object sender, EventArgs e)
        {
            try
            {
                var dt = ConnectionDB.ExecuteQuery("SELECT * FROM SCOREBOARD");

                dgvScores.DataSource = dt;
            }
            catch (Exception exceptionUpdateScores)
            {
                MessageBox.Show("An error has ocurred");
            }
        }
Ejemplo n.º 4
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                var dt = ConnectionDB.ExecuteQuery("SELECT * FROM PLAYER order by score desc LIMIT 10");

                dgvScores.DataSource = dt;
            }
            catch (Exception exceptionUpdateScores)
            {
                MessageBox.Show("An error has ocurred");
            }
        }
        //This function is a button that shows the Top 10
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                var dt = ConnectionDB.ExecuteQuery("SELECT pl.name, sc.score " +
                                                   "FROM PLAYER pl, SCOREBOARD sc " +
                                                   "WHERE pl.idscore = sc.idscore order by sc.score desc " +
                                                   "LIMIT 10");

                dataGridView1.DataSource = dt;
            }
            catch (Exception exceptionUpdateScores)
            {
                MessageBox.Show("An error has ocurred");
            }
        }
Ejemplo n.º 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            var name = txtName.Text;

            if (name.Length == 0)
            {
                MessageBox.Show("you did not enter the name!", "Name Empty",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                //verificacion con la base de datos por si esta repetido
                var dt = ConnectionDB.ExecuteQuery("SELECT Name " +
                                                   "FROM PLAYER");

                foreach (DataRow dr in dt.Rows)
                {
                    if (dr[0].ToString().Equals(txtName.Text))
                    {
                        MessageBox.Show("The name already exist", "name repeated",
                                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                        Continue = false;
                        break;
                    }
                }

                //luego se inicia el juego
                if (Continue == true)
                {
                    ConnectionDB.ExecuteNonQuery("INSERT INTO PLAYER(Name) " +
                                                 $"VALUES('{txtName.Text}')");
                    Game game = new Game();
                    game.Show();
                    this.Close();
                }
            }
        }