private void button3_Click(object sender, EventArgs e) { //variable gets event string selected = listBox1.GetItemText(listBox1.SelectedItem); //gets total time double total; double[] num = new double[7]; num[0] = Convert.ToDouble(textBox2.Text); num[1] = Convert.ToDouble(textBox3.Text); num[2] = Convert.ToDouble(textBox4.Text); num[3] = Convert.ToDouble(textBox5.Text); num[4] = Convert.ToDouble(textBox6.Text); num[5] = Convert.ToDouble(textBox7.Text); num[6] = Convert.ToDouble(textBox8.Text); total = num[0] + num[1] + num[2] + num[3] + num[4] + num[5] + num[6]; total = total - (num.Min() + num.Max()); total = total / 5; //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(); //instance of class used to enter score Scoring TimeEntry = new Scoring(); //member function adds the Time to database TimeEntry.EnterScore(total, selected, AthleteScore.firstName, AthleteScore.lastName); //this will update the score board to reflect the changes string View = "SELECT * FROM " + SelectedEvent + " ORDER BY Score 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(); } }
private void button1_Click(object sender, EventArgs e) { //string used to place cell contents into string country; //gets selected row int rowindex = dataGridView2.CurrentCell.RowIndex; //enters selected row into a string variable country = dataGridView2.CurrentCell.Value.ToString(); //string to store selected gender string selected = listBox1.GetItemText(listBox1.SelectedItem); //object used to store athletes info Athlete AddAthlete = new Athlete(); //add athletes info to object AddAthlete.firstName = textBox1.Text; AddAthlete.lastName = textBox2.Text; AddAthlete.gender = selected; //object from registration class Registration RegAthlete = new Registration(); //calls member function of Registration RegAthlete.registerAthlete(AddAthlete.firstName, AddAthlete.lastName, AddAthlete.gender, country); //this will refresh the list string ViewTable = "SELECT * FROM 'Athlete Information'";//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(ViewTable, con); da.Fill(ds); dataGridView1.DataSource = ds.Tables[0].DefaultView; } else { MessageBox.Show("Connection failed."); } } con.Close(); } }
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(); } }
private void button1_Click(object sender, EventArgs e) { //class created to store athletes info Athlete AddAthlete = new Athlete(); //objects used to store the athletes info AddAthlete.firstName = dataGridView1.SelectedCells[1].Value.ToString(); AddAthlete.lastName = dataGridView1.SelectedCells[2].Value.ToString(); //stores country name string country = dataGridView1.SelectedCells[0].Value.ToString(); //select puts the selected event into a string string selected = listBox1.GetItemText(listBox1.SelectedItem); //if statements check the selected item from list box and will execute //the corresponding class member functions if (selected == "Mens 500m Speed Skating, Monday, 12:00pm, Rink 1") { //create new instance of an object SS500m EventRegister = new SS500m(); //member function adds athlete to database EventRegister.AddAthleteMale(country, AddAthlete.firstName, AddAthlete.lastName); } if (selected == "Womens 500m Speed Skating, Monday, 12:00pm Rink 2") { //create new instance of an object SS500m EventRegister = new SS500m(); //member function adds athlete to database EventRegister.AddAthleteFemale(country, AddAthlete.firstName, AddAthlete.lastName); } if (selected == "Mens 1000m Speed Skating, Tueday, 12:00pm, Rink 1") { //create new instance of an object SS1000m EventRegister = new SS1000m(); //member function adds athlete to database EventRegister.AddAthleteMale(country, AddAthlete.firstName, AddAthlete.lastName); } if (selected == "Womens 1000m Speed Skating, Tuesday, 12:00pm, Rink 2") { //create new instance of an object SS1000m EventRegister = new SS1000m(); //member function adds athlete to database EventRegister.AddAthleteFemale(country, AddAthlete.firstName, AddAthlete.lastName); } if (selected == "Mens 1500m Speed Skating, Wednesday, 12:00pm, Rink 1") { //create new instance of an object SS1500m EventRegister = new SS1500m(); //member function adds athlete to database EventRegister.AddathleteMale(country, AddAthlete.firstName, AddAthlete.lastName); } if (selected == "Womens 1500m Speed Skating, Wednesday, 12:00pm, Rink 2") { //create new instance of an object SS1500m EventRegister = new SS1500m(); //member function adds athlete to database EventRegister.AddAthleteFemale(country, AddAthlete.firstName, AddAthlete.lastName); } if (selected == "Single Skating Mens, Monday, 11:00am, Rink 3") { //create new instance of an object SingleSkating EventRegister = new SingleSkating(); //member function adds athlete to database EventRegister.AddAthleteMale(country, AddAthlete.firstName, AddAthlete.lastName); } if (selected == "Single Skating Womens, Monday, 11:00am, Rink 4") { //create new instance of an object SingleSkating EventRegister = new SingleSkating(); //member function adds athlete to database EventRegister.AddAthleteFemale(country, AddAthlete.firstName, AddAthlete.lastName); } if (selected == "Ice Dance Mens, Tuesday, 2:00pm, Rink 3") { //create new instance of an object IceDance EventRegister = new IceDance(); //member function adds athlete to database EventRegister.AddAthleteMale(country, AddAthlete.firstName, AddAthlete.lastName); } if (selected == "Ice Dance Womens, Tuesday, 2:00pm, Rink 4") { //create new instance of an object IceDance EventRegister = new IceDance(); //member function adds athlete to database EventRegister.AddAthleteFemale(country, AddAthlete.firstName, AddAthlete.lastName); } if (selected == "Couple Skating, Monday, 5:00pm, Rink 3") { //create new instance of an object PairSkating EventRegister = new PairSkating(); //member function adds athlete to database EventRegister.AddAthlete(country, AddAthlete.firstName, AddAthlete.lastName); } //this will repopulate Event with the added entry string View = "SELECT * FROM 'Events'";//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); dataGridView2.DataSource = ds.Tables[0].DefaultView; } else { MessageBox.Show("Connection failed."); } } con.Close(); } }