private void mnuUnregisterRestaurant_Click(object sender, EventArgs e) { DialogResult button = MessageBox.Show( "Are you sure you want to delete the entire restaurant layout?", "Confirm Layout Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (button == DialogResult.Yes) { ReservationDA.DeleteAllReservations(); TableDA.DeleteAllTables(); BarSeatDA.DeleteAllBarSeats(); BarTableDA.DeleteBarTable(); ServerDA.DeleteAllServers(); RestaurantDA.DeleteRestaurant(); NoCurrentRestaurant(); if (mnuRegisterRestaurant.Enabled == false) { mnuRegisterRestaurant.Enabled = true; } MessageBox.Show("Restaurant has been unregistered!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void DisplayAvailableTables() { List <Table> oTables = TableDA.GetAvailableTables(); List <DisplayData> oDataDisplay = new List <DisplayData>(); foreach (Table oTable in oTables) { oDataDisplay.Add(new DisplayData() { Value = oTable.TableNumber.ToString(), Text = "Table Number: " + oTable.TableNumber + " Seats: " + oTable.NumberOfSeats }); } lstAvailable.DisplayMember = "Text"; lstAvailable.DataSource = oDataDisplay; lstAvailable.ClearSelected(); }
private void btnClearTable_Click(object sender, EventArgs e) { //clear table from assigned table list foreach (var item in lstAssignments.SelectedItems) { ServerDA.FreeTable(((DisplayData)item).Value); TableDA.UpdateTableState(((DisplayData)item).Value, TableState.Bussable.ToString()); } pnlRoom.Controls.Clear(); DisplayAssignments(); DisplayAvailableTables(); LoadTables(); LoadBarTable(); LoadBarSeats(); btnClearTable.Visible = false; lstAssignments.ClearSelected(); }
public void DeleteLayout() { tables = TableDA.GetTableLayout(); if (Utility.IsNullOrEmpty(tables)) { MessageBox.Show("Error: Layout was not Successfully Deleted", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { TableDA.DeleteAllTables(); BarTableDA.DeleteBarTable(); BarSeatDA.DeleteAllBarSeats(); lblMessage.Text = "Restaurant layout was successfully deleted."; } ResetLayout(); //btnSaveLayout.Enabled = true; }
private void btnSaveLayout_Click(object sender, EventArgs e) { btnSaveLayout.Enabled = false; if (tables != null) { TableDA.SaveTableLayout(tables); } if (barTable != null) { BarTableDA.SaveBarTableLayout(barTable); } if (barSeats != null) { BarSeatDA.SaveBarSeatLayout(barSeats); } SectionDA.AssignTableToSection(assignedList); lblMessage.Text = "Restaurant layout saved."; }
public void LoadTables() { List <Table> oTables = TableDA.GetTableLayout(); if (!(Utility.IsNullOrEmpty(oTables))) { foreach (Table oTable in oTables) { RoundButton button = new RoundButton(); button.Cursor = Cursors.Hand; button.Height = 50; button.Width = 50; button.FlatStyle = FlatStyle.Flat; button.FlatAppearance.BorderSize = 0; if (oTable.TableState == TableState.Empty.ToString()) { button.BackColor = Color.Cyan; } else if (oTable.TableState == TableState.Occupied.ToString()) { button.BackColor = Color.Red; } else if (oTable.TableState == TableState.Bussable.ToString()) { button.BackColor = Color.Yellow; } button.Tag = oTable.TableNumber; button.Text = Convert.ToString(oTable.TableNumber) + "\n" + Convert.ToString(oTable.NumberOfSeats) + " seats"; //button.Text = "#"+Convert.ToString(oTable.TableNumber) // + "\nSeats " + Convert.ToString(oTable.NumberOfSeats); button.Location = new Point(oTable.TablePositionX, oTable.TablePositionY); button.Click += new EventHandler(btnSeatClick); pnlRoom.Controls.Add(button); } } }
private void btnMerge_Click(object sender, EventArgs e) { bool bIsValid = true; string sErrorMess = ""; if (!(lstServers.SelectedIndex == -1)) { if (!(lstAvailable.SelectedIndex == -1)) { List <Table> oTables = new List <Table>(); int seatNum = 0; bool bReservationSelected = false; foreach (var item in lstAvailable.SelectedItems) { Table oTable = new Table(); string sAssign = ((DisplayData)item).Value; oTable = TableDA.GetTableByID(sAssign); oTables.Add(oTable); } foreach (Table oTable in oTables) { seatNum += oTable.NumberOfSeats; } if (!(lstReservations.SelectedIndex == -1)) { bReservationSelected = true; int groupSize = ReservationDA.GetGroupSize((lstReservations.SelectedItem as DisplayData).Value); cboSeats.SelectedItem = groupSize.ToString(); } if (cboSeats.SelectedItem == null) { bIsValid = false; } if (seatNum >= Convert.ToInt16(cboSeats.SelectedItem) && bIsValid) { //assign here foreach (Table oTable in oTables) { string sServerID = (lstServers.SelectedItem as DisplayData).Value; int nSectionNumber = SectionDA.GetAssignedSection(oTable.TableNumber.ToString()); ServerDA.AssignServerToTable(oTable.TableNumber.ToString(), sServerID, nSectionNumber.ToString()); TableDA.UpdateTableState(oTable.TableNumber.ToString(), TableState.Occupied.ToString()); } if (bReservationSelected) { ReservationDA.DeleteReservation((lstReservations.SelectedItem as DisplayData).Value); lstReservations.ClearSelected(); } pnlRoom.Controls.Clear(); LoadTables(); LoadBarTable(); LoadBarSeats(); DisplayReservationList(); DisplayAssignments(); DisplayAvailableTables(); } else { bIsValid = false; if (cboSeats.SelectedItem == null) { sErrorMess += "Error: Number of seats must be provided"; } else { sErrorMess += "Error: Those tables cannot seat that many customers"; } } } else { bIsValid = false; sErrorMess = "Error: No tables selected to merge"; } } else { bIsValid = false; sErrorMess = "Error: Those tables cannot seat that many customers"; } if (!bIsValid) { MessageBox.Show(sErrorMess, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void btnSeatClick(object sender, EventArgs e) { Button oButton = sender as Button; string sTableNumber = oButton.Tag.ToString(); string sErrorMess = ""; bool bIsValid = true; bool bReservationSelected = false; //get table by id to check/update state Table oSpecificTable = TableDA.GetTableByID(sTableNumber); int nSectionNumber = SectionDA.GetAssignedSection(sTableNumber); if (rdoAssignTable.Checked) { //makes sure a server is selected in the list box if (!(lstServers.SelectedIndex == -1)) { try { Convert.ToInt32(cboSeats.SelectedItem); } catch (Exception) { bIsValid = false; sErrorMess += "\nNumber of Seats is required and must be a number"; } if (bIsValid) { if (!(lstReservations.SelectedIndex == -1)) { bReservationSelected = true; int groupSize = ReservationDA.GetGroupSize((lstReservations.SelectedItem as DisplayData).Value); cboSeats.SelectedItem = groupSize.ToString(); } if (cboSeats.SelectedItem == null) { bIsValid = false; sErrorMess += "Number of seats must be provided"; } if (oSpecificTable.NumberOfSeats >= Convert.ToInt16(cboSeats.SelectedItem) && bIsValid) { //Number of seats fit the amount to be seated if (oSpecificTable.TableState.ToLower() == TableState.Occupied.ToString().ToLower()) { bIsValid = false; sErrorMess = "Error: Table is currently busy"; } else if (oSpecificTable.TableState.ToLower() == TableState.Bussable.ToString().ToLower()) { bIsValid = false; sErrorMess = "Error: Table is not clean"; } } else { bIsValid = false; sErrorMess = "Error: That table cannot seat that many customers"; } } } else { bIsValid = false; sErrorMess = "Error: You have to select a server"; } } else if (rdoClearTable.Checked) { if (oSpecificTable.TableState.ToLower() == TableState.Empty.ToString().ToLower()) { bIsValid = false; sErrorMess = "Error: Table has nothing to clear"; } else if (oSpecificTable.TableState.ToLower() == TableState.Bussable.ToString().ToLower()) { bIsValid = false; sErrorMess = "Error: Table is not clean"; } } else if (rdoBusTable.Checked) { if (oSpecificTable.TableState.ToLower() == TableState.Empty.ToString().ToLower()) { bIsValid = false; sErrorMess = "Error: Table is already clean"; } else if (oSpecificTable.TableState.ToLower() == TableState.Occupied.ToString().ToLower()) { bIsValid = false; sErrorMess = "Error: Table is currently busy"; } } if (bIsValid) { string sUpdatedState = oSpecificTable.TableState; if (sUpdatedState.ToLower() == TableState.Empty.ToString().ToLower()) { //assign server here string sServerID = (lstServers.SelectedItem as DisplayData).Value; ServerDA.AssignServerToTable(sTableNumber, sServerID, nSectionNumber.ToString()); if (bReservationSelected) { ReservationDA.DeleteReservation((lstReservations.SelectedItem as DisplayData).Value); lstReservations.ClearSelected(); } sUpdatedState = TableState.Occupied.ToString(); } else if (sUpdatedState.ToLower() == TableState.Occupied.ToString().ToLower()) { ServerDA.FreeTable(sTableNumber); DisplayAssignments(); sUpdatedState = TableState.Bussable.ToString(); } else if (sUpdatedState.ToLower() == TableState.Bussable.ToString().ToLower()) { sUpdatedState = TableState.Empty.ToString(); } //Updating Table State TableDA.UpdateTableState(oSpecificTable.TableNumber.ToString(), sUpdatedState); pnlRoom.Controls.Clear(); LoadTables(); LoadBarTable(); LoadBarSeats(); DisplayReservationList(); DisplayAssignments(); DisplayAvailableTables(); if (btnUse.Text == "Cancel") { lstReservations.Enabled = false; btnUse.Text = "Use Reservation"; } } else { MessageBox.Show(sErrorMess, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public void LoadTables() { // Load Tables tables = TableDA.GetTableLayout(); if (!(Utility.IsNullOrEmpty(tables))) { foreach (Table eachTable in tables) { table = eachTable; RoundButton button = new RoundButton(); button.Cursor = Cursors.Hand; button.Height = 50; button.Width = 50; button.FlatStyle = FlatStyle.Flat; button.FlatAppearance.BorderSize = 0; button.BackColor = Color.Cyan; button.Tag = table; button.Text = Convert.ToString(table.TableNumber) + "\n" + Convert.ToString(table.NumberOfSeats) + " seats"; button.Location = new Point(table.TablePositionX, table.TablePositionY); pnlRoom.Controls.Add(button); button.MouseDown += button_MouseDown; button.MouseUp += button_MouseUp; button.MouseMove += button_MouseMove; } txtTableNumber.Text = Convert.ToString(Table.TotalTables); } //Load BarSeats. barSeats = BarSeatDA.GetBarSeatLayout(); if (!(Utility.IsNullOrEmpty(barSeats))) { foreach (BarSeat eachBarSeat in barSeats) { barSeat = eachBarSeat; RoundButton button = new RoundButton(); button.Cursor = Cursors.Hand; button.Height = 30; button.Width = 30; button.FlatStyle = FlatStyle.Flat; button.FlatAppearance.BorderSize = 0; button.BackColor = Color.Cyan; button.Tag = barSeat; button.Text = "B" + Convert.ToString(barSeat.TableNumber); button.Location = new Point(barSeat.TablePositionX, barSeat.TablePositionY); pnlRoom.Controls.Add(button); button.MouseDown += button_MouseDown; button.MouseUp += button_MouseUp; button.MouseMove += button_MouseMove; } txtBarSeatNumber.Text = Convert.ToString(BarSeat.TotalTables); } // Load BarTable. barTable = BarTableDA.GetBarTableLayout(); if (barTable != null) { StayInsideButton button = new StayInsideButton(); button.Cursor = Cursors.Hand; button.Height = 30; button.Width = 200; button.FlatStyle = FlatStyle.Flat; button.FlatAppearance.BorderSize = 0; button.BackColor = Color.Cyan; button.Tag = barTable; button.Text = "Bar"; button.Location = new Point(barTable.TablePositionX, barTable.TablePositionY); pnlRoom.Controls.Add(button); button.MouseDown += button_MouseDown; button.MouseUp += button_MouseUp; button.MouseMove += button_MouseMove; } lblMessage.Text = "Seating layout successfully loaded!"; }
public void button_MouseDown(object sender, MouseEventArgs e) { Button button = (Button)sender; if (deleteTable == true) { table = (Table)button.Tag; string tableNumber = Convert.ToString(table.TableNumber); table = TableDA.GetTableByID(tableNumber); TableDA.DeleteTable(table); pnlRoom.Controls.Remove(button); //UpdateView(); lblMessage.Text = "Table " + tableNumber + " successfully deleted."; btnDeleteTable.Text = "Delete Table"; // Set deleteTable back to false so it's ready to be used in another delete. deleteTable = false; } else if (deleteBarSeat == true) { barSeat = (BarSeat)button.Tag; string barSeatNumber = Convert.ToString(barSeat.TableNumber); //barSeat = BarSeatDA.DeleteBarSeat(barSeat); BarSeatDA.DeleteBarSeat(barSeat); pnlRoom.Controls.Remove(button); //UpdateView(); lblMessage.Text = "BarSeat " + barSeatNumber + " successfully deleted."; btnDeleteBarseat.Text = "Delete Barseat"; // Set deleteBarSeat back to false so it's ready to be used in another delete. deleteBarSeat = false; } else if (deleteBar == true) { //barTable = (BarTable)button.Tag; BarTableDA.DeleteBarTable(); pnlRoom.Controls.Remove(button); //UpdateView(); lblMessage.Text = "Bar successfully deleted."; btnDeleteBar.Text = "Delete Bar"; // Set deleteBar back to false so it's ready to be used in another delete. deleteBar = false; } else if (e.Button == MouseButtons.Left) { //xPos = e.X; //yPos = e.Y; mouseDownPoint = pnlRoom.PointToClient(button.PointToScreen(e.Location)); if (btnSaveLayout.Enabled == false) { btnSaveLayout.Enabled = true; } } }