From ea974c31da0f587516ff86aca5b85cfb0fba9fa2 Mon Sep 17 00:00:00 2001 From: "RKant\\TEST" Date: Thu, 16 Mar 2017 16:21:54 -0400 Subject: [PATCH] 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; + } + } + } } }