// event when the user clicks on the login button.
 private void btnLogin_LoginMenu_Click(object sender, EventArgs e)
 {
     // locked out?
     if (lockOut)
     {
         // show error form
         FormError lockmsg = new FormError();
         lockmsg.changeLabel.Text = "Locked. Please try again later.";
         lockmsg.changeButtonTwo.Hide();
         lockmsg.changeButtonOne.Text = "Ok";
         lockmsg.changeTimer.Interval = 5000; // auto close the error message after 5 seconds
         lockmsg.ShowDialog();
     }
     else
     {
         // check for empty input
         if (inputUserName_LoginMenu.Text == String.Empty || inputPassword_LoginMenu.Text == String.Empty)
         {
             loginFailForm();
         }
         else
         {
             authenticateLogin();
         }
     }
 }
        // 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();
            }
        }
示例#3
0
        // error messages
        private void errorMessage(int errorCode)
        {
            FormError paymentError = new FormError();

            switch (errorCode)
            {
            case 0:

                paymentError.changeLabel.Text = "Please enter a payment amount.";
                paymentError.changeTitle      = "Payment Error";
                paymentError.changeButtonTwo.Hide();
                break;

            case 1:
                // successful payment
                paymentError.changeLabel.Text = "Transaction Completed.";
                paymentError.changeTitle      = "Successful Payment";
                paymentError.changeButtonTwo.Hide();
                break;

            case 2:
                // added 4/18
                paymentError.changeLabel.Text = "Not enough to calculate change.";
                paymentError.changeTitle      = "Calculation Error";
                paymentError.changeButtonTwo.Hide();
                break;

            case 3:
                // added 4/19
                paymentError.changeLabel.Text = "Card Information not filled completely.";
                paymentError.changeTitle      = "Card Error";
                paymentError.changeButtonTwo.Hide();
                break;

            case 4:
                paymentError.changeLabel.Text = "Invalid Card Number";
                paymentError.changeTitle      = "Card Error";
                paymentError.changeButtonTwo.Hide();
                break;

            case 5:
                paymentError.changeLabel.Text = "Invalid CCV";
                paymentError.changeTitle      = "Card Error";
                paymentError.changeButtonTwo.Hide();
                break;
            }
            paymentError.ShowDialog();
        }
示例#4
0
        private void btn_search_Click(object sender, EventArgs e)
        {
            if (textBox_search.Text != "")
            {
                TabPage searchTab = new TabPage();
                string  search    = textBox_search.Text.ToLower();;

                bool found = dbe.tblProducts.Any(p => p.ProductID.ToString() == search || p.Description.ToLower() == search ||
                                                 p.Description.ToLower().StartsWith(search) ||
                                                 (search.Length >= 3 && p.Description.ToLower().Contains(search)));

                if (found)
                {
                    searched = true;
                    flp      = new FlowLayoutPanel();
                    flp.Size = new Size(1269, 669); // resize when change sizing

                    flp.AutoSize   = true;
                    flp.AutoScroll = true;
                    flp.Dock       = DockStyle.Fill;

                    List <tblProduct> list = dbe.tblProducts.Where(p => p.ProductID.ToString() == search ||
                                                                   p.Description.ToLower() == search ||
                                                                   p.Description.ToLower().StartsWith(search) ||
                                                                   (search.Length >= 3 && p.Description.ToLower().Contains(search))).ToList();

                    foreach (tblProduct product in list)
                    {
                        flp.Controls.Add(createButton(product));
                    }

                    //showing the searching result:
                    searchTab.Controls.Add(flp);
                    tbControlItems.Controls.Clear();
                    tbControlItems.Controls.Add(searchTab);
                }

                if (!found)
                {
                    FormError errorBox = new FormError();
                    errorBox.changeTitle      = "Error";
                    errorBox.changeLabel.Text = "Cannot find the product.";
                    errorBox.changeButtonTwo.Hide();
                    errorBox.ShowDialog();
                    textBox_search.Text = "";
                }
            }
        }
        private void loginFailForm()
        {
            // fail login message
            FormError failForm = new FormError();

            // fail form configuration
            failForm.changeLabel.Text = "Cannot Login\nPlease check your id or password and try again.";
            failForm.changeTitle      = "Authentication Attempt: " + LoginAttempt;

            // last notice before lock out
            if (LoginAttempt == 4)
            {
                failForm.changeLabel.Text = "Warning:\nNext failure will lock the application.";
            }

            failForm.changeButtonOne.Text = "Continue";
            failForm.changeButtonTwo.Hide();
            failForm.ShowDialog();
        }
