private void bnt_genwrfs_Click(object sender, EventArgs e) { try { DataTable dt = new DataTable(); double fat_to, fat_from, bmi_to, bmi_from; string workout_name; int match; bool test = false; double member_bmi, member_fat; member_bmi = double.Parse(txtgetW_bmi.Text); member_fat = double.Parse(txtgetW_fat.Text); Buisness_Logic.workout_repository wr = new Buisness_Logic.workout_repository(); dt = wr.searchWorkouts_for_grid(); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { bmi_from = (double)dt.Rows[i]["BMI_rate_from"]; bmi_to = (double)dt.Rows[i]["BMI_rate_to"]; fat_from = (double)dt.Rows[i]["fat_level_from"]; fat_to = (double)dt.Rows[i]["fat_level_to"]; if (member_bmi >= bmi_from && member_bmi < bmi_to && member_fat >= fat_from && member_fat < fat_to) { match = i; workout_name = dt.Rows[i]["w_name"].ToString(); // txtgw_workoutName.Text = dt.Rows[match]["w_name"].ToString(); MessageBox.Show("Workout generated.", "Information.", MessageBoxButtons.OK, MessageBoxIcon.Information); txtgw_workoutName.Text = workout_name; txtgetW_shedule.Text = dt.Rows[i]["interval_days"].ToString(); test = true; break; } } if (test == false) { MessageBox.Show("No workout match found.", "Information.", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception gf) { throw; } }
private void workout_to_datagrid() { Buisness_Logic.workout_repository wr = new Buisness_Logic.workout_repository(); dataGrid_workout.DataSource = wr.searchWorkouts_for_grid(); }