diff --git a/Enigma/Popups/TableAssign.Designer.cs b/Enigma/Popups/TableAssign.Designer.cs index 985186b..f599b87 100644 --- a/Enigma/Popups/TableAssign.Designer.cs +++ b/Enigma/Popups/TableAssign.Designer.cs @@ -145,6 +145,7 @@ private void InitializeComponent() this.DisplayHeader = false; this.Name = "TableAssign"; this.Padding = new System.Windows.Forms.Padding(20, 30, 20, 20); + this.Style = MetroFramework.MetroColorStyle.Green; this.Text = "TableAssign"; this.Load += new System.EventHandler(this.TableAssign_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); diff --git a/Enigma/Popups/checkoutTablePopup.Designer.cs b/Enigma/Popups/checkoutTablePopup.Designer.cs index 4a5e14b..feb013d 100644 --- a/Enigma/Popups/checkoutTablePopup.Designer.cs +++ b/Enigma/Popups/checkoutTablePopup.Designer.cs @@ -60,6 +60,7 @@ private void InitializeComponent() this.confirm.TabIndex = 2; this.confirm.Text = "Ok"; this.confirm.UseSelectable = true; + this.confirm.Click += new System.EventHandler(this.confirm_Click); // // checkoutTablePopup // @@ -72,6 +73,7 @@ private void InitializeComponent() this.DisplayHeader = false; this.Name = "checkoutTablePopup"; this.Padding = new System.Windows.Forms.Padding(20, 30, 20, 20); + this.Style = MetroFramework.MetroColorStyle.Red; this.Text = "checkoutTablePopup"; this.Load += new System.EventHandler(this.checkoutTablePopup_Load); this.ResumeLayout(false); diff --git a/Enigma/Popups/checkoutTablePopup.cs b/Enigma/Popups/checkoutTablePopup.cs index 72ac31f..a0a3ead 100644 --- a/Enigma/Popups/checkoutTablePopup.cs +++ b/Enigma/Popups/checkoutTablePopup.cs @@ -8,19 +8,43 @@ using System.Threading.Tasks; using System.Windows.Forms; using MetroFramework.Forms; +using EnigmaX; +using EnigmaX.Classes; +using Enigma.StationsGUI; +using MySql.Data.MySqlClient; namespace Enigma.Popups { public partial class checkoutTablePopup : MetroForm { - public checkoutTablePopup() + WaiterStationView wsv = new WaiterStationView(); + public checkoutTablePopup(WaiterStationView waiterStation) { InitializeComponent(); + wsv = waiterStation; } private void checkoutTablePopup_Load(object sender, EventArgs e) { } + + private void confirm_Click(object sender, EventArgs e) + { + DBConnect db = new DBConnect(); + db.getConnection().Open(); + MySqlCommand cmd = new MySqlCommand("UPDATE Seating SET status = @status WHERE tableNumber = @tableNumber", db.getConnection()); + //parametrize the variables + cmd.Parameters.AddWithValue("@status", 1); + cmd.Parameters.AddWithValue("@tableNumber", wsv._tableNumber); + cmd.ExecuteNonQuery(); + + cmd = new MySqlCommand("UPDATE Seating SET tableOrder = @tableOrder WHERE tableNumber = @tableNumber", db.getConnection()); + cmd.Parameters.AddWithValue("@tableOrder", null); + cmd.Parameters.AddWithValue("@tableNumber", wsv._tableNumber); + cmd.ExecuteNonQuery(); + + db.getConnection().Close(); + } } } diff --git a/Enigma/Popups/chequePrintPopup.Designer.cs b/Enigma/Popups/chequePrintPopup.Designer.cs index 29b8428..46b4ae5 100644 --- a/Enigma/Popups/chequePrintPopup.Designer.cs +++ b/Enigma/Popups/chequePrintPopup.Designer.cs @@ -32,8 +32,10 @@ private void InitializeComponent() this.printConfirm = new MetroFramework.Controls.MetroButton(); this.metroLabel1 = new MetroFramework.Controls.MetroLabel(); this.metroLabel2 = new MetroFramework.Controls.MetroLabel(); - this.listBox1 = new System.Windows.Forms.ListBox(); + this.ticketItems = new System.Windows.Forms.ListBox(); this.metroLabel3 = new MetroFramework.Controls.MetroLabel(); + this.ticketTotalCost = new MetroFramework.Controls.MetroLabel(); + this.ticketTax = new MetroFramework.Controls.MetroLabel(); this.SuspendLayout(); // // cancel @@ -44,6 +46,7 @@ private void InitializeComponent() this.cancel.TabIndex = 0; this.cancel.Text = "Cancel"; this.cancel.UseSelectable = true; + this.cancel.Click += new System.EventHandler(this.cancel_Click); // // printConfirm // @@ -53,6 +56,7 @@ private void InitializeComponent() this.printConfirm.TabIndex = 1; this.printConfirm.Text = "Print"; this.printConfirm.UseSelectable = true; + this.printConfirm.Click += new System.EventHandler(this.printConfirm_Click); // // metroLabel1 // @@ -72,14 +76,15 @@ private void InitializeComponent() this.metroLabel2.TabIndex = 4; this.metroLabel2.Text = "Tax:"; // - // listBox1 + // ticketItems // - this.listBox1.FormattingEnabled = true; - this.listBox1.ItemHeight = 16; - this.listBox1.Location = new System.Drawing.Point(11, 15); - this.listBox1.Name = "listBox1"; - this.listBox1.Size = new System.Drawing.Size(328, 228); - this.listBox1.TabIndex = 5; + this.ticketItems.Font = new System.Drawing.Font("Segoe UI Light", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.ticketItems.FormattingEnabled = true; + this.ticketItems.ItemHeight = 31; + this.ticketItems.Location = new System.Drawing.Point(11, 15); + this.ticketItems.Name = "ticketItems"; + this.ticketItems.Size = new System.Drawing.Size(328, 221); + this.ticketItems.TabIndex = 5; // // metroLabel3 // @@ -90,13 +95,33 @@ private void InitializeComponent() this.metroLabel3.TabIndex = 6; this.metroLabel3.Text = "metroLabel3"; // + // ticketTotalCost + // + this.ticketTotalCost.AutoSize = true; + this.ticketTotalCost.Location = new System.Drawing.Point(89, 280); + this.ticketTotalCost.Name = "ticketTotalCost"; + this.ticketTotalCost.Size = new System.Drawing.Size(87, 20); + this.ticketTotalCost.TabIndex = 7; + this.ticketTotalCost.Text = "metroLabel4"; + // + // ticketTax + // + this.ticketTax.AutoSize = true; + this.ticketTax.Location = new System.Drawing.Point(89, 250); + this.ticketTax.Name = "ticketTax"; + this.ticketTax.Size = new System.Drawing.Size(87, 20); + this.ticketTax.TabIndex = 8; + this.ticketTax.Text = "metroLabel4"; + // // chequePrintPopup // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(468, 352); + this.Controls.Add(this.ticketTax); + this.Controls.Add(this.ticketTotalCost); this.Controls.Add(this.metroLabel3); - this.Controls.Add(this.listBox1); + this.Controls.Add(this.ticketItems); this.Controls.Add(this.metroLabel2); this.Controls.Add(this.metroLabel1); this.Controls.Add(this.printConfirm); @@ -104,6 +129,7 @@ private void InitializeComponent() this.DisplayHeader = false; this.Name = "chequePrintPopup"; this.Padding = new System.Windows.Forms.Padding(20, 30, 20, 20); + this.Style = MetroFramework.MetroColorStyle.Red; this.Text = "chequePrintPopup"; this.Load += new System.EventHandler(this.chequePrintCheck_Load); this.ResumeLayout(false); @@ -117,7 +143,9 @@ private void InitializeComponent() private MetroFramework.Controls.MetroButton printConfirm; private MetroFramework.Controls.MetroLabel metroLabel1; private MetroFramework.Controls.MetroLabel metroLabel2; - private System.Windows.Forms.ListBox listBox1; + private System.Windows.Forms.ListBox ticketItems; private MetroFramework.Controls.MetroLabel metroLabel3; + private MetroFramework.Controls.MetroLabel ticketTotalCost; + private MetroFramework.Controls.MetroLabel ticketTax; } } \ No newline at end of file diff --git a/Enigma/Popups/chequePrintPopup.cs b/Enigma/Popups/chequePrintPopup.cs index 5716dab..9be4633 100644 --- a/Enigma/Popups/chequePrintPopup.cs +++ b/Enigma/Popups/chequePrintPopup.cs @@ -26,6 +26,8 @@ public chequePrintPopup(WaiterStationView waiterStation) InitializeComponent(); wsv = waiterStation; importTableOrder(); + drawOrderedItems(); + } private void chequePrintCheck_Load(object sender, EventArgs e) @@ -57,5 +59,49 @@ private void importTableOrder() } } + + private void drawOrderedItems() + { + ticketItems.Items.Clear(); + foreach (EnigmaMenuItem item in tableOrderList) + { + ticketItems.Items.Add(item); + } + costCalculator(); //cost info updated + } + + private void costCalculator() + { + float preTaxTotal = 0; + float tax = 0; + float postTaxTotal = 0; + foreach(EnigmaMenuItem item in tableOrderList) + { + preTaxTotal += item.Price; + } + tax = preTaxTotal * (float)0.0635; + postTaxTotal = preTaxTotal + tax; + + ticketTax.Text = String.Format("{0:0.00}", tax); + ticketTotalCost.Text= String.Format("{0:0.00}", postTaxTotal); + } + + private void cancel_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void printConfirm_Click(object sender, EventArgs e) + { + DBConnect db = new DBConnect(); + db.getConnection().Open(); + MySqlCommand cmd = new MySqlCommand("UPDATE Seating SET status = @status WHERE tableNumber = @tableNumber", db.getConnection()); + //parametrize the variables + cmd.Parameters.AddWithValue("@status", 5); + cmd.Parameters.AddWithValue("@tableNumber", wsv._tableNumber); + cmd.ExecuteNonQuery(); + db.getConnection().Close(); + this.Close(); + } } } diff --git a/Enigma/Popups/resAdd.Designer.cs b/Enigma/Popups/resAdd.Designer.cs index dbac701..350e1ca 100644 --- a/Enigma/Popups/resAdd.Designer.cs +++ b/Enigma/Popups/resAdd.Designer.cs @@ -158,6 +158,7 @@ private void InitializeComponent() this.DisplayHeader = false; this.Name = "resAdd"; this.Padding = new System.Windows.Forms.Padding(20, 30, 20, 20); + this.Style = MetroFramework.MetroColorStyle.Green; this.Text = "resAdd"; this.Load += new System.EventHandler(this.resAdd_Load); ((System.ComponentModel.ISupportInitialize)(this.sizeInput)).EndInit(); diff --git a/Enigma/Popups/waitListAdd.Designer.cs b/Enigma/Popups/waitListAdd.Designer.cs index c5df775..5a60ba0 100644 --- a/Enigma/Popups/waitListAdd.Designer.cs +++ b/Enigma/Popups/waitListAdd.Designer.cs @@ -135,6 +135,7 @@ private void InitializeComponent() this.Controls.Add(this.metroLabel1); this.Controls.Add(this.inputName); this.Name = "waitListAdd"; + this.Style = MetroFramework.MetroColorStyle.Green; this.Text = "Form1"; this.Load += new System.EventHandler(this.waitListAdd_Load); ((System.ComponentModel.ISupportInitialize)(this.sizeInput)).EndInit(); diff --git a/Enigma/StationsGUI/HostStationView.Designer.cs b/Enigma/StationsGUI/HostStationView.Designer.cs index 7f5b974..4cdc1d9 100644 --- a/Enigma/StationsGUI/HostStationView.Designer.cs +++ b/Enigma/StationsGUI/HostStationView.Designer.cs @@ -120,6 +120,7 @@ private void InitializeComponent() 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.Style = MetroFramework.MetroColorStyle.Green; this.Text = "HostStationView"; this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.HostStationView_FormClosed); this.Load += new System.EventHandler(this.HostStationView_Load); diff --git a/Enigma/StationsGUI/WaiterStationView.Designer.cs b/Enigma/StationsGUI/WaiterStationView.Designer.cs index 2119d2c..01b6ff2 100644 --- a/Enigma/StationsGUI/WaiterStationView.Designer.cs +++ b/Enigma/StationsGUI/WaiterStationView.Designer.cs @@ -64,6 +64,7 @@ private void InitializeComponent() this.checkoutTable.TabIndex = 3; this.checkoutTable.Text = "Checkout Table"; this.checkoutTable.UseSelectable = true; + this.checkoutTable.Click += new System.EventHandler(this.checkoutTable_Click); // // printCheque // diff --git a/Enigma/StationsGUI/WaiterStationView.cs b/Enigma/StationsGUI/WaiterStationView.cs index 03e3f47..171aa33 100644 --- a/Enigma/StationsGUI/WaiterStationView.cs +++ b/Enigma/StationsGUI/WaiterStationView.cs @@ -48,5 +48,11 @@ private void setTableNumber(int tableNum) { _tableNumber = tableNum; } + + private void checkoutTable_Click(object sender, EventArgs e) + { + checkoutTablePopup checkout = new checkoutTablePopup(this); + checkout.Show(); + } } } diff --git a/EnigmaX/Classes/EnigmaMenuItem.cs b/EnigmaX/Classes/EnigmaMenuItem.cs index 2f58bf9..e7cd038 100644 --- a/EnigmaX/Classes/EnigmaMenuItem.cs +++ b/EnigmaX/Classes/EnigmaMenuItem.cs @@ -52,6 +52,13 @@ public int getItemType() return (int)_itemType + 1; } + public float Price + { + get + { + return _price; + } + } public static EnigmaMenuItem idToMenuItem(int id) {