Example #1
0
        private void btnAddExrcise_Click(object sender, EventArgs e)
        {
            using (var frm = new frmWorkOut())
            {
                var exercises = Dal.GetExercises();
                frm.cbExercise.DisplayMember = "Name";
                frm.cbExercise.ValueMember = "Id";

                frm.cbExercise.SelectedValueChanged += (o, es) =>
                {
                    frm.convertedImagePictureBox.Image = exercises.Select("id=" + ((int)frm.cbExercise.SelectedValue))[0]["Image"].ToString().Base64StringToImage();
                };
                frm.cbExercise.DataSource = exercises;

                frm.cbExercise.SelectedIndex = 0;
                if (frm.ShowDialog() == DialogResult.Cancel)
                    return;

                var Repetitions = (int)frm.nmRepetitions.Value;
                var Sets = (int)frm.nmSets.Value;
                var WorkoutExercise = (int)frm.cbExercise.SelectedValue;

                var w = Dal.GetWorkouts().NewRow();
                Dal.AddOrUpdateWorkout(null, Sets, Repetitions, WorkoutExercise, (int)(workoutProgramBindingSource.Current as DataRowView).Row["id"]);
            }

            LoadData();
        }
Example #2
0
        private void EditWorkout(DataRow workout)
        {
            using (var frm = new frmWorkOut())
            {

                var exercises = Dal.GetExercises();

                frm.cbExercise.DataSource = exercises;
                frm.cbExercise.DisplayMember = "Name";
                frm.cbExercise.ValueMember = "Id";

                frm.cbExercise.SelectedValue = workout["WorkoutExercise_Id"];
                frm.convertedImagePictureBox.Image = Dal.GetExercises((int)workout["WorkoutExercise_Id"]).Rows[0]["Image"].ToString().Base64StringToImage();
                frm.cbExercise.SelectedValueChanged += (o, e) =>
                {
                    frm.convertedImagePictureBox.Image = exercises.Select("id=" + ((int)frm.cbExercise.SelectedValue))[0]["Image"].ToString().Base64StringToImage();
                };
                frm.nmSets.Value = (int)workout["Sets"];
                frm.nmRepetitions.Value = (int)workout["Repetitions"];

                if (frm.ShowDialog() == DialogResult.Cancel)
                    return;

                workout["Repetitions"] = (int)frm.nmRepetitions.Value;
                workout["Sets"] = (int)frm.nmSets.Value;
                workout["WorkoutExercise_id"] = frm.cbExercise.SelectedValue;

            }

            UpdateWorkout(workout);
        }