// private static System.Timers.Timer TIME_OUT = new System.Timers.Timer(); // wrong timer object


        // OLD NOT NEEDED ANYMORE

        /**
         * // this is the configuration for the timer, it must be activated on each form load
         * public static void timeToDuel()
         * {
         *  TIME_OUT.Tick += new EventHandler(OnTimedEvent);  // event to run at x interval
         *  TIME_OUT.Interval = 180000; // time (milliseconds) before timeout
         *  TIME_OUT.Enabled = true;    // enables the timer
         *  TIME_OUT.Stop();            // stop & start resets the timer
         *  TIME_OUT.Start();
         * }
         */

        // session timeout
        // you can comment this out to disable the timeout
        public static void OnTimedEvent(Object myObject, EventArgs e)
        {
            timeToNotDuel();    // stops the timer

            // calls the error form and change the title and text accordingly
            FormError timeoutBox = new FormError();

            // timeout form configuration
            timeoutBox.changeLabel.Text     = "Inactivity Detected\nLogging off in 10 seconds...";
            timeoutBox.changeTimer.Interval = 10000;
            timeoutBox.changeTitle          = "Session Timeout";
            timeoutBox.changeButtonOne.Text = "Stop";
            timeoutBox.changeButtonTwo.Hide();
            timeoutBox.changeTimer.Enabled = true;

            FormError.clickResult_FormError = false;
            timeoutBox.ShowDialog();

            if (!FormError.getClickResult_FormError())
            {
                // Application.Exit();
                Application.Restart();
            }
            else
            {
                timeToReduel();

                // TIME_OUT.Tick -= new EventHandler(OnTimedEvent);
                // timeToDuel();
            }
        }
        /*
         * Clear button is to reset everything
         * set every tables to empty (0s)
         * set every tables back to color GREEN
         */

        private void CLEAR_Click(object sender, EventArgs e)
        {
            bool empty = true;

            if (FormFrontPage.finalizeBill)
            {
                FormFrontPage.finalizeBill = false;
                changeOrderImage();
            }

            for (int i = 0; i < tables.Length; i++)
            {
                if (tables[i] != 0)
                {
                    empty = false;
                }
            }

            if (!empty)
            {
                FormError confirmDialog = new FormError();
                confirmDialog.changeLabel.Text = "Are you sure to clear all?\n";

                confirmDialog.changeTitle          = "Confirm Delete";
                confirmDialog.changeButtonTwo.Text = "Cancel";
                confirmDialog.ShowDialog();


                if (FormError.getClickResult_FormError())
                {
                    for (int i = 0; i < tables.Length; i++) //reset for empty tables:
                    {
                        if (tables[i] != 0)
                        {
                            tables[i] = 0;

                            if (i == 0)
                            {
                                nextPage1 = new FormOrderPage();
                            }

                            else if (i == 1)
                            {
                                nextPage2 = new FormOrderPage();
                            }

                            else if (i == 2)
                            {
                                nextPage3 = new FormOrderPage();
                            }

                            else if (i == 3)
                            {
                                nextPage4 = new FormOrderPage();
                            }

                            else if (i == 4)
                            {
                                nextPage5 = new FormOrderPage();
                            }

                            else if (i == 5)
                            {
                                nextPage6 = new FormOrderPage();
                            }

                            else if (i == 6)
                            {
                                nextPage7 = new FormOrderPage();
                            }

                            else if (i == 7)
                            {
                                nextPage8 = new FormOrderPage();
                            }

                            else if (i == 8)
                            {
                                nextPage9 = new FormOrderPage();
                            }

                            else if (i == 9)
                            {
                                nextPage10 = new FormOrderPage();
                            }
                        }
                    }

                    foreach (Control myControl in panelTable.Controls)
                    {
                        if (myControl is Button)
                        {
                            myControl.BackColor = Color.Green;
                        }
                        if (myControl is PictureBox)
                        {
                            myControl.Hide();
                        }
                    }
                }
            }

            else
            {
                FormError confirmDialog = new FormError();
                confirmDialog.changeLabel.Text = "All tables/rooms are empty\n";

                confirmDialog.changeTitle = "OK.";
                confirmDialog.changeButtonTwo.Hide();
                confirmDialog.ShowDialog();
            }
        }
        /**
         *  tableSelectionError() display predefined custom error message dialog
         *  @param int an integer to specify the error message
         *  @return false if user select no/exit
         */
        private bool tableSelectionError(int errorCode)
        {
            // calls the error form and change the title and text accordingly
            FormError errorBox    = new FormError();
            bool      errorResult = true;

            switch (errorCode)
            {
            case 0:
                errorBox.changeTitle      = "Error";
                errorBox.changeLabel.Text = "Please select another table or room.";
                errorBox.changeButtonTwo.Hide();
                errorBox.ShowDialog();
                break;

            case 1:
                errorBox.changeTitle      = "Not Reserved";
                errorBox.changeLabel.Text = "This table/room has not been reserved.";
                errorBox.changeButtonTwo.Hide();
                errorBox.ShowDialog();
                break;

            case 2:
                errorBox.changeTitle          = "Unselect";
                errorBox.changeLabel.Text     = "Are you sure you want to unselect this?";
                errorBox.changeButtonOne.Text = "Yes";
                errorBox.changeButtonTwo.Text = "No";
                errorBox.ShowDialog();
                if (FormError.getClickResult_FormError())
                {
                    errorResult = true;
                }
                else
                {
                    errorResult = false;
                }
                break;

            case 3:
                errorBox.changeTitle          = "Check In?";
                errorBox.changeLabel.Text     = "Are you sure you want to check in?";
                errorBox.changeButtonOne.Text = "Yes";
                errorBox.changeButtonTwo.Text = "No";
                errorBox.ShowDialog();
                if (FormError.getClickResult_FormError())
                {
                    errorResult = true;
                }
                else
                {
                    errorResult = false;
                }
                break;

            case 4:
                errorBox.changeTitle          = "Reservation Only.";
                errorBox.changeLabel.Text     = "You can only make reservation.";
                errorBox.changeButtonOne.Text = "OK";
                errorBox.changeButtonTwo.Hide();
                errorBox.ShowDialog();
                break;

            default:
                errorBox.changeTitle             = "Error";
                errorBox.changeLabel.Text        = "Oops! Something went wrong.";
                errorBox.changeButtonTwo.Enabled = false;
                errorBox.ShowDialog();
                break;
            }

            return(errorResult);
        }