示例#6
0
        private void quantity_formOrderPage_Click(object sender, EventArgs e)
        {
            if (products.Count != 0)
            {
                selectedProduct = (tblProduct)listBoxOrderItems.SelectedItem;
                FormLoginMenu.getBackStack().Push(editQuan);
                editQuan.ShowDialog();

                listBoxOrderItems.Refresh();
            }

            else
            {
                FormError errorBox = new FormError();
                errorBox.changeTitle      = "Error";
                errorBox.changeLabel.Text = "Nothing to edit quantity!";
                errorBox.changeButtonTwo.Hide();
                errorBox.ShowDialog();
            }
        }
示例#7
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if (txtBoxPromoCode.Text != "")
            {
                found = dbe.tblPromotions.Any(p => p.PromoCode.ToString() == txtBoxPromoCode.Text);

                if (found)
                {
                    tblPromotion promo = dbe.tblPromotions.First(p => p.PromoCode == txtBoxPromoCode.Text);
                    discount = promo.Discount;

                    txbTax.Text      = string.Format("{0:c}", calculateTax());
                    txbSubTotal.Text = string.Format("{0:c}", calculateSubTotal());
                    txbTotal.Text    = string.Format("{0:c}", calculateTotal());
                    txb_Balance.Text = string.Format("{0:c}", calculateBalance());

                    // removes the promotion code used from the database
                    dbe.tblPromotions.Remove(promo);

                    dbe.SaveChanges();

                    FormError error = new FormError();
                    error.changeTitle      = "Successful.";
                    error.changeLabel.Text = "Successful!";
                    error.changeButtonTwo.Hide();
                    error.ShowDialog();
                }

                else
                {
                    FormError error = new FormError();
                    error.changeTitle      = "Error.";
                    error.changeLabel.Text = "Invalid Promotional Code!";
                    error.changeButtonTwo.Hide();
                    error.ShowDialog();
                }

                txtBoxPromoCode.Text = "";
            }
        }
        private void authenticateLogin()
        {
            // create an object of the database
            // DatabaseEntities dbe = new DatabaseEntities();

            // user's input
            string id = inputUserName_LoginMenu.Text.ToString();
            string pw = inputPassword_LoginMenu.Text.ToString();

            // loops through all the rows in tblUser
            bool found = false;

            // loops through the table
            foreach (var temp in dbe.tblUsers)
            {
                // check the crudential
                if (temp.Username == id && temp.Password == pw)
                {
                    // authentication success message
                    FormError successForm = new FormError();

                    // success form configuration
                    successForm.changeLabel.Text = "Logging in...\nWelcome "
                                                   + temp.Firstname + " " + temp.Lastname;
                    successForm.Text = "Authentication Successful";
                    successForm.changeButtonOne.Hide();
                    successForm.changeButtonTwo.Hide();
                    successForm.changeTimer.Interval = 1500;    // timer to close success message in 1.5 seconds
                    successForm.changeTimer.Enabled  = true;
                    successForm.Show();

                    found = true;

                    if (temp.Status.CompareTo("1") == 0)
                    {
                        callAdminPage();
                    }
                    else
                    {
                        callFrontPage();
                    }

                    LoginAttempt = 0;
                    break;
                }
            }

            if (!found)
            {
                LoginAttempt++;
                cleanAll();

                // too many login attempt;
                if (LoginAttempt > 4)
                {
                    // locks the user out for 1 minutes
                    timerLockOut.Interval = 60000;  // milliseconds
                    timerLockOut.Enabled  = true;
                    timerLockOut.Start();

                    // fail login message
                    FormError failForm = new FormError();

                    // fail form configuration
                    failForm.changeLabel.Text = "Login Unsuccesful\nToo many failed attempt.\nLocking Application.";
                    failForm.Text             = "Authentication Unsuccessful";
                    failForm.changeButtonOne.Hide();
                    failForm.changeButtonTwo.Hide();
                    failForm.changeTimer.Interval = 3000;
                    failForm.changeTimer.Enabled  = true;
                    failForm.ShowDialog();

                    lockOut = true;
                }
                else
                {
                    loginFailForm();
                }
            }
            cleanAll(); // erase input field
        }
        /*
         * 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);
        }