From 07b292f1f727f2722b987860da0d34329882348f Mon Sep 17 00:00:00 2001 From: "RKant\\TEST" Date: Mon, 6 Mar 2017 21:48:29 -0500 Subject: [PATCH 1/4] Added host UI and connection to server --- Enigma/Program.cs | 11 ++- Enigma/Stations/HostStation.cs | 9 +- .../StationsGUI/HostStationView.Designer.cs | 40 ++++++++- Enigma/StationsGUI/HostStationView.cs | 85 ++++++++++++++++++- EnigmaX/Classes/DBConnect.cs | 4 + 5 files changed, 142 insertions(+), 7 deletions(-) diff --git a/Enigma/Program.cs b/Enigma/Program.cs index 5ca2335..dc7ed32 100644 --- a/Enigma/Program.cs +++ b/Enigma/Program.cs @@ -18,9 +18,16 @@ static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - DebugStation station = new DebugStation(EnigmaX.Classes.StationTypeDef.host, "debug"); - station.showView(); + //DebugStation station = new DebugStation(EnigmaX.Classes.StationTypeDef.host, "debug"); + // station.showView(); + + HostStation host = new HostStation(EnigmaX.Classes.StationTypeDef.host, "host"); + host.showView(); + Application.Run(); + + + } } } diff --git a/Enigma/Stations/HostStation.cs b/Enigma/Stations/HostStation.cs index c4ed512..88a9635 100644 --- a/Enigma/Stations/HostStation.cs +++ b/Enigma/Stations/HostStation.cs @@ -9,11 +9,16 @@ namespace Enigma.Stations { class HostStation : Station { - public HostStation(string stationid) : base(StationTypeDef.host, stationid) + public HostStation(StationTypeDef type, string stationid) : base(type, stationid) { view = new StationsGUI.HostStationView(); } - + + public override void showView() + { + view.Show(); + } + } } diff --git a/Enigma/StationsGUI/HostStationView.Designer.cs b/Enigma/StationsGUI/HostStationView.Designer.cs index 56e5757..7bf6752 100644 --- a/Enigma/StationsGUI/HostStationView.Designer.cs +++ b/Enigma/StationsGUI/HostStationView.Designer.cs @@ -28,20 +28,56 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { + this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.SuspendLayout(); // + // comboBox1 + // + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Items.AddRange(new object[] { + "Reservations", + "Wait List", + "Table Status"}); + this.comboBox1.Location = new System.Drawing.Point(21, 70); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(121, 24); + this.comboBox1.TabIndex = 0; + this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); + // + // dataGridView1 + // + this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.Window; + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView1.Location = new System.Drawing.Point(21, 101); + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.RowTemplate.Height = 24; + this.dataGridView1.Size = new System.Drawing.Size(800, 426); + this.dataGridView1.TabIndex = 1; + this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick); + // // HostStationView // - this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1432, 934); + this.ClientSize = new System.Drawing.Size(1273, 747); + this.Controls.Add(this.dataGridView1); + this.Controls.Add(this.comboBox1); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.Name = "HostStationView"; + this.Padding = new System.Windows.Forms.Padding(18, 60, 18, 16); this.Text = "HostStationView"; this.Load += new System.EventHandler(this.HostStationView_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.ResumeLayout(false); } #endregion + + private System.Windows.Forms.ComboBox comboBox1; + private System.Windows.Forms.DataGridView dataGridView1; } } \ No newline at end of file diff --git a/Enigma/StationsGUI/HostStationView.cs b/Enigma/StationsGUI/HostStationView.cs index 81aaff3..a92a80f 100644 --- a/Enigma/StationsGUI/HostStationView.cs +++ b/Enigma/StationsGUI/HostStationView.cs @@ -7,19 +7,102 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using MetroFramework.Forms; +using EnigmaX; +using System.Data.SqlClient; +using MySql.Data.MySqlClient; namespace Enigma.StationsGUI { - public partial class HostStationView : Form + public partial class HostStationView : MetroForm { + DataTable dt = new DataTable(); + BindingSource SBind = new BindingSource(); + DBConnect db = new DBConnect(); + public HostStationView() { InitializeComponent(); + } private void HostStationView_Load(object sender, EventArgs e) { } + + private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) + { + if (comboBox1.Text.Equals("Wait List")) + { + dt = new DataTable(); + SBind.DataSource = dt; + + dataGridView1.DataSource = SBind; + dataGridView1.Refresh(); + + //db.WriteCommand("select * from Waitlist "); + MySqlCommand cmd = new MySqlCommand("select * from Waitlist", db.getConnection()); + db.getConnection().Open(); + + MySqlDataAdapter sda = new MySqlDataAdapter(cmd); + sda.Fill(dt); + + //dt.Columns.Add(new DataColumn("Name", typeof(string))); + //dt.Columns.Add(new DataColumn("Reservation Time", typeof(string))); + + SBind.DataSource = dt; + + dataGridView1.DataSource = SBind; + dataGridView1.Refresh(); + + db.getConnection().Close(); + sda.Dispose(); + } + else if (comboBox1.Text.Equals("Reservations")) + { + dt = new DataTable(); + SBind.DataSource = dt; + + dataGridView1.DataSource = SBind; + dataGridView1.Refresh(); + + + + } + else if(comboBox1.Text.Equals("Table Status")) + { + dt = new DataTable(); + SBind.DataSource = dt; + + dataGridView1.DataSource = SBind; + dataGridView1.Refresh(); + + //db.WriteCommand("select * from Waitlist "); + MySqlCommand cmd = new MySqlCommand("SELECT tableNumber,Seats, foodStatus FROM Seating;", db.getConnection()); + db.getConnection().Open(); + + MySqlDataAdapter sda = new MySqlDataAdapter(cmd); + sda.Fill(dt); + + //dt.Columns.Add(new DataColumn("Name", typeof(string))); + //dt.Columns.Add(new DataColumn("Reservation Time", typeof(string))); + + SBind.DataSource = dt; + + dataGridView1.DataSource = SBind; + dataGridView1.Refresh(); + + db.getConnection().Close(); + sda.Dispose(); + } + } + + private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + + } + + } } diff --git a/EnigmaX/Classes/DBConnect.cs b/EnigmaX/Classes/DBConnect.cs index 73eecd3..bcd174c 100644 --- a/EnigmaX/Classes/DBConnect.cs +++ b/EnigmaX/Classes/DBConnect.cs @@ -124,6 +124,10 @@ public List> ReadCommand(string str, params string[] } + public MySqlConnection getConnection() + { + return connection; + } /*public string ReadSingleCommand(string str) { if (this.OpenConnection() == true) From 11bc1b5036803723e8dd875ae6184bb3227e0226 Mon Sep 17 00:00:00 2001 From: Evan Langlais Date: Tue, 7 Mar 2017 13:32:15 -0500 Subject: [PATCH 2/4] Added parties, tables, addparty popup form --- Enigma/Enigma.csproj | 9 ++ Enigma/Popups/AddParty.Designer.cs | 165 ++++++++++++++++++++++++++ Enigma/Popups/AddParty.cs | 46 +++++++ Enigma/Popups/AddParty.resx | 120 +++++++++++++++++++ Enigma/Stations/HostStation.cs | 3 + Enigma/StationsGUI/HostStationView.cs | 2 +- EnigmaX/Classes/Party.cs | 34 ++++++ EnigmaX/Classes/Station.cs | 1 + EnigmaX/Classes/Table.cs | 52 ++++++++ EnigmaX/EnigmaX.csproj | 2 + 10 files changed, 433 insertions(+), 1 deletion(-) create mode 100644 Enigma/Popups/AddParty.Designer.cs create mode 100644 Enigma/Popups/AddParty.cs create mode 100644 Enigma/Popups/AddParty.resx create mode 100644 EnigmaX/Classes/Party.cs create mode 100644 EnigmaX/Classes/Table.cs diff --git a/Enigma/Enigma.csproj b/Enigma/Enigma.csproj index 4959c33..d33b703 100644 --- a/Enigma/Enigma.csproj +++ b/Enigma/Enigma.csproj @@ -62,6 +62,12 @@ + + Form + + + AddParty.cs + Form @@ -78,6 +84,9 @@ + + AddParty.cs + DebugStationView.cs diff --git a/Enigma/Popups/AddParty.Designer.cs b/Enigma/Popups/AddParty.Designer.cs new file mode 100644 index 0000000..8b5f579 --- /dev/null +++ b/Enigma/Popups/AddParty.Designer.cs @@ -0,0 +1,165 @@ +namespace Enigma.Popups +{ + partial class AddParty + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.partyName = new MetroFramework.Controls.MetroTextBox(); + this.metroLabel1 = new MetroFramework.Controls.MetroLabel(); + this.addPartyButton = new MetroFramework.Controls.MetroButton(); + this.metroLabel2 = new MetroFramework.Controls.MetroLabel(); + this.countBox = new System.Windows.Forms.NumericUpDown(); + this.metroLabel3 = new MetroFramework.Controls.MetroLabel(); + this.tableSelectionBox = new MetroFramework.Controls.MetroComboBox(); + ((System.ComponentModel.ISupportInitialize)(this.countBox)).BeginInit(); + this.SuspendLayout(); + // + // partyName + // + // + // + // + this.partyName.CustomButton.Image = null; + this.partyName.CustomButton.Location = new System.Drawing.Point(668, 1); + this.partyName.CustomButton.Name = ""; + this.partyName.CustomButton.Size = new System.Drawing.Size(21, 21); + this.partyName.CustomButton.Style = MetroFramework.MetroColorStyle.Blue; + this.partyName.CustomButton.TabIndex = 1; + this.partyName.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light; + this.partyName.CustomButton.UseSelectable = true; + this.partyName.CustomButton.Visible = false; + this.partyName.Lines = new string[] { + "Name of Party"}; + this.partyName.Location = new System.Drawing.Point(81, 60); + this.partyName.MaxLength = 32767; + this.partyName.Name = "partyName"; + this.partyName.PasswordChar = '\0'; + this.partyName.ScrollBars = System.Windows.Forms.ScrollBars.None; + this.partyName.SelectedText = ""; + this.partyName.SelectionLength = 0; + this.partyName.SelectionStart = 0; + this.partyName.ShortcutsEnabled = true; + this.partyName.Size = new System.Drawing.Size(690, 23); + this.partyName.TabIndex = 0; + this.partyName.Text = "Name of Party"; + this.partyName.UseSelectable = true; + this.partyName.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109))))); + this.partyName.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel); + // + // metroLabel1 + // + this.metroLabel1.AutoSize = true; + this.metroLabel1.Location = new System.Drawing.Point(23, 60); + this.metroLabel1.Name = "metroLabel1"; + this.metroLabel1.Size = new System.Drawing.Size(52, 19); + this.metroLabel1.TabIndex = 1; + this.metroLabel1.Text = "Name: "; + // + // addPartyButton + // + this.addPartyButton.Location = new System.Drawing.Point(777, 60); + this.addPartyButton.Name = "addPartyButton"; + this.addPartyButton.Size = new System.Drawing.Size(178, 90); + this.addPartyButton.TabIndex = 4; + this.addPartyButton.Text = "Add Party"; + this.addPartyButton.UseSelectable = true; + this.addPartyButton.Click += new System.EventHandler(this.addPartyButton_Click); + // + // metroLabel2 + // + this.metroLabel2.AutoSize = true; + this.metroLabel2.Location = new System.Drawing.Point(23, 89); + this.metroLabel2.Name = "metroLabel2"; + this.metroLabel2.Size = new System.Drawing.Size(47, 19); + this.metroLabel2.TabIndex = 3; + this.metroLabel2.Text = "Count:"; + // + // countBox + // + this.countBox.Location = new System.Drawing.Point(81, 89); + this.countBox.Name = "countBox"; + this.countBox.Size = new System.Drawing.Size(180, 26); + this.countBox.TabIndex = 5; + this.countBox.Value = new decimal(new int[] { + 1, + 0, + 0, + 0}); + // + // metroLabel3 + // + this.metroLabel3.AutoSize = true; + this.metroLabel3.Location = new System.Drawing.Point(23, 122); + this.metroLabel3.Name = "metroLabel3"; + this.metroLabel3.Size = new System.Drawing.Size(42, 19); + this.metroLabel3.TabIndex = 6; + this.metroLabel3.Text = "Table:"; + // + // tableSelectionBox + // + this.tableSelectionBox.FormattingEnabled = true; + this.tableSelectionBox.ItemHeight = 23; + this.tableSelectionBox.Items.AddRange(new object[] { + "None"}); + this.tableSelectionBox.Location = new System.Drawing.Point(81, 121); + this.tableSelectionBox.Name = "tableSelectionBox"; + this.tableSelectionBox.Size = new System.Drawing.Size(323, 29); + this.tableSelectionBox.TabIndex = 7; + this.tableSelectionBox.UseSelectable = true; + // + // AddParty + // + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(978, 172); + this.Controls.Add(this.tableSelectionBox); + this.Controls.Add(this.metroLabel3); + this.Controls.Add(this.countBox); + this.Controls.Add(this.addPartyButton); + this.Controls.Add(this.metroLabel2); + this.Controls.Add(this.metroLabel1); + this.Controls.Add(this.partyName); + this.Name = "AddParty"; + this.Text = "Add Party"; + this.Load += new System.EventHandler(this.AddPatron_Load); + ((System.ComponentModel.ISupportInitialize)(this.countBox)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private MetroFramework.Controls.MetroTextBox partyName; + private MetroFramework.Controls.MetroLabel metroLabel1; + private MetroFramework.Controls.MetroButton addPartyButton; + private MetroFramework.Controls.MetroLabel metroLabel2; + private System.Windows.Forms.NumericUpDown countBox; + private MetroFramework.Controls.MetroLabel metroLabel3; + private MetroFramework.Controls.MetroComboBox tableSelectionBox; + } +} \ No newline at end of file diff --git a/Enigma/Popups/AddParty.cs b/Enigma/Popups/AddParty.cs new file mode 100644 index 0000000..088fb51 --- /dev/null +++ b/Enigma/Popups/AddParty.cs @@ -0,0 +1,46 @@ +using EnigmaX.Classes; +using MetroFramework.Forms; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Enigma.Popups +{ + public partial class AddParty : MetroForm + { + + List tables; + + public AddParty(List
_tables) + { + InitializeComponent(); + tables = _tables; + } + + private void AddPatron_Load(object sender, EventArgs e) + { + foreach (Table table in tables) { + tableSelectionBox.Items.Add("Table " + table.tableId() + " " + table.count + " / " + table.capacity); + } + } + + private void addPartyButton_Click(object sender, EventArgs e) + { + Party party = new Party(partyName.Text, (int)countBox.Value); + if (tableSelectionBox.SelectedIndex > 0) { + // index 0 is always "none" + Table selected = tables[tableSelectionBox.SelectedIndex - 1]; + if (selected.remaining >= (int)countBox.Value) { + selected.addPatron(party); + party.setTable(selected); + } + } + } + } +} diff --git a/Enigma/Popups/AddParty.resx b/Enigma/Popups/AddParty.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Enigma/Popups/AddParty.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/Enigma/Stations/HostStation.cs b/Enigma/Stations/HostStation.cs index 88a9635..4da3379 100644 --- a/Enigma/Stations/HostStation.cs +++ b/Enigma/Stations/HostStation.cs @@ -9,6 +9,9 @@ namespace Enigma.Stations { class HostStation : Station { + + public List
tables = new List
(); + public HostStation(StationTypeDef type, string stationid) : base(type, stationid) { view = new StationsGUI.HostStationView(); diff --git a/Enigma/StationsGUI/HostStationView.cs b/Enigma/StationsGUI/HostStationView.cs index a92a80f..b958cba 100644 --- a/Enigma/StationsGUI/HostStationView.cs +++ b/Enigma/StationsGUI/HostStationView.cs @@ -28,7 +28,7 @@ public HostStationView() private void HostStationView_Load(object sender, EventArgs e) { - + } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) diff --git a/EnigmaX/Classes/Party.cs b/EnigmaX/Classes/Party.cs new file mode 100644 index 0000000..fb97ac8 --- /dev/null +++ b/EnigmaX/Classes/Party.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EnigmaX.Classes +{ + public class Party + { + + public string name; + public DateTime queueTime; + public Table table; + public int count; + + public Party(string name, int count) { + this.name = name; + table = null; + this.count = count; + queueTime = new DateTime(); + } + + public void setTable(Table table) + { + this.table = table; + } + + public bool isWaiting() { + return (table == null); + } + + } +} diff --git a/EnigmaX/Classes/Station.cs b/EnigmaX/Classes/Station.cs index 59bec25..4e3299d 100644 --- a/EnigmaX/Classes/Station.cs +++ b/EnigmaX/Classes/Station.cs @@ -52,6 +52,7 @@ public Station(StationTypeDef type, string stationid) { public bool registerStation() { interCom = new Intercom(_stationId, _stationType); _registered = interCom.register(); + Console.WriteLine(_stationId + " registered: " + _registered); return _registered; } diff --git a/EnigmaX/Classes/Table.cs b/EnigmaX/Classes/Table.cs new file mode 100644 index 0000000..e9bfce0 --- /dev/null +++ b/EnigmaX/Classes/Table.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EnigmaX.Classes +{ + public class Table + { + private int id; + public int capacity; + public int count; + public List patrons; + + public Table(int id, int capacity) { + this.id = id; + this.capacity = capacity; + patrons = new List(); + count = 0; + } + + public bool isFull() { + return count >= capacity; + } + + public int remaining { + get { + return capacity - count; + } + } + + public int tableId() { + return id; + } + + public void addPatron(Party p) { + if (!isFull()) { + patrons.Add(p); + p.setTable(this); + count++; + } + } + + public void removePatron(Party p) { + patrons.Remove(p); + count--; + } + + + } +} diff --git a/EnigmaX/EnigmaX.csproj b/EnigmaX/EnigmaX.csproj index 4abf994..709de8d 100644 --- a/EnigmaX/EnigmaX.csproj +++ b/EnigmaX/EnigmaX.csproj @@ -61,7 +61,9 @@ + + From ea974c31da0f587516ff86aca5b85cfb0fba9fa2 Mon Sep 17 00:00:00 2001 From: "RKant\\TEST" Date: Thu, 16 Mar 2017 16:21:54 -0400 Subject: [PATCH 3/4] WaitList add and remove functional. Assign party to table functional. Addition of popups for both events. --- Enigma/Enigma.csproj | 18 ++ Enigma/Popups/AddParty.cs | 8 +- Enigma/Popups/AddWaitlist.Designer.cs | 165 +++++++++++++++++ Enigma/Popups/AddWaitlist.cs | 46 +++++ Enigma/Popups/AddWaitlist.resx | 120 +++++++++++++ Enigma/Popups/TableAssign.Designer.cs | 168 ++++++++++++++++++ Enigma/Popups/TableAssign.cs | 133 ++++++++++++++ Enigma/Popups/TableAssign.resx | 120 +++++++++++++ Enigma/Popups/waitListAdd.Designer.cs | 157 ++++++++++++++++ Enigma/Popups/waitListAdd.cs | 61 +++++++ Enigma/Popups/waitListAdd.resx | 120 +++++++++++++ .../StationsGUI/HostStationView.Designer.cs | 64 ++++++- Enigma/StationsGUI/HostStationView.cs | 161 ++++++++++++++++- Enigma/StationsGUI/HostStationView.resx | 3 + EnigmaX/Classes/Party.cs | 62 +++++-- EnigmaX/Classes/Table.cs | 85 +++++++-- 16 files changed, 1451 insertions(+), 40 deletions(-) create mode 100644 Enigma/Popups/AddWaitlist.Designer.cs create mode 100644 Enigma/Popups/AddWaitlist.cs create mode 100644 Enigma/Popups/AddWaitlist.resx create mode 100644 Enigma/Popups/TableAssign.Designer.cs create mode 100644 Enigma/Popups/TableAssign.cs create mode 100644 Enigma/Popups/TableAssign.resx create mode 100644 Enigma/Popups/waitListAdd.Designer.cs create mode 100644 Enigma/Popups/waitListAdd.cs create mode 100644 Enigma/Popups/waitListAdd.resx diff --git a/Enigma/Enigma.csproj b/Enigma/Enigma.csproj index d33b703..49659cd 100644 --- a/Enigma/Enigma.csproj +++ b/Enigma/Enigma.csproj @@ -68,6 +68,18 @@ AddParty.cs + + Form + + + TableAssign.cs + + + Form + + + waitListAdd.cs + Form @@ -87,6 +99,12 @@ AddParty.cs + + TableAssign.cs + + + waitListAdd.cs + DebugStationView.cs diff --git a/Enigma/Popups/AddParty.cs b/Enigma/Popups/AddParty.cs index 088fb51..e4d2934 100644 --- a/Enigma/Popups/AddParty.cs +++ b/Enigma/Popups/AddParty.cs @@ -16,7 +16,11 @@ public partial class AddParty : MetroForm { List
tables; - + public AddParty() + { + InitializeComponent(); + + } public AddParty(List
_tables) { InitializeComponent(); @@ -26,7 +30,7 @@ public AddParty(List
_tables) private void AddPatron_Load(object sender, EventArgs e) { foreach (Table table in tables) { - tableSelectionBox.Items.Add("Table " + table.tableId() + " " + table.count + " / " + table.capacity); + tableSelectionBox.Items.Add("Table " + table.tableId() + " " + table._count + " / " + table._capacity); } } diff --git a/Enigma/Popups/AddWaitlist.Designer.cs b/Enigma/Popups/AddWaitlist.Designer.cs new file mode 100644 index 0000000..8b5f579 --- /dev/null +++ b/Enigma/Popups/AddWaitlist.Designer.cs @@ -0,0 +1,165 @@ +namespace Enigma.Popups +{ + partial class AddParty + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.partyName = new MetroFramework.Controls.MetroTextBox(); + this.metroLabel1 = new MetroFramework.Controls.MetroLabel(); + this.addPartyButton = new MetroFramework.Controls.MetroButton(); + this.metroLabel2 = new MetroFramework.Controls.MetroLabel(); + this.countBox = new System.Windows.Forms.NumericUpDown(); + this.metroLabel3 = new MetroFramework.Controls.MetroLabel(); + this.tableSelectionBox = new MetroFramework.Controls.MetroComboBox(); + ((System.ComponentModel.ISupportInitialize)(this.countBox)).BeginInit(); + this.SuspendLayout(); + // + // partyName + // + // + // + // + this.partyName.CustomButton.Image = null; + this.partyName.CustomButton.Location = new System.Drawing.Point(668, 1); + this.partyName.CustomButton.Name = ""; + this.partyName.CustomButton.Size = new System.Drawing.Size(21, 21); + this.partyName.CustomButton.Style = MetroFramework.MetroColorStyle.Blue; + this.partyName.CustomButton.TabIndex = 1; + this.partyName.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light; + this.partyName.CustomButton.UseSelectable = true; + this.partyName.CustomButton.Visible = false; + this.partyName.Lines = new string[] { + "Name of Party"}; + this.partyName.Location = new System.Drawing.Point(81, 60); + this.partyName.MaxLength = 32767; + this.partyName.Name = "partyName"; + this.partyName.PasswordChar = '\0'; + this.partyName.ScrollBars = System.Windows.Forms.ScrollBars.None; + this.partyName.SelectedText = ""; + this.partyName.SelectionLength = 0; + this.partyName.SelectionStart = 0; + this.partyName.ShortcutsEnabled = true; + this.partyName.Size = new System.Drawing.Size(690, 23); + this.partyName.TabIndex = 0; + this.partyName.Text = "Name of Party"; + this.partyName.UseSelectable = true; + this.partyName.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109))))); + this.partyName.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel); + // + // metroLabel1 + // + this.metroLabel1.AutoSize = true; + this.metroLabel1.Location = new System.Drawing.Point(23, 60); + this.metroLabel1.Name = "metroLabel1"; + this.metroLabel1.Size = new System.Drawing.Size(52, 19); + this.metroLabel1.TabIndex = 1; + this.metroLabel1.Text = "Name: "; + // + // addPartyButton + // + this.addPartyButton.Location = new System.Drawing.Point(777, 60); + this.addPartyButton.Name = "addPartyButton"; + this.addPartyButton.Size = new System.Drawing.Size(178, 90); + this.addPartyButton.TabIndex = 4; + this.addPartyButton.Text = "Add Party"; + this.addPartyButton.UseSelectable = true; + this.addPartyButton.Click += new System.EventHandler(this.addPartyButton_Click); + // + // metroLabel2 + // + this.metroLabel2.AutoSize = true; + this.metroLabel2.Location = new System.Drawing.Point(23, 89); + this.metroLabel2.Name = "metroLabel2"; + this.metroLabel2.Size = new System.Drawing.Size(47, 19); + this.metroLabel2.TabIndex = 3; + this.metroLabel2.Text = "Count:"; + // + // countBox + // + this.countBox.Location = new System.Drawing.Point(81, 89); + this.countBox.Name = "countBox"; + this.countBox.Size = new System.Drawing.Size(180, 26); + this.countBox.TabIndex = 5; + this.countBox.Value = new decimal(new int[] { + 1, + 0, + 0, + 0}); + // + // metroLabel3 + // + this.metroLabel3.AutoSize = true; + this.metroLabel3.Location = new System.Drawing.Point(23, 122); + this.metroLabel3.Name = "metroLabel3"; + this.metroLabel3.Size = new System.Drawing.Size(42, 19); + this.metroLabel3.TabIndex = 6; + this.metroLabel3.Text = "Table:"; + // + // tableSelectionBox + // + this.tableSelectionBox.FormattingEnabled = true; + this.tableSelectionBox.ItemHeight = 23; + this.tableSelectionBox.Items.AddRange(new object[] { + "None"}); + this.tableSelectionBox.Location = new System.Drawing.Point(81, 121); + this.tableSelectionBox.Name = "tableSelectionBox"; + this.tableSelectionBox.Size = new System.Drawing.Size(323, 29); + this.tableSelectionBox.TabIndex = 7; + this.tableSelectionBox.UseSelectable = true; + // + // AddParty + // + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(978, 172); + this.Controls.Add(this.tableSelectionBox); + this.Controls.Add(this.metroLabel3); + this.Controls.Add(this.countBox); + this.Controls.Add(this.addPartyButton); + this.Controls.Add(this.metroLabel2); + this.Controls.Add(this.metroLabel1); + this.Controls.Add(this.partyName); + this.Name = "AddParty"; + this.Text = "Add Party"; + this.Load += new System.EventHandler(this.AddPatron_Load); + ((System.ComponentModel.ISupportInitialize)(this.countBox)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private MetroFramework.Controls.MetroTextBox partyName; + private MetroFramework.Controls.MetroLabel metroLabel1; + private MetroFramework.Controls.MetroButton addPartyButton; + private MetroFramework.Controls.MetroLabel metroLabel2; + private System.Windows.Forms.NumericUpDown countBox; + private MetroFramework.Controls.MetroLabel metroLabel3; + private MetroFramework.Controls.MetroComboBox tableSelectionBox; + } +} \ No newline at end of file diff --git a/Enigma/Popups/AddWaitlist.cs b/Enigma/Popups/AddWaitlist.cs new file mode 100644 index 0000000..088fb51 --- /dev/null +++ b/Enigma/Popups/AddWaitlist.cs @@ -0,0 +1,46 @@ +using EnigmaX.Classes; +using MetroFramework.Forms; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Enigma.Popups +{ + public partial class AddParty : MetroForm + { + + List
tables; + + public AddParty(List
_tables) + { + InitializeComponent(); + tables = _tables; + } + + private void AddPatron_Load(object sender, EventArgs e) + { + foreach (Table table in tables) { + tableSelectionBox.Items.Add("Table " + table.tableId() + " " + table.count + " / " + table.capacity); + } + } + + private void addPartyButton_Click(object sender, EventArgs e) + { + Party party = new Party(partyName.Text, (int)countBox.Value); + if (tableSelectionBox.SelectedIndex > 0) { + // index 0 is always "none" + Table selected = tables[tableSelectionBox.SelectedIndex - 1]; + if (selected.remaining >= (int)countBox.Value) { + selected.addPatron(party); + party.setTable(selected); + } + } + } + } +} diff --git a/Enigma/Popups/AddWaitlist.resx b/Enigma/Popups/AddWaitlist.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Enigma/Popups/AddWaitlist.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/Enigma/Popups/TableAssign.Designer.cs b/Enigma/Popups/TableAssign.Designer.cs new file mode 100644 index 0000000..985186b --- /dev/null +++ b/Enigma/Popups/TableAssign.Designer.cs @@ -0,0 +1,168 @@ +namespace Enigma.Popups +{ + partial class TableAssign + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.tableAvailable = new MetroFramework.Controls.MetroLabel(); + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.metroLabel1 = new MetroFramework.Controls.MetroLabel(); + this.name = new MetroFramework.Controls.MetroLabel(); + this.partySize = new MetroFramework.Controls.MetroLabel(); + this.cancel = new MetroFramework.Controls.MetroButton(); + this.ok = new MetroFramework.Controls.MetroButton(); + this.nameOutput = new MetroFramework.Controls.MetroLabel(); + this.sizeOutput = new MetroFramework.Controls.MetroLabel(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); + this.SuspendLayout(); + // + // tableAvailable + // + this.tableAvailable.AutoSize = true; + this.tableAvailable.Location = new System.Drawing.Point(13, 18); + this.tableAvailable.Name = "tableAvailable"; + this.tableAvailable.Size = new System.Drawing.Size(106, 20); + this.tableAvailable.TabIndex = 0; + this.tableAvailable.Text = "Tables Available"; + // + // dataGridView1 + // + this.dataGridView1.AllowUserToAddRows = false; + this.dataGridView1.AllowUserToDeleteRows = false; + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView1.Location = new System.Drawing.Point(13, 42); + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.ReadOnly = true; + this.dataGridView1.RowTemplate.Height = 24; + this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dataGridView1.Size = new System.Drawing.Size(493, 222); + this.dataGridView1.TabIndex = 1; + this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick); + // + // metroLabel1 + // + this.metroLabel1.AutoSize = true; + this.metroLabel1.Location = new System.Drawing.Point(512, 42); + this.metroLabel1.Name = "metroLabel1"; + this.metroLabel1.Size = new System.Drawing.Size(96, 20); + this.metroLabel1.TabIndex = 2; + this.metroLabel1.Text = "Customer Info"; + // + // name + // + this.name.AutoSize = true; + this.name.Location = new System.Drawing.Point(512, 68); + this.name.Name = "name"; + this.name.Size = new System.Drawing.Size(50, 20); + this.name.TabIndex = 3; + this.name.Text = "Name:"; + // + // partySize + // + this.partySize.AutoSize = true; + this.partySize.Location = new System.Drawing.Point(512, 98); + this.partySize.Name = "partySize"; + this.partySize.Size = new System.Drawing.Size(72, 20); + this.partySize.TabIndex = 4; + this.partySize.Text = "Party Size:"; + // + // cancel + // + this.cancel.Location = new System.Drawing.Point(529, 238); + this.cancel.Name = "cancel"; + this.cancel.Size = new System.Drawing.Size(96, 26); + this.cancel.TabIndex = 5; + this.cancel.Text = "Cancel"; + this.cancel.UseSelectable = true; + this.cancel.Click += new System.EventHandler(this.cancel_Click); + // + // ok + // + this.ok.Location = new System.Drawing.Point(643, 238); + this.ok.Name = "ok"; + this.ok.Size = new System.Drawing.Size(96, 26); + this.ok.TabIndex = 6; + this.ok.Text = "Assign"; + this.ok.UseSelectable = true; + this.ok.Click += new System.EventHandler(this.ok_Click); + // + // nameOutput + // + this.nameOutput.AutoSize = true; + this.nameOutput.Location = new System.Drawing.Point(569, 68); + this.nameOutput.Name = "nameOutput"; + this.nameOutput.Size = new System.Drawing.Size(87, 20); + this.nameOutput.TabIndex = 7; + this.nameOutput.Text = "metroLabel2"; + // + // sizeOutput + // + this.sizeOutput.AutoSize = true; + this.sizeOutput.Location = new System.Drawing.Point(601, 98); + this.sizeOutput.Name = "sizeOutput"; + this.sizeOutput.Size = new System.Drawing.Size(87, 20); + this.sizeOutput.TabIndex = 8; + this.sizeOutput.Text = "metroLabel3"; + // + // TableAssign + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(753, 287); + this.Controls.Add(this.sizeOutput); + this.Controls.Add(this.nameOutput); + this.Controls.Add(this.ok); + this.Controls.Add(this.cancel); + this.Controls.Add(this.partySize); + this.Controls.Add(this.name); + this.Controls.Add(this.metroLabel1); + this.Controls.Add(this.dataGridView1); + this.Controls.Add(this.tableAvailable); + this.DisplayHeader = false; + this.Name = "TableAssign"; + this.Padding = new System.Windows.Forms.Padding(20, 30, 20, 20); + this.Text = "TableAssign"; + this.Load += new System.EventHandler(this.TableAssign_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private MetroFramework.Controls.MetroLabel tableAvailable; + private System.Windows.Forms.DataGridView dataGridView1; + private MetroFramework.Controls.MetroLabel metroLabel1; + private MetroFramework.Controls.MetroLabel name; + private MetroFramework.Controls.MetroLabel partySize; + private MetroFramework.Controls.MetroButton cancel; + private MetroFramework.Controls.MetroButton ok; + private MetroFramework.Controls.MetroLabel nameOutput; + private MetroFramework.Controls.MetroLabel sizeOutput; + } +} \ No newline at end of file diff --git a/Enigma/Popups/TableAssign.cs b/Enigma/Popups/TableAssign.cs new file mode 100644 index 0000000..d53b6e3 --- /dev/null +++ b/Enigma/Popups/TableAssign.cs @@ -0,0 +1,133 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using MetroFramework.Forms; +using EnigmaX; +using MySql.Data.MySqlClient; +using Enigma.StationsGUI; + +namespace Enigma.Popups +{ + public partial class TableAssign : MetroForm + { + DataTable dt = new DataTable(); + BindingSource SBind = new BindingSource(); + DBConnect db = new DBConnect(); + HostStationView hsv; + + private string _name; + private string _partySize; + + public TableAssign() + { + InitializeComponent(); + } + + public TableAssign(HostStationView host, string name, string partySize) + { + hsv = host; + _name = name; + _partySize = partySize; + InitializeComponent(); + } + + private void TableAssign_Load(object sender, EventArgs e) + { + nameOutput.Text = _name; + sizeOutput.Text = _partySize; + + dt = new DataTable(); + SBind.DataSource = dt; + + dataGridView1.DataSource = SBind; + dataGridView1.Refresh(); + + //db.WriteCommand("select * from Waitlist "); + MySqlCommand cmd = new MySqlCommand("SELECT tableNumber,Seats, status FROM Seating WHERE status=1", db.getConnection()); + db.getConnection().Open(); + + MySqlDataAdapter sda = new MySqlDataAdapter(cmd); + sda.Fill(dt); + + //dt.Columns.Add(new DataColumn("Name", typeof(string))); + //dt.Columns.Add(new DataColumn("Reservation Time", typeof(string))); + + SBind.DataSource = dt; + + dataGridView1.DataSource = SBind; + dataGridView1.Refresh(); + + db.getConnection().Close(); + sda.Dispose(); + } + + private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + + } + + private void cancel_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void ok_Click(object sender, EventArgs e) + { + foreach (DataGridViewRow row in dataGridView1.SelectedRows)//take the selected row and split data + { + int tableNumber= Int32.Parse( row.Cells[0].Value.ToString()); + int tableSize = Int32.Parse(row.Cells[1].Value.ToString()); + string status = row.Cells[2].Value.ToString(); + + for(int i = 0; i< hsv.tables.Count(); i++) + { + if (hsv.tables[i].getTableNumber().Equals(tableNumber) && hsv.tables[i].getTableCapacity().Equals(tableSize) && Int32.Parse(_partySize)<=tableSize) + { + hsv.tables[i].setStatus("seated"); + + db.getConnection().Open(); //open a channel + //update the initialWaitTime in the sql table + MySqlCommand cmd = new MySqlCommand("UPDATE Seating SET status = @status WHERE tableNumber = @tableNumber and Seats = @Seats", db.getConnection()); + //parametrize the variables + cmd.Parameters.Add("@status", hsv.tables[i].getStatus()); + cmd.Parameters.Add("@tableNumber", hsv.tables[i].getTableNumber()); + cmd.Parameters.Add("@Seats", hsv.tables[i].getTableCapacity()); + cmd.ExecuteNonQuery(); //execute the update + db.getConnection().Close(); + + for (int n = 0; n < hsv.waitList.Count(); n++) + { + if (hsv.waitList[n].getName().Equals(_name) && hsv.waitList[n].getCount().ToString().Equals(_partySize)) + { + hsv.waitList.Remove(hsv.waitList[n]);//remove the party from the list + + db.getConnection().Open(); //remove the row from the sql table + cmd = new MySqlCommand("DELETE FROM Waitlist WHERE Name = @Name and Party = @Party", db.getConnection()); + cmd.Parameters.Add("@Name", _name); + cmd.Parameters.Add("@Party", _partySize); + cmd.ExecuteNonQuery(); + db.getConnection().Close(); + } + } + + + + + db.getConnection().Close(); //close the channel + // dataGridView1.Refresh(); //check if works + + + } + } + this.Close(); + } + + } + } +} diff --git a/Enigma/Popups/TableAssign.resx b/Enigma/Popups/TableAssign.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Enigma/Popups/TableAssign.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/Enigma/Popups/waitListAdd.Designer.cs b/Enigma/Popups/waitListAdd.Designer.cs new file mode 100644 index 0000000..c5df775 --- /dev/null +++ b/Enigma/Popups/waitListAdd.Designer.cs @@ -0,0 +1,157 @@ +namespace Enigma.Popups +{ + partial class waitListAdd + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.inputName = new MetroFramework.Controls.MetroTextBox(); + this.metroLabel1 = new MetroFramework.Controls.MetroLabel(); + this.metroLabel2 = new MetroFramework.Controls.MetroLabel(); + this.sizeInput = new System.Windows.Forms.NumericUpDown(); + this.metroLabel3 = new MetroFramework.Controls.MetroLabel(); + this.timeInput = new System.Windows.Forms.NumericUpDown(); + this.metroButton1 = new MetroFramework.Controls.MetroButton(); + ((System.ComponentModel.ISupportInitialize)(this.sizeInput)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.timeInput)).BeginInit(); + this.SuspendLayout(); + // + // inputName + // + // + // + // + this.inputName.CustomButton.Image = null; + this.inputName.CustomButton.Location = new System.Drawing.Point(132, 1); + this.inputName.CustomButton.Name = ""; + this.inputName.CustomButton.Size = new System.Drawing.Size(21, 21); + this.inputName.CustomButton.Style = MetroFramework.MetroColorStyle.Blue; + this.inputName.CustomButton.TabIndex = 1; + this.inputName.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light; + this.inputName.CustomButton.UseSelectable = true; + this.inputName.CustomButton.Visible = false; + this.inputName.Lines = new string[] { + "metroTextBox1"}; + this.inputName.Location = new System.Drawing.Point(161, 60); + this.inputName.MaxLength = 32767; + this.inputName.Name = "inputName"; + this.inputName.PasswordChar = '\0'; + this.inputName.ScrollBars = System.Windows.Forms.ScrollBars.None; + this.inputName.SelectedText = ""; + this.inputName.SelectionLength = 0; + this.inputName.SelectionStart = 0; + this.inputName.ShortcutsEnabled = true; + this.inputName.Size = new System.Drawing.Size(154, 23); + this.inputName.TabIndex = 0; + this.inputName.Text = "metroTextBox1"; + this.inputName.UseSelectable = true; + this.inputName.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109))))); + this.inputName.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel); + // + // metroLabel1 + // + this.metroLabel1.AutoSize = true; + this.metroLabel1.Location = new System.Drawing.Point(24, 63); + this.metroLabel1.Name = "metroLabel1"; + this.metroLabel1.Size = new System.Drawing.Size(47, 20); + this.metroLabel1.TabIndex = 1; + this.metroLabel1.Text = "Name"; + // + // metroLabel2 + // + this.metroLabel2.AutoSize = true; + this.metroLabel2.Location = new System.Drawing.Point(24, 87); + this.metroLabel2.Name = "metroLabel2"; + this.metroLabel2.Size = new System.Drawing.Size(69, 20); + this.metroLabel2.TabIndex = 2; + this.metroLabel2.Text = "Party Size"; + // + // sizeInput + // + this.sizeInput.Location = new System.Drawing.Point(161, 85); + this.sizeInput.Name = "sizeInput"; + this.sizeInput.Size = new System.Drawing.Size(120, 22); + this.sizeInput.TabIndex = 3; + // + // metroLabel3 + // + this.metroLabel3.AutoSize = true; + this.metroLabel3.Location = new System.Drawing.Point(24, 111); + this.metroLabel3.Name = "metroLabel3"; + this.metroLabel3.Size = new System.Drawing.Size(131, 20); + this.metroLabel3.TabIndex = 4; + this.metroLabel3.Text = "Wait Time (minutes)"; + // + // timeInput + // + this.timeInput.Location = new System.Drawing.Point(161, 111); + this.timeInput.Name = "timeInput"; + this.timeInput.Size = new System.Drawing.Size(120, 22); + this.timeInput.TabIndex = 5; + // + // metroButton1 + // + this.metroButton1.Location = new System.Drawing.Point(338, 60); + this.metroButton1.Name = "metroButton1"; + this.metroButton1.Size = new System.Drawing.Size(124, 75); + this.metroButton1.TabIndex = 6; + this.metroButton1.Text = "Add to Waitlist"; + this.metroButton1.UseSelectable = true; + this.metroButton1.Click += new System.EventHandler(this.metroButton1_Click); + // + // waitListAdd + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(532, 162); + this.Controls.Add(this.metroButton1); + this.Controls.Add(this.timeInput); + this.Controls.Add(this.metroLabel3); + this.Controls.Add(this.sizeInput); + this.Controls.Add(this.metroLabel2); + this.Controls.Add(this.metroLabel1); + this.Controls.Add(this.inputName); + this.Name = "waitListAdd"; + this.Text = "Form1"; + this.Load += new System.EventHandler(this.waitListAdd_Load); + ((System.ComponentModel.ISupportInitialize)(this.sizeInput)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.timeInput)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private MetroFramework.Controls.MetroTextBox inputName; + private MetroFramework.Controls.MetroLabel metroLabel1; + private MetroFramework.Controls.MetroLabel metroLabel2; + private System.Windows.Forms.NumericUpDown sizeInput; + private MetroFramework.Controls.MetroLabel metroLabel3; + private System.Windows.Forms.NumericUpDown timeInput; + private MetroFramework.Controls.MetroButton metroButton1; + } +} \ No newline at end of file diff --git a/Enigma/Popups/waitListAdd.cs b/Enigma/Popups/waitListAdd.cs new file mode 100644 index 0000000..1924bd4 --- /dev/null +++ b/Enigma/Popups/waitListAdd.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using MetroFramework.Forms; +using EnigmaX.Classes; +using EnigmaX; +using MySql.Data.MySqlClient; +using Enigma.StationsGUI; + +namespace Enigma.Popups +{ + public partial class waitListAdd : MetroForm + { + HostStationView _hsv; + Party party; + bool flag = false; + + public waitListAdd(HostStationView hsv) + { + InitializeComponent(); + _hsv = hsv; + } + + private void waitListAdd_Load(object sender, EventArgs e) + { + + } + + private void metroButton1_Click(object sender, EventArgs e) + { + party = new Party(inputName.Text, (int)sizeInput.Value, (int)timeInput.Value); + + + DBConnect db = new DBConnect(); + db.getConnection().Open(); + MySqlCommand cmd = new MySqlCommand("INSERT INTO Waitlist (Name, Party, initialWaitTime) VALUES (@Name, @Party, @initialWaitTime)", db.getConnection()); + cmd.Parameters.Add("@Name", party.getName()); + cmd.Parameters.Add("@Party", party.getCount()); + cmd.Parameters.Add("@initialWaitTime", party.getWaitTime()); + cmd.ExecuteNonQuery(); + db.getConnection().Close(); + + this.Close(); + _hsv.setList(party); + } + + public Party getWaitList() + { + + return party; + } + + + } +} diff --git a/Enigma/Popups/waitListAdd.resx b/Enigma/Popups/waitListAdd.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Enigma/Popups/waitListAdd.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/Enigma/StationsGUI/HostStationView.Designer.cs b/Enigma/StationsGUI/HostStationView.Designer.cs index 7bf6752..04f4820 100644 --- a/Enigma/StationsGUI/HostStationView.Designer.cs +++ b/Enigma/StationsGUI/HostStationView.Designer.cs @@ -28,8 +28,13 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); this.comboBox1 = new System.Windows.Forms.ComboBox(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.addToWaitlist = new MetroFramework.Controls.MetroButton(); + this.waitListRefresh = new System.Windows.Forms.Timer(this.components); + this.label1 = new System.Windows.Forms.Label(); + this.tableAssign = new MetroFramework.Controls.MetroButton(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.SuspendLayout(); // @@ -40,9 +45,9 @@ private void InitializeComponent() "Reservations", "Wait List", "Table Status"}); - this.comboBox1.Location = new System.Drawing.Point(21, 70); + this.comboBox1.Location = new System.Drawing.Point(21, 33); this.comboBox1.Name = "comboBox1"; - this.comboBox1.Size = new System.Drawing.Size(121, 24); + this.comboBox1.Size = new System.Drawing.Size(180, 24); this.comboBox1.TabIndex = 0; this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); // @@ -51,27 +56,68 @@ private void InitializeComponent() this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.Window; this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView1.Location = new System.Drawing.Point(21, 101); + this.dataGridView1.Location = new System.Drawing.Point(21, 63); this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.ReadOnly = true; this.dataGridView1.RowTemplate.Height = 24; - this.dataGridView1.Size = new System.Drawing.Size(800, 426); + this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dataGridView1.Size = new System.Drawing.Size(829, 616); this.dataGridView1.TabIndex = 1; - this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick); + this.dataGridView1.RowHeaderMouseDoubleClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dataGridView1_RowHeaderMouseDoubleClick); + // + // addToWaitlist + // + this.addToWaitlist.Location = new System.Drawing.Point(886, 63); + this.addToWaitlist.Name = "addToWaitlist"; + this.addToWaitlist.Size = new System.Drawing.Size(168, 78); + this.addToWaitlist.TabIndex = 2; + this.addToWaitlist.Text = "Add to Waitlist"; + this.addToWaitlist.UseSelectable = true; + this.addToWaitlist.Click += new System.EventHandler(this.addToWaitList_Click); + // + // waitListRefresh + // + this.waitListRefresh.Interval = 5000; + this.waitListRefresh.Tick += new System.EventHandler(this.waitListRefresh_Tick); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(883, 404); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(46, 17); + this.label1.TabIndex = 3; + this.label1.Text = "label1"; + // + // tableAssign + // + this.tableAssign.Location = new System.Drawing.Point(886, 170); + this.tableAssign.Name = "tableAssign"; + this.tableAssign.Size = new System.Drawing.Size(168, 78); + this.tableAssign.TabIndex = 4; + this.tableAssign.Text = "Assign to Table"; + this.tableAssign.UseSelectable = true; + this.tableAssign.Click += new System.EventHandler(this.tableAssign_Click); // // HostStationView // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1273, 747); + this.ClientSize = new System.Drawing.Size(1111, 747); + this.Controls.Add(this.tableAssign); + this.Controls.Add(this.label1); + this.Controls.Add(this.addToWaitlist); this.Controls.Add(this.dataGridView1); this.Controls.Add(this.comboBox1); + this.DisplayHeader = false; this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.Name = "HostStationView"; - this.Padding = new System.Windows.Forms.Padding(18, 60, 18, 16); + this.Padding = new System.Windows.Forms.Padding(18, 30, 18, 16); this.Text = "HostStationView"; this.Load += new System.EventHandler(this.HostStationView_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.ResumeLayout(false); + this.PerformLayout(); } @@ -79,5 +125,9 @@ private void InitializeComponent() private System.Windows.Forms.ComboBox comboBox1; private System.Windows.Forms.DataGridView dataGridView1; + private MetroFramework.Controls.MetroButton addToWaitlist; + private System.Windows.Forms.Timer waitListRefresh; + private System.Windows.Forms.Label label1; + private MetroFramework.Controls.MetroButton tableAssign; } } \ No newline at end of file diff --git a/Enigma/StationsGUI/HostStationView.cs b/Enigma/StationsGUI/HostStationView.cs index b958cba..b196c7c 100644 --- a/Enigma/StationsGUI/HostStationView.cs +++ b/Enigma/StationsGUI/HostStationView.cs @@ -8,9 +8,13 @@ using System.Threading.Tasks; using System.Windows.Forms; using MetroFramework.Forms; +using MetroFramework; using EnigmaX; using System.Data.SqlClient; using MySql.Data.MySqlClient; +using Enigma.Popups; +using EnigmaX.Classes; + namespace Enigma.StationsGUI { @@ -19,11 +23,13 @@ public partial class HostStationView : MetroForm DataTable dt = new DataTable(); BindingSource SBind = new BindingSource(); DBConnect db = new DBConnect(); - + public List waitList = new List(); //The waitlist + public List
tables = new List
(); public HostStationView() { InitializeComponent(); - + waitListRefresh.Start(); //start the timer for incrmenting the wait time (updates every minute) for testing increment at 5sec + importTables(); } private void HostStationView_Load(object sender, EventArgs e) @@ -33,7 +39,7 @@ private void HostStationView_Load(object sender, EventArgs e) private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { - if (comboBox1.Text.Equals("Wait List")) + if (comboBox1.Text.Equals("Wait List")) //load the table for the waitlist { dt = new DataTable(); SBind.DataSource = dt; @@ -42,7 +48,7 @@ private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) dataGridView1.Refresh(); //db.WriteCommand("select * from Waitlist "); - MySqlCommand cmd = new MySqlCommand("select * from Waitlist", db.getConnection()); + MySqlCommand cmd = new MySqlCommand("select Name, Party, initialWaitTime from Waitlist", db.getConnection()); db.getConnection().Open(); MySqlDataAdapter sda = new MySqlDataAdapter(cmd); @@ -59,8 +65,9 @@ private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) db.getConnection().Close(); sda.Dispose(); } - else if (comboBox1.Text.Equals("Reservations")) + else if (comboBox1.Text.Equals("Reservations")) //load table for any reservation { + //FINISH dt = new DataTable(); SBind.DataSource = dt; @@ -70,7 +77,7 @@ private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) } - else if(comboBox1.Text.Equals("Table Status")) + else if(comboBox1.Text.Equals("Table Status")) //Table statuses { dt = new DataTable(); SBind.DataSource = dt; @@ -79,7 +86,7 @@ private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) dataGridView1.Refresh(); //db.WriteCommand("select * from Waitlist "); - MySqlCommand cmd = new MySqlCommand("SELECT tableNumber,Seats, foodStatus FROM Seating;", db.getConnection()); + MySqlCommand cmd = new MySqlCommand("SELECT tableNumber,Seats, status FROM Seating;", db.getConnection()); db.getConnection().Open(); MySqlDataAdapter sda = new MySqlDataAdapter(cmd); @@ -95,14 +102,150 @@ private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) db.getConnection().Close(); sda.Dispose(); + + } } - private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) + + + private void addToWaitList_Click(object sender, EventArgs e) { + + waitListAdd wl = new waitListAdd(this); + wl.Show(); + //waitList.Add(wl.getWaitList()); } - + + + private void waitListRefresh_Tick(object sender, EventArgs e) //actions when the timer ticks + { + try + { + label1.Text = waitList.Count().ToString(); //FOR TESTING + label1.Refresh();//FOR TESTING + for (int i = 0; i < waitList.Count(); i++)//interate through all objects in the waitlist + { + + waitList[i].decrementTime();//change the time in the local party object + + db.getConnection().Open(); //open a channel + //update the initialWaitTime in the sql table + MySqlCommand cmd = new MySqlCommand("UPDATE Waitlist SET initialWaitTime = @initialWaitTime WHERE Name = @Name and Party = @Party", db.getConnection()); + //parametrize the variables + cmd.Parameters.Add("@initialWaitTime", waitList[i].getWaitTime()); + cmd.Parameters.Add("@Name", waitList[i].getName()); + cmd.Parameters.Add("@Party", waitList[i].getCount()); + cmd.ExecuteNonQuery(); //execute the update + db.getConnection().Close(); //close the channel + dataGridView1.Refresh(); //check if works + + } + } + catch + { + + } + dataGridView1.Refresh(); //check if works + } + + + public void setList(Party party) //called by waitListAdd popup to add new party to list + { + waitList.Add(party); + } + + + + private void dataGridView1_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)//when row header is double clicked + { + //open a message box asking to confirm deletion + DialogResult dialogResult = MetroMessageBox.Show(this,"Do you want to delete this customer from the waitlist?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); + if (dialogResult == DialogResult.Yes)//if yes, proceed with deletion + { + foreach(DataGridViewRow row in dataGridView1.SelectedRows)//take the selected row and split data + { + string name = row.Cells[0].Value.ToString(); + string partySize = row.Cells[1].Value.ToString(); + string waitTime = row.Cells[2].Value.ToString(); + + for (int i = 0; i < waitList.Count(); i++)//iterate through local list to find the party + { + + if (waitList[i].getName().Equals(name) && waitList[i].getCount().ToString().Equals(partySize)) + { + waitList.Remove(waitList[i]);//remove the party from the list + + db.getConnection().Open(); //remove the row from the sql table + MySqlCommand cmd = new MySqlCommand("DELETE FROM Waitlist WHERE Name = @Name and Party = @Party", db.getConnection()); + cmd.Parameters.Add("@Name", name); + cmd.Parameters.Add("@Party", partySize); + cmd.ExecuteNonQuery(); + db.getConnection().Close(); + } + } + } + + + } + else if (dialogResult == DialogResult.No) + { + //do something else + } + } + + private void tableAssign_Click(object sender, EventArgs e) + { + /* for(int i=0; i < tables.Count(); i++) + { + MessageBox.Show(tables[i]._tableStatus.ToString()); + }*/ + + + foreach (DataGridViewRow row in dataGridView1.SelectedRows)//take the selected row and split data + { + string name = row.Cells[0].Value.ToString(); + string partySize = row.Cells[1].Value.ToString(); + string waitTime = row.Cells[2].Value.ToString(); + + TableAssign ta = new TableAssign(this, name, partySize); + ta.Show(); + } + + + + } + + private void importTables() + { + MySqlCommand cmd = new MySqlCommand("SELECT * FROM Seating", db.getConnection()); + try + { + db.getConnection().Open(); + MySqlDataReader reader = cmd.ExecuteReader(); + Table table; + while (reader.Read()) + { + int tableNumber = Int32.Parse(reader["tableNumber"].ToString()); + int tableCapacity = Int32.Parse(reader["seats"].ToString()); + string tableOccupied = reader["TableOccupied"].ToString(); + string reservation = reader["reservation"].ToString(); + string tableStatus = reader["status"].ToString(); + + table = new Table(tableNumber, tableCapacity, reservation, tableStatus); + tables.Add(table); + table = new Table(); + } + db.getConnection().Close(); + } + catch(SqlException ex) + { + + } + } + + } } diff --git a/Enigma/StationsGUI/HostStationView.resx b/Enigma/StationsGUI/HostStationView.resx index 1af7de1..734ee48 100644 --- a/Enigma/StationsGUI/HostStationView.resx +++ b/Enigma/StationsGUI/HostStationView.resx @@ -117,4 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + \ No newline at end of file diff --git a/EnigmaX/Classes/Party.cs b/EnigmaX/Classes/Party.cs index fb97ac8..cb4ec87 100644 --- a/EnigmaX/Classes/Party.cs +++ b/EnigmaX/Classes/Party.cs @@ -9,25 +9,65 @@ namespace EnigmaX.Classes public class Party { - public string name; - public DateTime queueTime; - public Table table; - public int count; + public string _name; + public DateTime _queueTime; + public int _waitTime; + public Table _table; + public int _count; - public Party(string name, int count) { - this.name = name; - table = null; - this.count = count; - queueTime = new DateTime(); + public Party() + { + + } + + public Party(string name, int count) + { + this._name = name; + _table = null; + this._count = count; + _queueTime = new DateTime(); + this._waitTime = 0; + } + public Party(string name, int count, int waitTime) { + this._name = name; + _table = null; + this._count = count; + _queueTime = new DateTime(); + this._waitTime = waitTime; } public void setTable(Table table) { - this.table = table; + this._table = table; } public bool isWaiting() { - return (table == null); + return (_table == null); + } + public String getName() + { + return _name; + } + + public int getCount() + { + return _count; + } + + public int getWaitTime() + { + return _waitTime; + } + public void decrementTime() + { + if (_waitTime > 0) + { + _waitTime = _waitTime - 1; + } + else + { + _waitTime = 0; + } } } diff --git a/EnigmaX/Classes/Table.cs b/EnigmaX/Classes/Table.cs index e9bfce0..73b4968 100644 --- a/EnigmaX/Classes/Table.cs +++ b/EnigmaX/Classes/Table.cs @@ -8,45 +8,108 @@ namespace EnigmaX.Classes { public class Table { - private int id; - public int capacity; - public int count; + private int _id; //table number + public int _capacity; //Seats + public int _count; + public enum _reservation { no, yes}; + public enum _status{empty, seated, ordered, served, paid };//NOTE SQL ENUMS START WITH 1! + public bool tableOccupied; //IF NECESSARY + public bool isReservation; + public int _tableStatus; public List patrons; + public Table() { } public Table(int id, int capacity) { - this.id = id; - this.capacity = capacity; + this._id = id; + this._capacity = capacity; patrons = new List(); - count = 0; + _count = 0; + } + public Table(int id, int capacity, string reservation, string status) + { + this._id = id; + this._capacity = capacity; + _reservation Res; + if(Enum.TryParse(reservation, out Res)) + { + switch (Res) + { + case _reservation.no: isReservation = false; break; + case _reservation.yes: isReservation = true; break; + + } + } + + _status stat; + if (Enum.TryParse(status, out stat)) + { + switch (stat) + { + case _status.empty: _tableStatus = 0; break; + case _status.seated: _tableStatus = 1; break; + case _status.ordered: _tableStatus = 2; break; + case _status.served: _tableStatus = 3; break; + case _status.paid: _tableStatus = 4; break; + } + } } public bool isFull() { - return count >= capacity; + return _count >= _capacity; } public int remaining { get { - return capacity - count; + return _capacity - _count; } } public int tableId() { - return id; + return _id; } public void addPatron(Party p) { if (!isFull()) { patrons.Add(p); p.setTable(this); - count++; + _count++; } } public void removePatron(Party p) { patrons.Remove(p); - count--; + _count--; } + public int getTableNumber() + { + return _id; + } + public int getTableCapacity() + { + return _capacity; + } + + public int getStatus() + { + return _tableStatus + 1; + } + + public void setStatus(string status) + { + _status stat; + if (Enum.TryParse(status, out stat)) + { + switch (stat) + { + case _status.empty: _tableStatus = 0; break; + case _status.seated: _tableStatus = 1; break; + case _status.ordered: _tableStatus = 2; break; + case _status.served: _tableStatus = 3; break; + case _status.paid: _tableStatus = 4; break; + } + } + } } } From 1dc8cecc1bca7bcb5ef8c94affcefaaabb9056d7 Mon Sep 17 00:00:00 2001 From: "RKant\\TEST" Date: Fri, 24 Mar 2017 11:32:18 -0400 Subject: [PATCH 4/4] Added reservation portion to the host station, therefore host station is fully functional. Did not fix the refresh issue --- Enigma/Enigma.csproj | 9 + Enigma/Popups/HostStationView.Designer.cs | 133 ++++++++++ Enigma/Popups/HostStationView.cs | 251 ++++++++++++++++++ Enigma/Popups/HostStationView.resx | 123 +++++++++ Enigma/Popups/Stations/DebugStation.cs | 22 ++ Enigma/Popups/Stations/HostStation.cs | 27 ++ Enigma/Popups/resAdd.Designer.cs | 183 +++++++++++++ Enigma/Popups/resAdd.cs | 87 ++++++ Enigma/Popups/resAdd.resx | 120 +++++++++ .../StationsGUI/HostStationView.Designer.cs | 21 ++ Enigma/StationsGUI/HostStationView.cs | 120 +++++++-- Enigma/StationsGUI/HostStationView.resx | 3 + EnigmaX/Classes/Party.cs | 22 ++ EnigmaX/Classes/Table.cs | 6 +- 14 files changed, 1103 insertions(+), 24 deletions(-) create mode 100644 Enigma/Popups/HostStationView.Designer.cs create mode 100644 Enigma/Popups/HostStationView.cs create mode 100644 Enigma/Popups/HostStationView.resx create mode 100644 Enigma/Popups/Stations/DebugStation.cs create mode 100644 Enigma/Popups/Stations/HostStation.cs create mode 100644 Enigma/Popups/resAdd.Designer.cs create mode 100644 Enigma/Popups/resAdd.cs create mode 100644 Enigma/Popups/resAdd.resx diff --git a/Enigma/Enigma.csproj b/Enigma/Enigma.csproj index 49659cd..f5ab589 100644 --- a/Enigma/Enigma.csproj +++ b/Enigma/Enigma.csproj @@ -68,6 +68,12 @@ AddParty.cs + + Form + + + resAdd.cs + Form @@ -99,6 +105,9 @@ AddParty.cs + + resAdd.cs + TableAssign.cs diff --git a/Enigma/Popups/HostStationView.Designer.cs b/Enigma/Popups/HostStationView.Designer.cs new file mode 100644 index 0000000..04f4820 --- /dev/null +++ b/Enigma/Popups/HostStationView.Designer.cs @@ -0,0 +1,133 @@ +namespace Enigma.StationsGUI +{ + partial class HostStationView + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.addToWaitlist = new MetroFramework.Controls.MetroButton(); + this.waitListRefresh = new System.Windows.Forms.Timer(this.components); + this.label1 = new System.Windows.Forms.Label(); + this.tableAssign = new MetroFramework.Controls.MetroButton(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); + this.SuspendLayout(); + // + // comboBox1 + // + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Items.AddRange(new object[] { + "Reservations", + "Wait List", + "Table Status"}); + this.comboBox1.Location = new System.Drawing.Point(21, 33); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(180, 24); + this.comboBox1.TabIndex = 0; + this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); + // + // dataGridView1 + // + this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.Window; + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView1.Location = new System.Drawing.Point(21, 63); + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.ReadOnly = true; + this.dataGridView1.RowTemplate.Height = 24; + this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dataGridView1.Size = new System.Drawing.Size(829, 616); + this.dataGridView1.TabIndex = 1; + this.dataGridView1.RowHeaderMouseDoubleClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dataGridView1_RowHeaderMouseDoubleClick); + // + // addToWaitlist + // + this.addToWaitlist.Location = new System.Drawing.Point(886, 63); + this.addToWaitlist.Name = "addToWaitlist"; + this.addToWaitlist.Size = new System.Drawing.Size(168, 78); + this.addToWaitlist.TabIndex = 2; + this.addToWaitlist.Text = "Add to Waitlist"; + this.addToWaitlist.UseSelectable = true; + this.addToWaitlist.Click += new System.EventHandler(this.addToWaitList_Click); + // + // waitListRefresh + // + this.waitListRefresh.Interval = 5000; + this.waitListRefresh.Tick += new System.EventHandler(this.waitListRefresh_Tick); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(883, 404); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(46, 17); + this.label1.TabIndex = 3; + this.label1.Text = "label1"; + // + // tableAssign + // + this.tableAssign.Location = new System.Drawing.Point(886, 170); + this.tableAssign.Name = "tableAssign"; + this.tableAssign.Size = new System.Drawing.Size(168, 78); + this.tableAssign.TabIndex = 4; + this.tableAssign.Text = "Assign to Table"; + this.tableAssign.UseSelectable = true; + this.tableAssign.Click += new System.EventHandler(this.tableAssign_Click); + // + // HostStationView + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1111, 747); + this.Controls.Add(this.tableAssign); + this.Controls.Add(this.label1); + this.Controls.Add(this.addToWaitlist); + this.Controls.Add(this.dataGridView1); + this.Controls.Add(this.comboBox1); + this.DisplayHeader = false; + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.Name = "HostStationView"; + this.Padding = new System.Windows.Forms.Padding(18, 30, 18, 16); + this.Text = "HostStationView"; + this.Load += new System.EventHandler(this.HostStationView_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ComboBox comboBox1; + private System.Windows.Forms.DataGridView dataGridView1; + private MetroFramework.Controls.MetroButton addToWaitlist; + private System.Windows.Forms.Timer waitListRefresh; + private System.Windows.Forms.Label label1; + private MetroFramework.Controls.MetroButton tableAssign; + } +} \ No newline at end of file diff --git a/Enigma/Popups/HostStationView.cs b/Enigma/Popups/HostStationView.cs new file mode 100644 index 0000000..b196c7c --- /dev/null +++ b/Enigma/Popups/HostStationView.cs @@ -0,0 +1,251 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using MetroFramework.Forms; +using MetroFramework; +using EnigmaX; +using System.Data.SqlClient; +using MySql.Data.MySqlClient; +using Enigma.Popups; +using EnigmaX.Classes; + + +namespace Enigma.StationsGUI +{ + public partial class HostStationView : MetroForm + { + DataTable dt = new DataTable(); + BindingSource SBind = new BindingSource(); + DBConnect db = new DBConnect(); + public List waitList = new List(); //The waitlist + public List
tables = new List
(); + public HostStationView() + { + InitializeComponent(); + waitListRefresh.Start(); //start the timer for incrmenting the wait time (updates every minute) for testing increment at 5sec + importTables(); + } + + private void HostStationView_Load(object sender, EventArgs e) + { + + } + + private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) + { + if (comboBox1.Text.Equals("Wait List")) //load the table for the waitlist + { + dt = new DataTable(); + SBind.DataSource = dt; + + dataGridView1.DataSource = SBind; + dataGridView1.Refresh(); + + //db.WriteCommand("select * from Waitlist "); + MySqlCommand cmd = new MySqlCommand("select Name, Party, initialWaitTime from Waitlist", db.getConnection()); + db.getConnection().Open(); + + MySqlDataAdapter sda = new MySqlDataAdapter(cmd); + sda.Fill(dt); + + //dt.Columns.Add(new DataColumn("Name", typeof(string))); + //dt.Columns.Add(new DataColumn("Reservation Time", typeof(string))); + + SBind.DataSource = dt; + + dataGridView1.DataSource = SBind; + dataGridView1.Refresh(); + + db.getConnection().Close(); + sda.Dispose(); + } + else if (comboBox1.Text.Equals("Reservations")) //load table for any reservation + { + //FINISH + dt = new DataTable(); + SBind.DataSource = dt; + + dataGridView1.DataSource = SBind; + dataGridView1.Refresh(); + + + + } + else if(comboBox1.Text.Equals("Table Status")) //Table statuses + { + dt = new DataTable(); + SBind.DataSource = dt; + + dataGridView1.DataSource = SBind; + dataGridView1.Refresh(); + + //db.WriteCommand("select * from Waitlist "); + MySqlCommand cmd = new MySqlCommand("SELECT tableNumber,Seats, status FROM Seating;", db.getConnection()); + db.getConnection().Open(); + + MySqlDataAdapter sda = new MySqlDataAdapter(cmd); + sda.Fill(dt); + + //dt.Columns.Add(new DataColumn("Name", typeof(string))); + //dt.Columns.Add(new DataColumn("Reservation Time", typeof(string))); + + SBind.DataSource = dt; + + dataGridView1.DataSource = SBind; + dataGridView1.Refresh(); + + db.getConnection().Close(); + sda.Dispose(); + + + } + } + + + + private void addToWaitList_Click(object sender, EventArgs e) + { + + waitListAdd wl = new waitListAdd(this); + wl.Show(); + + //waitList.Add(wl.getWaitList()); + } + + + + private void waitListRefresh_Tick(object sender, EventArgs e) //actions when the timer ticks + { + try + { + label1.Text = waitList.Count().ToString(); //FOR TESTING + label1.Refresh();//FOR TESTING + for (int i = 0; i < waitList.Count(); i++)//interate through all objects in the waitlist + { + + waitList[i].decrementTime();//change the time in the local party object + + db.getConnection().Open(); //open a channel + //update the initialWaitTime in the sql table + MySqlCommand cmd = new MySqlCommand("UPDATE Waitlist SET initialWaitTime = @initialWaitTime WHERE Name = @Name and Party = @Party", db.getConnection()); + //parametrize the variables + cmd.Parameters.Add("@initialWaitTime", waitList[i].getWaitTime()); + cmd.Parameters.Add("@Name", waitList[i].getName()); + cmd.Parameters.Add("@Party", waitList[i].getCount()); + cmd.ExecuteNonQuery(); //execute the update + db.getConnection().Close(); //close the channel + dataGridView1.Refresh(); //check if works + + } + } + catch + { + + } + dataGridView1.Refresh(); //check if works + } + + + public void setList(Party party) //called by waitListAdd popup to add new party to list + { + waitList.Add(party); + } + + + + private void dataGridView1_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)//when row header is double clicked + { + //open a message box asking to confirm deletion + DialogResult dialogResult = MetroMessageBox.Show(this,"Do you want to delete this customer from the waitlist?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); + if (dialogResult == DialogResult.Yes)//if yes, proceed with deletion + { + foreach(DataGridViewRow row in dataGridView1.SelectedRows)//take the selected row and split data + { + string name = row.Cells[0].Value.ToString(); + string partySize = row.Cells[1].Value.ToString(); + string waitTime = row.Cells[2].Value.ToString(); + + for (int i = 0; i < waitList.Count(); i++)//iterate through local list to find the party + { + + if (waitList[i].getName().Equals(name) && waitList[i].getCount().ToString().Equals(partySize)) + { + waitList.Remove(waitList[i]);//remove the party from the list + + db.getConnection().Open(); //remove the row from the sql table + MySqlCommand cmd = new MySqlCommand("DELETE FROM Waitlist WHERE Name = @Name and Party = @Party", db.getConnection()); + cmd.Parameters.Add("@Name", name); + cmd.Parameters.Add("@Party", partySize); + cmd.ExecuteNonQuery(); + db.getConnection().Close(); + } + } + } + + + } + else if (dialogResult == DialogResult.No) + { + //do something else + } + } + + private void tableAssign_Click(object sender, EventArgs e) + { + /* for(int i=0; i < tables.Count(); i++) + { + MessageBox.Show(tables[i]._tableStatus.ToString()); + }*/ + + + foreach (DataGridViewRow row in dataGridView1.SelectedRows)//take the selected row and split data + { + string name = row.Cells[0].Value.ToString(); + string partySize = row.Cells[1].Value.ToString(); + string waitTime = row.Cells[2].Value.ToString(); + + TableAssign ta = new TableAssign(this, name, partySize); + ta.Show(); + } + + + + } + + private void importTables() + { + MySqlCommand cmd = new MySqlCommand("SELECT * FROM Seating", db.getConnection()); + try + { + db.getConnection().Open(); + MySqlDataReader reader = cmd.ExecuteReader(); + Table table; + while (reader.Read()) + { + int tableNumber = Int32.Parse(reader["tableNumber"].ToString()); + int tableCapacity = Int32.Parse(reader["seats"].ToString()); + string tableOccupied = reader["TableOccupied"].ToString(); + string reservation = reader["reservation"].ToString(); + string tableStatus = reader["status"].ToString(); + + table = new Table(tableNumber, tableCapacity, reservation, tableStatus); + tables.Add(table); + table = new Table(); + } + db.getConnection().Close(); + } + catch(SqlException ex) + { + + } + } + + + } +} diff --git a/Enigma/Popups/HostStationView.resx b/Enigma/Popups/HostStationView.resx new file mode 100644 index 0000000..734ee48 --- /dev/null +++ b/Enigma/Popups/HostStationView.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 17, 17 + + \ No newline at end of file diff --git a/Enigma/Popups/Stations/DebugStation.cs b/Enigma/Popups/Stations/DebugStation.cs new file mode 100644 index 0000000..2f54f74 --- /dev/null +++ b/Enigma/Popups/Stations/DebugStation.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using EnigmaX.Classes; +namespace Enigma.Stations +{ + public class DebugStation : Station + { + public DebugStation(StationTypeDef type, string stationid) : base(type, stationid) + { + + view = new DebugStationView(this); + } + + public override void showView() + { + view.Show(); + } + } +} diff --git a/Enigma/Popups/Stations/HostStation.cs b/Enigma/Popups/Stations/HostStation.cs new file mode 100644 index 0000000..4da3379 --- /dev/null +++ b/Enigma/Popups/Stations/HostStation.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using EnigmaX.Classes; + +namespace Enigma.Stations +{ + class HostStation : Station + { + + public List
tables = new List
(); + + public HostStation(StationTypeDef type, string stationid) : base(type, stationid) + { + view = new StationsGUI.HostStationView(); + + } + + public override void showView() + { + view.Show(); + } + + } +} diff --git a/Enigma/Popups/resAdd.Designer.cs b/Enigma/Popups/resAdd.Designer.cs new file mode 100644 index 0000000..dbac701 --- /dev/null +++ b/Enigma/Popups/resAdd.Designer.cs @@ -0,0 +1,183 @@ +namespace Enigma.Popups +{ + partial class resAdd + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.addRes = new MetroFramework.Controls.MetroButton(); + this.resTime = new MetroFramework.Controls.MetroLabel(); + this.sizeInput = new System.Windows.Forms.NumericUpDown(); + this.partySize = new MetroFramework.Controls.MetroLabel(); + this.partyName = new MetroFramework.Controls.MetroLabel(); + this.inputName = new MetroFramework.Controls.MetroTextBox(); + this.hour = new System.Windows.Forms.NumericUpDown(); + this.label1 = new System.Windows.Forms.Label(); + this.minutes = new System.Windows.Forms.NumericUpDown(); + ((System.ComponentModel.ISupportInitialize)(this.sizeInput)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.hour)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.minutes)).BeginInit(); + this.SuspendLayout(); + // + // addRes + // + this.addRes.Location = new System.Drawing.Point(364, 71); + this.addRes.Name = "addRes"; + this.addRes.Size = new System.Drawing.Size(124, 75); + this.addRes.TabIndex = 13; + this.addRes.Text = "Add Reservation"; + this.addRes.UseSelectable = true; + this.addRes.Click += new System.EventHandler(this.addRes_Click); + // + // resTime + // + this.resTime.AutoSize = true; + this.resTime.Location = new System.Drawing.Point(23, 126); + this.resTime.Name = "resTime"; + this.resTime.Size = new System.Drawing.Size(117, 20); + this.resTime.TabIndex = 11; + this.resTime.Text = "Reservation TIme"; + // + // sizeInput + // + this.sizeInput.Location = new System.Drawing.Point(162, 100); + this.sizeInput.Name = "sizeInput"; + this.sizeInput.Size = new System.Drawing.Size(120, 22); + this.sizeInput.TabIndex = 10; + // + // partySize + // + this.partySize.AutoSize = true; + this.partySize.Location = new System.Drawing.Point(23, 102); + this.partySize.Name = "partySize"; + this.partySize.Size = new System.Drawing.Size(69, 20); + this.partySize.TabIndex = 9; + this.partySize.Text = "Party Size"; + // + // partyName + // + this.partyName.AutoSize = true; + this.partyName.Location = new System.Drawing.Point(23, 78); + this.partyName.Name = "partyName"; + this.partyName.Size = new System.Drawing.Size(47, 20); + this.partyName.TabIndex = 8; + this.partyName.Text = "Name"; + // + // inputName + // + // + // + // + this.inputName.CustomButton.Image = null; + this.inputName.CustomButton.Location = new System.Drawing.Point(132, 1); + this.inputName.CustomButton.Name = ""; + this.inputName.CustomButton.Size = new System.Drawing.Size(21, 21); + this.inputName.CustomButton.Style = MetroFramework.MetroColorStyle.Blue; + this.inputName.CustomButton.TabIndex = 1; + this.inputName.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light; + this.inputName.CustomButton.UseSelectable = true; + this.inputName.CustomButton.Visible = false; + this.inputName.Lines = new string[] { + "metroTextBox1"}; + this.inputName.Location = new System.Drawing.Point(162, 75); + this.inputName.MaxLength = 32767; + this.inputName.Name = "inputName"; + this.inputName.PasswordChar = '\0'; + this.inputName.ScrollBars = System.Windows.Forms.ScrollBars.None; + this.inputName.SelectedText = ""; + this.inputName.SelectionLength = 0; + this.inputName.SelectionStart = 0; + this.inputName.ShortcutsEnabled = true; + this.inputName.Size = new System.Drawing.Size(154, 23); + this.inputName.TabIndex = 7; + this.inputName.Text = "metroTextBox1"; + this.inputName.UseSelectable = true; + this.inputName.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109))))); + this.inputName.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel); + // + // hour + // + this.hour.Location = new System.Drawing.Point(162, 129); + this.hour.Name = "hour"; + this.hour.Size = new System.Drawing.Size(48, 22); + this.hour.TabIndex = 14; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(216, 131); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(12, 17); + this.label1.TabIndex = 15; + this.label1.Text = ":"; + // + // minutes + // + this.minutes.Location = new System.Drawing.Point(234, 129); + this.minutes.Name = "minutes"; + this.minutes.Size = new System.Drawing.Size(59, 22); + this.minutes.TabIndex = 16; + // + // resAdd + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(583, 203); + this.Controls.Add(this.minutes); + this.Controls.Add(this.label1); + this.Controls.Add(this.hour); + this.Controls.Add(this.addRes); + this.Controls.Add(this.resTime); + this.Controls.Add(this.sizeInput); + this.Controls.Add(this.partySize); + this.Controls.Add(this.partyName); + this.Controls.Add(this.inputName); + this.DisplayHeader = false; + this.Name = "resAdd"; + this.Padding = new System.Windows.Forms.Padding(20, 30, 20, 20); + this.Text = "resAdd"; + this.Load += new System.EventHandler(this.resAdd_Load); + ((System.ComponentModel.ISupportInitialize)(this.sizeInput)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.hour)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.minutes)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private MetroFramework.Controls.MetroButton addRes; + private MetroFramework.Controls.MetroLabel resTime; + private System.Windows.Forms.NumericUpDown sizeInput; + private MetroFramework.Controls.MetroLabel partySize; + private MetroFramework.Controls.MetroLabel partyName; + private MetroFramework.Controls.MetroTextBox inputName; + private System.Windows.Forms.NumericUpDown hour; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.NumericUpDown minutes; + } +} \ No newline at end of file diff --git a/Enigma/Popups/resAdd.cs b/Enigma/Popups/resAdd.cs new file mode 100644 index 0000000..e98b467 --- /dev/null +++ b/Enigma/Popups/resAdd.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using MetroFramework.Forms; +using Enigma.StationsGUI; +using EnigmaX.Classes; +using EnigmaX; +using MySql.Data.MySqlClient; + + +namespace Enigma.Popups +{ + public partial class resAdd : MetroForm + { + HostStationView hsv; + DBConnect db = new DBConnect(); + Party party = new Party(); + public resAdd(HostStationView hsv) + { + InitializeComponent(); + this.hsv = hsv; + } + + private void resAdd_Load(object sender, EventArgs e) + { + + } + + private void metroDateTime1_ValueChanged(object sender, EventArgs e) + { + + } + + private void addRes_Click(object sender, EventArgs e) + { + DateTime time = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, (int)hour.Value, (int)minutes.Value, 0); + + + for (int i = 0; i < hsv.tables.Count(); i++) + { + if (hsv.tables[i].getStatus()==1 /*denotes empty in terms of sql enums*/ && hsv.tables[i].getTableCapacity()==sizeInput.Value) + { + hsv.tables[i].setStatus("reserved"); + + db.getConnection().Open(); //open a channel + //update the initialWaitTime in the sql table + MySqlCommand cmd = new MySqlCommand("UPDATE Seating SET status = @status WHERE tableNumber = @tableNumber and Seats = @Seats", db.getConnection()); + //parametrize the variables + cmd.Parameters.Add("@status", hsv.tables[i].getStatus()); + cmd.Parameters.Add("@tableNumber", hsv.tables[i].getTableNumber()); + cmd.Parameters.Add("@Seats", hsv.tables[i].getTableCapacity()); + cmd.ExecuteNonQuery(); //execute the update + db.getConnection().Close(); + + party = new Party(inputName.Text, (int)sizeInput.Value, time, hsv.tables[i].getTableNumber()); + hsv.resListAdd(party); + break; + } + else if(hsv.tables[i].getStatus() == 1 /*denotes empty in terms of sql enums*/ && hsv.tables[i].getTableCapacity() > sizeInput.Value) + { + hsv.tables[i].setStatus("reserved"); + + db.getConnection().Open(); //open a channel + //update the initialWaitTime in the sql table + MySqlCommand cmd = new MySqlCommand("UPDATE Seating SET status = @status WHERE tableNumber = @tableNumber and Seats = @Seats", db.getConnection()); + //parametrize the variables + cmd.Parameters.Add("@status", hsv.tables[i].getStatus()); + cmd.Parameters.Add("@tableNumber", hsv.tables[i].getTableNumber()); + cmd.Parameters.Add("@Seats", hsv.tables[i].getTableCapacity()); + cmd.ExecuteNonQuery(); //execute the update + db.getConnection().Close(); + + party = new Party(inputName.Text, (int)sizeInput.Value, time, hsv.tables[i].getTableNumber()); + hsv.resListAdd(party); + break; + } + } + this.Close(); + } + } +} diff --git a/Enigma/Popups/resAdd.resx b/Enigma/Popups/resAdd.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Enigma/Popups/resAdd.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/Enigma/StationsGUI/HostStationView.Designer.cs b/Enigma/StationsGUI/HostStationView.Designer.cs index 04f4820..2b94ef4 100644 --- a/Enigma/StationsGUI/HostStationView.Designer.cs +++ b/Enigma/StationsGUI/HostStationView.Designer.cs @@ -35,6 +35,8 @@ private void InitializeComponent() this.waitListRefresh = new System.Windows.Forms.Timer(this.components); this.label1 = new System.Windows.Forms.Label(); this.tableAssign = new MetroFramework.Controls.MetroButton(); + this.viewRefresh = new System.Windows.Forms.Timer(this.components); + this.resAdd = new MetroFramework.Controls.MetroButton(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.SuspendLayout(); // @@ -99,11 +101,27 @@ private void InitializeComponent() this.tableAssign.UseSelectable = true; this.tableAssign.Click += new System.EventHandler(this.tableAssign_Click); // + // viewRefresh + // + this.viewRefresh.Interval = 5000; + this.viewRefresh.Tick += new System.EventHandler(this.viewRefresh_Tick); + // + // resAdd + // + this.resAdd.Location = new System.Drawing.Point(886, 274); + this.resAdd.Name = "resAdd"; + this.resAdd.Size = new System.Drawing.Size(168, 77); + this.resAdd.TabIndex = 5; + this.resAdd.Text = "Add Reservation"; + this.resAdd.UseSelectable = true; + this.resAdd.Click += new System.EventHandler(this.resAdd_Click); + // // HostStationView // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1111, 747); + this.Controls.Add(this.resAdd); this.Controls.Add(this.tableAssign); this.Controls.Add(this.label1); this.Controls.Add(this.addToWaitlist); @@ -114,6 +132,7 @@ private void InitializeComponent() this.Name = "HostStationView"; this.Padding = new System.Windows.Forms.Padding(18, 30, 18, 16); this.Text = "HostStationView"; + this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.HostStationView_FormClosed); this.Load += new System.EventHandler(this.HostStationView_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.ResumeLayout(false); @@ -129,5 +148,7 @@ private void InitializeComponent() private System.Windows.Forms.Timer waitListRefresh; private System.Windows.Forms.Label label1; private MetroFramework.Controls.MetroButton tableAssign; + private System.Windows.Forms.Timer viewRefresh; + private MetroFramework.Controls.MetroButton resAdd; } } \ No newline at end of file diff --git a/Enigma/StationsGUI/HostStationView.cs b/Enigma/StationsGUI/HostStationView.cs index b196c7c..aa4f2bb 100644 --- a/Enigma/StationsGUI/HostStationView.cs +++ b/Enigma/StationsGUI/HostStationView.cs @@ -20,15 +20,18 @@ namespace Enigma.StationsGUI { public partial class HostStationView : MetroForm { - DataTable dt = new DataTable(); - BindingSource SBind = new BindingSource(); - DBConnect db = new DBConnect(); + DataTable dt = new DataTable(); //data table + BindingSource SBind = new BindingSource(); //intermediary between datatable and data view + DBConnect db = new DBConnect(); //database connect dll public List waitList = new List(); //The waitlist public List
tables = new List
(); + public List reservations = new List(); + public HostStationView() { InitializeComponent(); waitListRefresh.Start(); //start the timer for incrmenting the wait time (updates every minute) for testing increment at 5sec + //viewRefresh.Start(); importTables(); } @@ -41,47 +44,64 @@ private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox1.Text.Equals("Wait List")) //load the table for the waitlist { - dt = new DataTable(); - SBind.DataSource = dt; - - dataGridView1.DataSource = SBind; - dataGridView1.Refresh(); - - //db.WriteCommand("select * from Waitlist "); + //This is to make sure there is no existing data in the view, therefore acting as a reset + dt = new DataTable(); //initialization of the data table + SBind.DataSource = dt; //the source for the intermediary is from the data table + dataGridView1.DataSource = SBind; //the source for the view is the binding source + dataGridView1.Refresh(); //redraw the form + + //SQL call that is sent to the database to query + //this call just recieves the name, paty, initialWaitTime columns from the waitlist MySqlCommand cmd = new MySqlCommand("select Name, Party, initialWaitTime from Waitlist", db.getConnection()); - db.getConnection().Open(); - - MySqlDataAdapter sda = new MySqlDataAdapter(cmd); - sda.Fill(dt); - - //dt.Columns.Add(new DataColumn("Name", typeof(string))); - //dt.Columns.Add(new DataColumn("Reservation Time", typeof(string))); + db.getConnection().Open(); //open the connection dialog + MySqlDataAdapter sda = new MySqlDataAdapter(cmd); //this is just a data adapter for the mySql + sda.Fill(dt); //fill the data table with the data adapter + + //binding as done above SBind.DataSource = dt; - dataGridView1.DataSource = SBind; dataGridView1.Refresh(); - db.getConnection().Close(); - sda.Dispose(); + db.getConnection().Close(); //close the dialog connecting to the database + sda.Dispose();//get rid of the data stored in the data adapter } else if (comboBox1.Text.Equals("Reservations")) //load table for any reservation { //FINISH dt = new DataTable(); SBind.DataSource = dt; + dataGridView1.DataSource = SBind; + dataGridView1.Refresh(); + + + dt = new DataTable(); + dt.Columns.Add("Name"); + dt.Columns.Add("Party Size"); + dt.Columns.Add("Reservation Time"); + DataRow row = dt.NewRow(); + for (int i=0; i < reservations.Count(); i++) + { + row = dt.NewRow(); + row["Name"] = reservations[i].getName(); + row["Party Size"] = reservations[i].getCount(); + row["Reservation Time"] = reservations[i].getResTime().ToString(); + dt.Rows.Add(row); + } + SBind.DataSource = dt; dataGridView1.DataSource = SBind; dataGridView1.Refresh(); - - + + + + } else if(comboBox1.Text.Equals("Table Status")) //Table statuses { dt = new DataTable(); SBind.DataSource = dt; - dataGridView1.DataSource = SBind; dataGridView1.Refresh(); @@ -245,7 +265,61 @@ private void importTables() } } + //this action occurs when the form is closed, hence the end of a day, causing all data in the waitlist to be deleted. + //Truncation will not occur if program crashes + private void HostStationView_FormClosed(object sender, FormClosedEventArgs e) + { + db.getConnection().Open(); //remove the row from the sql table + MySqlCommand cmd = new MySqlCommand("TRUNCATE Table Waitlist", db.getConnection()); + + cmd.ExecuteNonQuery(); + + cmd = new MySqlCommand("UPDATE Seating SET status = @status ", db.getConnection()); + //parametrize the variables + cmd.Parameters.Add("@status", 1); + cmd.ExecuteNonQuery(); + db.getConnection().Close(); + } + + private void viewRefresh_Tick(object sender, EventArgs e) + { + if(comboBox1.Text.Equals("Wait List")) + { + //This is to make sure there is no existing data in the view, therefore acting as a reset + dt = new DataTable(); //initialization of the data table + SBind.DataSource = dt; //the source for the intermediary is from the data table + dataGridView1.DataSource = SBind; //the source for the view is the binding source + dataGridView1.Refresh(); //redraw the form + + //SQL call that is sent to the database to query + //this call just recieves the name, paty, initialWaitTime columns from the waitlist + MySqlCommand cmd = new MySqlCommand("select Name, Party, initialWaitTime from Waitlist", db.getConnection()); + db.getConnection().Open(); //open the connection dialog + + MySqlDataAdapter sda = new MySqlDataAdapter(cmd); //this is just a data adapter for the mySql + sda.Fill(dt); //fill the data table with the data adapter + + //binding as done above + SBind.DataSource = dt; + dataGridView1.DataSource = SBind; + dataGridView1.Refresh(); + + db.getConnection().Close(); //close the dialog connecting to the database + sda.Dispose();//get rid of the data stored in the data adapter + } + } + + private void resAdd_Click(object sender, EventArgs e) + { + resAdd ra = new resAdd(this); + ra.Show(); + } + + public void resListAdd(Party party) + { + reservations.Add(party); + } } } diff --git a/Enigma/StationsGUI/HostStationView.resx b/Enigma/StationsGUI/HostStationView.resx index 734ee48..7777df2 100644 --- a/Enigma/StationsGUI/HostStationView.resx +++ b/Enigma/StationsGUI/HostStationView.resx @@ -120,4 +120,7 @@ 17, 17 + + 175, 17 + \ No newline at end of file diff --git a/EnigmaX/Classes/Party.cs b/EnigmaX/Classes/Party.cs index cb4ec87..289fd53 100644 --- a/EnigmaX/Classes/Party.cs +++ b/EnigmaX/Classes/Party.cs @@ -14,6 +14,8 @@ public class Party public int _waitTime; public Table _table; public int _count; + public DateTime _resTime; + public int _tableAssigned; public Party() { @@ -28,6 +30,7 @@ public Party(string name, int count) _queueTime = new DateTime(); this._waitTime = 0; } + //for waitlist public Party(string name, int count, int waitTime) { this._name = name; _table = null; @@ -36,6 +39,15 @@ public Party(string name, int count, int waitTime) { this._waitTime = waitTime; } + public Party(string name, int count, DateTime dt, int tableAssigned) + { + this._name = name; + _tableAssigned = tableAssigned; + this._count = count; + _resTime = dt; + + } + public void setTable(Table table) { this._table = table; @@ -58,6 +70,7 @@ public int getWaitTime() { return _waitTime; } + public void decrementTime() { if (_waitTime > 0) @@ -70,5 +83,14 @@ public void decrementTime() } } + public DateTime getResTime() + { + return _resTime; + } + + public int gettableAssigned() + { + return _tableAssigned; + } } } diff --git a/EnigmaX/Classes/Table.cs b/EnigmaX/Classes/Table.cs index 73b4968..b5078d4 100644 --- a/EnigmaX/Classes/Table.cs +++ b/EnigmaX/Classes/Table.cs @@ -12,7 +12,7 @@ public class Table public int _capacity; //Seats public int _count; public enum _reservation { no, yes}; - public enum _status{empty, seated, ordered, served, paid };//NOTE SQL ENUMS START WITH 1! + public enum _status{empty, seated, ordered, served, paid, reserved };//NOTE SQL ENUMS START WITH 1! public bool tableOccupied; //IF NECESSARY public bool isReservation; public int _tableStatus; @@ -50,6 +50,7 @@ public Table(int id, int capacity, string reservation, string status) case _status.ordered: _tableStatus = 2; break; case _status.served: _tableStatus = 3; break; case _status.paid: _tableStatus = 4; break; + case _status.reserved: _tableStatus = 5;break; } } } @@ -108,8 +109,11 @@ public void setStatus(string status) case _status.ordered: _tableStatus = 2; break; case _status.served: _tableStatus = 3; break; case _status.paid: _tableStatus = 4; break; + case _status.reserved: _tableStatus = 5; break; } } } + + } }