Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions TournamentsDB/TournamentsDB.sqlproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,6 @@
</ItemGroup>
<ItemGroup>
<None Include="PublishProfiles\TournamentsDBToPc.publish.xml" />
<None Include="PublishProfiles\TournamentsDBToLocalDB.publish.xml" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion TrackerLibrary/DataAccess/SqlConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace TrackerLibrary.DataAccess
public class SqlConnector : IDataConnection
{
private const string db = "Tournaments";
//TODO - Make the CreatePrize method actually save to the database

/// <summary>
/// Gives and ID to the new prize and save it to the database.
/// </summary>
Expand Down
3 changes: 0 additions & 3 deletions TrackerLibrary/DataAccess/TextConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ public void CreatePrize(PrizeModel model)
if (prizes.Count > 0)
currentId = prizes.OrderByDescending(x => x.Id).First().Id + 1;

//TODO - This is an alternative to the code of the line 34 through 37
//int currentId = prizes.OrderByDescending(x => x.ID).Select(x => x.ID).FirstOrDefault() + 1;

model.Id = currentId;

//Add the new record with the new ID (max + 1)
Expand Down
1 change: 0 additions & 1 deletion TrackerLibrary/EmailLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public static void SendEmail(List<string> to, List<string> bcc, string subject,
{
mail.Bcc.Add(email);
}
// TODO: Continue here 39:42

mail.From = fromMailAddress;
mail.Subject = subject;
Expand Down
2 changes: 0 additions & 2 deletions TrackerLibrary/GlobalConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,12 @@ public static void InitializeConnections(DatabaseType db)
{
if (db == DatabaseType.Sql)
{
//TODO - Set up the SQL Connector properly
SqlConnector sql = new SqlConnector();
Connection = sql;
}

if (db == DatabaseType.TextFile)
{
//TODO - Create the Text Connection
TextConnector text = new TextConnector();
Connection = text;
}
Expand Down
4 changes: 2 additions & 2 deletions TrackerLibrary/Models/TournamentModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace TrackerLibrary.Models
/// </summary>
public class TournamentModel
{
public event EventHandler<DateTime> OnTournamentComplete;
public event EventHandler OnTournamentComplete;
/// <summary>
/// The unique identifier for the tournament.
/// </summary>
Expand Down Expand Up @@ -36,7 +36,7 @@ public class TournamentModel

public void CompleteTournament()
{
OnTournamentComplete?.Invoke(this, DateTime.Now);
OnTournamentComplete?.Invoke(this, EventArgs.Empty);
}
}
}
2 changes: 1 addition & 1 deletion TrackerUI/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</appSettings>
<connectionStrings>
<add name="Tournaments"
connectionString="Server=.;Database=Tournaments;Trusted_Connection=True;"
connectionString="Data Source=(localdb)\MSSQLLocalDB;Database=TournamentsDB;Integrated Security=True;"
providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.net>
Expand Down
7 changes: 5 additions & 2 deletions TrackerUI/CreateTournamentForm.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using TrackerLibrary;
using TrackerLibrary.Models;
Expand All @@ -10,6 +11,7 @@ public partial class CreateTournamentForm : Form, IPrizeRequester, ITeamRequeste
List<TeamModel> availableTeams = GlobalConfig.Connection.GetTeam_All();
List<TeamModel> selectedTeams = new List<TeamModel>();
List<PrizeModel> selectedPrizes = new List<PrizeModel>();
public event EventHandler OnTournamentCreated;

public CreateTournamentForm()
{
Expand Down Expand Up @@ -122,7 +124,6 @@ private void createTournamentButton_Click(object sender, System.EventArgs e)
tm.Prizes = selectedPrizes;
tm.EnteredTeams = selectedTeams;

//TODO - Wire up our matchups
TournamentLogic.CreateRounds(tm);

//Create Tournament entry
Expand All @@ -132,6 +133,8 @@ private void createTournamentButton_Click(object sender, System.EventArgs e)

tm.AlertUsersToNewRound();

OnTournamentCreated?.Invoke(this, EventArgs.Empty);

TournamentViewerForm frm = new TournamentViewerForm(tm);
frm.Show();
this.Close();
Expand Down
12 changes: 12 additions & 0 deletions TrackerUI/TournamentDashboardForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,28 @@ public void WireUpLists()
loadExistingTournamentDropDown.DisplayMember = "TournamentName";
}

public void RefreshLists(object sender, EventArgs e)
{
tournaments = GlobalConfig.Connection.GetTournament_All();

loadExistingTournamentDropDown.DataSource = null;
loadExistingTournamentDropDown.DataSource = tournaments;
loadExistingTournamentDropDown.DisplayMember = "TournamentName";
}

private void createTournamentButton_Click(object sender, EventArgs e)
{
CreateTournamentForm frm = new CreateTournamentForm();
frm.OnTournamentCreated += RefreshLists;
frm.Show();
}

private void loadTournamentButton_Click(object sender, EventArgs e)
{
TournamentModel tm = (TournamentModel)loadExistingTournamentDropDown.SelectedItem;
tm.OnTournamentComplete += RefreshLists;
TournamentViewerForm frm = new TournamentViewerForm(tm);
// create a subcriber method for the event im going to create in tournamentviewerform
frm.Show();
}
}
Expand Down
2 changes: 1 addition & 1 deletion TrackerUI/TournamentViewerForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public TournamentViewerForm(TournamentModel tournamentModel)
LoadRounds();
}

private void Tournament_OnTournamentComplete(object sender, DateTime e)
private void Tournament_OnTournamentComplete(object sender, EventArgs e)
{
this.Close();
}
Expand Down
Loading