Ejemplo n.º 1
0
        /*
         * This handler determines the transaction type from the radio
         * button input and calls the appropriate routines to perform
         * the transaction.
         */
        private void mnuTransaction_Click(object sender, System.EventArgs e)
        {
            OrderForm frmOrderFormObject = new OrderForm();

            frmOrderFormObject.MdiParent = this;
            frmOrderFormObject.Show();

            Cone       regCone = new Cone();
            WaffleCone wafCone = new WaffleCone();
            SugarCone  sugCone = new SugarCone();

            double cost = regCone.GetCostPerCone();

            cost = wafCone.GetCostPerCone();
            cost = sugCone.GetCostPerCone();
        }
Ejemplo n.º 2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            Cone   myCone       = new Cone();
            double dOrderCost   = 0.0;
            int    nOrderNumber = nOrderCount + 1;

            string orderStr = nOrderNumber.ToString() + ". ";

            if ((cbSelItem.SelectedIndex != -1) &&
                (cbSelFlavor.SelectedIndex != -1) &&
                (cbSelCone.SelectedIndex != -1) &&
                (cbScoops.SelectedIndex != -1))
            {
                if (nOrderNumber <= Order.MAX_ORDER)
                {
                    switch (cbSelItem.Items[cbSelItem.SelectedIndex].ToString())
                    {
                    case "Yogurt":
                        myCone.Choice = Cone.CHOICE_TYPE.Yogurt;
                        orderStr     += "Yogurt:";
                        break;

                    default:
                        myCone.Choice = Cone.CHOICE_TYPE.IceCream;
                        orderStr     += "Ice Cream:";
                        break;
                    }

                    switch (cbSelFlavor.Items[cbSelFlavor.SelectedIndex].ToString())
                    {
                    case "Chocolate":
                        myCone.FlavorChoice = Cone.FLAVOR_CHOICE.Chocolate;
                        orderStr           += "Chocolate:";
                        break;

                    case "Vanilla":
                        myCone.FlavorChoice = Cone.FLAVOR_CHOICE.Vanilla;
                        orderStr           += "Vanilla:";
                        break;

                    default:     // Strawberry
                        myCone.FlavorChoice = Cone.FLAVOR_CHOICE.Strawberry;
                        orderStr           += "Strawberry:";
                        break;
                    }

                    switch (cbSelCone.Items[cbSelCone.SelectedIndex].ToString())
                    {
                    case "Regular":
                        dConeCost = myCone.GetCostPerCone();
                        orderStr += "Regular Cone:";
                        break;

                    case "Sugar":
                        SugarCone mySugarCone = new SugarCone();
                        dConeCost = mySugarCone.GetCostPerCone();
                        orderStr += "Sugar Cone:";
                        break;

                    default:     // Waffle
                        WaffleCone myWaffleCone = new WaffleCone();
                        dConeCost = myWaffleCone.GetCostPerCone();
                        orderStr += "Waffle Cone:";
                        break;
                    }

                    myCone.NumberOfScoops = Convert.ToInt32(cbScoops.Items[cbScoops.SelectedIndex].ToString());

                    dOrderCost = myCone.NumberOfScoops * myCone.GetCostPerScoop() + (dConeCost);

                    // Set total cost for each cone
                    myCone.TotalCost = dOrderCost;

                    // Add to order
                    if (lbCurrentOrder.Items.Count < Order.MAX_ORDER)
                    {
                        myCurrentOrder.SetOrder(nOrderCount, myCone);
                    }

                    dBalance += dOrderCost;

                    lblBalance.Text = "Balance is " + dBalance.ToString("C");

                    orderStr += myCone.NumberOfScoops.ToString() + " scoop(s):";

                    orderStr += dOrderCost.ToString("C");

                    lbCurrentOrder.Items.Insert(nOrderCount, orderStr);

                    nOrderCount++;
                }
                else
                {
                    MessageBox.Show("Maximum number of 10 orders.", "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }  // end if
            else
            {
                MessageBox.Show("Please enter all fields in Enter Order form.", "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        } // end btnOK_Click