Esempio n. 1
0
        public static int DeleteBarSeat(BarSeat barSeat)
        {
            SqlConnection connection    = RestaurantConnection.GetConnection();
            SqlCommand    command       = new SqlCommand();
            int           success       = 0;
            int           barSeatNumber = barSeat.TableNumber;

            command.CommandText = "DELETE FROM barSeats "
                                  + "WHERE tableNumber = @barSeatNumber";
            command.Parameters.AddWithValue("@barSeatNumber", barSeatNumber);
            command.CommandType = CommandType.Text;
            command.Connection  = connection;

            try {
                connection.Open();
                success = command.ExecuteNonQuery();
            }
            catch (SqlException ex) {
                MessageBox.Show(ex.Message);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }

            return(success);
        }
Esempio n. 2
0
        public static List <BarSeat> GetBarSeatLayout()
        {
            SqlConnection  connection = RestaurantConnection.GetConnection();
            List <BarSeat> barSeats   = new List <BarSeat>();
            SqlCommand     command    = new SqlCommand();
            SqlDataReader  reader     = null;

            command.CommandText = "Select * FROM barSeats";
            command.CommandType = CommandType.Text;
            command.Connection  = connection;

            try {
                connection.Open();
                reader = command.ExecuteReader();

                while (reader.Read())
                {
                    BarSeat barSeat = new BarSeat();

                    //uncomment for sqldb
                    //barSeat.NumberOfSeats = (int)reader["numberOfSeats"];
                    barSeat.TableNumber    = (int)reader["tableNumber"];
                    barSeat.TablePositionX = (int)reader["tablePositionX"];
                    barSeat.TablePositionY = (int)reader["tablePositionY"];
                    barSeat.TableState     = (string)reader["tableState"];

                    barSeats.Add(barSeat);
                }
            }
            catch (SqlException ex) {
                MessageBox.Show(ex.Message);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }

            finally {
                connection.Close();
            }

            return(barSeats);
        }
Esempio n. 3
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);
            }
        }
Esempio n. 4
0
        private void btnAddBarSeat_Click(object sender, EventArgs e)
        {
            barSeat  = new BarSeat();
            assigned = new AssignedTable();
            int startLeft = pnlRoom.Left;
            int startTop  = pnlRoom.Top;

            string sErrorMess = "";
            bool   bIsValid   = true;

            try {
                barSeat.TableNumber  = Convert.ToInt32(txtBarSeatNumber.Text);
                assigned.TableNumber = barSeat.TableNumber;
                assigned.SectionNum  = (int)AvailableSections.Section4;
            }
            catch (Exception) {
                bIsValid    = false;
                sErrorMess += "TableNumber is required and must be a number";
            }

            //try {

            //    barSeat.NumberOfSeats = Convert.ToInt32(txtNumberOfSeats.Text);

            //}
            //catch (Exception) {

            //    bIsValid = false;
            //    sErrorMess += "\nNumber of Seats is required and must be a number";

            //}

            if (bIsValid)
            {
                barSeat.TablePositionX = startLeft;
                barSeat.TablePositionY = startTop;
                barSeats.Add(barSeat);
                assignedList.Add(assigned);
                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(startLeft, startTop);
                pnlRoom.Controls.Add(button);

                button.MouseDown += button_MouseDown;
                button.MouseUp   += button_MouseUp;
                button.MouseMove += button_MouseMove;

                txtBarSeatNumber.Text = Convert.ToString(BarSeat.TotalTables);
                btnSaveLayout.Enabled = true;
                lblMessage.Text       = "BarSeat " + barSeat.TableNumber + " successfully added.";
            }
            else
            {
                MessageBox.Show(sErrorMess, "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Esempio n. 5
0
        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!";
        }
Esempio n. 6
0
        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;
                }
            }
        }