TournamentViewer is working but no save yet

Interface cganged
This commit is contained in:
2020-04-13 17:30:54 +02:00
parent 52eea1a7f2
commit ac1fa4cfaa
8 changed files with 161 additions and 42 deletions

View File

@ -11,6 +11,7 @@ namespace TrackerLibrary.DataAccess
PersonModel CreatePerson(PersonModel model); PersonModel CreatePerson(PersonModel model);
TeamModel CreateTeam(TeamModel model); TeamModel CreateTeam(TeamModel model);
void CreateTournament(TournamentModel model); void CreateTournament(TournamentModel model);
void UpdateMatchup(MatchupModel model);
List<TeamModel> GetTeam_All(); List<TeamModel> GetTeam_All();
List<PersonModel> GetPerson_All(); List<PersonModel> GetPerson_All();
List<TournamentModel> GetTournament_All(); List<TournamentModel> GetTournament_All();

View File

@ -296,5 +296,10 @@ namespace TrackerLibrary.DataAccess
} }
return output; return output;
} }
public void UpdateMatchup(MatchupModel model)
{
}
} }
} }

View File

@ -131,5 +131,10 @@ namespace TrackerLibrary.DataAccess
.LoadFile() .LoadFile()
.ConvertToTournamentModels(TeamFile, PeopleFile, PrizesFile); .ConvertToTournamentModels(TeamFile, PeopleFile, PrizesFile);
} }
public void UpdateMatchup(MatchupModel model)
{
throw new NotImplementedException();
}
} }
} }

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.CodeAnalysis.Analyzers.3.0.0\build\Microsoft.CodeAnalysis.Analyzers.props" Condition="Exists('..\packages\Microsoft.CodeAnalysis.Analyzers.3.0.0\build\Microsoft.CodeAnalysis.Analyzers.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -12,6 +13,8 @@
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -63,5 +66,17 @@
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.Analyzers.3.0.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.Analyzers.3.0.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>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}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.Analyzers.3.0.0\build\Microsoft.CodeAnalysis.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeAnalysis.Analyzers.3.0.0\build\Microsoft.CodeAnalysis.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.Analyzers.3.0.0\build\Microsoft.CodeAnalysis.Analyzers.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeAnalysis.Analyzers.3.0.0\build\Microsoft.CodeAnalysis.Analyzers.targets'))" />
</Target>
<Import Project="..\packages\Microsoft.CodeAnalysis.Analyzers.3.0.0\build\Microsoft.CodeAnalysis.Analyzers.targets" Condition="Exists('..\packages\Microsoft.CodeAnalysis.Analyzers.3.0.0\build\Microsoft.CodeAnalysis.Analyzers.targets')" />
</Project> </Project>

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Dapper" version="2.0.30" targetFramework="net472" /> <package id="Dapper" version="2.0.30" targetFramework="net472" />
<package id="Microsoft.CodeAnalysis.Analyzers" version="3.0.0" targetFramework="net472" developmentDependency="true" />
</packages> </packages>

View File

@ -4,8 +4,8 @@
<add key="filePath" value="D:\data\TournamentTracker"/> <add key="filePath" value="D:\data\TournamentTracker"/>
</appSettings> </appSettings>
<connectionStrings> <connectionStrings>
<!--<add name="Tournaments" connectionString="Server=TOMMYASUS\SQLEXPR2017;Database=Tournaments;Trusted_Connection=True;" providerName="System.Data.SqlClient"/>--> <add name="Tournaments" connectionString="Server=TOMMYASUS\SQLEXPR2017;Database=Tournaments;Trusted_Connection=True;" providerName="System.Data.SqlClient"/>
<add name="Tournaments" connectionString="Server=.\SQLEXPR2017;Database=Tournaments;Trusted_Connection=True;" providerName="System.Data.SqlClient"/> <!--<add name="Tournaments" connectionString="Server=.\SQLEXPR2017;Database=Tournaments;Trusted_Connection=True;" providerName="System.Data.SqlClient"/>-->
<!--Data Source=TOMMYASUS\SQLEXPR2017;Initial Catalog=Tournaments;Integrated Security=True--> <!--Data Source=TOMMYASUS\SQLEXPR2017;Initial Catalog=Tournaments;Integrated Security=True-->
</connectionStrings> </connectionStrings>
<startup> <startup>

View File

