Exemple #1
0
        private void setUpMatches(int roundNumber)
        {
            DataTable table = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutScores + "_" + roundNumber);
            // Overwrite existing team numbers to avoid unique value errors
            int count = -1;

            foreach (DataRow dRow in table.Rows)
            {
                dRow["Team_Number"] = count--;
            }
            AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.KnockoutScores + "_" + roundNumber);
            DataTable previousTable = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutScores + "_" + (roundNumber + 1));
            int       matchNumber   = 1;

            foreach (DataRow dRow in table.Rows)
            {
                DataRow[] dRows     = previousTable.Select("Match_Number = " + matchNumber);
                DataRow   winnerRow = findWinner(dRows);
                dRow["Team_Number"] = AccessDatabaseUtilities.getIntValue(winnerRow, "Team_Number");
                dRow["Team_Name"]   = AccessDatabaseUtilities.getStringValue(winnerRow, "Team_Name");
                matchNumber++;
            }
            AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.KnockoutScores + "_" + roundNumber);
            knockoutRoundsCombobox.SelectedIndex = roundNumber - 1;
        }
        public void updateSessions()
        {
            DataTable table = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutSessions);

            foreach (DataRow dRow in table.Rows)
            {
                List <string> removeColumns    = null;
                int           roundNumber      = (int)dRow["Round_Number"];
                int           numberOfSessions = (int)dRow["Number_Of_Sessions"];
                if (numberOfSessions > m_oldNumberOfSessions[roundNumber])
                {
                    List <DatabaseField> fields = new List <DatabaseField>();
                    for (int i = m_oldNumberOfSessions[roundNumber] + 1; i <= numberOfSessions; ++i)
                    {
                        fields.Add(new DatabaseField("Session_" + i + "_Score", "NUMBER"));
                    }
                    AccessDatabaseUtilities.addColumn(m_databaseFileName, Constants.TableName.KnockoutScores + "_" + roundNumber, fields);
                }
                else if (m_oldNumberOfSessions[roundNumber] > numberOfSessions)
                {
                    removeColumns = new List <string>();
                    List <DatabaseField> fields = new List <DatabaseField>();
                    for (int i = numberOfSessions + 1; i <= m_oldNumberOfSessions[roundNumber]; ++i)
                    {
                        fields.Add(new DatabaseField("Session_" + i + "_Score", "NUMBER"));
                        removeColumns.Add("Session_" + i + "_Score");
                    }
                    AccessDatabaseUtilities.dropColumn(m_databaseFileName, Constants.TableName.KnockoutScores + "_" + roundNumber, fields);
                }
                m_oldNumberOfSessions[roundNumber] = numberOfSessions;
                AccessDatabaseUtilities.loadDatabaseToTable(m_databaseFileName, Constants.TableName.KnockoutScores + "_" + roundNumber, "", removeColumns);
            }
            AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.KnockoutSessions);
        }
        private void populateKnockoutTables()
        {
            DataTable table = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutTeams);
            int       count = 0;

            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");
                        int     teamNumber         = count + 1;
                        DataRow newRow             = table.Rows[count];
                        newRow["Team_Number"]          = teamNumber;
                        newRow["Team_Name"]            = teamName;
                        newRow["Member_Names"]         = memberNames;
                        newRow["Original_Team_Number"] = originalTeamNumber;
                        newRow["Original_Event_Name"]  = eventName;
                        count++;
                    }
                }
            }
            AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.KnockoutTeams);
        }
Exemple #4
0
        private string getTeamMemberNames(int teamNumber)
        {
            DataTable table = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.EventNames);
            DataRow   dRow  = table.Rows.Find(teamNumber);

            return("" + dRow["Member_Names"]);
        }
