using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ch4_8
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void otherGroup_Enter(object sender, EventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void btnCheckout_Click(object sender, EventArgs e)
        {
            int priceSize = 0, toppingPrice, totalPrice, topping = 0;
            int breadPrice, potatoPrice, waterPrice, sodaPrice;
            //Get the price of pizza depending on size
            if (radioSmall.Checked == true)
                priceSize = Convert.ToInt32(textSmall.Text);
            if(radioMedium.Checked == true )
                priceSize = Convert.ToInt32(textMedium.Text);
            if (radioLarge.Checked == true)
                priceSize = Convert.ToInt32(textLarge.Text);
            //Get the price of toppins
            for (int i = 0; i < topListBox.Items.Count; i++)
                if (topListBox.GetItemChecked(i))
                    topping += 1;
            toppingPrice = topping * Convert.ToInt32(textEach.Text);
            //Get Other orders price
            breadPrice = Convert .ToInt32 ( txtQtBread.Text ) * Convert .ToInt32 (txtUnitBread.Text);
            txtSubBread.Text = breadPrice.ToString();
            potatoPrice = Convert.ToInt32(txtQtPotato.Text ) * Convert.ToInt32(txtUnitPotato.Text );
            txtSubPotato.Text = potatoPrice.ToString();
            //Get Drinks price
            waterPrice = Convert.ToInt32(txtQtWater.Text) * Convert.ToInt32(txtUnitWater.Text);
            sodaPrice = Convert.ToInt32(txtQtSoda.Text) * Convert.ToInt32(txtUnitSoda.Text);
            totalPrice = priceSize + toppingPrice + breadPrice + potatoPrice + waterPrice + sodaPrice;
            if (!takeCheck.Checked)
                totalPrice += Convert.ToInt32(txtService.Text);
            txtTotal.Text = totalPrice.ToString();
        }
    }
}
