-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated pinscreen gui, migrated pinscreen to EnigmaX, fixed depency i…
…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
Showing
17 changed files
with
474 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.