@ -37,12 +37,12 @@
this.MatchUpListBox = new System.Windows.Forms.ListBox(); this.MatchUpListBox = new System.Windows.Forms.ListBox();
this.teamOneName = new System.Windows.Forms.Label(); this.teamOneName = new System.Windows.Forms.Label();
this.teamOneScoreLabel = new System.Windows.Forms.Label(); this.teamOneScoreLabel = new System.Windows.Forms.Label();
this.teamOneScoeValue = new System.Windows.Forms.TextBox(); this.teamOneScoreValue = new System.Windows.Forms.TextBox();
this.teamTwoScoeValue = new System.Windows.Forms.TextBox(); this.teamTwoScoreValue = new System.Windows.Forms.TextBox();
this.teamTwoScoreLabel = new System.Windows.Forms.Label(); this.teamTwoScoreLabel = new System.Windows.Forms.Label();
this.teamTwoName = new System.Windows.Forms.Label(); this.teamTwoName = new System.Windows.Forms.Label();
this.versusLabel = 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(); this.SuspendLayout();
// //
// headerLabel // headerLabel
@ -99,6 +99,7 @@
this.unplayedOnlyCheckbox.TabIndex = 4; this.unplayedOnlyCheckbox.TabIndex = 4;
this.unplayedOnlyCheckbox.Text = "Unplayed Only"; this.unplayedOnlyCheckbox.Text = "Unplayed Only";
this.unplayedOnlyCheckbox.UseVisualStyleBackColor = true; this.unplayedOnlyCheckbox.UseVisualStyleBackColor = true;
this.unplayedOnlyCheckbox.CheckedChanged += new System.EventHandler(this.unplayedOnlyCheckbox_CheckedChanged);
// //
// MatchUpListBox // MatchUpListBox
// //
@ -133,19 +134,19 @@
this.teamOneScoreLabel.TabIndex = 7; this.teamOneScoreLabel.TabIndex = 7;
this.teamOneScoreLabel.Text = "Score"; this.teamOneScoreLabel.Text = "Score";
// //
// teamOneScoeValue // teamOneScoreValue
// //
this.teamOneScoeValue.Location = new System.Drawing.Point(498, 250); this.teamOneScoreValue.Location = new System.Drawing.Point(498, 250);
this.teamOneScoeValue.Name = "teamOneScoeValue"; this.teamOneScoreValue.Name = "teamOneScoreValue";
this.teamOneScoeValue.Size = new System.Drawing.Size(100, 35); this.teamOneScoreValue.Size = new System.Drawing.Size(100, 35);
this.teamOneScoeValue.TabIndex = 8; this.teamOneScoreValue.TabIndex = 8;
// //
// teamTwoScoeValue // teamTwoScoreValue
// //
this.teamTwoScoeValue.Location = new System.Drawing.Point(498, 389); this.teamTwoScoreValue.Location = new System.Drawing.Point(498, 389);
this.teamTwoScoeValue.Name = "teamTwoScoeValue"; this.teamTwoScoreValue.Name = "teamTwoScoreValue";
this.teamTwoScoeValue.Size = new System.Drawing.Size(100, 35); this.teamTwoScoreValue.Size = new System.Drawing.Size(100, 35);
this.teamTwoScoeValue.TabIndex = 11; this.teamTwoScoreValue.TabIndex = 11;
// //
// teamTwoScoreLabel // teamTwoScoreLabel
// //
@ -180,19 +181,20 @@
this.versusLabel.TabIndex = 12; this.versusLabel.TabIndex = 12;
this.versusLabel.Text = "- VS -"; this.versusLabel.Text = "- VS -";
// //
// button1 // scoreButton
// //
this.button1.FlatAppearance.BorderColor = System.Drawing.Color.Silver; this.scoreButton.FlatAppearance.BorderColor = System.Drawing.Color.Silver;
this.button1.FlatAppearance.MouseDownBackColor = System.Drawing.Color.DimGray; this.scoreButton.FlatAppearance.MouseDownBackColor = System.Drawing.Color.DimGray;
this.button1.FlatAppearance.MouseOverBackColor = System.Drawing.Color.WhiteSmoke; this.scoreButton.FlatAppearance.MouseOverBackColor = System.Drawing.Color.WhiteSmoke;
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.scoreButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button1.ForeColor = System.Drawing.Color.DodgerBlue; this.scoreButton.ForeColor = System.Drawing.Color.DodgerBlue;
this.button1.Location = new System.Drawing.Point(616, 286); this.scoreButton.Location = new System.Drawing.Point(616, 286);
this.button1.Name = "button1"; this.scoreButton.Name = "scoreButton";
this.button1.Size = new System.Drawing.Size(125, 58); this.scoreButton.Size = new System.Drawing.Size(125, 58);
this.button1.TabIndex = 13; this.scoreButton.TabIndex = 13;
this.button1.Text = "Score"; this.scoreButton.Text = "Score";
this.button1.UseVisualStyleBackColor = true; this.scoreButton.UseVisualStyleBackColor = true;
this.scoreButton.Click += new System.EventHandler(this.scoreButton_Click);
// //
// TournamentViewerForm // TournamentViewerForm
// //
@ -200,12 +202,12 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White; this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(763, 487); 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.versusLabel);
this.Controls.Add(this.teamTwoScoeValue); this.Controls.Add(this.teamTwoScoreValue);
this.Controls.Add(this.teamTwoScoreLabel); this.Controls.Add(this.teamTwoScoreLabel);
this.Controls.Add(this.teamTwoName); this.Controls.Add(this.teamTwoName);
this.Controls.Add(this.teamOneScoeValue); this.Controls.Add(this.teamOneScoreValue);
this.Controls.Add(this.teamOneScoreLabel); this.Controls.Add(this.teamOneScoreLabel);
this.Controls.Add(this.teamOneName); this.Controls.Add(this.teamOneName);
this.Controls.Add(this.MatchUpListBox); this.Controls.Add(this.MatchUpListBox);
@ -234,12 +236,12 @@
private System.Windows.Forms.ListBox MatchUpListBox; private System.Windows.Forms.ListBox MatchUpListBox;
private System.Windows.Forms.Label teamOneName; private System.Windows.Forms.Label teamOneName;
private System.Windows.Forms.Label teamOneScoreLabel; private System.Windows.Forms.Label teamOneScoreLabel;
private System.Windows.Forms.TextBox teamOneScoeValue; private System.Windows.Forms.TextBox teamOneScoreValue;
private System.Windows.Forms.TextBox teamTwoScoeValue; private System.Windows.Forms.TextBox teamTwoScoreValue;
private System.Windows.Forms.Label teamTwoScoreLabel; private System.Windows.Forms.Label teamTwoScoreLabel;
private System.Windows.Forms.Label teamTwoName; private System.Windows.Forms.Label teamTwoName;
private System.Windows.Forms.Label versusLabel; private System.Windows.Forms.Label versusLabel;
private System.Windows.Forms.Button button1; private System.Windows.Forms.Button scoreButton;
} }
} }

