Skip to content

Commit

Permalink
Updated pinscreen gui, migrated pinscreen to EnigmaX, fixed depency i…
Browse files Browse the repository at this point in the history
…ssues, created system function to enforce pinscreen and employee permission roles.
  • Loading branch information
Evan Langlais authored and Evan Langlais committed Mar 24, 2017
1 parent 62765a7 commit 595cd04
Show file tree
Hide file tree
Showing 17 changed files with 474 additions and 98 deletions.
9 changes: 0 additions & 9 deletions Enigma/Enigma.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@
<Compile Include="StationsGUI\HostStationView.Designer.cs">
<DependentUpon>HostStationView.cs</DependentUpon>
</Compile>
<Compile Include="StationsGUI\PinScreen.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="StationsGUI\PinScreen.Designer.cs">
<DependentUpon>PinScreen.cs</DependentUpon>
</Compile>
<Compile Include="StationsGUI\WaiterStationView.cs">
<SubType>Form</SubType>
</Compile>
Expand Down Expand Up @@ -116,9 +110,6 @@
<EmbeddedResource Include="StationsGUI\HostStationView.resx">
<DependentUpon>HostStationView.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="StationsGUI\PinScreen.resx">
<DependentUpon>PinScreen.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="StationsGUI\WaiterStationView.resx">
<DependentUpon>WaiterStationView.cs</DependentUpon>
</EmbeddedResource>
Expand Down
3 changes: 2 additions & 1 deletion Enigma/EnigmaMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Enigma.Stations;
using EnigmaX.Classes;
using Enigma.StationsGUI;
using EnigmaX.GUI;

namespace Enigma
{
Expand Down Expand Up @@ -62,7 +63,7 @@ private void debugButton_Click(object sender, EventArgs e)

private void metroButton1_Click(object sender, EventArgs e)
{
PinScreen pinScreen = new PinScreen();
PinScreen pinScreen = new PinScreen(EmployeeRole.waiter);
pinScreen.ShowDialog();
}
}
Expand Down
1 change: 1 addition & 0 deletions Enigma/Stations/HostStation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class HostStation : Station
{
public HostStation(string stationid) : base(StationTypeDef.host, stationid)
{
Employee activeEmployee = SystemFunctions.showPinScreenUntilAuthenticated(EmployeeRole.host);
view = new StationsGUI.HostStationView();

}
Expand Down
61 changes: 61 additions & 0 deletions EnigmaX/Classes/Employee.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EnigmaX.Classes
{
public enum EmployeeRole { waiter, chef, admin, host};
public class Employee
{

private int _id;
private string _username;
private string _first;
private string _last;
private List<EmployeeRole> _roles;
private int _pin;

public Employee(int id, string username, string first, string last, List<EmployeeRole> roles, int pin) {
_id = id;
_username = username;
_first = first;
_last = last;
_roles = roles;
_pin = pin;
}

public static Employee getEmployeeWithPin(string pin)
{

if (pin.Length != 4)
{
return null;
}

DBConnect db = new DBConnect();
List<Dictionary<string, string>> result = db.ReadCommand("SELECT * FROM Users WHERE pin='" + pin + "' LIMIT 1", "id", "username", "first", "last", "role");
if (result.Count == 1)
{
return new Employee(Convert.ToInt32(result[0]["id"]), result[0]["username"], result[0]["first"], result[0]["last"], getRoles(result[0]["role"]), Convert.ToInt32(pin));
}
else {
return null;
}
}

public static List<EmployeeRole> getRoles(string roles) {
List<EmployeeRole> roleslist = new List<EmployeeRole>();
foreach (string role in roles.Split(',')) {
roleslist.Add((EmployeeRole)Enum.Parse(typeof(EmployeeRole), role));
}
return roleslist;
}

public bool hasRole(EmployeeRole role) {
return _roles.Contains(role);
}

}
}
27 changes: 27 additions & 0 deletions EnigmaX/Classes/SystemFunctions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using EnigmaX.GUI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace EnigmaX.Classes
{
public class SystemFunctions
{

public static Employee showPinScreenUntilAuthenticated(EmployeeRole role)
{
PinScreen backgroundPinScreen = new PinScreen(role);
if (backgroundPinScreen.ShowDialog() == DialogResult.OK)
{
return backgroundPinScreen.enteredEmployee;
}
else {
return null;
}
}

}
}
1 change: 1 addition & 0 deletions EnigmaX/Classes/XMessageBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EnigmaX.GUI;

namespace EnigmaX.Classes
{
Expand Down
32 changes: 29 additions & 3 deletions EnigmaX/EnigmaX.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,52 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Classes\DBConnect.cs" />
<Compile Include="Classes\Employee.cs" />
<Compile Include="Classes\ICMessage.cs" />
<Compile Include="Classes\Intercom.cs" />
<Compile Include="Classes\Station.cs" />
<Compile Include="Classes\SystemFunctions.cs" />
<Compile Include="Classes\XMessageBox.cs" />
<Compile Include="GUI\PinScreen.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="GUI\PinScreen.Designer.cs">
<DependentUpon>PinScreen.cs</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Forms\XMessageBoxForm.cs">
<Compile Include="GUI\XMessageBoxForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\XMessageBoxForm.Designer.cs">
<Compile Include="GUI\XMessageBoxForm.Designer.cs">
<DependentUpon>XMessageBoxForm.cs</DependentUpon>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Forms\XMessageBoxForm.resx">
<EmbeddedResource Include="GUI\PinScreen.resx">
<DependentUpon>PinScreen.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\XMessageBoxForm.resx">
<DependentUpon>XMessageBoxForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="Resources\background-cool-13.jpg" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\gradient-background-26046-26731-hd-wallpapers.jpg.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
Loading

0 comments on commit 595cd04

Please sign in to comment.