Skip to content

Commit

Permalink
Fixed Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Langlais authored and Evan Langlais committed Apr 6, 2017
2 parents b72ba04 + 7132c49 commit 3fd3a4f
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 108 deletions.
24 changes: 15 additions & 9 deletions Enigma/StationsGUI/HostStationView.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

223 changes: 128 additions & 95 deletions Enigma/StationsGUI/HostStationView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}


Expand Down Expand Up @@ -216,24 +134,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());

for(int i=0;i<reservations.Count(); i++)
{
if(reservations[i].getName().Equals(name) && reservations[i].getCount()==party_size)
{
int tableNumber = reservations[i].gettableAssigned();

db.getConnection().Open();
MySqlCommand cmd = new MySqlCommand("UPDATE Seating SET status = @status WHERE tableNumber = @tableNumber", db.getConnection());
cmd.Parameters.Add("@status", 2); //seated
cmd.Parameters.Add("@tableNumber", tableNumber);
cmd.ExecuteNonQuery();
db.getConnection().Close();

TableAssign ta = new TableAssign(this, name, partySize);
ta.Show();
reservations.Remove(reservations[i]);
}
}
}
}



}

private void importTables()
Expand Down Expand Up @@ -319,5 +260,97 @@ public void resListAdd(Party party)
{
reservations.Add(party);
}

public void refreshDataTables()
{
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();


}
}

private void refreshButton_Click(object sender, EventArgs e)
{
refreshDataTables();
}
}
}
3 changes: 0 additions & 3 deletions Enigma/StationsGUI/HostStationView.resx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,4 @@
<metadata name="waitListRefresh.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="viewRefresh.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>175, 17</value>
</metadata>
</root>
2 changes: 1 addition & 1 deletion EnigmaX/Classes/Party.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 3fd3a4f

Please sign in to comment.