private void loadRecord(Record record) { athlete_name_textbox.Text = record.name; score1_time.Text = record.time1.ToString(); score1_technical.Text = record.score1t.ToString(); score1_presentation.Text = record.score1p.ToString(); score1_total.Text = record.score1f.ToString(); score2_time.Text = record.time2.ToString(); score2_technical.Text = record.score2t.ToString(); score2_presentation.Text = record.score2p.ToString(); score2_total.Text = record.score2f.ToString(); score_final.Text = record.scoref.ToString(); foreach (Judge judge in judges) { judge.Technical1 = record.judgeScores[judge.Id - 1].score1t.ToString(); judge.Presentation1 = record.judgeScores[judge.Id - 1].score1p.ToString(); judge.Technical2 = record.judgeScores[judge.Id - 1].score2t.ToString(); judge.Presentation2 = record.judgeScores[judge.Id - 1].score2p.ToString(); } }
private void onEditAthlete(object sender, EventArgs e) { if (division_table.SelectedCells.Count == 0) { return; } DataGridViewRow row = division_table.Rows[division_table.SelectedCells[0].RowIndex]; Record record = new Record(); record.name = row.Cells[0].Value.ToString(); if (!Double.TryParse(row.Cells[1].Value.ToString(), out record.scoref)) { MessageBox.Show("Couldn't save record!\nInvalid combine Poomsae score!"); return; } if (!Double.TryParse(row.Cells[2].Value.ToString(), out record.score1f)) { MessageBox.Show("Couldn't save record!\nInvalid Poomsae 1 final score!"); return; } if (!Double.TryParse(row.Cells[3].Value.ToString(), out record.score1t)) { MessageBox.Show("Couldn't save record!\nInvalid Poomsae 1 technical score!"); return; } if (!Double.TryParse(row.Cells[4].Value.ToString(), out record.score1p)) { MessageBox.Show("Couldn't save record!\nInvalid Poomsae 1 presentation score!"); return; } if (!Double.TryParse(row.Cells[5].Value.ToString(), out record.time1)) { MessageBox.Show("Couldn't save record!\nInvalid Poomsae 1 time!"); return; } if (!Double.TryParse(row.Cells[6].Value.ToString(), out record.score2f)) { MessageBox.Show("Couldn't save record!\nInvalid Poomsae 2 final score!"); return; } if (!Double.TryParse(row.Cells[7].Value.ToString(), out record.score2t)) { MessageBox.Show("Couldn't save record!\nInvalid Poomsae 2 technical score!"); return; } if (!Double.TryParse(row.Cells[8].Value.ToString(), out record.score2p)) { MessageBox.Show("Couldn't save record!\nInvalid Poomsae 2 presentation score!"); return; } if (!Double.TryParse(row.Cells[9].Value.ToString(), out record.time2)) { MessageBox.Show("Couldn't save record!\nInvalid Poomsae 2 time!"); return; } record.judgeCount = judges.Count; record.judgeScores = new QuadDouble[record.judgeCount]; foreach (Judge judge in judges) { var i = judge.Id - 1; record.judgeScores[judge.Id - 1] = new QuadDouble(); record.judgeScores[judge.Id - 1].score1t = Double.Parse(row.Cells[10 + i * 4].Value.ToString()); record.judgeScores[judge.Id - 1].score1p = Double.Parse(row.Cells[11 + i * 4].Value.ToString()); record.judgeScores[judge.Id - 1].score2t = Double.Parse(row.Cells[12 + i * 4].Value.ToString()); record.judgeScores[judge.Id - 1].score2p = Double.Parse(row.Cells[13 + i * 4].Value.ToString()); } this.loadRecord(record); }
private void saveFile() { // Save Scores Record record = new Record(); record.name = athlete_name_textbox.Text.Replace(",", ""); if (!Int32.TryParse(judgecount_textbox.Text, out record.judgeCount)) { MessageBox.Show("Couldn't save record!\nInvalid number of judges!"); return; } if (!Double.TryParse(score1_time.Text, out record.time1)) { MessageBox.Show("Couldn't save record!\nInvalid Poomsae 1 time!"); return; } if (!Double.TryParse(score1_technical.Text, out record.score1t)) { MessageBox.Show("Couldn't save record!\nInvalid Poomsae 1 technical score!"); return; } if (!Double.TryParse(score1_presentation.Text, out record.score1p)) { MessageBox.Show("Couldn't save record!\nInvalid Poomsae 1 presentation score!"); return; } if (!Double.TryParse(score1_total.Text, out record.score1f)) { MessageBox.Show("Couldn't save record!\nInvalid Poomsae 1 final score!"); return; } if (!Double.TryParse(score2_time.Text, out record.time2)) { MessageBox.Show("Couldn't save record!\nInvalid Poomsae 2 time!"); return; } if (!Double.TryParse(score2_technical.Text, out record.score2t)) { MessageBox.Show("Couldn't save record!\nInvalid Poomsae 2 technical score!"); return; } if (!Double.TryParse(score2_presentation.Text, out record.score2p)) { MessageBox.Show("Couldn't save record!\nInvalid Poomsae 2 presentation score!"); return; } if (!Double.TryParse(score2_total.Text, out record.score2f)) { MessageBox.Show("Couldn't save record!\nInvalid Poomsae 2 final score!"); return; } if (!Double.TryParse(score_final.Text, out record.scoref)) { MessageBox.Show("Couldn't save record!\nInvalid combine Poomsae score!"); return; } record.judgeScores = new QuadDouble[record.judgeCount]; foreach (Judge judge in judges) { record.judgeScores[judge.Id - 1] = new QuadDouble(); record.judgeScores[judge.Id - 1].score1t = Double.Parse(judge.Technical1); record.judgeScores[judge.Id - 1].score1p = Double.Parse(judge.Presentation1); record.judgeScores[judge.Id - 1].score2t = Double.Parse(judge.Technical2); record.judgeScores[judge.Id - 1].score2p = Double.Parse(judge.Presentation2); } Directory.CreateDirectory("results"); String file = "results/" + division_textbox.Text + ".csv"; Record.append(file, record); clearScores(); loadFile(); }