Exemple #5
0
        public static bool hasWithdrawn(string databaseFileName, int teamNumber, int roundNumber)
        {
            DataTable table = AccessDatabaseUtilities.getDataTable(databaseFileName, Constants.TableName.EventNames);

            DataRow[] foundRows = table.Select("Team_Number=" + teamNumber + " AND NOT Withdraw_Round is null AND WithDraw_Round <= " + roundNumber, "");
            return(foundRows.Length > 0);
        }
Exemple #6
0
        private void knockoutScoresDataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView dgv              = sender as DataGridView;
            string       columnName       = dgv.Columns[e.ColumnIndex].Name;
            int          roundNumber      = knockoutRoundsCombobox.SelectedIndex + 1;
            DataTable    sessionsTable    = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutSessions);
            DataRow      dRow             = sessionsTable.Rows.Find(roundNumber);
            int          numberOfSessions = (int)dRow["Number_Of_Sessions"];

            if (columnName.Contains("Session") || columnName == "Carryover")
            {
                double total = 0;
                Object value = dgv.Rows[e.RowIndex].Cells["Carryover"].Value;
                total += (value == DBNull.Value) ? 0 : (double)value;
                for (int i = 1; i <= numberOfSessions; ++i)
                {
                    value  = dgv.Rows[e.RowIndex].Cells["Session_" + i + "_Score"].Value;
                    total += (value == DBNull.Value) ? 0 : (double)value;
                }
                dgv.Rows[e.RowIndex].Cells["Total"].Value = total;
            }
            else if (columnName == "Team_Number")
            {
                dgv.Rows[e.RowIndex].Cells["Team_Name"].Value = LocalUtilities.getTeamName(m_databaseFileName, Constants.TableName.KnockoutTeams, (int)dgv.Rows[e.RowIndex].Cells["Team_Number"].Value);
            }
        }
Exemple #7
0
        public static string getTeamName(string databaseFileName, string tableName, int teamNumber)
        {
            DataTable table = AccessDatabaseUtilities.getDataTable(databaseFileName, tableName);

            DataRow[] dRows = table.Select("Team_Number = " + teamNumber);
            return((dRows.Length > 0) ? (string)dRows[0]["Team_Name"] : "Unknown");
        }
Exemple #8
0
        public static int teamsLeft(string databaseFileName, int roundNumber)
        {
            DataTable table = AccessDatabaseUtilities.getDataTable(databaseFileName, Constants.TableName.EventNames);

            DataRow[] rows = table.Select("Withdraw_Round is null OR WithDraw_Round > " + roundNumber);
            return(rows.Length);
        }
