public DayForm(string date, int dayId) { InitializeComponent(); this.Text = date; this.dayId = dayId; ctx = new NewGymPlannerEntities(); }
public MainForm(User user) { this.user = user; InitializeComponent(); if (this.user.isAdmin()) { ExercisesMenuStrip.Visible = true; } else { ExercisesMenuStrip.Visible = false; } this.ctx = new NewGymPlannerEntities(); this.ctx.Exercises.Load(); this.exercisesBindingSource.DataSource = this.ctx.Exercises.Local.ToBindingList(); MuscleGroupToolStripComboBox.ComboBox.DataSource = ctx.MuscleGroups.Select(g => g.Name).ToList(); UpdateCalendar(); string muscleGroup = MuscleGroupToolStripComboBox.SelectedItem.ToString(); List <string> exercises = (from ex in ctx.Exercises.Where(ex => ex.Workouts.Any(w => w.Days.Any(d => d.Users.Any(u => u.Login == user.Login))) && ex.MuscleGroups.Any(mg => mg.Name == muscleGroup)) select ex.Name).ToList(); this.UpdateChart(exercises); workoutsListView.Columns.Add("День", -1, HorizontalAlignment.Left); workoutsListView.Columns.Add("Вправа", -2, HorizontalAlignment.Left); workoutsListView.View = View.Details; FindButton_Click(this, EventArgs.Empty); }
public NewExerciseForm() { InitializeComponent(); ctx = new NewGymPlannerEntities(); ctx.MuscleGroups.Load(); ChooseMuscleGroupComboBox.DataSource = ctx.MuscleGroups.Local.ToBindingList(); }
public EditSetsForm(int workoutId) { InitializeComponent(); this.workoutId = workoutId; ctx = new NewGymPlannerEntities(); UpdateListView(); }
private void FindButton_Click(object sender, EventArgs e) { this.workoutsListView.Items.Clear(); this.ctx = new NewGymPlannerEntities(); this.ctx.Configuration.ProxyCreationEnabled = false; int reps; Int32.TryParse(RepsTextBox.Text, out reps); int minW; Int32.TryParse(minWeightTextBox.Text, out minW); int maxW; Int32.TryParse(maxWeightTextBox.Text, out maxW); var workouts = (from w in ctx.Workouts select w); workouts = workouts.Where(w => w.Days.Any(d => d.Users.Any(u => u.Login == user.Login))); workouts = workouts.Where(w => w.Days.Any(d => d.Date.CompareTo(this.BeforeDateTimePicker.Value) <= 0 && d.Date.CompareTo(this.AfterDateTimePicker.Value) >= 0 && d.Workouts.Count() > 0)); if (this.searchExerciseChosen) { workouts = workouts.Where(w => w.Exercises.Any(ex => ex.Name == ExerciseNameLabel.Text)); } if (this.RepsTextBox.Text != "") { workouts = workouts.Where(w => w.Sets.Any(s => s.Num_Reps == reps)); } if (this.maxWeightTextBox.Text != "") { workouts = workouts.Where(w => w.Sets.Any(s => s.Weight <= maxW)); } if (this.minWeightTextBox.Text != "") { workouts = workouts.Where(w => w.Sets.Any(s => s.Weight >= minW)); } var workoutPlusDay = (from w in workouts select new { day = w.Days.FirstOrDefault().Date, workout = w.Exercises.FirstOrDefault().Name }); foreach (var wpd in workoutPlusDay) { workoutsListView.Items.Add(new ListViewItem(new[] { wpd.day.ToString(), wpd.workout })); } this.wereFoundLabel.Text = "Знайдено :" + workoutsListView.Items.Count; this.workoutsListView.Columns[0].Width = -1; }
public AuthorizationForm() { InitializeComponent(); ctx = new NewGymPlannerEntities(); ctx.Users.Load(); this.LoginTextBox.Text = "admin"; this.PassTextBox.Text = "admin"; this.PassTextBox.UseSystemPasswordChar = true; }
public ExerciseChooseForm() { ctx = new NewGymPlannerEntities(); ctx.MuscleGroups.Load(); InitializeComponent(); ctx.Configuration.ProxyCreationEnabled = false; this.exercisesList = ctx.Exercises.Select(e => e.Name).ToList(); this.ExercisesListBox.DataSource = this.exercisesList; var groups = ctx.MuscleGroups.Local.ToBindingList(); ChooseMuscleGroupComboBox.Items.Add("Всі"); foreach (var group in groups) { ChooseMuscleGroupComboBox.Items.Add(group.Name); } ChooseMuscleGroupComboBox.SelectedIndex = 0; }
private void MuscleGroupToolStripComboBox_Click(object sender, EventArgs e) { this.ctx = new NewGymPlannerEntities(); if (!this.MuscleGroupToolStripComboBox.Selected) { return; } string muscleGroup = MuscleGroupToolStripComboBox.SelectedItem.ToString(); List <string> exercises = (from ex in ctx.Exercises.Where(ex => ex.Workouts.Any(w => w.Days.Any(d => d.Users.Any(u => u.Login == user.Login))) && ex.MuscleGroups.Any(mg => mg.Name == muscleGroup)) select ex.Name).ToList(); this.UpdateChart(exercises); }
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(); }
public NewAccountForm() { InitializeComponent(); ctx = new NewGymPlannerEntities(); }