void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            var row  = dataGridView1.Rows[e.RowIndex];
            var cell = row.Cells[e.ColumnIndex];

            if (cell.OwningColumn == colExercise)
            {
                Guid exerciseId = (Guid)cell.Value;
                if (exerciseId == Guid.Empty)
                {//user wants to add a new exercise
                    var exercise = new ExerciseDTO(Guid.NewGuid());
                    exercise.ExerciseType = ExerciseType.Biceps;
                    AddExercise dlg = new AddExercise();
                    dlg.Fill(exercise);
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        ObjectsReposidory.ClearExerciseCache();
                        fillExerciseComboBox();
                        cell.Value = dlg.NewExercise.GlobalId;
                        dataGridView1.NotifyCurrentCellDirty(true);
                        dataGridView1.EndEdit();
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void OpenExercise(ExerciseDTO exercise)
        {
            if (exercise.GlobalId != Guid.Empty)
            {
                exercise = exercise.Clone();
            }

            AddExercise dlg = new AddExercise();

            dlg.Fill(exercise);
            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                OnFillReqest();
            }
        }