Exemple #9
0
        private string getTeamLink(Object teamNumberObject, bool showNumber, bool showName)
        {
            string result = "";

            if (teamNumberObject == DBNull.Value)
            {
                return("-");
            }
            int       teamNumber = (int)teamNumberObject;
            DataTable table      = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutTeams);

            DataRow[] dRows = table.Select("Team_Number = " + teamNumber);
            Debug.Assert(dRows.Length == 1);
            DataRow dRow = dRows[0];
            string  originalEventName = AccessDatabaseUtilities.getStringValue(dRow, "Original_Event_Name");

            if (string.IsNullOrWhiteSpace(originalEventName))
            {
                result = "<span title='" + dRow["Member_Names"] + "' >" + (showNumber ? dRow["Team_Number"] + " " : "") + (showName ? dRow["Team_Name"] : "") + "</span>";
            }
            else
            {
                int originalTeamNumber = AccessDatabaseUtilities.getIntValue(dRow, "Original_Team_Number");
                //string webpagesRootDirectory = Path.Combine("..", "..", Constants.WebpagesFolderName, Utilities.makeIdentifier_(originalEventName));
                //string link = Path.Combine(webpagesRootDirectory, "teams", "team" + originalTeamNumber + "score.html");
                string webpagesRootDirectory = "../" + Utilities.makeIdentifier_(originalEventName);
                string link = webpagesRootDirectory + "/teams/team" + originalTeamNumber + "score.html";
                result = "<a href='" + link + "' title='" + dRow["Member_Names"] + "'>" + (showNumber ? dRow["Team_Number"] + " " : "") + (showName ? dRow["Team_Name"] : "") + "</a>";
            }
            return(result);
        }
        private static void populateNamesTable()
        {
            DataTable table = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.EventNames);
            DataTable computedScoresTable = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.EventComputedScores);
            DataTable existingTable       = m_dataSet.Tables["Names"];

            foreach (DataRow existingRow in existingTable.Rows)
            {
                DataRow dRow = table.NewRow();
                dRow["Team_Number"]  = AccessDatabaseUtilities.getIntValue(existingRow, "Number");
                dRow["Team_Name"]    = getStringValue(existingRow, "Team Name");
                dRow["Member_Names"] = getStringValue(existingRow, "Member 1 Name") + ", " +
                                       getStringValue(existingRow, "Member 2 Name") + ", " +
                                       getStringValue(existingRow, "Member 3 Name") + ", " +
                                       getStringValue(existingRow, "Member 4 Name") + ", " +
                                       getStringValue(existingRow, "Member 5 Name") + ", " +
                                       getStringValue(existingRow, "Member 6 Name");
                table.Rows.Add(dRow);
                dRow = computedScoresTable.NewRow();
                dRow["Team_Number"] = AccessDatabaseUtilities.getIntValue(existingRow, "Number");
                computedScoresTable.Rows.Add(dRow);
            }
            AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.EventNames);
            AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.EventComputedScores);
        }
Exemple #11
0
        private void writeKnockoutPage(string fileName)
        {
            DataTable table = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutSessions);

            DataRow[] dRows = table.Select("", "Round_Number ASC");
            if (dRows.Length < 1)
            {
                return;
            }
            StreamWriter sw = new StreamWriter(fileName);

            sw.WriteLine("<html><head></head><body>");
            string title          = "<h2>Knockout Scores</h2>";
            string headerTemplate = title + "<br/>[_commonPageHeader]";

            sw.WriteLine(applyTemplate_(headerTemplate, null));
            bool scoresAvailable = false;

            foreach (DataRow dRow in dRows)
            {
                string html = getKnockoutRoundTable(dRow);
                if (!string.IsNullOrWhiteSpace(html))
                {
                    scoresAvailable = true;
                    sw.Write(html + Environment.NewLine);
                    sw.Write("<hr/>" + Environment.NewLine);
                }
            }
            if (!scoresAvailable)
            {
                sw.WriteLine("<h1>No Scores Available Yet!</h1>");
            }
            sw.WriteLine("</body></html>");
            sw.Close();
        }
Exemple #12
0
        private void checkRoundCompletion(int roundNumber, int numberOfSessions)
        {
            DataTable     sessionsTable   = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutSessions);
            List <string> skipColumnNames = new List <string>();

            skipColumnNames.Add("Carryover");
            DataTable table = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutScores + "_" + roundNumber);

            if (Utilities.HasNull(table, skipColumnNames))
            {
                return;
            }
            roundNumber--;
            if (roundNumber < 1)
            {
                return;
            }
            table = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutScores + "_" + roundNumber);
            DataRow dRow = sessionsTable.Rows.Find(roundNumber);

            numberOfSessions = (int)dRow["Number_Of_Sessions"];
            for (int i = 1; i <= numberOfSessions; ++i)
            {
                if (!Utilities.AllNull(table, "Session_" + i + "_Score"))
                {
                    return;
                }
            }
            setUpMatches(roundNumber);
        }
Exemple #13
0
        private void knockoutRoundsCombobox_SelectedIndexChanged(object sender, EventArgs e)
        {
            DataTable table = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutScores + "_" + (knockoutRoundsCombobox.SelectedIndex + 1));
            DataView  dView = new DataView(table);

            dView.RowFilter = "";
            dView.Sort      = "Match_Number ASC";
            knockoutScoresDataGridView.DataSource = dView;
        }
