From 7132c4954a26d88c3d4e83b17dcc3cc699f57da0 Mon Sep 17 00:00:00 2001 From: "RKant\\TEST" Date: Sat, 25 Mar 2017 14:36:32 -0400 Subject: [PATCH] Finished reservation tab in host station. Added refresh button to host station to update views --- .../StationsGUI/HostStationView.Designer.cs | 37 ++- Enigma/StationsGUI/HostStationView.cs | 226 ++++++++++-------- Enigma/StationsGUI/HostStationView.resx | 3 - EnigmaX/Classes/Party.cs | 2 +- 4 files changed, 145 insertions(+), 123 deletions(-) diff --git a/Enigma/StationsGUI/HostStationView.Designer.cs b/Enigma/StationsGUI/HostStationView.Designer.cs index 2b94ef4..7d7137d 100644 --- a/Enigma/StationsGUI/HostStationView.Designer.cs +++ b/Enigma/StationsGUI/HostStationView.Designer.cs @@ -33,10 +33,9 @@ private void InitializeComponent() 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(); - this.viewRefresh = new System.Windows.Forms.Timer(this.components); this.resAdd = new MetroFramework.Controls.MetroButton(); + this.refreshButton = new MetroFramework.Controls.MetroButton(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.SuspendLayout(); // @@ -82,18 +81,9 @@ private void InitializeComponent() 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.Location = new System.Drawing.Point(886, 262); this.tableAssign.Name = "tableAssign"; this.tableAssign.Size = new System.Drawing.Size(168, 78); this.tableAssign.TabIndex = 4; @@ -101,14 +91,9 @@ 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.Location = new System.Drawing.Point(886, 166); this.resAdd.Name = "resAdd"; this.resAdd.Size = new System.Drawing.Size(168, 77); this.resAdd.TabIndex = 5; @@ -116,14 +101,24 @@ private void InitializeComponent() this.resAdd.UseSelectable = true; this.resAdd.Click += new System.EventHandler(this.resAdd_Click); // + // refreshButton + // + this.refreshButton.Location = new System.Drawing.Point(886, 361); + this.refreshButton.Name = "refreshButton"; + this.refreshButton.Size = new System.Drawing.Size(168, 77); + this.refreshButton.TabIndex = 6; + this.refreshButton.Text = "Refresh"; + this.refreshButton.UseSelectable = true; + this.refreshButton.Click += new System.EventHandler(this.refreshButton_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.refreshButton); this.Controls.Add(this.resAdd); 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); @@ -136,7 +131,6 @@ private void InitializeComponent() this.Load += new System.EventHandler(this.HostStationView_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.ResumeLayout(false); - this.PerformLayout(); } @@ -146,9 +140,8 @@ private void InitializeComponent() 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; - private System.Windows.Forms.Timer viewRefresh; private MetroFramework.Controls.MetroButton resAdd; + private MetroFramework.Controls.MetroButton refreshButton; } } \ No newline at end of file diff --git a/Enigma/StationsGUI/HostStationView.cs b/Enigma/StationsGUI/HostStationView.cs index aa4f2bb..3e381d9 100644 --- a/Enigma/StationsGUI/HostStationView.cs +++ b/Enigma/StationsGUI/HostStationView.cs @@ -42,89 +42,7 @@ 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 - { - //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 - } - 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(); - - //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(); - - - } + refreshDataTables(); } @@ -144,8 +62,7 @@ private void waitListRefresh_Tick(object sender, EventArgs e) //actions when the { 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 { @@ -218,24 +135,47 @@ private void dataGridView1_RowHeaderMouseDoubleClick(object sender, DataGridView private void tableAssign_Click(object sender, EventArgs e) { - /* for(int i=0; i < tables.Count(); i++) - { - MessageBox.Show(tables[i]._tableStatus.ToString()); - }*/ + if (comboBox1.Text.Equals("Wait List")) + { + 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(); + } - foreach (DataGridViewRow row in dataGridView1.SelectedRows)//take the selected row and split data + } + else if (comboBox1.Text.Equals("Reservations")) { - string name = row.Cells[0].Value.ToString(); - string partySize = row.Cells[1].Value.ToString(); - string waitTime = row.Cells[2].Value.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 resTime = row.Cells[2].Value.ToString(); + int party_size = Int32.Parse(row.Cells[1].Value.ToString()); - TableAssign ta = new TableAssign(this, name, partySize); - ta.Show(); + for(int i=0;i 17, 17 - - 175, 17 - \ No newline at end of file diff --git a/EnigmaX/Classes/Party.cs b/EnigmaX/Classes/Party.cs index 289fd53..9296542 100644 --- a/EnigmaX/Classes/Party.cs +++ b/EnigmaX/Classes/Party.cs @@ -13,7 +13,7 @@ public class Party public DateTime _queueTime; public int _waitTime; public Table _table; - public int _count; + public int _count; //party size public DateTime _resTime; public int _tableAssigned;