Exemplo n.º 1
0
        //instantiates a new OrderPageBMC form
        private void newBMC()
        {
            OrderPageBMC bmc = new OrderPageBMC();

            bmc.MdiParent = this;

            bmc.Show();
            this.LayoutMdi(MdiLayout.Cascade);
        }
Exemplo n.º 2
0
        //function that actually does the work of cancelling the order so we can call it
        //when the payment attempts are exceeded
        private void cancelOrder()
        {
            //close active window
            switch (step)
            {
            case 1:          //cancel has been clicked from OrderPageBMC
                OrderPageBMC bmc = (OrderPageBMC)ActiveMdiChild;
                bmc.Close(); //close the current child window

                break;

            case 2:     //cancel has been clicked from OrderPageVS
                OrderPageVS vs = (OrderPageVS)ActiveMdiChild;

                vs.Close();     //close the current child window
                break;

            case 3:
                OrderPagePay pay = (OrderPagePay)ActiveMdiChild;

                pay.Close();     //close the current child window
                break;
            } //end switch

            //empty sandwichSelections list
            sandwichSelections.Clear();
            //reset step to 0
            step = 0;

            MessageBox.Show("Order Canceled",
                            "Order Canceled", MessageBoxButtons.OK, MessageBoxIcon.None);

            nextToolStripMenuItem.Enabled        = false;
            cancelToolStripMenuItem.Enabled      = false;
            newSandwichToolStripMenuItem.Enabled = true;
        }
Exemplo n.º 3
0
        private void nextToolStripMenuItem_Click(object sender, EventArgs e)
        {
            switch (step)
            {
            case 1:     //next has been clicked from OrderPageBMC
                OrderPageBMC bmc = (OrderPageBMC)ActiveMdiChild;

                if (bmc.allSelected())     //save selection values, open next window, close bmc
                {
                    //retrieve and store the users selections from the form
                    saveSelections(bmc.selections());

                    bmc.Close(); //close the current child window
                    newVS();     //create and show new OrderPageVS child
                    step = 2;    //iteratestep counter to VS window
                }
                else             //create message window informing user to select one of each
                {
                    MessageBox.Show("You must select at least one option from each group",
                                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                break;

            case 2:     //next has been clicked from OrderPageVS
                //retrieve and store users selections from the form
                OrderPageVS vs = (OrderPageVS)ActiveMdiChild;
                saveSelections(vs.selections());

                vs.Close();
                newPay();    //create and show new OrderPagePay child
                step = 3;    //iterate step counter to Pay window
                break;

            case 3:     //next clicked from OrderPagePay
                //retrieve the form
                OrderPagePay pay = (OrderPagePay)ActiveMdiChild;
                //validate the pay info, if the allowed attempts is exceeded cancel the order
                if (!pay.validatePayment())     //if the payment was invalid
                {
                    //validatePayment does all the heavy lifting except for cancelling the order
                    //which we have to do here, so if the allowed attempts have been exceeded
                    //we cal the function to cancel the order.
                    if (pay.Attempts == 0)     //if there are no attempts left
                    {
                        cancelOrder();
                    }
                }
                else     //thank customer for order and close window, update inventory and display
                {
                    MessageBox.Show("Thank you for your order",
                                    "Thank your", MessageBoxButtons.OK, MessageBoxIcon.None);
                    pay.Close();

                    updateInventory();     //remove sandwichSelections from inventory and clear list

                    //display the updated inventory screen
                    newInv();

                    //Disable the cancel button since it no longer applies
                    cancelToolStripMenuItem.Enabled = false;
                    step = 4;
                }
                break;

            case 4:     //next is pressed from OrderPageInventory
                OrderPageInventory inv = (OrderPageInventory)ActiveMdiChild;
                inv.Close();

                //enable/disable controls and reset step counter
                nextToolStripMenuItem.Enabled        = false;
                newSandwichToolStripMenuItem.Enabled = true;
                step = 0;
                //program is now ready to accept a new sandwich order
                break;
            } //end switch
        }