Exemple #14
0
        private void saveKnockoutScoresButton_Click(object sender, EventArgs e)
        {
            int roundNumber = knockoutRoundsCombobox.SelectedIndex + 1;

            AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.KnockoutScores + "_" + roundNumber);
            DataTable sessionsTable    = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutSessions);
            DataRow   dRow             = sessionsTable.Rows.Find(roundNumber);
            int       numberOfSessions = (int)dRow["Number_Of_Sessions"];

            checkRoundCompletion(roundNumber, numberOfSessions);
        }
        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);
        }
Exemple #16
0
 private void selectCurrentKnockoutRound()
 {
     for (int i = m_knockoutSessions.NumberOfRounds; i >= 1; --i)
     {
         List <string> skipColumnNames = new List <string>();
         skipColumnNames.Add("Carryover");
         if (Utilities.HasNull(AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutScores + "_" + i), skipColumnNames))
         {
             knockoutRoundsCombobox.SelectedIndex = i - 1;
             return;
         }
     }
     knockoutRoundsCombobox.SelectedIndex = 0;
 }
Exemple #17
0
 private void initialize()
 {
     this.Text = NiniUtilities.getStringValue(Constants.getCurrentTourneyInformationFileName(), Constants.TourneyNameFieldName) + " : " + m_eventName;
     Utilities.SetDataGridViewProperties(this);
     m_knockoutSessions = new KnockoutSessions(eventSetupPropertyGrid, m_eventName, m_niniFileName, m_databaseFileName, true);
     knockoutSessionsDataGridView.DataSource = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutSessions);
     knockoutNamesDataGridView.DataSource    = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutTeams);
     populateKnockoutRounds();
     m_resultsPublishParameters = new ResultsPublishParameters(m_eventName, Constants.getResultsPublishParametersFileName(m_eventName), true);
     resultsPublishPropertyGrid.SelectedObject = m_resultsPublishParameters;
     if (string.IsNullOrWhiteSpace(m_resultsPublishParameters.ResultsWebsite))
     {
         m_resultsPublishParameters.ResultsWebsite = Constants.getEventResultsWebsite(m_eventName);
     }
 }
        public void update()
        {
            DataTable table      = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutSessions);
            DataTable teamsTable = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutTeams);

            if (numberOfRounds > oldNumberOfRounds)
            {
                for (int i = oldNumberOfRounds + 1; i <= numberOfRounds; ++i)
                {
                    DataRow dRow        = table.NewRow();
                    string  sessionName = (Constants.KnockoutSessionNames.Length >= i ? Constants.KnockoutSessionNames[i - 1] : "Round_of_" + Math.Pow(2, i));
                    dRow["Round_Number"]       = i;
                    dRow["Round_Name"]         = sessionName;
                    dRow["Number_Of_Sessions"] = 3;
                    table.Rows.Add(dRow);
                    createRoundScoresTable(i);
                }
                AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.KnockoutSessions);
                for (int i = oldNumberOfTeams + 1; i <= numberOfTeams; ++i)
                {
                    DataRow dRow        = teamsTable.NewRow();
                    string  sessionName = (Constants.KnockoutSessionNames.Length >= i ? Constants.KnockoutSessionNames[i - 1] : "Round_of_" + Math.Pow(2, i));
                    dRow["Team_Number"] = i;
                    dRow["Team_Name"]   = "Team " + i;
                    teamsTable.Rows.Add(dRow);
                }
                AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.KnockoutTeams);
            }
            else if (numberOfRounds < oldNumberOfRounds)
            {
                for (int i = numberOfRounds + 1; i <= oldNumberOfRounds; ++i)
                {
                    table.Rows.Find(i).Delete();
                    AccessDatabaseUtilities.dropTable(m_databaseFileName, Constants.TableName.KnockoutScores + "_" + i);
                    m_oldNumberOfSessions.Remove(i);
                }
                AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.KnockoutSessions);
                for (int i = numberOfTeams + 1; i <= oldNumberOfTeams; ++i)
                {
                    teamsTable.Rows.Find(i).Delete();
                }
                AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.KnockoutTeams);
            }
            oldNumberOfRounds = numberOfRounds;
            oldNumberOfTeams  = numberOfTeams;
        }
        private void createRoundScoresTable(int roundNumber)
        {
            List <DatabaseField> fields = new List <DatabaseField>();

            fields.Add(new DatabaseField("Match_Number", "INTEGER"));
            fields.Add(new DatabaseField("Team_Number", "INTEGER"));
            fields.Add(new DatabaseField("Team_Name", "TEXT", 255));
            fields.Add(new DatabaseField("Carryover", "NUMBER"));
            fields.Add(new DatabaseField("Total", "NUMBER"));
            DataTable table            = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutSessions);
            DataRow   dRow             = table.Rows.Find(roundNumber);
            int       numberOfSessions = (int)dRow["Number_Of_Sessions"];

            m_oldNumberOfSessions[roundNumber] = numberOfSessions;
            for (int i = 1; i <= numberOfSessions; ++i)
            {
                fields.Add(new DatabaseField("Session_" + i + "_Score", "NUMBER"));
            }
            List <string> primaryKeys = new List <string>();

            primaryKeys.Add("Match_Number");
            primaryKeys.Add("Team_Number");
            DataTable scoresTable     = AccessDatabaseUtilities.createTable(m_databaseFileName, Constants.TableName.KnockoutScores + "_" + roundNumber, fields, primaryKeys);
            int       numberOfMatches = Convert.ToInt32(Math.Pow(2, roundNumber - 1));

            for (int i = 1; i <= numberOfMatches; ++i)
            {
                DataRow dScoresRow = scoresTable.NewRow();
                dScoresRow["Match_Number"] = i;
                int teamNumber = i;
                dScoresRow["Team_Number"] = i;
                dScoresRow["Team_Name"]   = LocalUtilities.getTeamName(m_databaseFileName, Constants.TableName.KnockoutTeams, i);
                scoresTable.Rows.Add(dScoresRow);
                dScoresRow = scoresTable.NewRow();
                dScoresRow["Match_Number"] = i;
                teamNumber = 2 * numberOfMatches - (i - 1);
                dScoresRow["Team_Number"] = teamNumber;
                dScoresRow["Team_Name"]   = LocalUtilities.getTeamName(m_databaseFileName, Constants.TableName.KnockoutTeams, teamNumber);
                scoresTable.Rows.Add(dScoresRow);
            }
            AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.KnockoutScores + "_" + roundNumber);
        }
        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);
        }
