Beispiel #1
0
        private void UpdateTreeView()
        {
            PlanTreeView.Nodes.Clear();
            DataTable ids = workoutByDayAdapter.GetData(dayId);

            DayCommentRichTextBox.Text = daysAdapter.GetDataById(dayId).Rows[0]["Comment"].ToString();
            //List<string> exerciseNames = new List<string>(table.Rows.Count);
            foreach (DataRow idRow in ids.Rows)
            {
                TreeNode exerciseNode = PlanTreeView.Nodes.Add(idRow["Name_Exercise"].ToString());
                exerciseNode.Tag = (idRow["ID_Workout"]);
                DataTable sets = setsAdapter.GetDataByWorkoutId((int)idRow["ID_Workout"]);
                foreach (DataRow setRow in sets.Rows)
                {
                    exerciseNode.Nodes.Add(setRow["Num_Reps"].ToString() + " раз(и) по " + setRow["Weight"].ToString() + " кг");
                }
            }
            PlanTreeView.ExpandAll();
        }
Beispiel #2
0
        private void UpdateTreeView()
        {
            ctx.Dispose();
            ctx = new NewGymPlannerEntities();
            PlanTreeView.Nodes.Clear();
            var workouts = (from d in ctx.Days.Where(d => d.ID_Day == dayId) select d).SingleOrDefault().Workouts;

            DayCommentRichTextBox.Text = (from d in ctx.Days.Where(d => d.ID_Day == dayId)
                                          select d).SingleOrDefault().Comment.ToString();
            foreach (Workouts workout in workouts)
            {
                TreeNode exerciseNode = PlanTreeView.Nodes.Add(workout.Exercises.SingleOrDefault().Name);
                exerciseNode.Tag = (workout.ID_Workout);
                var sets = (from w in ctx.Workouts.Where(w => w.ID_Workout == workout.ID_Workout) select w).SingleOrDefault().Sets;
                foreach (Sets set in sets)
                {
                    exerciseNode.Nodes.Add(set.Num_Reps + " раз(и) по " + set.Weight + " кг");
                }
            }
            PlanTreeView.ExpandAll();
        }