Exemplo n.º 1
0
        private void onClick(object sender, EventArgs e)
        {
            quanTextbox = Convert.ToInt16(numericUpDown1.Value);
            String name  = ((MyButton)sender).Text;
            double price = ((MyButton)sender).Price;
            int    id    = ((MyButton)sender).ProductId1;



            //  listBox1.Items.Add(snack.ToString());

            if (tabControl1.SelectedTab == tabPage1)
            {
                Snack     snack     = new Snack(id, name, price);
                OrderLine orderLine = new OrderLine(holder1, quanTextbox, snack);
                order.AddOrderLine(orderLine);
                listBox1.Items.Add(orderLine.AsString());
                double p = 0;
                foreach (OrderLine item in order.getAllOrderLines())
                {
                    p += item.Price * item.Quantity;
                }
                lbTotal.Text = "Total: € " + p;
            }
            else if (tabControl1.SelectedTab == tabPage2)
            {
                Drink     drink     = new Drink(id, name, price);
                OrderLine orderLine = new OrderLine(drink.Name, quanTextbox, drink);
                order.AddOrderLine(orderLine);
                listBox1.Items.Add(orderLine.AsString());
                double p = 0;
                foreach (OrderLine item in order.getAllOrderLines())
                {
                    p += item.Price * item.Quantity;
                }
                lbTotal.Text = "Total: € " + p;
            }
        }