Exemple #1
0
        private void btnBarSeatClick(object sender, EventArgs e)
        {
            Button  oButton              = sender as Button;
            BarSeat oBarSeat             = (BarSeat)oButton.Tag;
            string  sErrorMess           = "";
            bool    bIsValid             = true;
            bool    bReservationSelected = false;

            if (rdoAssignTable.Checked)
            {
                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 (Convert.ToInt16(cboSeats.SelectedItem) <= 1 && Convert.ToInt16(cboSeats.SelectedItem) > 0 && bIsValid)
                    {
                        //Number of seats fit the amount to be seated
                        if (oBarSeat.TableState.ToLower() == TableState.Occupied.ToString().ToLower())
                        {
                            bIsValid   = false;
                            sErrorMess = "Error: Bar Seat is currently busy";
                        }
                        else if (oBarSeat.TableState.ToLower() == TableState.Bussable.ToString().ToLower())
                        {
                            bIsValid   = false;
                            sErrorMess = "Error: Bar Seat is not clean";
                        }
                    }
                    else
                    {
                        bIsValid   = false;
                        sErrorMess = "Error: That Bar Seat cannot seat that many customers";
                    }
                }
            }
            else if (rdoClearTable.Checked)
            {
                if (oBarSeat.TableState.ToLower() == TableState.Empty.ToString().ToLower())
                {
                    bIsValid   = false;
                    sErrorMess = "Error: Bar Seat has nothing to clear";
                }
                else if (oBarSeat.TableState.ToLower() == TableState.Bussable.ToString().ToLower())
                {
                    bIsValid   = false;
                    sErrorMess = "Error: Bar Seat is not clean";
                }
            }
            else if (rdoBusTable.Checked)
            {
                if (oBarSeat.TableState.ToLower() == TableState.Empty.ToString().ToLower())
                {
                    bIsValid   = false;
                    sErrorMess = "Error: Bar Seat is already clean";
                }
                else if (oBarSeat.TableState.ToLower() == TableState.Occupied.ToString().ToLower())
                {
                    bIsValid   = false;
                    sErrorMess = "Error: Bar Seat is currently busy";
                }
            }

            if (bIsValid)
            {
                string sUpdatedState = oBarSeat.TableState;
                if (sUpdatedState.ToLower() == TableState.Empty.ToString().ToLower())
                {
                    if (bReservationSelected)
                    {
                        ReservationDA.DeleteReservation((lstReservations.SelectedItem as DisplayData).Value);
                        lstReservations.ClearSelected();
                    }
                    sUpdatedState = TableState.Occupied.ToString();
                }
                else if (sUpdatedState.ToLower() == TableState.Occupied.ToString().ToLower())
                {
                    sUpdatedState = TableState.Bussable.ToString();
                }
                else if (sUpdatedState.ToLower() == TableState.Bussable.ToString().ToLower())
                {
                    sUpdatedState = TableState.Empty.ToString();
                }

                //Updating Table State
                BarSeatDA.UpdateBarSeatState(oBarSeat.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);
            }
        }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
        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);
            }
        }