Tournament Dashboard fixed, started to wire up tournamentviewer form
This commit is contained in:
@ -13,5 +13,6 @@ namespace TrackerLibrary.DataAccess
|
|||||||
void CreateTournament(TournamentModel model);
|
void CreateTournament(TournamentModel model);
|
||||||
List<TeamModel> GetTeam_All();
|
List<TeamModel> GetTeam_All();
|
||||||
List<PersonModel> GetPerson_All();
|
List<PersonModel> GetPerson_All();
|
||||||
|
List<TournamentModel> GetTournament_All();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -157,7 +157,7 @@ namespace TrackerLibrary.DataAccess
|
|||||||
|
|
||||||
p = new DynamicParameters();
|
p = new DynamicParameters();
|
||||||
p.Add("@MatchupId", matchup.Id);
|
p.Add("@MatchupId", matchup.Id);
|
||||||
if(entry.ParentMatchup == null)
|
if (entry.ParentMatchup == null)
|
||||||
{
|
{
|
||||||
p.Add("@ParentMatchupId", null);
|
p.Add("@ParentMatchupId", null);
|
||||||
}
|
}
|
||||||
@ -226,5 +226,75 @@ namespace TrackerLibrary.DataAccess
|
|||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<TournamentModel> GetTournament_All()
|
||||||
|
{
|
||||||
|
List<TournamentModel> output;
|
||||||
|
using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db)))
|
||||||
|
{
|
||||||
|
output = connection.Query<TournamentModel>("dbo.spTournaments_GetAll").ToList();
|
||||||
|
var p = new DynamicParameters();
|
||||||
|
foreach (TournamentModel t in output)
|
||||||
|
{
|
||||||
|
// Populate prizes
|
||||||
|
p.Add("@TournamentId", t.Id);
|
||||||
|
t.Prizes = connection.Query<PrizeModel>("dbo.spPrizes_GetByTournament", p, commandType: CommandType.StoredProcedure).ToList();
|
||||||
|
// Populate Teams
|
||||||
|
t.EnteredTeams = connection.Query<TeamModel>("dbo.spTeam_GetByTournament", p, commandType: CommandType.StoredProcedure).ToList();
|
||||||
|
foreach (TeamModel team in t.EnteredTeams)
|
||||||
|
{
|
||||||
|
p = new DynamicParameters();
|
||||||
|
p.Add("@TeamId", team.Id);
|
||||||
|
team.TeamMembers = connection.Query<PersonModel>("dbo.spTeamMembers_GetByTeam", p, commandType: CommandType.StoredProcedure).ToList();
|
||||||
|
}
|
||||||
|
// Populate Rounds
|
||||||
|
p = new DynamicParameters();
|
||||||
|
p.Add("@TournamentId", t.Id);
|
||||||
|
List<MatchupModel> matchups = connection.Query<MatchupModel>("dbo.spMatchups_GetByTournament", p, commandType: CommandType.StoredProcedure).ToList();
|
||||||
|
foreach (MatchupModel m in matchups)
|
||||||
|
{
|
||||||
|
p = new DynamicParameters();
|
||||||
|
p.Add("@MatchupId", m.Id);
|
||||||
|
m.Entries = connection.Query<MatchupEntryModel>("dbo.spMatchupEntries_GetByMatchup", p, commandType: CommandType.StoredProcedure).ToList();
|
||||||
|
|
||||||
|
List<TeamModel> allTeams = GetTeam_All();
|
||||||
|
|
||||||
|
if (m.WinnerId > 0)
|
||||||
|
{
|
||||||
|
m.Winner = allTeams.Where(x => x.Id == m.WinnerId).First();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var me in m.Entries)
|
||||||
|
{
|
||||||
|
if (me.TeamCompetingId > 0)
|
||||||
|
{
|
||||||
|
me.TeamCompeting = allTeams.Where(x => x.Id == me.TeamCompetingId).First();
|
||||||
|
}
|
||||||
|
if (me.ParentMatchupId > 0)
|
||||||
|
{
|
||||||
|
me.ParentMatchup = matchups.Where(x => x.Id == me.ParentMatchupId).First();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// List<List<MatchupModel>>
|
||||||
|
List<MatchupModel> currRow = new List<MatchupModel>();
|
||||||
|
int currRound = 1;
|
||||||
|
foreach (MatchupModel m in matchups)
|
||||||
|
{
|
||||||
|
if(m.MatchupRound > currRound)
|
||||||
|
{
|
||||||
|
t.Rounds.Add(currRow);
|
||||||
|
currRow = new List<MatchupModel>();
|
||||||
|
currRound += 1;
|
||||||
|
}
|
||||||
|
currRow.Add(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Rounds.Add(currRow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -124,5 +124,12 @@ namespace TrackerLibrary.DataAccess
|
|||||||
tournaments.SaveToTournamentFile(TournamentFile);
|
tournaments.SaveToTournamentFile(TournamentFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<TournamentModel> GetTournament_All()
|
||||||
|
{
|
||||||
|
return TournamentFile
|
||||||
|
.FullFilePath()
|
||||||
|
.LoadFile()
|
||||||
|
.ConvertToTournamentModels(TeamFile, PeopleFile, PrizesFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -108,6 +108,8 @@ namespace TrackerLibrary.DataAccess.TextHelpers
|
|||||||
List<TournamentModel> output = new List<TournamentModel>();
|
List<TournamentModel> output = new List<TournamentModel>();
|
||||||
List<TeamModel> teams = teamFileName.FullFilePath().LoadFile().ConvertToTeamModels(peopleFileName);
|
List<TeamModel> teams = teamFileName.FullFilePath().LoadFile().ConvertToTeamModels(peopleFileName);
|
||||||
List<PrizeModel> prizes = prizesFileName.FullFilePath().LoadFile().ConvertToPrizeModels();
|
List<PrizeModel> prizes = prizesFileName.FullFilePath().LoadFile().ConvertToPrizeModels();
|
||||||
|
List<MatchupModel> matchups = GlobalConfig.MatchupFile.FullFilePath().LoadFile().ConvertToMatchupModels();
|
||||||
|
|
||||||
foreach (string line in lines)
|
foreach (string line in lines)
|
||||||
{
|
{
|
||||||
string[] cols = line.Split(',');
|
string[] cols = line.Split(',');
|
||||||
@ -120,13 +122,27 @@ namespace TrackerLibrary.DataAccess.TextHelpers
|
|||||||
{
|
{
|
||||||
tm.EnteredTeams.Add(teams.Where(x => x.Id == int.Parse(teamId)).First());
|
tm.EnteredTeams.Add(teams.Where(x => x.Id == int.Parse(teamId)).First());
|
||||||
}
|
}
|
||||||
|
if (cols[4].Length > 0)
|
||||||
|
{
|
||||||
string[] prizeIds = cols[4].Split('|');
|
string[] prizeIds = cols[4].Split('|');
|
||||||
foreach (string prizeId in prizeIds)
|
foreach (string prizeId in prizeIds)
|
||||||
{
|
{
|
||||||
tm.Prizes.Add(prizes.Where(x => x.Id == int.Parse(prizeId)).First());
|
tm.Prizes.Add(prizes.Where(x => x.Id == int.Parse(prizeId)).First());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Capture rounds information
|
// Capture rounds information
|
||||||
|
string[] rounds = cols[5].Split('|');
|
||||||
|
foreach (string round in rounds)
|
||||||
|
{
|
||||||
|
List<MatchupModel> ms = new List<MatchupModel>();
|
||||||
|
string[] mstext = round.Split('^');
|
||||||
|
foreach (string matchupModelTextId in mstext)
|
||||||
|
{
|
||||||
|
ms.Add(matchups.Where(x => x.Id == int.Parse(matchupModelTextId)).First());
|
||||||
|
}
|
||||||
|
tm.Rounds.Add(ms);
|
||||||
|
}
|
||||||
|
|
||||||
output.Add(tm);
|
output.Add(tm);
|
||||||
|
|
||||||
@ -197,7 +213,14 @@ namespace TrackerLibrary.DataAccess.TextHelpers
|
|||||||
string[] cols = line.Split(',');
|
string[] cols = line.Split(',');
|
||||||
MatchupEntryModel me = new MatchupEntryModel();
|
MatchupEntryModel me = new MatchupEntryModel();
|
||||||
me.Id = int.Parse(cols[0]);
|
me.Id = int.Parse(cols[0]);
|
||||||
me.TeamCompeting = LookupTeamById(int.Parse( cols[1]));
|
if(cols[1].Length == 0)
|
||||||
|
{
|
||||||
|
me.TeamCompeting = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
me.TeamCompeting = LookupTeamById(int.Parse(cols[1]));
|
||||||
|
}
|
||||||
me.Score = double.Parse( cols[2]);
|
me.Score = double.Parse( cols[2]);
|
||||||
|
|
||||||
int parentId = 0;
|
int parentId = 0;
|
||||||
@ -207,7 +230,7 @@ namespace TrackerLibrary.DataAccess.TextHelpers
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
me.ParentMatchup = null);
|
me.ParentMatchup = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
output.Add(me);
|
output.Add(me);
|
||||||
@ -219,25 +242,54 @@ namespace TrackerLibrary.DataAccess.TextHelpers
|
|||||||
{
|
{
|
||||||
string[] ids = input.Split('|');
|
string[] ids = input.Split('|');
|
||||||
List<MatchupEntryModel> output = new List<MatchupEntryModel>();
|
List<MatchupEntryModel> output = new List<MatchupEntryModel>();
|
||||||
List<MatchupEntryModel> entries = GlobalConfig.MatchupEntryFile.FullFilePath().LoadFile().ConvertToMatchupEntryModels();
|
List<string> entries = GlobalConfig.MatchupEntryFile.FullFilePath().LoadFile();
|
||||||
|
List<string> matchingEntries = new List<string>();
|
||||||
foreach (string id in ids)
|
foreach (string id in ids)
|
||||||
{
|
{
|
||||||
output.Add(entries.Where(x => x.Id == int.Parse(id)).First());
|
foreach (string entry in entries)
|
||||||
|
{
|
||||||
|
string[] cols = entry.Split(',');
|
||||||
|
if (cols[0] == id) {
|
||||||
|
matchingEntries.Add(entry);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
output = matchingEntries.ConvertToMatchupEntryModels();
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TeamModel LookupTeamById(int id)
|
private static TeamModel LookupTeamById(int id)
|
||||||
{
|
{
|
||||||
List<TeamModel> teams = GlobalConfig.TeamFile.FullFilePath().LoadFile().ConvertToTeamModels(GlobalConfig.PeopleFile);
|
List<string> teams = GlobalConfig.TeamFile.FullFilePath().LoadFile();
|
||||||
return teams.Where(x => x.Id == id).First();
|
foreach (string team in teams)
|
||||||
|
{
|
||||||
|
string[] cols = team.Split(',');
|
||||||
|
if (cols[0] == id.ToString())
|
||||||
|
{
|
||||||
|
List<string> matchingTeams = new List<string>();
|
||||||
|
matchingTeams.Add(team);
|
||||||
|
return matchingTeams.ConvertToTeamModels(GlobalConfig.PeopleFile).First();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MatchupModel LookupMatchupById(int id)
|
private static MatchupModel LookupMatchupById(int id)
|
||||||
{
|
{
|
||||||
List<MatchupModel> matchups = GlobalConfig.MatchupFile.FullFilePath().LoadFile().ConvertToMatchupModels();
|
List<string> matchups = GlobalConfig.MatchupFile.FullFilePath().LoadFile();
|
||||||
return matchups.Where(x => x.Id == id).First();
|
foreach (string matchup in matchups)
|
||||||
|
{
|
||||||
|
string[] cols = matchup.Split(',');
|
||||||
|
if (cols[0] == id.ToString())
|
||||||
|
{
|
||||||
|
List<string> matchingMatchups = new List<string>();
|
||||||
|
matchingMatchups.Add(matchup);
|
||||||
|
return matchingMatchups.ConvertToMatchupModels().First();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<MatchupModel> ConvertToMatchupModels(this List<string> lines)
|
public static List<MatchupModel> ConvertToMatchupModels(this List<string> lines)
|
||||||
@ -251,7 +303,14 @@ namespace TrackerLibrary.DataAccess.TextHelpers
|
|||||||
MatchupModel p = new MatchupModel();
|
MatchupModel p = new MatchupModel();
|
||||||
p.Id = int.Parse(cols[0]);
|
p.Id = int.Parse(cols[0]);
|
||||||
p.Entries = ConvertStringToMatchupEntryModels(cols[1]);
|
p.Entries = ConvertStringToMatchupEntryModels(cols[1]);
|
||||||
|
if (cols[2].Length == 0)
|
||||||
|
{
|
||||||
|
p.Winner = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
p.Winner = LookupTeamById(int.Parse(cols[2]));
|
p.Winner = LookupTeamById(int.Parse(cols[2]));
|
||||||
|
}
|
||||||
p.MatchupRound = int.Parse(cols[3]);
|
p.MatchupRound = int.Parse(cols[3]);
|
||||||
output.Add(p);
|
output.Add(p);
|
||||||
}
|
}
|
||||||
@ -268,6 +327,9 @@ namespace TrackerLibrary.DataAccess.TextHelpers
|
|||||||
currentId = matchups.OrderByDescending(x => x.Id).First().Id + 1;
|
currentId = matchups.OrderByDescending(x => x.Id).First().Id + 1;
|
||||||
}
|
}
|
||||||
matchup.Id = currentId;
|
matchup.Id = currentId;
|
||||||
|
|
||||||
|
matchups.Add(matchup);
|
||||||
|
|
||||||
foreach (MatchupEntryModel entry in matchup.Entries)
|
foreach (MatchupEntryModel entry in matchup.Entries)
|
||||||
{
|
{
|
||||||
entry.SaveEntryToFile(matchupEntryFile);
|
entry.SaveEntryToFile(matchupEntryFile);
|
||||||
@ -304,9 +366,14 @@ namespace TrackerLibrary.DataAccess.TextHelpers
|
|||||||
string parent = "";
|
string parent = "";
|
||||||
if(e.ParentMatchup != null)
|
if(e.ParentMatchup != null)
|
||||||
{
|
{
|
||||||
parent = e.ParentMatchup.Id.ToString(); ;
|
parent = e.ParentMatchup.Id.ToString();
|
||||||
}
|
}
|
||||||
lines.Add($"{e.Id},{e.TeamCompeting.Id},{e.Score},{parent}");
|
string teamCompeting = "";
|
||||||
|
if(e.TeamCompeting != null)
|
||||||
|
{
|
||||||
|
teamCompeting = e.TeamCompeting.Id.ToString();
|
||||||
|
}
|
||||||
|
lines.Add($"{e.Id},{teamCompeting},{e.Score},{parent}");
|
||||||
}
|
}
|
||||||
|
|
||||||
File.WriteAllLines(GlobalConfig.MatchupEntryFile.FullFilePath(), lines);
|
File.WriteAllLines(GlobalConfig.MatchupEntryFile.FullFilePath(), lines);
|
||||||
@ -319,12 +386,7 @@ namespace TrackerLibrary.DataAccess.TextHelpers
|
|||||||
List<string> lines = new List<string>();
|
List<string> lines = new List<string>();
|
||||||
foreach (TournamentModel tm in models)
|
foreach (TournamentModel tm in models)
|
||||||
{
|
{
|
||||||
lines.Add($@"{tm.Id},
|
lines.Add($@"{tm.Id},{tm.TournamentName},{tm.EntryFee},{ConvertTeamListToString(tm.EnteredTeams)},{ConvertPrizeListToString(tm.Prizes)},{ConvertRoundListToString(tm.Rounds)}");
|
||||||
{tm.TournamentName},
|
|
||||||
{tm.EntryFee},
|
|
||||||
{ConvertTeamListToString(tm.EnteredTeams)},
|
|
||||||
{ConvertPrizeListToString(tm.Prizes)},
|
|
||||||
{ConvertRoundListToString(tm.Rounds)}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
File.WriteAllLines(fileName.FullFilePath(), lines);
|
File.WriteAllLines(fileName.FullFilePath(), lines);
|
||||||
|
|||||||
@ -11,6 +11,10 @@ namespace TrackerLibrary.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// The unique identifier for the team
|
||||||
|
/// </summary>
|
||||||
|
public int TeamCompetingId { get; set; }
|
||||||
|
/// <summary>
|
||||||
/// Represents one team in the matchup
|
/// Represents one team in the matchup
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public TeamModel TeamCompeting { get; set; }
|
public TeamModel TeamCompeting { get; set; }
|
||||||
@ -19,6 +23,10 @@ namespace TrackerLibrary.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public double Score { get; set; }
|
public double Score { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// The unique identifier for the parent matchup (team)
|
||||||
|
/// </summary>
|
||||||
|
public int ParentMatchupId { get; set; }
|
||||||
|
/// <summary>
|
||||||
/// Represents the matchup that this team came
|
/// Represents the matchup that this team came
|
||||||
/// from as winner
|
/// from as winner
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -18,6 +18,10 @@ namespace TrackerLibrary.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public List<MatchupEntryModel> Entries { get; set; } = new List<MatchupEntryModel>();
|
public List<MatchupEntryModel> Entries { get; set; } = new List<MatchupEntryModel>();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// The Id from database that will be used to lookup the winner
|
||||||
|
/// </summary>
|
||||||
|
public int WinnerId { get; set; }
|
||||||
|
/// <summary>
|
||||||
/// The winner of the match.
|
/// The winner of the match.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public TeamModel Winner { get; set; }
|
public TeamModel Winner { get; set; }
|
||||||
@ -25,5 +29,34 @@ namespace TrackerLibrary.Models
|
|||||||
/// Which round this match is a part of.
|
/// Which round this match is a part of.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int MatchupRound { get; set; }
|
public int MatchupRound { get; set; }
|
||||||
|
|
||||||
|
public string DisplayName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
string output = "";
|
||||||
|
foreach (MatchupEntryModel me in Entries)
|
||||||
|
{
|
||||||
|
if (me.TeamCompeting != null)
|
||||||
|
{
|
||||||
|
if (output.Length == 0)
|
||||||
|
{
|
||||||
|
output = me.TeamCompeting.TeamName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
output += $" vs. {me.TeamCompeting.TeamName}";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
output = "Matchup not yet Determined";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,9 +20,7 @@ namespace TrackerUI
|
|||||||
|
|
||||||
// Initialize the database connections
|
// Initialize the database connections
|
||||||
GlobalConfig.InitializeConnections(DatabaseType.Sql);
|
GlobalConfig.InitializeConnections(DatabaseType.Sql);
|
||||||
Application.Run(new CreateTournamentForm());
|
Application.Run(new TournamentDashboardForm());
|
||||||
|
|
||||||
//Application.Run(new TournamentDashboardForm());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2
TrackerUI/TournamentDashboardForm.Designer.cs
generated
2
TrackerUI/TournamentDashboardForm.Designer.cs
generated
@ -80,6 +80,7 @@
|
|||||||
this.loadTournamentButton.TabIndex = 25;
|
this.loadTournamentButton.TabIndex = 25;
|
||||||
this.loadTournamentButton.Text = "Load Tournament";
|
this.loadTournamentButton.Text = "Load Tournament";
|
||||||
this.loadTournamentButton.UseVisualStyleBackColor = true;
|
this.loadTournamentButton.UseVisualStyleBackColor = true;
|
||||||
|
this.loadTournamentButton.Click += new System.EventHandler(this.loadTournamentButton_Click);
|
||||||
//
|
//
|
||||||
// createTournamentButton
|
// createTournamentButton
|
||||||
//
|
//
|
||||||
@ -94,6 +95,7 @@
|
|||||||
this.createTournamentButton.TabIndex = 26;
|
this.createTournamentButton.TabIndex = 26;
|
||||||
this.createTournamentButton.Text = "Create Tournament";
|
this.createTournamentButton.Text = "Create Tournament";
|
||||||
this.createTournamentButton.UseVisualStyleBackColor = true;
|
this.createTournamentButton.UseVisualStyleBackColor = true;
|
||||||
|
this.createTournamentButton.Click += new System.EventHandler(this.createTournamentButton_Click);
|
||||||
//
|
//
|
||||||
// TournamentDashboardForm
|
// TournamentDashboardForm
|
||||||
//
|
//
|
||||||
|
|||||||
@ -7,14 +7,37 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using TrackerLibrary;
|
||||||
|
using TrackerLibrary.Models;
|
||||||
|
|
||||||
namespace TrackerUI
|
namespace TrackerUI
|
||||||
{
|
{
|
||||||
public partial class TournamentDashboardForm : Form
|
public partial class TournamentDashboardForm : Form
|
||||||
{
|
{
|
||||||
|
List<TournamentModel> tournaments = GlobalConfig.Connection.GetTournament_All();
|
||||||
public TournamentDashboardForm()
|
public TournamentDashboardForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
WireUpLists();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void WireUpLists()
|
||||||
|
{
|
||||||
|
loadExistingTournamentDropDown.DataSource = tournaments;
|
||||||
|
loadExistingTournamentDropDown.DisplayMember = "TournamentName";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createTournamentButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
CreateTournamentForm frm = new CreateTournamentForm();
|
||||||
|
frm.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadTournamentButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
TournamentModel tm = (TournamentModel)loadExistingTournamentDropDown.SelectedItem;
|
||||||
|
TournamentViewerForm frm = new TournamentViewerForm(tm);
|
||||||
|
frm.Show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1
TrackerUI/TournamentViewerForm.Designer.cs
generated
1
TrackerUI/TournamentViewerForm.Designer.cs
generated
@ -86,6 +86,7 @@
|
|||||||
this.roundDropDown.Name = "roundDropDown";
|
this.roundDropDown.Name = "roundDropDown";
|
||||||
this.roundDropDown.Size = new System.Drawing.Size(245, 38);
|
this.roundDropDown.Size = new System.Drawing.Size(245, 38);
|
||||||
this.roundDropDown.TabIndex = 3;
|
this.roundDropDown.TabIndex = 3;
|
||||||
|
this.roundDropDown.SelectedIndexChanged += new System.EventHandler(this.roundDropDown_SelectedIndexChanged);
|
||||||
//
|
//
|
||||||
// unplayedOnlyCheckbox
|
// unplayedOnlyCheckbox
|
||||||
//
|
//
|
||||||
|
|||||||
@ -7,14 +7,74 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using TrackerLibrary.Models;
|
||||||
|
|
||||||
namespace TrackerUI
|
namespace TrackerUI
|
||||||
{
|
{
|
||||||
public partial class TournamentViewerForm : Form
|
public partial class TournamentViewerForm : Form
|
||||||
{
|
{
|
||||||
public TournamentViewerForm()
|
private readonly TournamentModel tournament;
|
||||||
|
List<int> rounds = new List<int>();
|
||||||
|
List<MatchupModel> selectedMatchups = new List<MatchupModel>();
|
||||||
|
public TournamentViewerForm(TournamentModel tournamentModel)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
tournament = tournamentModel;
|
||||||
|
LoadFormData();
|
||||||
|
LoadRounds();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadFormData()
|
||||||
|
{
|
||||||
|
tournamentName.Text = tournament.TournamentName;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void WireUpRoundsLists()
|
||||||
|
{
|
||||||
|
roundDropDown.DataSource = null;
|
||||||
|
roundDropDown.DataSource = rounds;
|
||||||
|
|
||||||
|
}
|
||||||
|
private void WireUpMatchupsLists()
|
||||||
|
{
|
||||||
|
MatchUpListBox.DataSource = null;
|
||||||
|
MatchUpListBox.DataSource = selectedMatchups;
|
||||||
|
MatchUpListBox.DisplayMember = "DisplayName";
|
||||||
|
}
|
||||||
|
private void LoadRounds()
|
||||||
|
{
|
||||||
|
rounds = new List<int>();
|
||||||
|
|
||||||
|
rounds.Add(1);
|
||||||
|
int currRound = 1;
|
||||||
|
foreach (List<MatchupModel> matchups in tournament.Rounds)
|
||||||
|
{
|
||||||
|
if (matchups.First().MatchupRound > currRound)
|
||||||
|
{
|
||||||
|
currRound = matchups.First().MatchupRound;
|
||||||
|
rounds.Add(currRound);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WireUpRoundsLists();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void roundDropDown_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadMatchups();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void LoadMatchups()
|
||||||
|
{
|
||||||
|
int round = (int)roundDropDown.SelectedItem;
|
||||||
|
foreach (List<MatchupModel> matchups in tournament.Rounds)
|
||||||
|
{
|
||||||
|
if (matchups.First().MatchupRound == round)
|
||||||
|
{
|
||||||
|
selectedMatchups = matchups;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WireUpMatchupsLists();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user