예제 #1
0
        private void btnLoadRank_Click(object sender, EventArgs e)
        {
            //cambio el nombre de la ventana por el valor seleccionado en CboRankngs y muestro FrmRankings
            Form ranking = new FrmRanking(cboRankngs.SelectedItem.ToString(), RankingNames);

            ranking.Text = cboRankngs.SelectedItem.ToString();

            this.Hide();

            ranking.ShowDialog();

            this.Show();
            getRankings();
            btnLoadRank.Enabled = false;
        }
예제 #2
0
        private void btnNewRank_Click(object sender, EventArgs e)
        {
            // pido el nombre del nuevo ranking
            string RankingName = Interaction.InputBox("Ingrese el nombre del nuevo ranking", "Nuevo Ranking", "Ranking Nuevo");

            var  count    = cboRankngs.Items.Count;
            bool repetido = false;

            //comparo con el nombre del nuevo ranking con los anteriores para no tener repetidos
            for (int i = 0; i < count; i++)
            {
                cboRankngs.SelectedIndex = i;
                if (cboRankngs.SelectedItem.Equals(RankingName))
                {
                    repetido = true;
                }
            }

            if (RankingName == "")
            {
                MessageBox.Show("Ingrese un valor");
            }
            else if (repetido)
            {
                MessageBox.Show("Ya existe un ranking con ese nombre, eliga otro nombre");
            }
            else if (RankingName.Length > 30)
            {
                MessageBox.Show("nombre no valido, mas corto");
            }
            else if (!regexItem.IsMatch(RankingName))
            {
                MessageBox.Show("Favor de solo ingresar numeros y letras");
            }
            else
            {
                //creo el query y la conexion con la base de datos
                string          query = "CALL NewRanking('" + RankingName + "');";
                MySqlConnection databaseConnection = new MySqlConnection(connectionString);
                MySqlCommand    commandDatabase    = new MySqlCommand(query, databaseConnection);
                commandDatabase.CommandTimeout = 60;

                try
                {
                    //ejecuto el insert, y muestro la venta FrmRanking
                    databaseConnection.Open();
                    MySqlDataReader myReader = commandDatabase.ExecuteReader();

                    MessageBox.Show("Ranking Creado correctamente");

                    databaseConnection.Close();

                    Form ranking = new FrmRanking(RankingName, RankingNames);
                    ranking.Text = RankingName;

                    this.Hide();

                    ranking.ShowDialog();

                    this.Show();
                    getRankings();
                    btnLoadRank.Enabled = false;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }