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(); }
private void AuthorizationForm_FormClosing(object sender, FormClosingEventArgs e) { ctx.Dispose(); }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { ctx.Dispose(); }
private void ExerciseChooseForm_FormClosing(object sender, FormClosingEventArgs e) { ctx.Dispose(); }
private void NewAccountForm_FormClosing(object sender, FormClosingEventArgs e) { ctx.Dispose(); }