Пример #1
0
        /// <summary>
        /// Refreshes values in DataGridView
        /// </summary>
        private void refreshTable()
        {
            try
            {
                DBReader.connectionOpen(connection);
                adapter = new MySqlDataAdapter();
                if (textBoxSelectedPlayer.Text == "For all")
                {
                    adapter.SelectCommand = DBReader.commandForTheWholeTable(connection, entityName);
                }
                else if (textBoxSelectedPlayer.Text.StartsWith("Player "))
                {
                    playersID = DBReader.selectAllPlayersID(connection, DBName);
                    int ID = playersID[Int32.Parse(textBoxSelectedPlayer.Text.Substring(7)) - 1];
                    adapter.SelectCommand = DBReader.commandForSelectedPlayer(connection, entityName, ID);
                }

                dataSet = new DataTable();
                adapter.Fill(dataSet);
                BindingSource source = new BindingSource();

                source.DataSource      = dataSet;
                tableEntity.DataSource = source;
                adapter.Update(dataSet);
            }
            catch (MySqlException ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                DBReader.connectionEnd(connection);
            }
        }
Пример #2
0
 /// <summary>
 /// Rotates players when clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonRightArrow_Click(object sender, EventArgs e)
 {
     playersID = new List <int>();
     try
     {
         DBReader.connectionOpen(connection);
         playersID = DBReader.selectAllPlayersID(connection, DBName);
         if (textBoxSelectedPlayer.Text == "For all")
         {
             buttonInsUp.Enabled        = false;
             currentID                  = 0;
             textBoxSelectedPlayer.Text = "Player " + playersID[0];
         }
         else if (textBoxSelectedPlayer.Text == "Player " + playersID[playersID.Count() - 1])
         {
             if (textBoxSelectedItem.Text != "")
             {
                 buttonInsUp.Enabled = true;
             }
             else
             {
                 buttonInsUp.Enabled = false;
             }
             currentID = -1;
             textBoxSelectedPlayer.Text = "For all";
         }
         else if (textBoxSelectedPlayer.Text.StartsWith("Player "))
         {
             buttonInsUp.Enabled = false;
             currentID++;
             textBoxSelectedPlayer.Text = "Player " + playersID[currentID];
         }
     }
     catch (MySqlException ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         DBReader.connectionEnd(connection);
     }
 }