Пример #1
0
        //THE COMMENTS FOR THIS METHOD APPLY TO ALL OTHER PICTUREBOX CLICK EVENT HANDLERS
        private void PicCola_Click(object sender, EventArgs e)
        {
            //create instance of structure
            TypesDrinks details = new TypesDrinks();

            int priceCola = 1;                                         //sets the price of drink

            totalSales = priceCola + totalSales;                       //adds price to total sales

            int subtract = int.Parse(lblDrinksLeftCola.Text);          //makes an int that is equal to the current number of drinks left

            details.remainingCola = 0;                                 //initializes details.remainingDrink to 0
            int needed = 1;                                            //number of drinks user wants (one per click)

            details.remainingCola  = subtract - needed;                //remaining drinks are the current number of drinks left minus needed drinks
            lblDrinksLeftCola.Text = details.remainingCola.ToString(); //displays new number of drinks left

            //error message if no drinks left
            if (details.remainingCola <= 0)
            {
                MessageBox.Show("No drinks left!");
            }

            lblTotalSales.Text = totalSales.ToString("c"); //displays total sales
        }
Пример #2
0
        private void PicRootBeer_Click(object sender, EventArgs e)
        {
            //create instance of structure
            TypesDrinks details = new TypesDrinks();

            int priceRootBeer = 1;

            totalSales = priceRootBeer + totalSales;

            int subtract = int.Parse(lblDrinksLeftRootBeer.Text);

            details.remainingRootBeer = 0;
            int needed = 1;

            details.remainingRootBeer  = subtract - needed;
            lblDrinksLeftRootBeer.Text = details.remainingRootBeer.ToString();

            if (details.remainingRootBeer <= 0)
            {
                MessageBox.Show("No drinks left!");
            }

            lblTotalSales.Text = totalSales.ToString("c");
        }
Пример #3
0
        private void PicCreamSoda_Click(object sender, EventArgs e)
        {
            //create instance of structure
            TypesDrinks details = new TypesDrinks();

            double priceCreamSoda = 1.50;

            totalSales = priceCreamSoda + totalSales;

            int subtract = int.Parse(lblDrinksLeftCreamSoda.Text);

            details.remainingCreamSoda = 0;
            int needed = 1;

            details.remainingCreamSoda  = subtract - needed;
            lblDrinksLeftCreamSoda.Text = details.remainingCreamSoda.ToString();

            if (details.remainingCreamSoda <= 0)
            {
                MessageBox.Show("No drinks left!");
            }

            lblTotalSales.Text = totalSales.ToString("c");
        }