This commit is contained in:
Michiel.VanDorpe
2019-08-04 20:45:49 +02:00
8 changed files with 113 additions and 29 deletions

View File

@@ -21,7 +21,7 @@ namespace Data
List<Bet> list = new List<Bet>(); List<Bet> list = new List<Bet>();
try try
{ {
using (StreamReader file = File.OpenText(@"Data/bets.json")) using (StreamReader file = File.OpenText(@"../../Data/bets.json"))
{ {
JsonSerializer serializer = new JsonSerializer(); JsonSerializer serializer = new JsonSerializer();
@@ -42,7 +42,7 @@ namespace Data
try try
{ {
using (StreamReader file = File.OpenText(@"Data/games.json")) using (StreamReader file = File.OpenText(@"../../Data/games.json"))
{ {
JsonSerializer serializer = new JsonSerializer(); JsonSerializer serializer = new JsonSerializer();
list = (List<Game>)serializer.Deserialize(file, typeof(List<Game>)); list = (List<Game>)serializer.Deserialize(file, typeof(List<Game>));
@@ -61,7 +61,7 @@ namespace Data
List<Person> list = new List<Person>(); List<Person> list = new List<Person>();
try { try {
using (StreamReader file = File.OpenText(@"Data/persons.json")) using (StreamReader file = File.OpenText(@"../../Data/persons.json"))
{ {
JsonSerializer serializer = new JsonSerializer(); JsonSerializer serializer = new JsonSerializer();
list = (List<Person>)serializer.Deserialize(file, typeof(List<Person>)); list = (List<Person>)serializer.Deserialize(file, typeof(List<Person>));
@@ -80,7 +80,7 @@ namespace Data
List<Ploeg> list = new List<Ploeg>(); List<Ploeg> list = new List<Ploeg>();
try try
{ {
using (StreamReader file = File.OpenText(@"Data/ploegen.json")) using (StreamReader file = File.OpenText(@"../../Data/ploegen.json"))
{ {
JsonSerializer serializer = new JsonSerializer(); JsonSerializer serializer = new JsonSerializer();
list = (List<Ploeg>)serializer.Deserialize(file, typeof(List<Ploeg>)); list = (List<Ploeg>)serializer.Deserialize(file, typeof(List<Ploeg>));
@@ -96,7 +96,7 @@ namespace Data
public void saveBets(List<Bet> b) public void saveBets(List<Bet> b)
{ {
using (StreamWriter file = File.CreateText(@"Data/bets.json")) using (StreamWriter file = File.CreateText(@"../../Data/bets.json"))
{ {
JsonSerializer serializer = new JsonSerializer(); JsonSerializer serializer = new JsonSerializer();
serializer.Serialize(file, b); serializer.Serialize(file, b);
@@ -105,7 +105,7 @@ namespace Data
public void saveGames(List<Game> g) public void saveGames(List<Game> g)
{ {
using (StreamWriter file = File.CreateText(@"Data/games.json")) using (StreamWriter file = File.CreateText(@"../../Data/games.json"))
{ {
JsonSerializer serializer = new JsonSerializer(); JsonSerializer serializer = new JsonSerializer();
serializer.Serialize(file, g); serializer.Serialize(file, g);
@@ -114,7 +114,7 @@ namespace Data
public void savePersons(List<Person> p) public void savePersons(List<Person> p)
{ {
using (StreamWriter file = File.CreateText(@"Data/persons.json")) using (StreamWriter file = File.CreateText(@"../../Data/persons.json"))
{ {
JsonSerializer serializer = new JsonSerializer(); JsonSerializer serializer = new JsonSerializer();
serializer.Serialize(file, p); serializer.Serialize(file, p);
@@ -123,7 +123,7 @@ namespace Data
public void savePloegen(List<Ploeg> p) public void savePloegen(List<Ploeg> p)
{ {
using (StreamWriter file = File.CreateText(@"Data/ploegen.json")) using (StreamWriter file = File.CreateText(@"../../Data/ploegen.json"))
{ {
JsonSerializer serializer = new JsonSerializer(); JsonSerializer serializer = new JsonSerializer();
serializer.Serialize(file, p); serializer.Serialize(file, p);

View File

@@ -11,38 +11,62 @@ namespace Globals.classes
[JsonConstructor] [JsonConstructor]
public Game(int Id, Ploeg home, Ploeg away, DateTime date) public Game(int Id, Ploeg home, Ploeg away, DateTime date)
{ {
homeSetBool = false;
awaySetBool = false;
this.Id = Id; this.Id = Id;
this.home = home; this.home = home;
this.away = away; this.away = away;
this.home.scoreChanged += homeSet;
this.away.scoreChanged += awaySet;
this.date = date; this.date = date;
} }
public Game(Ploeg home, Ploeg away, DateTime d) public Game(Ploeg home, Ploeg away, DateTime d)
{ {
homeSetBool = false;
awaySetBool = false;
this.home = home; this.home = home;
this.away = away; this.away = away;
this.home.scoreChanged += homeSet;
this.away.scoreChanged += awaySet;
this.date = d; this.date = d;
} }
public Game(Ploeg home, Ploeg away, DateTime d, int scoreHome, int scoreAway) public Game(Ploeg home, Ploeg away, DateTime d, int scoreHome, int scoreAway)
{ {
homeSetBool = false;
awaySetBool = false;
this.home = home; this.home = home;
this.away = away; this.away = away;
this.home.score = scoreHome; this.home.scoreChanged += homeSet;
this.away.score = scoreAway; this.away.scoreChanged += awaySet;
this.home.setScore(scoreHome);
this.away.setScore(scoreAway);
this.date = d; this.date = d;
} }
public Game(int id, Ploeg home, Ploeg away) public Game(int id, Ploeg home, Ploeg away)
{ {
homeSetBool = false;
awaySetBool = false;
Id = id; Id = id;
this.home = home ?? throw new ArgumentNullException(nameof(home)); this.home = home ?? throw new ArgumentNullException(nameof(home));
this.away = away ?? throw new ArgumentNullException(nameof(away)); 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) public Game(int id, Ploeg home, Ploeg away, int scoreHome, int scoreAway)
{ {
homeSetBool = false;
awaySetBool = false;
Id = id; Id = id;
this.home = home ?? throw new ArgumentNullException(nameof(home)); this.home = home ?? throw new ArgumentNullException(nameof(home));
this.away = away ?? throw new ArgumentNullException(nameof(away)); this.away = away ?? throw new ArgumentNullException(nameof(away));
this.home.score = scoreHome; this.home.scoreChanged += homeSet;
this.away.score = scoreAway; this.away.scoreChanged += awaySet;
this.home.setScore(scoreHome);
this.away.setScore(scoreAway);
} }
[JsonProperty("id")] [JsonProperty("id")]
public int Id { get; set; } public int Id { get; set; }
@@ -53,6 +77,18 @@ namespace Globals.classes
[JsonProperty("Date")] [JsonProperty("Date")]
public DateTime date { get; set; } //y m d 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() public state getWinner()
{ {
if (!this.home.scoreSet || !this.away.scoreSet) if (!this.home.scoreSet || !this.away.scoreSet)

View File

@@ -34,9 +34,11 @@ namespace Globals.classes
public int Id { get; set; } public int Id { get; set; }
public string naam { get; set; } public string naam { get; set; }
public int score { get; set; } public int score { get; private set; }
public bool scoreSet { get => this.score != int.MinValue; } public bool scoreSet { get; }
public event EventHandler scoreChanged;
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
try try
@@ -66,5 +68,15 @@ namespace Globals.classes
return this.Id + ": " + this.naam + score; 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;
}
} }
} }

View File

@@ -11,5 +11,6 @@ namespace Globals.Interfaces
Ploeg away { get; set; } Ploeg away { get; set; }
DateTime date { get; set; } DateTime date { get; set; }
state getWinner(); state getWinner();
} }
} }

View File

@@ -5,7 +5,10 @@ namespace Globals.Interfaces
{ {
int Id { get; set; } int Id { get; set; }
string naam { get; set; } string naam { get; set; }
int score { get; set; } int score { get; }
bool scoreSet { get; } bool scoreSet { get; }
event EventHandler scoreChanged;
void setScore(int i);
int getScore();
} }
} }

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -9,6 +9,18 @@
<RootNamespace>Gui</RootNamespace> <RootNamespace>Gui</RootNamespace>
<AssemblyName>Gui</AssemblyName> <AssemblyName>Gui</AssemblyName>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>4.0</OldToolsVersion>
<UseIISExpress>true</UseIISExpress>
<Use64BitIISExpress />
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<UseGlobalApplicationHostFile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@@ -51,60 +63,70 @@
</Compile> </Compile>
<Compile Include="Default.aspx.cs"> <Compile Include="Default.aspx.cs">
<DependentUpon>Default.aspx</DependentUpon> <DependentUpon>Default.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile> </Compile>
<Compile Include="Default.aspx.designer.cs"> <Compile Include="Default.aspx.designer.cs">
<DependentUpon>Default.aspx</DependentUpon> <DependentUpon>Default.aspx</DependentUpon>
</Compile> </Compile>
<Compile Include="Login.aspx.cs"> <Compile Include="Login.aspx.cs">
<DependentUpon>Login.aspx</DependentUpon> <DependentUpon>Login.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile> </Compile>
<Compile Include="Login.aspx.designer.cs"> <Compile Include="Login.aspx.designer.cs">
<DependentUpon>Login.aspx</DependentUpon> <DependentUpon>Login.aspx</DependentUpon>
</Compile> </Compile>
<Compile Include="mainForm.aspx.cs"> <Compile Include="mainForm.aspx.cs">
<DependentUpon>mainForm.aspx</DependentUpon> <DependentUpon>mainForm.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile> </Compile>
<Compile Include="mainForm.aspx.designer.cs"> <Compile Include="mainForm.aspx.designer.cs">
<DependentUpon>mainForm.aspx</DependentUpon> <DependentUpon>mainForm.aspx</DependentUpon>
</Compile> </Compile>
<Compile Include="Admin.aspx.cs"> <Compile Include="Admin.aspx.cs">
<DependentUpon>Admin.aspx</DependentUpon> <DependentUpon>Admin.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile> </Compile>
<Compile Include="Admin.aspx.designer.cs"> <Compile Include="Admin.aspx.designer.cs">
<DependentUpon>Admin.aspx</DependentUpon> <DependentUpon>Admin.aspx</DependentUpon>
</Compile> </Compile>
<Compile Include="addUser.aspx.cs"> <Compile Include="addUser.aspx.cs">
<DependentUpon>addUser.aspx</DependentUpon> <DependentUpon>addUser.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile> </Compile>
<Compile Include="addUser.aspx.designer.cs"> <Compile Include="addUser.aspx.designer.cs">
<DependentUpon>addUser.aspx</DependentUpon> <DependentUpon>addUser.aspx</DependentUpon>
</Compile> </Compile>
<Compile Include="addBet.aspx.cs"> <Compile Include="addBet.aspx.cs">
<DependentUpon>addBet.aspx</DependentUpon> <DependentUpon>addBet.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile> </Compile>
<Compile Include="addBet.aspx.designer.cs"> <Compile Include="addBet.aspx.designer.cs">
<DependentUpon>addBet.aspx</DependentUpon> <DependentUpon>addBet.aspx</DependentUpon>
</Compile> </Compile>
<Compile Include="addMatch.aspx.cs"> <Compile Include="addMatch.aspx.cs">
<DependentUpon>addMatch.aspx</DependentUpon> <DependentUpon>addMatch.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile> </Compile>
<Compile Include="addMatch.aspx.designer.cs"> <Compile Include="addMatch.aspx.designer.cs">
<DependentUpon>addMatch.aspx</DependentUpon> <DependentUpon>addMatch.aspx</DependentUpon>
</Compile> </Compile>
<Compile Include="addPloeg.aspx.cs"> <Compile Include="addPloeg.aspx.cs">
<DependentUpon>addPloeg.aspx</DependentUpon> <DependentUpon>addPloeg.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile> </Compile>
<Compile Include="addPloeg.aspx.designer.cs"> <Compile Include="addPloeg.aspx.designer.cs">
<DependentUpon>addPloeg.aspx</DependentUpon> <DependentUpon>addPloeg.aspx</DependentUpon>
</Compile> </Compile>
<Compile Include="addBalance.aspx.cs"> <Compile Include="addBalance.aspx.cs">
<DependentUpon>addBalance.aspx</DependentUpon> <DependentUpon>addBalance.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile> </Compile>
<Compile Include="addBalance.aspx.designer.cs"> <Compile Include="addBalance.aspx.designer.cs">
<DependentUpon>addBalance.aspx</DependentUpon> <DependentUpon>addBalance.aspx</DependentUpon>
</Compile> </Compile>
<Compile Include="updateGame.aspx.cs"> <Compile Include="updateGame.aspx.cs">
<DependentUpon>updateGame.aspx</DependentUpon> <DependentUpon>updateGame.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile> </Compile>
<Compile Include="updateGame.aspx.designer.cs"> <Compile Include="updateGame.aspx.designer.cs">
<DependentUpon>updateGame.aspx</DependentUpon> <DependentUpon>updateGame.aspx</DependentUpon>
@@ -120,9 +142,7 @@
<Name>Globals</Name> <Name>Globals</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup />
<Folder Include="Data\" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Data\persons.json" /> <None Include="Data\persons.json" />
<None Include="Data\bets.json" /> <None Include="Data\bets.json" />
@@ -136,5 +156,22 @@
<XspParameters Port="8080" Address="127.0.0.1" SslMode="None" SslProtocol="Default" KeyType="None" CertFile="" KeyFile="" PasswordOptions="None" Password="" Verbose="True" /> <XspParameters Port="8080" Address="127.0.0.1" SslMode="None" SslProtocol="Default" KeyType="None" CertFile="" KeyFile="" PasswordOptions="None" Password="" Verbose="True" />
</Properties> </Properties>
</MonoDevelop> </MonoDevelop>
<VisualStudio>
<FlavorProperties GUID="{349C5851-65DF-11DA-9384-00065B846F21}">
<WebProjectProperties>
<UseIIS>True</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>0</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:50787/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions> </ProjectExtensions>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" />
</Project> </Project>

View File

@@ -13,7 +13,6 @@ namespace Logic
public LogicLayer() public LogicLayer()
{ {
d = new dataLayer(); d = new dataLayer();
persons = d.getPersons(); persons = d.getPersons();
bets = d.getBets(); bets = d.getBets();
ploegen = d.getPloegen(); ploegen = d.getPloegen();
@@ -76,10 +75,6 @@ namespace Logic
public void addGame(Game g) public void addGame(Game g)
{ {
games.Add(g); games.Add(g);
if (true)
{
int i = 0;
}
fixIds(); fixIds();
} }

View File

@@ -1,8 +1,10 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15 # Visual Studio Version 16
VisualStudioVersion = 15.0.28010.2026 VisualStudioVersion = 16.0.29123.88
MinimumVisualStudioVersion = 10.0.40219.1 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}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Online Gokkantoor_GUI", "Online Gokkantoor\Online Gokkantoor_GUI.csproj", "{62E2ECA5-72AF-4401-9FE3-D7BD5044D7E9}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataLaag", "DataLaag\DataLaag.csproj", "{CA62D8EA-2739-4C85-81B4-FBA040592DAE}" 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 EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp", "Console\ConsoleApp.csproj", "{75E1DDD1-C2F0-4C29-A95A-85A72D8C4948}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp", "Console\ConsoleApp.csproj", "{75E1DDD1-C2F0-4C29-A95A-85A72D8C4948}"
EndProject 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}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Data", "Data\Data.csproj", "{46C1FC26-4A1F-43E4-8682-853010AB38AC}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Logic", "Logic\Logic.csproj", "{82F1AF49-F9FA-42A1-BD3B-A37C36E340AD}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Logic", "Logic\Logic.csproj", "{82F1AF49-F9FA-42A1-BD3B-A37C36E340AD}"