Exemple #21
0
        private string getKnockoutRoundTable(DataRow dRow)
        {
            string    html        = "";
            int       roundNumber = (int)dRow["Round_Number"];
            string    roundName   = (string)dRow["Round_Name"];
            DataTable table       = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutScores + "_" + roundNumber);

            Debug.Assert(table != null);
            if (Utilities.AllNull(table, "Total"))
            {
                return("");
            }
            int numberOfMatches  = (int)Math.Pow(2, roundNumber);
            int numberOfSessions = (int)dRow["Number_Of_Sessions"];

            html += (Utilities.makeTablePreamble_() + "<thead><tr>");
            ArrayList tableHeader = new ArrayList();
            ArrayList tableRow    = new ArrayList();

            tableHeader.Add(roundName);
            html       += (Utilities.makeTableHeader_(tableHeader) + "</tr></thead><tbody><tr>");
            html       += (Utilities.makeTablePreamble_() + "<thead><tr>");
            tableHeader = new ArrayList();
            tableHeader.Add("Match No.");
            tableHeader.Add("Team");
            tableHeader.Add("Carryover");
            for (int i = 1; i <= numberOfSessions; ++i)
            {
                tableHeader.Add("Session " + i);
            }
            tableHeader.Add("Total");
            html += (Utilities.makeTableHeader_(tableHeader) + "</tr></thead><tbody>");
            for (int i = 1; i <= numberOfMatches / 2; ++i)
            {
                DataRow[] foundRows = table.Select("Match_Number = " + i);
                Debug.Assert(foundRows.Length == 2);
                html += createMatchRows(foundRows, numberOfSessions, i, i != 1);
            }
            html += ("</tbody></table>");
            return(html);
        }
        private bool addEvent(string eventName, string eventType)
        {
            if (string.IsNullOrWhiteSpace(eventName))
            {
                MessageBox.Show("Event Name cannot be empty!", "Empty Event Name!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            DataTable table = AccessDatabaseUtilities.getDataTable(Constants.getCurrentTourneyEventsFileName(), Constants.TableName.TourneyEvents);
            DataRow   dRow  = table.Rows.Find(eventName);

            if (dRow != null)
            {
                MessageBox.Show("Another event with same name (" + eventName + ") already exists!" + Environment.NewLine + "Either delete the other event first or provide a different event name!", "Duplicate Event Name!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            dRow = table.NewRow();
            dRow["Event_Name"] = eventName;
            dRow["Event_Type"] = eventType;
            table.Rows.Add(dRow);
            AccessDatabaseUtilities.saveTableToDatabase(Constants.getCurrentTourneyEventsFileName(), Constants.TableName.TourneyEvents);
            return(true);
        }
        private void loadSwissLeagues()
        {
            Label label = new Label();

            label.Text = "Events to Select Teams from : ";
            eventsListPanel.Controls.Clear();
            eventsListPanel.Controls.Add(label);
            DataTable table = AccessDatabaseUtilities.getDataTable(Constants.getCurrentTourneyEventsFileName(), Constants.TableName.TourneyEvents);

            foreach (DataRow dRow in table.Rows)
            {
                string eventType = AccessDatabaseUtilities.getStringValue(dRow, "Event_Type");
                string eventName = AccessDatabaseUtilities.getStringValue(dRow, "Event_Name");
                if (eventType == Constants.EventType.TeamsSwissLeague)
                {
                    CheckBox cb = new CheckBox();
                    cb.Text     = eventName;
                    cb.AutoSize = true;
                    cb.Click   += new EventHandler(eventCheckBoxes_Click);
                    eventsListPanel.Controls.Add(cb);
                }
            }
        }
        public void initializeMatches()
        {
            DataTable teamsTable = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutTeams);

            for (int i = 1; i <= numberOfRounds; ++i)
            {
                DataTable table           = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutScores + "_" + i);
                int       totalTeams      = Convert.ToInt32(Math.Pow(2, i));
                int       numberOfMatches = totalTeams / 2;
                for (int j = 1; j <= numberOfMatches; ++j)
                {
                    DataRow   team1Row = teamsTable.Rows[j - 1];
                    DataRow   team2Row = teamsTable.Rows[totalTeams - j];
                    DataRow[] dRows    = table.Select("Match_Number = " + j);
                    Debug.Assert(dRows.Length == 2);
                    dRows[0]["Team_Number"] = AccessDatabaseUtilities.getIntValue(team1Row, "Team_Number");
                    dRows[0]["Team_Name"]   = AccessDatabaseUtilities.getStringValue(team1Row, "Team_Name");
                    dRows[1]["Team_Number"] = AccessDatabaseUtilities.getIntValue(team2Row, "Team_Number");
                    dRows[1]["Team_Name"]   = AccessDatabaseUtilities.getStringValue(team2Row, "Team_Name");
                }
                AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.KnockoutScores + "_" + i);
            }
        }
 private DataTable getTable(string tableName)
 {
     return(AccessDatabaseUtilities.getDataTable(m_databaseFileName, tableName));
 }