Пример #1
0
        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();
        }
Пример #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);
            }
        }
Пример #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);
            }
        }