Пример #1
0
        private void insert_btn_Click(object sender, EventArgs e)
        {
            Finalize_btn.Enabled = true;
            int num;

            if ((exercises_cb.Text == "") || (muscles_cb.Text == ""))
            {
                MessageBox.Show("Muscle and Exercise fields cannot be empty!");
            }
            else
            {
                if ((int.TryParse(Sets_tb.Text, out num) != true) || (Int32.Parse(Sets_tb.Text) < 1))
                {
                    MessageBox.Show("Invalid format for the field: Number of sets!");
                }
                else
                {
                    var db  = new Model1();
                    var obj = new add_into_database();
                    Exercises_trainings inserted_extrain = new Exercises_trainings();
                    if (training_started == false)
                    {
                        training_started  = true;
                        inserted_training = obj.add_training(usern, date_dtp.Value);
                    }

                    inserted_extrain = obj.add_exercise_training(exercises_cb.Text, inserted_training.id);
                    obj.add_sets(inserted_extrain, Int32.Parse(Sets_tb.Text));
                    Sets_tb.Text = "";
                }
            }
        }
Пример #2
0
        private void add_user_btn_Click(object sender, EventArgs e)
        {
            var obj    = new add_into_database();
            var insert = obj.add_user();

            if (insert != null)
            {
                users_list.Items.Add(insert);
                MessageBox.Show("The user was succesfully created.");
            }
        }
Пример #3
0
        private void add_muscle_btn_Click(object sender, EventArgs e)
        {
            var obj    = new add_into_database();
            var insert = obj.add_muscle();

            if (insert != null)
            {
                muscles_list.Items.Add(insert);
                muscles_cb.Items.Add(insert);
                MessageBox.Show("Muscle group succesfully created.");
            }
        }
Пример #4
0
 private void add_ex_btn_Click(object sender, EventArgs e)
 {
     if (muscles_list.SelectedItems.Count < 1)
     {
         MessageBox.Show("A muscle group should be selected first!");
     }
     else
     {
         var obj   = new add_into_database();
         var input = obj.add_exercise(muscles_list.GetItemText(muscles_list.SelectedItem));
         if (input != null)
         {
             exercises_list.Items.Add(input);
             MessageBox.Show("Exercise succesfully created.");
         }
     }
 }