From 1aeb309343e34049a345c1359069bfc2ccc6fafb Mon Sep 17 00:00:00 2001 From: Evan Langlais Date: Fri, 31 Mar 2017 13:07:37 -0400 Subject: [PATCH] Fully pulls and draws data in admin panel --- .../StationsGUI/AdminStationView.Designer.cs | 87 +++++++++---------- Enigma/StationsGUI/AdminStationView.cs | 87 +++++++++++++++++-- EnigmaX/Classes/Employee.cs | 11 +++ EnigmaX/Classes/EnigmaMenu.cs | 16 +++- EnigmaX/Classes/EnigmaMenuItem.cs | 13 ++- EnigmaX/Classes/Station.cs | 7 +- 6 files changed, 163 insertions(+), 58 deletions(-) diff --git a/Enigma/StationsGUI/AdminStationView.Designer.cs b/Enigma/StationsGUI/AdminStationView.Designer.cs index 428c43f..656b395 100644 --- a/Enigma/StationsGUI/AdminStationView.Designer.cs +++ b/Enigma/StationsGUI/AdminStationView.Designer.cs @@ -31,7 +31,6 @@ private void InitializeComponent() this.adminTabControl = new MetroFramework.Controls.MetroTabControl(); this.menuTab = new MetroFramework.Controls.MetroTabPage(); this.menuListBox = new System.Windows.Forms.ListBox(); - this.menuSelectionBox = new MetroFramework.Controls.MetroComboBox(); this.menuSaveButton = new MetroFramework.Controls.MetroButton(); this.menuRevertButton = new MetroFramework.Controls.MetroButton(); this.groupBox1 = new System.Windows.Forms.GroupBox(); @@ -44,7 +43,7 @@ private void InitializeComponent() this.metroLabel1 = new MetroFramework.Controls.MetroLabel(); this.itemsTab = new MetroFramework.Controls.MetroTabPage(); this.itemsSaveButton = new MetroFramework.Controls.MetroButton(); - this.itemListBox = new System.Windows.Forms.ListBox(); + this.menuItemListBox = new System.Windows.Forms.ListBox(); this.itemsRevertButton = new MetroFramework.Controls.MetroButton(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.itemPrice = new System.Windows.Forms.NumericUpDown(); @@ -91,6 +90,7 @@ private void InitializeComponent() this.stationRenameButton = new MetroFramework.Controls.MetroButton(); this.stationAddButton = new MetroFramework.Controls.MetroButton(); this.metroLabel3 = new MetroFramework.Controls.MetroLabel(); + this.menuSelectionBox = new System.Windows.Forms.ComboBox(); this.adminTabControl.SuspendLayout(); this.menuTab.SuspendLayout(); this.groupBox1.SuspendLayout(); @@ -123,11 +123,12 @@ private void InitializeComponent() this.adminTabControl.Size = new System.Drawing.Size(1368, 832); this.adminTabControl.TabIndex = 0; this.adminTabControl.UseSelectable = true; + this.adminTabControl.SelectedIndexChanged += new System.EventHandler(this.adminTabControl_SelectedIndexChanged); // // menuTab // - this.menuTab.Controls.Add(this.menuListBox); this.menuTab.Controls.Add(this.menuSelectionBox); + this.menuTab.Controls.Add(this.menuListBox); this.menuTab.Controls.Add(this.menuSaveButton); this.menuTab.Controls.Add(this.menuRevertButton); this.menuTab.Controls.Add(this.groupBox1); @@ -173,18 +174,6 @@ private void InitializeComponent() this.menuListBox.Size = new System.Drawing.Size(696, 650); this.menuListBox.TabIndex = 11; // - // menuSelectionBox - // - this.menuSelectionBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.menuSelectionBox.FormattingEnabled = true; - this.menuSelectionBox.ItemHeight = 23; - this.menuSelectionBox.Location = new System.Drawing.Point(127, 36); - this.menuSelectionBox.Name = "menuSelectionBox"; - this.menuSelectionBox.Size = new System.Drawing.Size(318, 29); - this.menuSelectionBox.TabIndex = 10; - this.menuSelectionBox.UseSelectable = true; - // // menuSaveButton // this.menuSaveButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); @@ -219,7 +208,7 @@ private void InitializeComponent() this.groupBox1.Font = new System.Drawing.Font("Segoe UI Light", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.groupBox1.Location = new System.Drawing.Point(741, 287); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Padding = new System.Windows.Forms.Padding(8, 8, 8, 8); + this.groupBox1.Padding = new System.Windows.Forms.Padding(8); this.groupBox1.Size = new System.Drawing.Size(595, 418); this.groupBox1.TabIndex = 7; this.groupBox1.TabStop = false; @@ -262,7 +251,7 @@ private void InitializeComponent() this.menuGroup1.Font = new System.Drawing.Font("Segoe UI Light", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.menuGroup1.Location = new System.Drawing.Point(741, 63); this.menuGroup1.Name = "menuGroup1"; - this.menuGroup1.Padding = new System.Windows.Forms.Padding(8, 8, 8, 8); + this.menuGroup1.Padding = new System.Windows.Forms.Padding(8); this.menuGroup1.Size = new System.Drawing.Size(595, 218); this.menuGroup1.TabIndex = 6; this.menuGroup1.TabStop = false; @@ -322,7 +311,7 @@ private void InitializeComponent() // itemsTab // this.itemsTab.Controls.Add(this.itemsSaveButton); - this.itemsTab.Controls.Add(this.itemListBox); + this.itemsTab.Controls.Add(this.menuItemListBox); this.itemsTab.Controls.Add(this.itemsRevertButton); this.itemsTab.Controls.Add(this.groupBox2); this.itemsTab.Controls.Add(this.groupBox3); @@ -351,15 +340,15 @@ private void InitializeComponent() this.itemsSaveButton.Text = "Save"; this.itemsSaveButton.UseSelectable = true; // - // itemListBox + // menuItemListBox // - this.itemListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + this.menuItemListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.itemListBox.Font = new System.Drawing.Font("Segoe UI Light", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.itemListBox.FormattingEnabled = true; - this.itemListBox.ItemHeight = 38; - this.itemListBox.Items.AddRange(new object[] { + this.menuItemListBox.Font = new System.Drawing.Font("Segoe UI Light", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.menuItemListBox.FormattingEnabled = true; + this.menuItemListBox.ItemHeight = 38; + this.menuItemListBox.Items.AddRange(new object[] { "Item1", "Item1", "Item1", @@ -378,11 +367,11 @@ private void InitializeComponent() "Item3", "Item3", "Item3"}); - this.itemListBox.Location = new System.Drawing.Point(7, 69); - this.itemListBox.Name = "itemListBox"; - this.itemListBox.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; - this.itemListBox.Size = new System.Drawing.Size(696, 650); - this.itemListBox.TabIndex = 8; + this.menuItemListBox.Location = new System.Drawing.Point(7, 69); + this.menuItemListBox.Name = "menuItemListBox"; + this.menuItemListBox.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; + this.menuItemListBox.Size = new System.Drawing.Size(696, 650); + this.menuItemListBox.TabIndex = 8; // // itemsRevertButton // @@ -412,7 +401,7 @@ private void InitializeComponent() this.groupBox2.Font = new System.Drawing.Font("Segoe UI Light", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.groupBox2.Location = new System.Drawing.Point(741, 237); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Padding = new System.Windows.Forms.Padding(8, 8, 8, 8); + this.groupBox2.Padding = new System.Windows.Forms.Padding(8); this.groupBox2.Size = new System.Drawing.Size(595, 470); this.groupBox2.TabIndex = 12; this.groupBox2.TabStop = false; @@ -436,9 +425,9 @@ private void InitializeComponent() // // this.itemDescriptionTextbox.CustomButton.Image = null; - this.itemDescriptionTextbox.CustomButton.Location = new System.Drawing.Point(227, 1); + this.itemDescriptionTextbox.CustomButton.Location = new System.Drawing.Point(278, 1); this.itemDescriptionTextbox.CustomButton.Name = ""; - this.itemDescriptionTextbox.CustomButton.Size = new System.Drawing.Size(114, 116); + this.itemDescriptionTextbox.CustomButton.Size = new System.Drawing.Size(139, 139); this.itemDescriptionTextbox.CustomButton.Style = MetroFramework.MetroColorStyle.Blue; this.itemDescriptionTextbox.CustomButton.TabIndex = 1; this.itemDescriptionTextbox.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light; @@ -540,7 +529,7 @@ private void InitializeComponent() this.groupBox3.Font = new System.Drawing.Font("Segoe UI Light", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.groupBox3.Location = new System.Drawing.Point(741, 63); this.groupBox3.Name = "groupBox3"; - this.groupBox3.Padding = new System.Windows.Forms.Padding(8, 8, 8, 8); + this.groupBox3.Padding = new System.Windows.Forms.Padding(8); this.groupBox3.Size = new System.Drawing.Size(595, 168); this.groupBox3.TabIndex = 11; this.groupBox3.TabStop = false; @@ -692,7 +681,7 @@ private void InitializeComponent() this.groupBox6.Font = new System.Drawing.Font("Segoe UI Light", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.groupBox6.Location = new System.Drawing.Point(741, 287); this.groupBox6.Name = "groupBox6"; - this.groupBox6.Padding = new System.Windows.Forms.Padding(8, 8, 8, 8); + this.groupBox6.Padding = new System.Windows.Forms.Padding(8); this.groupBox6.Size = new System.Drawing.Size(595, 418); this.groupBox6.TabIndex = 19; this.groupBox6.TabStop = false; @@ -706,9 +695,9 @@ private void InitializeComponent() // // this.lastNameTextBox.CustomButton.Image = null; - this.lastNameTextBox.CustomButton.Location = new System.Drawing.Point(314, 2); + this.lastNameTextBox.CustomButton.Location = new System.Drawing.Point(384, 2); this.lastNameTextBox.CustomButton.Name = ""; - this.lastNameTextBox.CustomButton.Size = new System.Drawing.Size(25, 26); + this.lastNameTextBox.CustomButton.Size = new System.Drawing.Size(31, 31); this.lastNameTextBox.CustomButton.Style = MetroFramework.MetroColorStyle.Blue; this.lastNameTextBox.CustomButton.TabIndex = 1; this.lastNameTextBox.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light; @@ -750,9 +739,9 @@ private void InitializeComponent() // // this.firstNameTextBox.CustomButton.Image = null; - this.firstNameTextBox.CustomButton.Location = new System.Drawing.Point(314, 2); + this.firstNameTextBox.CustomButton.Location = new System.Drawing.Point(384, 2); this.firstNameTextBox.CustomButton.Name = ""; - this.firstNameTextBox.CustomButton.Size = new System.Drawing.Size(25, 26); + this.firstNameTextBox.CustomButton.Size = new System.Drawing.Size(31, 31); this.firstNameTextBox.CustomButton.Style = MetroFramework.MetroColorStyle.Blue; this.firstNameTextBox.CustomButton.TabIndex = 1; this.firstNameTextBox.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light; @@ -808,9 +797,9 @@ private void InitializeComponent() // // this.usernameTextBox.CustomButton.Image = null; - this.usernameTextBox.CustomButton.Location = new System.Drawing.Point(314, 2); + this.usernameTextBox.CustomButton.Location = new System.Drawing.Point(384, 2); this.usernameTextBox.CustomButton.Name = ""; - this.usernameTextBox.CustomButton.Size = new System.Drawing.Size(25, 26); + this.usernameTextBox.CustomButton.Size = new System.Drawing.Size(31, 31); this.usernameTextBox.CustomButton.Style = MetroFramework.MetroColorStyle.Blue; this.usernameTextBox.CustomButton.TabIndex = 1; this.usernameTextBox.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light; @@ -887,7 +876,7 @@ private void InitializeComponent() this.groupBox7.Font = new System.Drawing.Font("Segoe UI Light", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.groupBox7.Location = new System.Drawing.Point(741, 63); this.groupBox7.Name = "groupBox7"; - this.groupBox7.Padding = new System.Windows.Forms.Padding(8, 8, 8, 8); + this.groupBox7.Padding = new System.Windows.Forms.Padding(8); this.groupBox7.Size = new System.Drawing.Size(595, 218); this.groupBox7.TabIndex = 18; this.groupBox7.TabStop = false; @@ -1018,7 +1007,7 @@ private void InitializeComponent() this.groupBox4.Font = new System.Drawing.Font("Segoe UI Light", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.groupBox4.Location = new System.Drawing.Point(741, 287); this.groupBox4.Name = "groupBox4"; - this.groupBox4.Padding = new System.Windows.Forms.Padding(8, 8, 8, 8); + this.groupBox4.Padding = new System.Windows.Forms.Padding(8); this.groupBox4.Size = new System.Drawing.Size(595, 418); this.groupBox4.TabIndex = 13; this.groupBox4.TabStop = false; @@ -1060,7 +1049,7 @@ private void InitializeComponent() this.groupBox5.Font = new System.Drawing.Font("Segoe UI Light", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.groupBox5.Location = new System.Drawing.Point(741, 63); this.groupBox5.Name = "groupBox5"; - this.groupBox5.Padding = new System.Windows.Forms.Padding(8, 8, 8, 8); + this.groupBox5.Padding = new System.Windows.Forms.Padding(8); this.groupBox5.Size = new System.Drawing.Size(595, 218); this.groupBox5.TabIndex = 12; this.groupBox5.TabStop = false; @@ -1117,6 +1106,14 @@ private void InitializeComponent() this.metroLabel3.Text = "Select Stations"; this.metroLabel3.TextAlign = System.Drawing.ContentAlignment.BottomLeft; // + // menuSelectionBox + // + this.menuSelectionBox.FormattingEnabled = true; + this.menuSelectionBox.Location = new System.Drawing.Point(169, 35); + this.menuSelectionBox.Name = "menuSelectionBox"; + this.menuSelectionBox.Size = new System.Drawing.Size(355, 28); + this.menuSelectionBox.TabIndex = 12; + // // AdminStationView // this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); @@ -1159,7 +1156,7 @@ private void InitializeComponent() private System.Windows.Forms.ListBox displayedOnDevices; private System.Windows.Forms.Label label1; private MetroFramework.Controls.MetroTabPage stationTab; - private System.Windows.Forms.ListBox itemListBox; + private System.Windows.Forms.ListBox menuItemListBox; private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.Label label2; private System.Windows.Forms.ListBox categoryListBox; @@ -1207,7 +1204,7 @@ private void InitializeComponent() private MetroFramework.Controls.MetroTextBox usernameTextBox; private System.Windows.Forms.Label pin; private System.Windows.Forms.Label label9; - private MetroFramework.Controls.MetroComboBox menuSelectionBox; private System.Windows.Forms.ListBox menuListBox; + private System.Windows.Forms.ComboBox menuSelectionBox; } } \ No newline at end of file diff --git a/Enigma/StationsGUI/AdminStationView.cs b/Enigma/StationsGUI/AdminStationView.cs index c1e2cc7..76afca5 100644 --- a/Enigma/StationsGUI/AdminStationView.cs +++ b/Enigma/StationsGUI/AdminStationView.cs @@ -17,10 +17,10 @@ namespace Enigma.StationsGUI public partial class AdminStationView : MetroForm { Employee loggedIn; - List menuItems = new List(); + List enigmaMenuItems = new List(); List enigmaMenus = new List(); - List employees = new List(); - List stations = new List(); + List enigmaEmployees = new List(); + List enigmaStations = new List(); public AdminStationView(Employee loggedIn) { @@ -30,7 +30,8 @@ public AdminStationView(Employee loggedIn) private void AdminStationView_Load(object sender, EventArgs e) { - + loadAllData(); + drawAllData(); } private void loadAllData() { @@ -40,6 +41,54 @@ private void loadAllData() { loadEmployees(); } + private void drawAllData() + { + drawMenus(); + drawMenuItems(); + drawStations(); + drawEmployees(); + } + + private void drawMenus() { + menuSelectionBox.Items.Clear(); + menuListBox.Items.Clear(); + foreach (EnigmaMenu menu in enigmaMenus) + { + menuSelectionBox.Items.Add(menu); + foreach (EnigmaMenuItem item in menu.Items) { + menuListBox.Items.Add(item); + } + + } + } + + private void drawMenuItems() + { + menuItemListBox.Items.Clear(); + foreach (EnigmaMenuItem item in enigmaMenuItems) + { + menuItemListBox.Items.Add(item); + } + } + + private void drawStations() + { + stationListBox.Items.Clear(); + foreach (Station station in enigmaStations) + { + stationListBox.Items.Add(station); + } + } + + private void drawEmployees() + { + employeeListBox.Items.Clear(); + foreach (Employee employee in enigmaEmployees) + { + employeeListBox.Items.Add(employee); + } + } + private void loadMenus() { DBConnect db = new DBConnect(); List> menus = db.ReadCommand("SELECT * FROM Menus", "id", "title", "items"); @@ -51,18 +100,42 @@ private void loadMenus() { private void loadMenuItems() { - + DBConnect db = new DBConnect(); + List> result = db.ReadCommand("SELECT * FROM MenuItems", "id", "title", "description", "price", "category", "printingStation"); + foreach (Dictionary row in result) + { + EnigmaMenuItem menuItem = new EnigmaMenuItem(Convert.ToInt32(row["id"]), row["title"], row["description"], float.Parse(row["price"]), (MenuItemType)Enum.Parse(typeof(MenuItemType), row["category"]), (PrintingStationType)Enum.Parse(typeof(PrintingStationType), row["printingStation"])); + enigmaMenuItems.Add(menuItem); + } } private void loadEmployees() { - + DBConnect db = new DBConnect(); + List> employees = db.ReadCommand("SELECT * FROM Users", "id", "username", "first", "last", "role", "pin"); + foreach (Dictionary row in employees) + { + Employee employee = new Employee(Convert.ToInt32(row["id"]), row["username"], row["first"], row["last"], Employee.getRoles(row["role"]), Convert.ToInt32(row["pin"])); + enigmaEmployees.Add(employee); + } } private void loadStations() { - + DBConnect db = new DBConnect(); + List> result = db.ReadCommand("SELECT * FROM Stations", "stationid", "type"); + foreach (Dictionary row in result) + { + Station station = new Station((StationTypeDef)Enum.Parse(typeof(StationTypeDef), row["type"]), row["stationid"]); + enigmaStations.Add(station); + } } + private void adminTabControl_SelectedIndexChanged(object sender, EventArgs e) + { + switch (e.ToString()) { + + } + } } } diff --git a/EnigmaX/Classes/Employee.cs b/EnigmaX/Classes/Employee.cs index dc2afbb..7ebd3bc 100644 --- a/EnigmaX/Classes/Employee.cs +++ b/EnigmaX/Classes/Employee.cs @@ -26,6 +26,12 @@ public Employee(int id, string username, string first, string last, List Items { get @@ -40,10 +47,6 @@ public List Items } } - public void updateMenuInDB() { - - } - public static List stringToItemList(string items) { List itemList = new List(); foreach (string item in items.Split('|')) { @@ -52,5 +55,10 @@ public static List stringToItemList(string items) { return itemList; } + public override string ToString() + { + return _id + ": " + _title; + } + } } diff --git a/EnigmaX/Classes/EnigmaMenuItem.cs b/EnigmaX/Classes/EnigmaMenuItem.cs index 131cb76..ae6ee7a 100644 --- a/EnigmaX/Classes/EnigmaMenuItem.cs +++ b/EnigmaX/Classes/EnigmaMenuItem.cs @@ -8,7 +8,7 @@ namespace EnigmaX.Classes { - public enum MenuItemType { appitizer, entre, dessert, drink, other }; + public enum MenuItemType { appetizer, entre, dessert, drink, other }; public enum PrintingStationType { hot, cold }; public class EnigmaMenuItem @@ -30,6 +30,13 @@ public EnigmaMenuItem(int id, string title, string description, float price, Men _printingType = printingType; } + public int Id { + get + { + return _id; + } + } + public string Title { get { return _title; @@ -54,6 +61,10 @@ public static EnigmaMenuItem idToMenuItem(int id) return null; } } + + public override string ToString() { + return _id + ": " + _title; + } } } diff --git a/EnigmaX/Classes/Station.cs b/EnigmaX/Classes/Station.cs index 4e3299d..13070ba 100644 --- a/EnigmaX/Classes/Station.cs +++ b/EnigmaX/Classes/Station.cs @@ -8,7 +8,7 @@ namespace EnigmaX.Classes { public enum StationTypeDef { chef, waiter, admin, host }; - public abstract class Station + public class Station { private string _stationId = ""; private StationTypeDef _stationType; @@ -63,6 +63,11 @@ public virtual void showView() { } } + public override string ToString() + { + return _stationType + ": " +_stationId; + } + }