From 07b292f1f727f2722b987860da0d34329882348f Mon Sep 17 00:00:00 2001 From: "RKant\\TEST" Date: Mon, 6 Mar 2017 21:48:29 -0500 Subject: [PATCH] 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)