Exemple #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            //variable gets event
            string selected = listBox1.GetItemText(listBox1.SelectedItem);
            string time     = textBox1.Text;//gets team from text box
            //class created to store athletes info
            Athlete AthleteScore = new Athlete();

            //stores name of athlete
            AthleteScore.firstName = dataGridView1.SelectedCells[1].Value.ToString();
            AthleteScore.lastName  = dataGridView1.SelectedCells[2].Value.ToString();

            Scoring AddTime = new Scoring();

            AddTime.EnterTime(time, selected, AthleteScore.firstName, AthleteScore.lastName);
            //this will update the score board to reflect the changes
            string View = "SELECT * FROM " + SelectedEvent + " ORDER BY Times DESC;";//gets team table from database

            using (System.Data.SQLite.SQLiteConnection con = new System.Data.SQLite.SQLiteConnection("data source=OlympiaDB.sqlite"))
            {
                using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(con))
                {
                    con.Open();                            //opens DB
                    if (con.State == ConnectionState.Open) // if connection.Open was successful
                    {
                        //this sends sql commands to database
                        DataSet ds = new DataSet();
                        var     da = new SQLiteDataAdapter(View, con);
                        da.Fill(ds);
                        dataGridView1.DataSource = ds.Tables[0].DefaultView;
                    }
                    else
                    {
                        MessageBox.Show("Connection failed.");
                    }
                }
                con.Close();
            }
        }