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(); } }
public double TotalPrice(BarApp bar, int i, int quanlity, Drinks p) { totalprice += Convert.ToDouble(bar.GetAllDrinks()[i].TotalPrice(quanlity)); return(totalprice); }