From 1fb0e5801b0605cf0267c544a5738ef65bcffb32 Mon Sep 17 00:00:00 2001 From: Beppe Date: Sat, 3 Aug 2019 21:29:23 +0200 Subject: [PATCH 1/3] Events added for ploegen.cs (reset json files for next boot) --- Online Gokkantoor/Data/data.cs | 16 +++---- Online Gokkantoor/Globals/Classes/Game.cs | 44 +++++++++++++++++-- Online Gokkantoor/Globals/Classes/Ploeg.cs | 18 ++++++-- Online Gokkantoor/Globals/Interfaces/IGame.cs | 1 + .../Globals/Interfaces/IPloeg.cs | 5 ++- 5 files changed, 68 insertions(+), 16 deletions(-) diff --git a/Online Gokkantoor/Data/data.cs b/Online Gokkantoor/Data/data.cs index a26f2a3..27c796d 100644 --- a/Online Gokkantoor/Data/data.cs +++ b/Online Gokkantoor/Data/data.cs @@ -21,7 +21,7 @@ namespace Data List list = new List(); try { - using (StreamReader file = File.OpenText(@"Data/bets.json")) + using (StreamReader file = File.OpenText(@"../../Data/bets.json")) { JsonSerializer serializer = new JsonSerializer(); @@ -42,7 +42,7 @@ namespace Data try { - using (StreamReader file = File.OpenText(@"Data/games.json")) + using (StreamReader file = File.OpenText(@"../../Data/games.json")) { JsonSerializer serializer = new JsonSerializer(); list = (List)serializer.Deserialize(file, typeof(List)); @@ -61,7 +61,7 @@ namespace Data List list = new List(); try { - using (StreamReader file = File.OpenText(@"Data/persons.json")) + using (StreamReader file = File.OpenText(@"../../Data/persons.json")) { JsonSerializer serializer = new JsonSerializer(); list = (List)serializer.Deserialize(file, typeof(List)); @@ -80,7 +80,7 @@ namespace Data List list = new List(); try { - using (StreamReader file = File.OpenText(@"Data/ploegen.json")) + using (StreamReader file = File.OpenText(@"../../Data/ploegen.json")) { JsonSerializer serializer = new JsonSerializer(); list = (List)serializer.Deserialize(file, typeof(List)); @@ -96,7 +96,7 @@ namespace Data public void saveBets(List b) { - using (StreamWriter file = File.CreateText(@"Data/bets.json")) + using (StreamWriter file = File.CreateText(@"../../Data/bets.json")) { JsonSerializer serializer = new JsonSerializer(); serializer.Serialize(file, b); @@ -105,7 +105,7 @@ namespace Data public void saveGames(List g) { - using (StreamWriter file = File.CreateText(@"Data/games.json")) + using (StreamWriter file = File.CreateText(@"../../Data/games.json")) { JsonSerializer serializer = new JsonSerializer(); serializer.Serialize(file, g); @@ -114,7 +114,7 @@ namespace Data public void savePersons(List p) { - using (StreamWriter file = File.CreateText(@"Data/persons.json")) + using (StreamWriter file = File.CreateText(@"../../Data/persons.json")) { JsonSerializer serializer = new JsonSerializer(); serializer.Serialize(file, p); @@ -123,7 +123,7 @@ namespace Data public void savePloegen(List p) { - using (StreamWriter file = File.CreateText(@"Data/ploegen.json")) + using (StreamWriter file = File.CreateText(@"../../Data/ploegen.json")) { JsonSerializer serializer = new JsonSerializer(); serializer.Serialize(file, p); diff --git a/Online Gokkantoor/Globals/Classes/Game.cs b/Online Gokkantoor/Globals/Classes/Game.cs index 421c7c1..42053ba 100644 --- a/Online Gokkantoor/Globals/Classes/Game.cs +++ b/Online Gokkantoor/Globals/Classes/Game.cs @@ -11,38 +11,62 @@ namespace Globals.classes [JsonConstructor] public Game(int Id, Ploeg home, Ploeg away, DateTime date) { + homeSetBool = false; + awaySetBool = false; + this.Id = Id; this.home = home; this.away = away; + this.home.scoreChanged += homeSet; + this.away.scoreChanged += awaySet; this.date = date; } public Game(Ploeg home, Ploeg away, DateTime d) { + homeSetBool = false; + awaySetBool = false; + this.home = home; this.away = away; + this.home.scoreChanged += homeSet; + this.away.scoreChanged += awaySet; + this.date = d; } public Game(Ploeg home, Ploeg away, DateTime d, int scoreHome, int scoreAway) { + homeSetBool = false; + awaySetBool = false; + this.home = home; this.away = away; - this.home.score = scoreHome; - this.away.score = scoreAway; + this.home.scoreChanged += homeSet; + this.away.scoreChanged += awaySet; + this.home.setScore(scoreHome); + this.away.setScore(scoreAway); this.date = d; } public Game(int id, Ploeg home, Ploeg away) { + homeSetBool = false; + awaySetBool = false; Id = id; this.home = home ?? throw new ArgumentNullException(nameof(home)); this.away = away ?? throw new ArgumentNullException(nameof(away)); + this.home.scoreChanged += homeSet; + this.away.scoreChanged += awaySet; } public Game(int id, Ploeg home, Ploeg away, int scoreHome, int scoreAway) { + homeSetBool = false; + awaySetBool = false; Id = id; this.home = home ?? throw new ArgumentNullException(nameof(home)); this.away = away ?? throw new ArgumentNullException(nameof(away)); - this.home.score = scoreHome; - this.away.score = scoreAway; + this.home.scoreChanged += homeSet; + this.away.scoreChanged += awaySet; + this.home.setScore(scoreHome); + this.away.setScore(scoreAway); } [JsonProperty("id")] public int Id { get; set; } @@ -53,6 +77,18 @@ namespace Globals.classes [JsonProperty("Date")] public DateTime date { get; set; } //y m d + private bool homeSetBool; + private bool awaySetBool; + private void homeSet (object s, EventArgs e) + { + homeSetBool = true; + + } + private void awaySet(object s, EventArgs e) + { + awaySetBool = true; + } + public state getWinner() { if (!this.home.scoreSet || !this.away.scoreSet) diff --git a/Online Gokkantoor/Globals/Classes/Ploeg.cs b/Online Gokkantoor/Globals/Classes/Ploeg.cs index b247d12..e43108c 100644 --- a/Online Gokkantoor/Globals/Classes/Ploeg.cs +++ b/Online Gokkantoor/Globals/Classes/Ploeg.cs @@ -34,9 +34,11 @@ namespace Globals.classes public int Id { get; set; } public string naam { get; set; } - public int score { get; set; } - public bool scoreSet { get => this.score != int.MinValue; } - + public int score { get; private set; } + public bool scoreSet { get; } + + public event EventHandler scoreChanged; + public override bool Equals(object obj) { try @@ -66,5 +68,15 @@ namespace Globals.classes return this.Id + ": " + this.naam + score; } + public void setScore(int i) + { + EventHandler h = scoreChanged; + if (null != h) h(this, EventArgs.Empty); + this.score = i; + } + public int getScore() + { + return this.score; + } } } diff --git a/Online Gokkantoor/Globals/Interfaces/IGame.cs b/Online Gokkantoor/Globals/Interfaces/IGame.cs index 7b887df..9bea3c4 100644 --- a/Online Gokkantoor/Globals/Interfaces/IGame.cs +++ b/Online Gokkantoor/Globals/Interfaces/IGame.cs @@ -11,5 +11,6 @@ namespace Globals.Interfaces Ploeg away { get; set; } DateTime date { get; set; } state getWinner(); + } } diff --git a/Online Gokkantoor/Globals/Interfaces/IPloeg.cs b/Online Gokkantoor/Globals/Interfaces/IPloeg.cs index 7ffc8be..59e574a 100644 --- a/Online Gokkantoor/Globals/Interfaces/IPloeg.cs +++ b/Online Gokkantoor/Globals/Interfaces/IPloeg.cs @@ -5,7 +5,10 @@ namespace Globals.Interfaces { int Id { get; set; } string naam { get; set; } - int score { get; set; } + int score { get; } bool scoreSet { get; } + event EventHandler scoreChanged; + void setScore(int i); + int getScore(); } } From 99216fd7fbfe65320d1fe2040703f913d5be8ddd Mon Sep 17 00:00:00 2001 From: Beppe Vanrolleghem Date: Sun, 4 Aug 2019 20:11:16 +0200 Subject: [PATCH 2/3] tmp --- Online Gokkantoor/Gui/Gui.csproj | 45 ++++++++++++++++++++++--- Online Gokkantoor/Online Gokkantoor.sln | 8 ++--- 2 files changed, 45 insertions(+), 8 deletions(-) diff --git a/Online Gokkantoor/Gui/Gui.csproj b/Online Gokkantoor/Gui/Gui.csproj index 05f6a91..44fab2a 100644 --- a/Online Gokkantoor/Gui/Gui.csproj +++ b/Online Gokkantoor/Gui/Gui.csproj @@ -1,4 +1,4 @@ - + Debug @@ -9,6 +9,18 @@ Gui Gui v4.7 + + + + + 4.0 + true + + + + + + true @@ -51,60 +63,70 @@ Default.aspx + ASPXCodeBehind Default.aspx Login.aspx + ASPXCodeBehind Login.aspx mainForm.aspx + ASPXCodeBehind mainForm.aspx Admin.aspx + ASPXCodeBehind Admin.aspx addUser.aspx + ASPXCodeBehind addUser.aspx addBet.aspx + ASPXCodeBehind addBet.aspx addMatch.aspx + ASPXCodeBehind addMatch.aspx addPloeg.aspx + ASPXCodeBehind addPloeg.aspx addBalance.aspx + ASPXCodeBehind addBalance.aspx updateGame.aspx + ASPXCodeBehind updateGame.aspx @@ -120,9 +142,7 @@ Globals - - - + @@ -136,5 +156,22 @@ + + + + True + True + 0 + / + http://localhost:50787/ + False + False + + + False + + + + \ No newline at end of file diff --git a/Online Gokkantoor/Online Gokkantoor.sln b/Online Gokkantoor/Online Gokkantoor.sln index 53db7de..dc973ef 100644 --- a/Online Gokkantoor/Online Gokkantoor.sln +++ b/Online Gokkantoor/Online Gokkantoor.sln @@ -1,8 +1,10 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28010.2026 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29123.88 MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "old", "old", "{BF8F2852-F325-4C72-AFF6-E0C40808625B}" +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Online Gokkantoor_GUI", "Online Gokkantoor\Online Gokkantoor_GUI.csproj", "{62E2ECA5-72AF-4401-9FE3-D7BD5044D7E9}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataLaag", "DataLaag\DataLaag.csproj", "{CA62D8EA-2739-4C85-81B4-FBA040592DAE}" @@ -11,8 +13,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogicLayer", "LogicLayer\Lo EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp", "Console\ConsoleApp.csproj", "{75E1DDD1-C2F0-4C29-A95A-85A72D8C4948}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "old", "old", "{BF8F2852-F325-4C72-AFF6-E0C40808625B}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Data", "Data\Data.csproj", "{46C1FC26-4A1F-43E4-8682-853010AB38AC}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Logic", "Logic\Logic.csproj", "{82F1AF49-F9FA-42A1-BD3B-A37C36E340AD}" From df2a313df65e4325cba0aa6e16eee2414851cf71 Mon Sep 17 00:00:00 2001 From: Beppe Vanrolleghem Date: Sun, 4 Aug 2019 20:19:16 +0200 Subject: [PATCH 3/3] kleine fix --- Online Gokkantoor/Logic/LogicLayer.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Online Gokkantoor/Logic/LogicLayer.cs b/Online Gokkantoor/Logic/LogicLayer.cs index f6a586a..eea9ca0 100644 --- a/Online Gokkantoor/Logic/LogicLayer.cs +++ b/Online Gokkantoor/Logic/LogicLayer.cs @@ -13,7 +13,6 @@ namespace Logic public LogicLayer() { d = new dataLayer(); - persons = d.getPersons(); bets = d.getBets(); ploegen = d.getPloegen(); @@ -76,10 +75,6 @@ namespace Logic public void addGame(Game g) { games.Add(g); - if (true) - { - int i = 0; - } fixIds(); }