private void BindData() { TraineeBLL trainee = new TraineeBLL(connectionString); TraineeList.DataSource = trainee.GetAllTrainees(); TraineeList.DataBind(); }
/// <summary> /// Add Trainee to DB from user input form /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void TraineeAddButton_Click(object sender, EventArgs e) { //Checks to see if all Validation Controls are valid if (Page.IsValid) { //Grab connectionString from web.config file string connectionString = ConfigurationManager.ConnectionStrings["MySwoleMateConnectionString"].ToString(); //Create new instance of TraineeBLL TraineeBLL bll = new TraineeBLL(connectionString); //Create new instance of ViewModel with data from the user TraineeViewModel trainee = new TraineeViewModel(); //The Text property of each control will contain the data from the user trainee.FirstName = FirstName.Text; trainee.LastName = LastName.Text; trainee.Email = Email.Text; //Since the Text property returns a string, some properties would need to be converted trainee.Height = Convert.ToInt32(Height.Text); trainee.Weight = Convert.ToInt32(Weight.Text); trainee.CellNbr = CellNbr.Text; trainee.Gender = Gender.SelectedValue; trainee.Age = Convert.ToInt32(Age.Text); //Call the Business Logic method to add trainee bll.AddTrainee(trainee); //Return to the Trainees list after adding the trainee to database Response.Redirect("~/Trainees.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string connectionString = ConfigurationManager.ConnectionStrings["MySwoleMateConnectionString"].ToString(); TraineeBLL tbll = new TraineeBLL(connectionString); TraineeViewModel trainee = tbll.GetTraineeById(Convert.ToInt32(Request.QueryString["TraineeID"])); MainTitle.Text = "Workout Assigned to " + trainee.FirstName + " " + trainee.LastName; WorkoutBLL bll = new WorkoutBLL(connectionString); //int workoutID = Convert.ToInt32(Request.QueryString["WorkoutID"]); int workoutID = trainee.WorkoutID; if (workoutID != 0) { WorkoutViewModel workout = bll.GetWorkoutById(workoutID); Exercise1.Text = workout.DisplayExercise1; Exercise2.Text = workout.DisplayExercise2; Exercise3.Text = workout.DisplayExercise3; Exercise4.Text = workout.DisplayExercise4; Exercise5.Text = workout.DisplayExercise5; } else { Exercise1.Text = "No workout assigned"; } } }
protected void TraineeList_RowDeleting(object sender, GridViewDeleteEventArgs e) { int traineeID = Convert.ToInt32(TraineeList.DataKeys[e.RowIndex].Value.ToString()); TraineeBLL bll = new TraineeBLL(connectionString); bll.DeleteTrainee(traineeID); BindData(); }
public void BindData() { /* * MeasurementBLL mes = new MeasurementBLL(); * List<Models.Measurement> mesList = mes.GetMeasurements(); * //ProgressListParent.DataSource = mes.GetMeasurementPerTrainee(); * //ProgressListParent.DataBind(); */ string connectionString = ConfigurationManager.ConnectionStrings["MySwoleMateConnectionString"].ToString(); TraineeBLL trainee = new TraineeBLL(connectionString); ProgressListParent.DataSource = trainee.GetAllTrainees(); ProgressListParent.DataBind(); }