예제 #1
0
 public SnackBarForm()
 {
     InitializeComponent();
     bar        = new BarApp();
     this.order = new Order();
     bar.connect();
     for (int i = 0; i < bar.GetAllSnacks().Count; i++)
     {
         this.listBoxSnacks.Items.Add(bar.GetAllSnacks()[i].ToString());
     }
     for (int i = 0; i < bar.GetAllDrinks().Count; i++)
     {
         this.listBoxDrinks.Items.Add(bar.GetAllDrinks()[i].ToString());
     }
     this.timer1.Start();
 }
예제 #2
0
        private void btAddDrink_Click(object sender, EventArgs e)
        {
            try
            {
                int a = this.listBoxDrinks.SelectedIndex;
                if (bar.GetAllDrinks()[a].Stock >= Convert.ToInt32(this.textBox1.Text) && Convert.ToInt32(this.textBox1.Text) > 0)
                {
                    this.lbOrders.Items.Add(bar.GetAllDrinks()[a].AsString(Convert.ToInt32(this.textBox1.Text)));

                    this.lbTotalPrice.Text = "€" + Convert.ToString(order.TotalPrice(bar, a, Convert.ToInt32(this.textBox1.Text), bar.GetAllDrinks()[a]));
                }
                else
                {
                    MessageBox.Show("Not enough in stock");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Please type in right quality");
            }
        }
예제 #3
0
 public double TotalPrice(BarApp bar, int i, int quanlity, Drinks p)
 {
     totalprice += Convert.ToDouble(bar.GetAllDrinks()[i].TotalPrice(quanlity));
     return(totalprice);
 }