diff --git a/Enigma/Enigma.csproj b/Enigma/Enigma.csproj index 79fa64d..fd6dc55 100644 --- a/Enigma/Enigma.csproj +++ b/Enigma/Enigma.csproj @@ -82,12 +82,6 @@ HostStationView.cs - - Form - - - PinScreen.cs - Form @@ -116,9 +110,6 @@ HostStationView.cs - - PinScreen.cs - WaiterStationView.cs diff --git a/Enigma/EnigmaMain.cs b/Enigma/EnigmaMain.cs index 293ae2b..a9c300f 100644 --- a/Enigma/EnigmaMain.cs +++ b/Enigma/EnigmaMain.cs @@ -11,6 +11,7 @@ using Enigma.Stations; using EnigmaX.Classes; using Enigma.StationsGUI; +using EnigmaX.GUI; namespace Enigma { @@ -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(); } } diff --git a/Enigma/Stations/HostStation.cs b/Enigma/Stations/HostStation.cs index c4ed512..ffa5a30 100644 --- a/Enigma/Stations/HostStation.cs +++ b/Enigma/Stations/HostStation.cs @@ -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(); } diff --git a/EnigmaX/Classes/Employee.cs b/EnigmaX/Classes/Employee.cs new file mode 100644 index 0000000..dc2afbb --- /dev/null +++ b/EnigmaX/Classes/Employee.cs @@ -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 _roles; + private int _pin; + + public Employee(int id, string username, string first, string last, List 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> 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 getRoles(string roles) { + List roleslist = new List(); + 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); + } + + } +} diff --git a/EnigmaX/Classes/SystemFunctions.cs b/EnigmaX/Classes/SystemFunctions.cs new file mode 100644 index 0000000..66160c9 --- /dev/null +++ b/EnigmaX/Classes/SystemFunctions.cs @@ -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; + } + } + + } +} diff --git a/EnigmaX/Classes/XMessageBox.cs b/EnigmaX/Classes/XMessageBox.cs index 4f5e370..f853deb 100644 --- a/EnigmaX/Classes/XMessageBox.cs +++ b/EnigmaX/Classes/XMessageBox.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using EnigmaX.GUI; namespace EnigmaX.Classes { diff --git a/EnigmaX/EnigmaX.csproj b/EnigmaX/EnigmaX.csproj index 4abf994..266d33a 100644 --- a/EnigmaX/EnigmaX.csproj +++ b/EnigmaX/EnigmaX.csproj @@ -59,26 +59,52 @@ + + + + Form + + + PinScreen.cs + - + Form - + XMessageBoxForm.cs + + True + True + Resources.resx + - + + PinScreen.cs + + XMessageBoxForm.cs + + ResXFileCodeGenerator + Resources.Designer.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\background-cool-13.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\gradient-background-26046-26731-hd-wallpapers.jpg.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/EnigmaX/Resources/background-cool-13.jpg b/EnigmaX/Resources/background-cool-13.jpg new file mode 100644 index 0000000..0bb25c0 Binary files /dev/null and b/EnigmaX/Resources/background-cool-13.jpg differ diff --git a/EnigmaX/Resources/gradient-background-26046-26731-hd-wallpapers.jpg.png b/EnigmaX/Resources/gradient-background-26046-26731-hd-wallpapers.jpg.png new file mode 100644 index 0000000..c26e80b Binary files /dev/null and b/EnigmaX/Resources/gradient-background-26046-26731-hd-wallpapers.jpg.png differ