Ejemplo n.º 1
0
        //instantiates a new OrderPageInventory form
        private void newInv()
        {
            OrderPageInventory inv = new OrderPageInventory();

            inv.MdiParent = this;

            inv.Show();
            this.LayoutMdi(MdiLayout.Cascade);
        }
Ejemplo n.º 2
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
        }