diff --git a/TrackerLibrary/DataAccess/IDataConnection.cs b/TrackerLibrary/DataAccess/IDataConnection.cs index e6d2b2e..c7a1b9a 100644 --- a/TrackerLibrary/DataAccess/IDataConnection.cs +++ b/TrackerLibrary/DataAccess/IDataConnection.cs @@ -11,6 +11,7 @@ namespace TrackerLibrary.DataAccess PersonModel CreatePerson(PersonModel model); TeamModel CreateTeam(TeamModel model); void CreateTournament(TournamentModel model); + void UpdateMatchup(MatchupModel model); List GetTeam_All(); List GetPerson_All(); List GetTournament_All(); diff --git a/TrackerLibrary/DataAccess/SqlConnector.cs b/TrackerLibrary/DataAccess/SqlConnector.cs index 7ddb246..e82f81a 100644 --- a/TrackerLibrary/DataAccess/SqlConnector.cs +++ b/TrackerLibrary/DataAccess/SqlConnector.cs @@ -296,5 +296,10 @@ namespace TrackerLibrary.DataAccess } return output; } + + public void UpdateMatchup(MatchupModel model) + { + + } } } diff --git a/TrackerLibrary/DataAccess/TextConnector.cs b/TrackerLibrary/DataAccess/TextConnector.cs index 670b326..03737dc 100644 --- a/TrackerLibrary/DataAccess/TextConnector.cs +++ b/TrackerLibrary/DataAccess/TextConnector.cs @@ -131,5 +131,10 @@ namespace TrackerLibrary.DataAccess .LoadFile() .ConvertToTournamentModels(TeamFile, PeopleFile, PrizesFile); } + + public void UpdateMatchup(MatchupModel model) + { + throw new NotImplementedException(); + } } } diff --git a/TrackerLibrary/TrackerLibrary.csproj b/TrackerLibrary/TrackerLibrary.csproj index 10b101c..e01eaf1 100644 --- a/TrackerLibrary/TrackerLibrary.csproj +++ b/TrackerLibrary/TrackerLibrary.csproj @@ -1,5 +1,6 @@  + Debug @@ -12,6 +13,8 @@ v4.7.2 512 true + + true @@ -63,5 +66,17 @@ + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file diff --git a/TrackerLibrary/packages.config b/TrackerLibrary/packages.config index e38523d..e1845fe 100644 --- a/TrackerLibrary/packages.config +++ b/TrackerLibrary/packages.config @@ -1,4 +1,5 @@  + \ No newline at end of file diff --git a/TrackerUI/App.config b/TrackerUI/App.config index fa905af..3644139 100644 --- a/TrackerUI/App.config +++ b/TrackerUI/App.config @@ -4,8 +4,8 @@ - - + + diff --git a/TrackerUI/TournamentViewerForm.Designer.cs b/TrackerUI/TournamentViewerForm.Designer.cs index 141a935..95a9995 100644 --- a/TrackerUI/TournamentViewerForm.Designer.cs +++ b/TrackerUI/TournamentViewerForm.Designer.cs @@ -37,12 +37,12 @@ this.MatchUpListBox = new System.Windows.Forms.ListBox(); this.teamOneName = new System.Windows.Forms.Label(); this.teamOneScoreLabel = new System.Windows.Forms.Label(); - this.teamOneScoeValue = new System.Windows.Forms.TextBox(); - this.teamTwoScoeValue = new System.Windows.Forms.TextBox(); + this.teamOneScoreValue = new System.Windows.Forms.TextBox(); + this.teamTwoScoreValue = new System.Windows.Forms.TextBox(); this.teamTwoScoreLabel = new System.Windows.Forms.Label(); this.teamTwoName = new System.Windows.Forms.Label(); this.versusLabel = new System.Windows.Forms.Label(); - this.button1 = new System.Windows.Forms.Button(); + this.scoreButton = new System.Windows.Forms.Button(); this.SuspendLayout(); // // headerLabel @@ -99,6 +99,7 @@ this.unplayedOnlyCheckbox.TabIndex = 4; this.unplayedOnlyCheckbox.Text = "Unplayed Only"; this.unplayedOnlyCheckbox.UseVisualStyleBackColor = true; + this.unplayedOnlyCheckbox.CheckedChanged += new System.EventHandler(this.unplayedOnlyCheckbox_CheckedChanged); // // MatchUpListBox // @@ -133,19 +134,19 @@ this.teamOneScoreLabel.TabIndex = 7; this.teamOneScoreLabel.Text = "Score"; // - // teamOneScoeValue + // teamOneScoreValue // - this.teamOneScoeValue.Location = new System.Drawing.Point(498, 250); - this.teamOneScoeValue.Name = "teamOneScoeValue"; - this.teamOneScoeValue.Size = new System.Drawing.Size(100, 35); - this.teamOneScoeValue.TabIndex = 8; + this.teamOneScoreValue.Location = new System.Drawing.Point(498, 250); + this.teamOneScoreValue.Name = "teamOneScoreValue"; + this.teamOneScoreValue.Size = new System.Drawing.Size(100, 35); + this.teamOneScoreValue.TabIndex = 8; // - // teamTwoScoeValue + // teamTwoScoreValue // - this.teamTwoScoeValue.Location = new System.Drawing.Point(498, 389); - this.teamTwoScoeValue.Name = "teamTwoScoeValue"; - this.teamTwoScoeValue.Size = new System.Drawing.Size(100, 35); - this.teamTwoScoeValue.TabIndex = 11; + this.teamTwoScoreValue.Location = new System.Drawing.Point(498, 389); + this.teamTwoScoreValue.Name = "teamTwoScoreValue"; + this.teamTwoScoreValue.Size = new System.Drawing.Size(100, 35); + this.teamTwoScoreValue.TabIndex = 11; // // teamTwoScoreLabel // @@ -180,19 +181,20 @@ this.versusLabel.TabIndex = 12; this.versusLabel.Text = "- VS -"; // - // button1 + // scoreButton // - this.button1.FlatAppearance.BorderColor = System.Drawing.Color.Silver; - this.button1.FlatAppearance.MouseDownBackColor = System.Drawing.Color.DimGray; - this.button1.FlatAppearance.MouseOverBackColor = System.Drawing.Color.WhiteSmoke; - this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.button1.ForeColor = System.Drawing.Color.DodgerBlue; - this.button1.Location = new System.Drawing.Point(616, 286); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(125, 58); - this.button1.TabIndex = 13; - this.button1.Text = "Score"; - this.button1.UseVisualStyleBackColor = true; + this.scoreButton.FlatAppearance.BorderColor = System.Drawing.Color.Silver; + this.scoreButton.FlatAppearance.MouseDownBackColor = System.Drawing.Color.DimGray; + this.scoreButton.FlatAppearance.MouseOverBackColor = System.Drawing.Color.WhiteSmoke; + this.scoreButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.scoreButton.ForeColor = System.Drawing.Color.DodgerBlue; + this.scoreButton.Location = new System.Drawing.Point(616, 286); + this.scoreButton.Name = "scoreButton"; + this.scoreButton.Size = new System.Drawing.Size(125, 58); + this.scoreButton.TabIndex = 13; + this.scoreButton.Text = "Score"; + this.scoreButton.UseVisualStyleBackColor = true; + this.scoreButton.Click += new System.EventHandler(this.scoreButton_Click); // // TournamentViewerForm // @@ -200,12 +202,12 @@ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.White; this.ClientSize = new System.Drawing.Size(763, 487); - this.Controls.Add(this.button1); + this.Controls.Add(this.scoreButton); this.Controls.Add(this.versusLabel); - this.Controls.Add(this.teamTwoScoeValue); + this.Controls.Add(this.teamTwoScoreValue); this.Controls.Add(this.teamTwoScoreLabel); this.Controls.Add(this.teamTwoName); - this.Controls.Add(this.teamOneScoeValue); + this.Controls.Add(this.teamOneScoreValue); this.Controls.Add(this.teamOneScoreLabel); this.Controls.Add(this.teamOneName); this.Controls.Add(this.MatchUpListBox); @@ -234,12 +236,12 @@ private System.Windows.Forms.ListBox MatchUpListBox; private System.Windows.Forms.Label teamOneName; private System.Windows.Forms.Label teamOneScoreLabel; - private System.Windows.Forms.TextBox teamOneScoeValue; - private System.Windows.Forms.TextBox teamTwoScoeValue; + private System.Windows.Forms.TextBox teamOneScoreValue; + private System.Windows.Forms.TextBox teamTwoScoreValue; private System.Windows.Forms.Label teamTwoScoreLabel; private System.Windows.Forms.Label teamTwoName; private System.Windows.Forms.Label versusLabel; - private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button scoreButton; } } diff --git a/TrackerUI/TournamentViewerForm.cs b/TrackerUI/TournamentViewerForm.cs index cede55a..610be12 100644 --- a/TrackerUI/TournamentViewerForm.cs +++ b/TrackerUI/TournamentViewerForm.cs @@ -59,7 +59,7 @@ namespace TrackerUI private void roundDropDown_SelectedIndexChanged(object sender, EventArgs e) { - LoadMatchups( (int)roundDropDown.SelectedItem); + LoadMatchups((int)roundDropDown.SelectedItem); } @@ -73,13 +73,34 @@ namespace TrackerUI selectedMatchups.Clear(); foreach (MatchupModel mm in matchups) { - selectedMatchups.Add(mm); + if (mm.Winner == null || !unplayedOnlyCheckbox.Checked) + { + selectedMatchups.Add(mm); + } } loading = false; } } - LoadMatchup(selectedMatchups.First()); + if (selectedMatchups.Count > 0) + { + LoadMatchup(selectedMatchups.First()); + } + + DisplayMatchupInfo(); + } + + private void DisplayMatchupInfo() + { + bool isVisible = (selectedMatchups.Count > 0); + teamOneName.Visible = isVisible; + teamOneScoreLabel.Visible = isVisible; + teamOneScoreValue.Visible = isVisible; + teamTwoName.Visible = isVisible; + teamTwoScoreLabel.Visible = isVisible; + teamTwoScoreValue.Visible = isVisible; + versusLabel.Visible = isVisible; + scoreButton.Visible = isVisible; } private void LoadMatchup(MatchupModel m) @@ -93,15 +114,15 @@ namespace TrackerUI if (m.Entries[0].TeamCompeting != null) { teamOneName.Text = m.Entries[0].TeamCompeting.TeamName; - teamOneScoeValue.Text = m.Entries[0].Score.ToString(); + teamOneScoreValue.Text = m.Entries[0].Score.ToString(); teamTwoName.Text = ""; - teamTwoScoeValue.Text = "0"; + teamTwoScoreValue.Text = "0"; } else { teamOneName.Text = "Not Yet Set"; - teamOneScoeValue.Text = ""; + teamOneScoreValue.Text = ""; } } @@ -110,21 +131,90 @@ namespace TrackerUI if (m.Entries[1].TeamCompeting != null) { teamTwoName.Text = m.Entries[1].TeamCompeting.TeamName; - teamTwoScoeValue.Text = m.Entries[1].Score.ToString(); + teamTwoScoreValue.Text = m.Entries[1].Score.ToString(); } else { teamTwoName.Text = "Not Yet Set"; - teamTwoScoeValue.Text = ""; + teamTwoScoreValue.Text = ""; } } } + } } - } private void MatchUpListBox_SelectedIndexChanged(object sender, EventArgs e) { LoadMatchup((MatchupModel)MatchUpListBox.SelectedItem); } + + private void unplayedOnlyCheckbox_CheckedChanged(object sender, EventArgs e) + { + LoadMatchups((int)roundDropDown.SelectedItem); + } + + + private void scoreButton_Click(object sender, EventArgs e) + { + MatchupModel m = (MatchupModel)MatchUpListBox.SelectedItem; + double teamOneScore = 0; + double teamTwoScore = 0; + + for (int i = 0; i < m.Entries.Count; i++) + { + if (i == 0) + { + if (m.Entries[0].TeamCompeting != null) + { + var scoreValid = double.TryParse(teamOneScoreValue.Text, out teamOneScore); + if (scoreValid) + { + m.Entries[0].Score = teamOneScore; + } + else + { + MessageBox.Show("Please enter a valid score for team 1."); + return; + } + } + } + + if (i == 1) + { + if (m.Entries[1].TeamCompeting != null) + { + var scoreValid = double.TryParse(teamTwoScoreValue.Text, out teamTwoScore); + if (scoreValid) + { + m.Entries[1].Score = teamTwoScore; + } + else + { + MessageBox.Show("Please enter a valid score for team 2."); + return; + } + } + + } + } + + if (teamOneScore > teamTwoScore) + { + // Team one winns + m.Winner = m.Entries[0].TeamCompeting; + } + else + if (teamTwoScore > teamOneScore) + { + // Team one winns + m.Winner = m.Entries[1].TeamCompeting; + } + else + { + MessageBox.Show("I dont handle tie games."); + } + + LoadMatchups((int)roundDropDown.SelectedItem); + } } }