Ejemplo n.º 1
0
        private void AddMeal(Food food,DateTime dateTime)
        {
            SQLiteCommand command = Sql.SqlConnection.CreateCommand();
            command.Parameters.AddWithValue("@foodId", food.Id);
            command.Parameters.AddWithValue("@date", dateTime);
            command.CommandText = "INSERT INTO meals (foodId,date) VALUES(@foodId,@date)";
            command.ExecuteNonQuery();

            LoadMeals();
            UpdateMealTree();
        }
Ejemplo n.º 2
0
 public Meal(int id,Food food,DateTime date)
 {
     Id = id;
     Food = food;
     Date = date;
 }
Ejemplo n.º 3
0
 private void RemoveFood(Food food)
 {
     Sql.ExecuteNonQuery("UPDATE food SET hidden=1 WHERE id=" + food.Id);
     LoadFoods();
     UpdateFoodList();
 }
Ejemplo n.º 4
0
        private void LoadFoods()
        {
            foods.Clear();

            SQLiteCommand command = Sql.SqlConnection.CreateCommand();
            command.CommandText = "SELECT * FROM food ORDER BY name";
            using(SQLiteDataReader reader = command.ExecuteReader())
            {
                if(reader.HasRows)
                {
                    while(reader.Read())
                    {
                        int id = reader.GetInt32(0);
                        string name = reader.GetString(1);
                        int kcalPer100g = reader.GetInt32(2);
                        int grams = reader.GetInt32(3);
                        bool hidden = reader.GetBoolean(4);
                        Food food = new Food(id, name, kcalPer100g, grams, hidden);
                        foods.Add(food);
                    }
                }
            }
        }