Esempio n. 1
0
        private void Statistic_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            Statistic.SelectedItem = sender;
            DailyStats  daily  = (DailyStats)Statistic.SelectedItem;
            DateTime    result = DateTime.ParseExact(daily.Date.Substring(0, 10), "dd.MM.yyyy", CultureInfo.InvariantCulture);
            string      date   = result.ToString("yyyy-MM-dd");
            DataTable   dt     = SqlDB.Select($"select Dishes.[name], proteins, fats, carbohydrates, calories from Users_Dishes join Dishes on Dishes.id = id_dish where id_user={SqlDB.UserID} and [date]='{date}'");
            List <Dish> dishes = new List <Dish>();

            foreach (DataRow dr in dt.Rows)
            {
                dishes.Add(new Dish
                {
                    Name          = dr["name"].ToString(),
                    Proteins      = Convert.ToDouble(dr["proteins"]),
                    Fats          = Convert.ToDouble(dr["fats"]),
                    Carbohydrates = Convert.ToDouble(dr["carbohydrates"]),
                    Calories      = Convert.ToDouble(dr["calories"])
                });
            }
            Table.ItemsSource = dishes;
        }
Esempio n. 2
0
 public DishesWindow()
 {
     InitializeComponent();
     Categories.ItemsSource = SqlDB.GetDataOneAttribute("select [name] from Categories", "name");
     SetDishes();
 }