View File

@ -59,7 +59,7 @@ namespace TrackerUI
private void roundDropDown_SelectedIndexChanged(object sender, EventArgs e) private void roundDropDown_SelectedIndexChanged(object sender, EventArgs e)
{ {
LoadMatchups( (int)roundDropDown.SelectedItem); LoadMatchups((int)roundDropDown.SelectedItem);
} }
@ -72,16 +72,37 @@ namespace TrackerUI
loading = true; loading = true;
selectedMatchups.Clear(); selectedMatchups.Clear();
foreach (MatchupModel mm in matchups) foreach (MatchupModel mm in matchups)
{
if (mm.Winner == null || !unplayedOnlyCheckbox.Checked)
{ {
selectedMatchups.Add(mm); selectedMatchups.Add(mm);
} }
}
loading = false; loading = false;
} }
} }
if (selectedMatchups.Count > 0)
{
LoadMatchup(selectedMatchups.First()); 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) private void LoadMatchup(MatchupModel m)
{ {
if (!loading) if (!loading)
@ -93,15 +114,15 @@ namespace TrackerUI
if (m.Entries[0].TeamCompeting != null) if (m.Entries[0].TeamCompeting != null)
{ {
teamOneName.Text = m.Entries[0].TeamCompeting.TeamName; teamOneName.Text = m.Entries[0].TeamCompeting.TeamName;
teamOneScoeValue.Text = m.Entries[0].Score.ToString(); teamOneScoreValue.Text = m.Entries[0].Score.ToString();
teamTwoName.Text = "<bye>"; teamTwoName.Text = "<bye>";
teamTwoScoeValue.Text = "0"; teamTwoScoreValue.Text = "0";
} }
else else
{ {
teamOneName.Text = "Not Yet Set"; teamOneName.Text = "Not Yet Set";
teamOneScoeValue.Text = ""; teamOneScoreValue.Text = "";
} }
} }
@ -110,12 +131,12 @@ namespace TrackerUI
if (m.Entries[1].TeamCompeting != null) if (m.Entries[1].TeamCompeting != null)
{ {
teamTwoName.Text = m.Entries[1].TeamCompeting.TeamName; teamTwoName.Text = m.Entries[1].TeamCompeting.TeamName;
teamTwoScoeValue.Text = m.Entries[1].Score.ToString(); teamTwoScoreValue.Text = m.Entries[1].Score.ToString();
} }
else else
{ {
teamTwoName.Text = "Not Yet Set"; teamTwoName.Text = "Not Yet Set";
teamTwoScoeValue.Text = ""; teamTwoScoreValue.Text = "";
} }
} }
} }
@ -126,5 +147,74 @@ namespace TrackerUI
{ {
LoadMatchup((MatchupModel)MatchUpListBox.SelectedItem); 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);
}
} }
} }