diff --git a/TrackerLibrary/DataAccess/IDataConnection.cs b/TrackerLibrary/DataAccess/IDataConnection.cs
new file mode 100644
index 0000000..a1394e3
--- /dev/null
+++ b/TrackerLibrary/DataAccess/IDataConnection.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using TrackerLibrary.Models;
+
+namespace TrackerLibrary.DataAccess
+{
+ public interface IDataConnection
+ {
+ PrizeModel CreatePrize(PrizeModel model);
+ }
+}
diff --git a/TrackerLibrary/DataAccess/SqlConnector.cs b/TrackerLibrary/DataAccess/SqlConnector.cs
new file mode 100644
index 0000000..6700461
--- /dev/null
+++ b/TrackerLibrary/DataAccess/SqlConnector.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TrackerLibrary.DataAccess
+{
+ public class SqlConnector : IDataConnection
+ {
+ // TODO - Make the CreatePrize method actually save to the database
+ ///
+ /// Saves a prize to the database
+ ///
+ /// The prize information.
+ /// The prize information, including the unique identifier.
+ public Models.PrizeModel CreatePrize(Models.PrizeModel model)
+ {
+ model.Id = 1;
+ return model;
+ }
+ }
+}
diff --git a/TrackerLibrary/DataAccess/TextConnector.cs b/TrackerLibrary/DataAccess/TextConnector.cs
new file mode 100644
index 0000000..436e470
--- /dev/null
+++ b/TrackerLibrary/DataAccess/TextConnector.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using TrackerLibrary.Models;
+
+namespace TrackerLibrary.DataAccess
+{
+ public class TextConnector : IDataConnection
+ {
+ // TODO - Wire up the createPrize for textFiles
+ public PrizeModel CreatePrize(PrizeModel model)
+ {
+ model.Id = 1;
+ return model;
+ }
+ }
+}
diff --git a/TrackerLibrary/GlobalConfig.cs b/TrackerLibrary/GlobalConfig.cs
new file mode 100644
index 0000000..bbdaa2d
--- /dev/null
+++ b/TrackerLibrary/GlobalConfig.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using TrackerLibrary.DataAccess;
+
+namespace TrackerLibrary
+{
+ public static class GlobalConfig
+ {
+ public static List Connections { get; private set; } = new List();
+ public static void InitializeConnections(bool database, bool textFiles)
+ {
+ if (database)
+ {
+ // TODO - Set up the sql connector properly !
+ SqlConnector sql = new SqlConnector();
+ Connections.Add(sql);
+ }
+
+ if (textFiles)
+ {
+ // TODO - Create the text Connection
+ TextConnector text = new TextConnector();
+ Connections.Add(text);
+ }
+ }
+ }
+}
diff --git a/TrackerLibrary/MatchupEntryModel.cs b/TrackerLibrary/Models/MatchupEntryModel.cs
similarity index 94%
rename from TrackerLibrary/MatchupEntryModel.cs
rename to TrackerLibrary/Models/MatchupEntryModel.cs
index 62fe132..8abb927 100644
--- a/TrackerLibrary/MatchupEntryModel.cs
+++ b/TrackerLibrary/Models/MatchupEntryModel.cs
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
-namespace TrackerLibrary
+namespace TrackerLibrary.Models
{
public class MatchupEntryModel
{
diff --git a/TrackerLibrary/MatchupModel.cs b/TrackerLibrary/Models/MatchupModel.cs
similarity index 95%
rename from TrackerLibrary/MatchupModel.cs
rename to TrackerLibrary/Models/MatchupModel.cs
index d672b36..fd0491d 100644
--- a/TrackerLibrary/MatchupModel.cs
+++ b/TrackerLibrary/Models/MatchupModel.cs
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
-namespace TrackerLibrary
+namespace TrackerLibrary.Models
{
///
/// Represents one match in the tournament.
diff --git a/TrackerLibrary/PersonModel.cs b/TrackerLibrary/Models/PersonModel.cs
similarity index 90%
rename from TrackerLibrary/PersonModel.cs
rename to TrackerLibrary/Models/PersonModel.cs
index 465a0cc..79eda44 100644
--- a/TrackerLibrary/PersonModel.cs
+++ b/TrackerLibrary/Models/PersonModel.cs
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
-namespace TrackerLibrary
+namespace TrackerLibrary.Models
{
public class PersonModel
{
diff --git a/TrackerLibrary/Models/PrizeModel.cs b/TrackerLibrary/Models/PrizeModel.cs
new file mode 100644
index 0000000..6a92d07
--- /dev/null
+++ b/TrackerLibrary/Models/PrizeModel.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TrackerLibrary.Models
+{
+ public class PrizeModel
+
+ {
+ ///
+ /// The unique identifier for the prize
+ ///
+ public int Id { get; set; }
+ public int PlaceNumber { get; set; }
+ public string PlaceName { get; set; }
+ public decimal PrizeAmount { get; set; }
+ public double PrizePercentage { get; set; }
+
+ public PrizeModel()
+ {
+
+ }
+ public PrizeModel(string placeName, string placeNumber, string prizeAmount, string prizePercentage)
+ {
+ PlaceName = placeName;
+
+ int placeNumberValue = 0;
+ int.TryParse(placeNumber, out placeNumberValue);
+ PlaceNumber = placeNumberValue;
+
+ decimal prizeAmountValue = 0;
+ decimal.TryParse(prizeAmount, out prizeAmountValue);
+ PrizeAmount = prizeAmountValue;
+
+ double prizePercentageValue = 0;
+ double.TryParse(prizePercentage, out prizePercentageValue);
+ PrizePercentage = prizePercentageValue;
+ }
+ }
+}
diff --git a/TrackerLibrary/TeamModel.cs b/TrackerLibrary/Models/TeamModel.cs
similarity index 88%
rename from TrackerLibrary/TeamModel.cs
rename to TrackerLibrary/Models/TeamModel.cs
index 0eaac01..fd67889 100644
--- a/TrackerLibrary/TeamModel.cs
+++ b/TrackerLibrary/Models/TeamModel.cs
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
-namespace TrackerLibrary
+namespace TrackerLibrary.Models
{
public class TeamModel
{
diff --git a/TrackerLibrary/Models/TournamentModel.cs b/TrackerLibrary/Models/TournamentModel.cs
new file mode 100644
index 0000000..4d76675
--- /dev/null
+++ b/TrackerLibrary/Models/TournamentModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TrackerLibrary.Models
+{
+ public class TournamentModel
+ {
+ public string TournamentName { get; set; }
+ public decimal EntryFee { get; set; }
+ public List EnteredTeams { get; set; } = new List();
+ public List Prizes { get; set; } = new List();
+ public List> MyProperty { get; set; } = new List>();
+ }
+}
diff --git a/TrackerLibrary/PrizeModel.cs b/TrackerLibrary/PrizeModel.cs
deleted file mode 100644
index 6b390e3..0000000
--- a/TrackerLibrary/PrizeModel.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace TrackerLibrary
-{
- public class PrizeModel
-
- {
- public int PlaceNumber { get; set; }
- public string PlaceName { get; set; }
- public decimal PrizeAmount { get; set; }
- public double PrizePercentage { get; set; }
- }
-}
diff --git a/TrackerLibrary/TournamentModel.cs b/TrackerLibrary/TournamentModel.cs
deleted file mode 100644
index 394278d..0000000
--- a/TrackerLibrary/TournamentModel.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace TrackerLibrary
-{
- public class TournamentModel
- {
- public string TournamentName { get; set; }
- public decimal EntryFee { get; set; }
- public List EnteredTeams { get; set; } = new List();
- public List Prizes { get; set; } = new List();
- public List> MyProperty { get; set; } = new List>();
- }
-}
diff --git a/TrackerUI/CreatePrizeForm.Designer.cs b/TrackerUI/CreatePrizeForm.Designer.cs
index 186c496..561e5da 100644
--- a/TrackerUI/CreatePrizeForm.Designer.cs
+++ b/TrackerUI/CreatePrizeForm.Designer.cs
@@ -59,7 +59,7 @@
this.placeNumberValue.Location = new System.Drawing.Point(183, 83);
this.placeNumberValue.Name = "placeNumberValue";
this.placeNumberValue.Size = new System.Drawing.Size(234, 35);
- this.placeNumberValue.TabIndex = 14;
+ this.placeNumberValue.TabIndex = 1;
//
// placeNumberLabel
//
@@ -78,7 +78,8 @@
this.prizePercentageValue.Location = new System.Drawing.Point(183, 296);
this.prizePercentageValue.Name = "prizePercentageValue";
this.prizePercentageValue.Size = new System.Drawing.Size(234, 35);
- this.prizePercentageValue.TabIndex = 16;
+ this.prizePercentageValue.TabIndex = 4;
+ this.prizePercentageValue.Text = "0";
//
// prizePercentageLabel
//
@@ -97,7 +98,8 @@
this.prizeAmountValue.Location = new System.Drawing.Point(183, 185);
this.prizeAmountValue.Name = "prizeAmountValue";
this.prizeAmountValue.Size = new System.Drawing.Size(234, 35);
- this.prizeAmountValue.TabIndex = 18;
+ this.prizeAmountValue.TabIndex = 3;
+ this.prizeAmountValue.Text = "0";
//
// prizeAmountLabel
//
@@ -116,7 +118,7 @@
this.placeNameValue.Location = new System.Drawing.Point(183, 134);
this.placeNameValue.Name = "placeNameValue";
this.placeNameValue.Size = new System.Drawing.Size(234, 35);
- this.placeNameValue.TabIndex = 20;
+ this.placeNameValue.TabIndex = 2;
//
// placeNameLabel
//
@@ -154,6 +156,7 @@
this.createPrizeButton.TabIndex = 24;
this.createPrizeButton.Text = "Create Prize";
this.createPrizeButton.UseVisualStyleBackColor = true;
+ this.createPrizeButton.Click += new System.EventHandler(this.createPrizeButton_Click);
//
// CreatePrizeForm
//
diff --git a/TrackerUI/CreatePrizeForm.cs b/TrackerUI/CreatePrizeForm.cs
index ae534b6..e71e834 100644
--- a/TrackerUI/CreatePrizeForm.cs
+++ b/TrackerUI/CreatePrizeForm.cs
@@ -7,6 +7,8 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
+using TrackerLibrary;
+using TrackerLibrary.Models;
namespace TrackerUI
{
@@ -16,5 +18,77 @@ namespace TrackerUI
{
InitializeComponent();
}
+
+ private void createPrizeButton_Click(object sender, EventArgs e)
+ {
+ if (ValidateForm())
+ {
+ PrizeModel model = new PrizeModel(
+ placeNameValue.Text,
+ placeNumberValue.Text,
+ prizeAmountValue.Text,
+ prizePercentageValue.Text);
+
+ foreach (var db in GlobalConfig.Connections)
+ {
+ db.CreatePrize(model);
+ }
+
+ placeNameValue.Text = "";
+ placeNumberValue.Text = "";
+ prizeAmountValue.Text = "0";
+ prizePercentageValue.Text = "0";
+ }
+ else
+ {
+ MessageBox.Show("This form has invalid information. Please check it and try again.");
+ }
+
+ }
+
+ private bool ValidateForm()
+ {
+ bool output = true;
+ int placeNumber = 0;
+ bool placeNumberValidator = int.TryParse(placeNumberValue.Text, out placeNumber);
+
+ if (!placeNumberValidator)
+ {
+ output = false;
+ }
+
+ if (placeNumber < 1)
+ {
+ output = false;
+ }
+
+ if (placeNameValue.Text.Length == 0)
+ {
+ output = false;
+ }
+
+ decimal prizeAmount = 0;
+ int prizePercentage = 0;
+
+ bool prizeAmountValid = decimal.TryParse(prizeAmountValue.Text, out prizeAmount);
+ bool prizePercentageValid = int.TryParse(prizeAmountValue.Text, out prizePercentage);
+
+ if (prizePercentageValid == false || prizeAmountValid == false)
+ {
+ output = false;
+ }
+
+ if (prizeAmount <= 0 && prizePercentage <= 0)
+ {
+ output = false;
+ }
+
+ if (prizePercentage < 0 || prizePercentage > 100)
+ {
+ output = false;
+ }
+
+ return output;
+ }
}
}
diff --git a/TrackerUI/Program.cs b/TrackerUI/Program.cs
index 92ddd5f..5e517fa 100644
--- a/TrackerUI/Program.cs
+++ b/TrackerUI/Program.cs
@@ -16,7 +16,12 @@ namespace TrackerUI
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new TournamentViewerForm());
+
+ // Initialize the database connections
+ TrackerLibrary.GlobalConfig.InitializeConnections(true, true);
+ Application.Run(new CreatePrizeForm());
+
+ //Application.Run(new TournamentDashboardForm());
}
}
}
diff --git a/TrackerUI/TrackerUI.csproj b/TrackerUI/TrackerUI.csproj
index 959e7bd..cedd801 100644
--- a/TrackerUI/TrackerUI.csproj
+++ b/TrackerUI/TrackerUI.csproj
@@ -115,5 +115,11 @@
+
+
+ {b4ffd708-5d53-4d58-b5a6-5691020ef6dc}
+ TrackerLibrary
+
+
\ No newline at end of file