Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
0
        private void btnAddTable_Click(object sender, EventArgs e)
        {
            table    = new Table();
            assigned = new AssignedTable();
            int startLeft = pnlRoom.Left;
            int startTop  = pnlRoom.Top;

            string sErrorMess = "";
            bool   bIsValid   = true;

            try {
                table.TableNumber    = Convert.ToInt32(txtTableNumber.Text);
                assigned.TableNumber = table.TableNumber;

                if (rdoSection1.Checked)
                {
                    assigned.SectionNum = (int)AvailableSections.Section1;
                }
                else if (rdoSection2.Checked)
                {
                    assigned.SectionNum = (int)AvailableSections.Section2;
                }
                else if (rdoSection3.Checked)
                {
                    assigned.SectionNum = (int)AvailableSections.Section3;
                }
            }
            catch (Exception)  {
                bIsValid    = false;
                sErrorMess += "TableNumber is required and must be a number";
            }

            try {
                table.NumberOfSeats = Convert.ToInt32(cboSeats.SelectedItem);
                //table.NumberOfSeats = Convert.ToInt32(txtNumberOfSeats.Text);
            }
            catch (Exception) {
                bIsValid    = false;
                sErrorMess += "\nNumber of Seats is required and must be a number";
            }

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

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

                txtTableNumber.Text   = Convert.ToString(Table.TotalTables);
                btnSaveLayout.Enabled = true;
                lblMessage.Text       = "Table " + table.TableNumber + " successfully added.";
            }
            else
            {
                MessageBox.Show(sErrorMess, "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }