Ejemplo n.º 1
0
        public List <Drinks> GetAllDrinks()
        {
            string       sql     = "SELECT * FROM Products WHERE SnackType = \"Drink\";";
            MySqlCommand command = new MySqlCommand(sql, MySqlconnection);

            alldrinks = new List <Drinks>();

            try
            {
                MySqlconnection.Close();
                MySqlconnection.Open();
                MySqlDataReader reader = command.ExecuteReader();
                Drinks          drink;

                String name;
                double price;
                int    stock;
                bool   alc = true;
                int    id;

                while (reader.Read())
                {
                    name  = Convert.ToString(reader[0]);
                    price = Convert.ToDouble(reader[2]);
                    stock = Convert.ToInt32(reader[1]);
                    id    = Convert.ToInt32(reader[3]);
                    if (Convert.ToString(reader[4]) == "Y")
                    {
                        alc = true;
                    }
                    else if (Convert.ToString(reader[4]) == "N")
                    {
                        alc = false;
                    }

                    drink = new Drinks(name, price, stock, id, alc);
                    alldrinks.Add(drink);
                }
                MySqlconnection.Close();
                return(alldrinks);
            }
            catch (Exception)
            {
                MySqlconnection.Close();
                return(alldrinks);
            }
            finally
            {
                MySqlconnection.Close();
            }
        }
Ejemplo n.º 2
0
 public double TotalPrice(BarApp bar, int i, int quanlity, Drinks p)
 {
     totalprice += Convert.ToDouble(bar.GetAllDrinks()[i].TotalPrice(quanlity));
     return(totalprice);
 }