private void btnworkout_update_Click(object sender, EventArgs e) { try { Buisness_Logic.workout wk = new Buisness_Logic.workout(); wk.exName = comboW5_name.SelectedItem.ToString(); wk.workout_name = txtW3_Wname.Text; wk.repeats = int.Parse(txtW5_sets.Text); Buisness_Logic.workout_repository wr = new Buisness_Logic.workout_repository(); if (wr.updateWorkouts_ex_list(wk)) { MessageBox.Show("Workout list update successfull.", "Information.", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Workout list update failed.", "Information.", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception fs) { throw; } }
private void btnworkout_update_w_Click(object sender, EventArgs e) { try { Buisness_Logic.workout wk = new Buisness_Logic.workout(); wk.BMI_rate_from = double.Parse(txtW2_bmi_from.Text); wk.BMI_rate_to = double.Parse(txtW2_bmi_to.Text); wk.fat_level_from = double.Parse(txtW4_fat_from.Text); wk.fat_level_to = double.Parse(txtW4_fat_to.Text); wk.interval_days = txtW3_schedule.Text; wk.type = cmb_w5_type.SelectedItem.ToString(); wk.workout_name = txtW3_Wname.Text; Buisness_Logic.workout_repository wr = new Buisness_Logic.workout_repository(); if (wr.updateWorkouts(wk)) { MessageBox.Show("Workout update successfull.", "Information.", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Workout update failed.", "Information.", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception fs) { throw; } }
private void btnworkout_search_Click(object sender, EventArgs e) { try { Buisness_Logic.workout wrk = new Buisness_Logic.workout(); wrk.workout_name = txtW3_Wname.Text; wrk.exName = comboW5_name.SelectedItem.ToString(); wrk.repeats = int.Parse(txtW5_sets.Text); Buisness_Logic.workout_repository wo1 = new Buisness_Logic.workout_repository(); if (wo1.addExercises_to_workout(wrk)) { MessageBox.Show("Succesfull.", "Data Insertion.", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Unsucesfull.", "Data Insertion.", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception exp) { throw; } }
public bool searchWorkouts(Buisness_Logic.workout wrk) { bool temp = false; try { DataLayer.dbConnect workoutSearch = new DataLayer.dbConnect(); workoutSearch.openConnection(); string query1 = "SELECT * FROM tbl_workout WHERE w_name=@workout"; SqlCommand cmd1 = new SqlCommand(query1, workoutSearch.getConnection()); cmd1.Parameters.AddWithValue("@workout", wrk.workout_name); DataTable dtq = new DataTable(); SqlDataAdapter da1 = new SqlDataAdapter(cmd1); // workout wrk = new workout(); da1.Fill(dtq); if (dtq.Rows.Count > 0) { wrk.id = int.Parse(dtq.Rows[0]["w_id"].ToString()); wrk.workout_name = dtq.Rows[0]["w_name"].ToString(); wrk.type = dtq.Rows[0]["type"].ToString(); //wrk.BMI_rate = double.Parse(dtq.Rows[0]["BMI_rate"].ToString()); //wrk.fat_level = double.Parse(dtq.Rows[0]["fat_level"].ToString()); wrk.repeats = int.Parse(dtq.Rows[0]["repeats"].ToString()); wrk.interval_days = dtq.Rows[0]["interval_days"].ToString(); temp = true; } workoutSearch.closeConnection(); } catch (Exception exp) { throw; } if (temp == true) { return(true); } else { return(false); } }
public bool addWorkouts(Buisness_Logic.workout wo) { bool temp = false; try { DataLayer.dbConnect con1 = new DataLayer.dbConnect(); con1.openConnection(); string q1 = "INSERT INTO tbl_workout values (@name,@type,@bmi_f,@fat_f,@interval,@bmi_t,@fat_t)"; //(w_name,type, BMI_rate,fat_level,repeats,interval_days) SqlCommand cmd1 = new SqlCommand(q1, con1.getConnection()); cmd1.Parameters.AddWithValue("@name", wo.workout_name); cmd1.Parameters.AddWithValue("@type", wo.type); //from cmd1.Parameters.AddWithValue("@bmi_f", wo.BMI_rate_from); cmd1.Parameters.AddWithValue("@fat_f", wo.fat_level_from); //to cmd1.Parameters.AddWithValue("@bmi_t", wo.BMI_rate_to); cmd1.Parameters.AddWithValue("@fat_t", wo.fat_level_to); cmd1.Parameters.AddWithValue("@interval", wo.interval_days); cmd1.ExecuteNonQuery(); temp = true; } catch (Exception exr) { throw; } if (temp == true) { return(true); } else { return(false); } }
public bool updateWorkouts(Buisness_Logic.workout wo1) { bool temp = false; try { DataLayer.dbConnect mydb = new DataLayer.dbConnect(); mydb.openConnection(); SqlCommand cmd = null; string qry = "UPDATE tbl_workout SET type=@type, BMI_rate_from=@BMIf, fat_level_from=@fatf, interval_days=@interval,BMI_rate_to=@bmito,fat_level_to=@fatto WHERE w_name=@wname"; cmd = new SqlCommand(qry, mydb.getConnection()); cmd.Parameters.AddWithValue("@type", wo1.type); cmd.Parameters.AddWithValue("@BMIf", wo1.BMI_rate_from); cmd.Parameters.AddWithValue("@fatf", wo1.fat_level_from); cmd.Parameters.AddWithValue("@repeat", wo1.repeats); cmd.Parameters.AddWithValue("@interval", wo1.interval_days); cmd.Parameters.AddWithValue("@bmito", wo1.BMI_rate_to); cmd.Parameters.AddWithValue("@fatto", wo1.fat_level_to); cmd.Parameters.AddWithValue("@wname", wo1.workout_name); cmd.ExecuteNonQuery(); temp = true; } catch (Exception exr) { throw; } if (temp == true) { return(true); } else { return(false); } }
//update workout exercise list public bool updateWorkouts_ex_list(Buisness_Logic.workout wo1) { bool temp = false; try { DataLayer.dbConnect mydb = new DataLayer.dbConnect(); mydb.openConnection(); SqlCommand cmd = null; string qry = "UPDATE tbl_workout_exercise SET repeats=@r where ex_name=@ex and w_name=@wname"; cmd = new SqlCommand(qry, mydb.getConnection()); cmd.Parameters.AddWithValue("@r", wo1.repeats); cmd.Parameters.AddWithValue("@ex", wo1.exName); cmd.Parameters.AddWithValue("@wname", wo1.workout_name); cmd.ExecuteNonQuery(); temp = true; } catch (Exception exr) { throw; } if (temp == true) { return(true); } else { return(false); } }
// add exercises to given workout public bool addExercises_to_workout(Buisness_Logic.workout wo) { bool temp = false; try { DataLayer.dbConnect con1 = new DataLayer.dbConnect(); con1.openConnection(); string q1 = "INSERT INTO tbl_workout_exercise values (@name,@ex_name,@rep)"; SqlCommand cmd1 = new SqlCommand(q1, con1.getConnection()); cmd1.Parameters.AddWithValue("@name", wo.workout_name); cmd1.Parameters.AddWithValue("@ex_name", wo.exName); cmd1.Parameters.AddWithValue("@rep", wo.repeats); cmd1.ExecuteNonQuery(); temp = true; } catch (Exception fs) { throw; } if (temp == true) { return(true); } else { return(false); } }
private void btnworkout_save_Click(object sender, EventArgs e) { try { Buisness_Logic.workout wo = new Buisness_Logic.workout(); wo.workout_name = txtW3_Wname.Text; wo.type = cmb_w5_type.SelectedItem.ToString(); // from wo.BMI_rate_from = double.Parse(txtW2_bmi_from.Text); wo.fat_level_from = double.Parse(txtW4_fat_from.Text); //to wo.BMI_rate_to = double.Parse(txtW2_bmi_to.Text); wo.fat_level_to = double.Parse(txtW4_fat_to.Text); wo.interval_days = txtW3_schedule.Text; Buisness_Logic.workout_repository wr = new Buisness_Logic.workout_repository(); if (wr.addWorkouts(wo)) { MessageBox.Show("Succesfull.", "Data Insertion.", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Unsucesfull.", "Data Insertion.", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception exp) { throw; } }