private string createMatchRows(DataRow[] dRows, int numberOfSessions, int matchNumber, bool addExtraRowInFront = false) { string html = ""; if (addExtraRowInFront) { html += addEmptyRows(numberOfSessions); } for (int j = 0; j < 2; ++j) { html += ("<tr>"); int otherRow = 1 - j; int teamNumber = (int)dRows[j]["Team_Number"]; double total = (double)dRows[j]["Total"]; double otherTotal = (double)dRows[otherRow]["Total"]; if (j == 0) { html += Utilities.makeTableCell_("" + matchNumber, 1, false, 2); } int rowIndex = (total > otherTotal) ? 0 : 1; if (total > otherTotal) { html += Utilities.makeTableCell_("<b>" + getTeamLink(teamNumber, true, true) + "</b>", rowIndex); } else { html += Utilities.makeTableCell_(getTeamLink(teamNumber, true, true), rowIndex); } html += Utilities.makeTableCell_("" + AccessDatabaseUtilities.getDoubleValue(dRows[j], "Carryover"), rowIndex); for (int k = 1; k <= numberOfSessions; ++k) { string columnName = "Session_" + k + "_Score"; double sessionScore = AccessDatabaseUtilities.getDoubleValue(dRows[j], columnName); double otherSessionScore = AccessDatabaseUtilities.getDoubleValue(dRows[otherRow], columnName); if (sessionScore > otherSessionScore) { html += Utilities.makeTableCell_("<b>" + sessionScore + "</b>", rowIndex); } else { html += Utilities.makeTableCell_("" + sessionScore, rowIndex); } } if (total > otherTotal) { html += Utilities.makeTableCell_("<b>" + total + "</b>", rowIndex); } else { html += Utilities.makeTableCell_("" + total, rowIndex); } html += ("</tr>" + Environment.NewLine); } return(html); }
private void populateSwissLeagueTables(int numberOfRounds, int numberOfTeams) { DataTable table = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.EventNames); int count = 1; DataTable computedScoresTable = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.EventComputedScores); foreach (string eventName in m_selectedEventNames) { for (int i = 0; i < m_dataViews[eventName].Count; ++i) { if (m_selectedTeams[m_currentTabNumber][eventName][i]) { DataRow dRow = m_dataViews[eventName][i].Row; int originalTeamNumber = AccessDatabaseUtilities.getIntValue(dRow, "Team_Number"); string teamName = AccessDatabaseUtilities.getStringValue(dRow, "Team_Name"); string memberNames = AccessDatabaseUtilities.getStringValue(dRow, "Member_Names"); double totalScore = AccessDatabaseUtilities.getDoubleValue(dRow, "Total_Score"); int teamNumber = count; DataRow newRow = table.NewRow(); newRow["Team_Number"] = keepOriginalTeamNumbersCheckbox.Checked?originalTeamNumber:teamNumber; newRow["Team_Name"] = teamName; newRow["Member_Names"] = memberNames; newRow["Carryover"] = carryoverTotalCheckbox.Checked ? totalScore : 0; newRow["Original_Team_Number"] = originalTeamNumber; newRow["Original_Event_Name"] = eventName; newRow["Total_Score"] = 0; newRow["Tiebreaker_Score"] = 0; newRow["Rank"] = 1; table.Rows.Add(newRow); newRow = computedScoresTable.NewRow(); newRow["Team_Number"] = keepOriginalTeamNumbersCheckbox.Checked ? originalTeamNumber : teamNumber; computedScoresTable.Rows.Add(newRow); count++; } } DataTable scoresTable = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.EventScores); int numberOfMatches = (numberOfTeams / 2) + numberOfTeams % 2; for (int i = 1; i <= numberOfRounds; ++i) { for (int j = 1; j <= numberOfMatches; ++j) { DataRow dRow = scoresTable.NewRow(); dRow["Table_Number"] = j; dRow["Round_Number"] = i; scoresTable.Rows.Add(dRow); } } } AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.EventNames); AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.EventScores); AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.EventComputedScores); }
private static void populateScoresTable() { DataTable table = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.EventScores); DataTable existingTable = m_dataSet.Tables["Scores"]; foreach (DataRow existingRow in existingTable.Rows) { DataRow dRow = table.NewRow(); dRow["Round_Number"] = AccessDatabaseUtilities.getIntValue(existingRow, "Round Number"); dRow["Table_Number"] = AccessDatabaseUtilities.getIntValue(existingRow, "Table Number"); dRow["Team_1_Number"] = AccessDatabaseUtilities.getIntValue(existingRow, "Team 1 Number"); dRow["Team_2_Number"] = AccessDatabaseUtilities.getIntValue(existingRow, "Team 2 Number"); dRow["Team_1_VPs"] = AccessDatabaseUtilities.getDoubleValue(existingRow, "Team 1 VPs"); dRow["Team_2_VPs"] = AccessDatabaseUtilities.getDoubleValue(existingRow, "Team 2 VPs"); dRow["Team_1_VP_Adjustment"] = -1 * AccessDatabaseUtilities.getDoubleValue(existingRow, "Team 1 Adjustment"); dRow["Team_2_VP_Adjustment"] = -1 * AccessDatabaseUtilities.getDoubleValue(existingRow, "Team 2 Adjustment"); table.Rows.Add(dRow); } AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.EventScores); }
private double getDoubleValue(DataRow dRow, string columnName) { return(AccessDatabaseUtilities.getDoubleValue(dRow, columnName)); }
private DataRow findWinner(DataRow[] dRows) { return(AccessDatabaseUtilities.getDoubleValue(dRows[1], "Total") > AccessDatabaseUtilities.getDoubleValue(dRows[0], "Total") ? dRows[1] : dRows[0]); }