diff --git a/TrackerLibrary/DataAccess/IDataConnection.cs b/TrackerLibrary/DataAccess/IDataConnection.cs index f11d331..a3c0058 100644 --- a/TrackerLibrary/DataAccess/IDataConnection.cs +++ b/TrackerLibrary/DataAccess/IDataConnection.cs @@ -10,6 +10,7 @@ namespace TrackerLibrary.DataAccess PrizeModel CreatePrize(PrizeModel model); PersonModel CreatePerson(PersonModel model); TeamModel CreateTeam(TeamModel model); + List GetTeam_All(); List GetPerson_All(); } } diff --git a/TrackerLibrary/DataAccess/SqlConnector.cs b/TrackerLibrary/DataAccess/SqlConnector.cs index 710a017..06bcb95 100644 --- a/TrackerLibrary/DataAccess/SqlConnector.cs +++ b/TrackerLibrary/DataAccess/SqlConnector.cs @@ -99,5 +99,22 @@ namespace TrackerLibrary.DataAccess } return output; } + + public List GetTeam_All() + { + List output; + using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db))) + { + output = connection.Query("dbo.spTeam_GetAll").ToList(); + + foreach(TeamModel team in output) + { + var p = new DynamicParameters(); + p.Add("@TeamId", team.Id); + team.TeamMembers = connection.Query("dbo.spTeamMembers_GetByTeam",p, commandType: CommandType.StoredProcedure).ToList(); + } + } + return output; + } } } diff --git a/TrackerLibrary/DataAccess/TextConnector.cs b/TrackerLibrary/DataAccess/TextConnector.cs index e909355..d2bafcd 100644 --- a/TrackerLibrary/DataAccess/TextConnector.cs +++ b/TrackerLibrary/DataAccess/TextConnector.cs @@ -93,5 +93,10 @@ namespace TrackerLibrary.DataAccess { return PeopleFile.FullFilePath().LoadFile().ConvertToPersonModels(); } + + public List GetTeam_All() + { + throw new NotImplementedException(); + } } } diff --git a/TrackerUI/CreateTournamentForm.Designer.cs b/TrackerUI/CreateTournamentForm.Designer.cs index b466085..5c1a5b2 100644 --- a/TrackerUI/CreateTournamentForm.Designer.cs +++ b/TrackerUI/CreateTournamentForm.Designer.cs @@ -39,7 +39,7 @@ this.createNewTeamLink = new System.Windows.Forms.LinkLabel(); this.addTeamButton = new System.Windows.Forms.Button(); this.cratePrizeButton = new System.Windows.Forms.Button(); - this.tournamentPlayersListBox = new System.Windows.Forms.ListBox(); + this.tournamentTeamsListBox = new System.Windows.Forms.ListBox(); this.tournamentPlayersLabel = new System.Windows.Forms.Label(); this.deleteSelectedPlayerButton = new System.Windows.Forms.Button(); this.deleteSelectedPrizeButton = new System.Windows.Forms.Button(); @@ -153,15 +153,15 @@ this.cratePrizeButton.Text = "Create Prize"; this.cratePrizeButton.UseVisualStyleBackColor = true; // - // tournamentPlayersListBox + // tournamentTeamsListBox // - this.tournamentPlayersListBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.tournamentPlayersListBox.FormattingEnabled = true; - this.tournamentPlayersListBox.ItemHeight = 30; - this.tournamentPlayersListBox.Location = new System.Drawing.Point(431, 119); - this.tournamentPlayersListBox.Name = "tournamentPlayersListBox"; - this.tournamentPlayersListBox.Size = new System.Drawing.Size(338, 152); - this.tournamentPlayersListBox.TabIndex = 18; + this.tournamentTeamsListBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.tournamentTeamsListBox.FormattingEnabled = true; + this.tournamentTeamsListBox.ItemHeight = 30; + this.tournamentTeamsListBox.Location = new System.Drawing.Point(431, 119); + this.tournamentTeamsListBox.Name = "tournamentTeamsListBox"; + this.tournamentTeamsListBox.Size = new System.Drawing.Size(338, 152); + this.tournamentTeamsListBox.TabIndex = 18; // // tournamentPlayersLabel // @@ -209,9 +209,9 @@ this.prizesLabel.ForeColor = System.Drawing.Color.DodgerBlue; this.prizesLabel.Location = new System.Drawing.Point(424, 287); this.prizesLabel.Name = "prizesLabel"; - this.prizesLabel.Size = new System.Drawing.Size(198, 37); + this.prizesLabel.Size = new System.Drawing.Size(85, 37); this.prizesLabel.TabIndex = 22; - this.prizesLabel.Text = "Teams / Players"; + this.prizesLabel.Text = "Prizes"; // // prizesListBox // @@ -249,7 +249,7 @@ this.Controls.Add(this.prizesListBox); this.Controls.Add(this.deleteSelectedPlayerButton); this.Controls.Add(this.tournamentPlayersLabel); - this.Controls.Add(this.tournamentPlayersListBox); + this.Controls.Add(this.tournamentTeamsListBox); this.Controls.Add(this.cratePrizeButton); this.Controls.Add(this.addTeamButton); this.Controls.Add(this.createNewTeamLink); @@ -282,7 +282,7 @@ private System.Windows.Forms.LinkLabel createNewTeamLink; private System.Windows.Forms.Button addTeamButton; private System.Windows.Forms.Button cratePrizeButton; - private System.Windows.Forms.ListBox tournamentPlayersListBox; + private System.Windows.Forms.ListBox tournamentTeamsListBox; private System.Windows.Forms.Label tournamentPlayersLabel; private System.Windows.Forms.Button deleteSelectedPlayerButton; private System.Windows.Forms.Button deleteSelectedPrizeButton; diff --git a/TrackerUI/CreateTournamentForm.cs b/TrackerUI/CreateTournamentForm.cs index c834072..528123e 100644 --- a/TrackerUI/CreateTournamentForm.cs +++ b/TrackerUI/CreateTournamentForm.cs @@ -7,14 +7,28 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using TrackerLibrary; +using TrackerLibrary.Models; namespace TrackerUI { public partial class CreateTournamentForm : Form { + List availableTeams = GlobalConfig.Connection.GetTeam_All(); + List selectedTeams = new List(); public CreateTournamentForm() { InitializeComponent(); + InitializeLists(); + } + + private void InitializeLists() + { + selectTeamDropDown.DataSource = availableTeams; + selectTeamDropDown.DisplayMember = "TeamName"; + + tournamentTeamsListBox.DataSource = selectedTeams; + tournamentTeamsListBox.DisplayMember = "TeamName"; } } } diff --git a/TrackerUI/Program.cs b/TrackerUI/Program.cs index d0d883d..473bdd0 100644 --- a/TrackerUI/Program.cs +++ b/TrackerUI/Program.cs @@ -19,8 +19,8 @@ namespace TrackerUI Application.SetCompatibleTextRenderingDefault(false); // Initialize the database connections - GlobalConfig.InitializeConnections(DatabaseType.TextFile); - Application.Run(new CreateTeamForm()); + GlobalConfig.InitializeConnections(DatabaseType.Sql); + Application.Run(new CreateTournamentForm()); //Application.Run(new TournamentDashboardForm()); }