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);
TeamModel CreateTeam(TeamModel model);
void CreateTournament(TournamentModel model);
void UpdateMatchup(MatchupModel model);
List<TeamModel> GetTeam_All();
List<PersonModel> GetPerson_All();
List<TournamentModel> GetTournament_All();

View File

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

View File

@ -131,5 +131,10 @@ namespace TrackerLibrary.DataAccess
.LoadFile()
.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"?>
<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')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -12,6 +13,8 @@
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -63,5 +66,17 @@
<ItemGroup>
<None Include="packages.config" />
</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" />
<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>

View File

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

View File

@ -4,8 +4,8 @@
<add key="filePath" value="D:\data\TournamentTracker"/>
</appSettings>
<connectionStrings>
<!--<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=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"/>-->
<!--Data Source=TOMMYASUS\SQLEXPR2017;Initial Catalog=Tournaments;Integrated Security=True-->
</connectionStrings>
<startup>

View File

@ -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;
}
}

View File

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