/// <summary> /// click event for the profile button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnProfile_Click(object sender, EventArgs e) { //call form's constructor and assign variable MyProfileForm profile = new MyProfileForm(); //display MyProfile form profile.ShowDialog(); }
/// <summary> /// click event for Calculate BMR button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnBMRCalc_Click(object sender, EventArgs e) { //call form's constructor and assign variable MyProfileForm profile = new MyProfileForm(); //display MyProfile form profile.ShowDialog(); //declare variables for BMR and activity level double BMR; int activityLevel = lstBoxActivityLevel.SelectedIndex; //validate which radio button is checked if (rBtnMale.Checked) { //calculate Male BMR, based on input from profile form BMR = MALE_ADDITION + (MALE_WEIGHT_MULTIPLIER * profile.WEIGHT) + (MALE_HEIGHT_MULTIPLIER * profile.HEIGHT) - (MALE_AGE_MULTIPLIER * profile.AGE); } else { //calculate Female BMR, based on input from profile form BMR = FEMALE_ADDITION + (FEMALE_WEIGHT_MULTIPLIER * profile.WEIGHT) + (FEMALE_HEIGHT_MULTIPLIER * profile.HEIGHT) - (FEMALE_AGE_MULTIPLIER * profile.AGE); } //switch statement for activity level switch (activityLevel) { case 0: BMR *= LITTLE_EXCERCISE; break; case 1: BMR *= LIGHT_EXCERCISE; break; case 2: BMR *= MODERATE_EXCERCISE; break; case 3: BMR *= HEAVY_EXCERCISE; break; case 4: BMR *= VHEAVY_EXCERCISE; break; default: MessageBox.Show("Don't forget to select an activity level!", "Activity Level Error", MessageBoxButtons.OK, MessageBoxIcon.Error); //don't close form this.DialogResult = DialogResult.None; break; } //display results of the calculation in respective lables txtBoxBMR.Text = BMR.ToString("n2"); }
/// <summary> /// click event for Calculate BMR button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnBMRCalc_Click(object sender, EventArgs e) { //call form's constructor and assign variable MyProfileForm profile = new MyProfileForm(); //display MyProfile form profile.ShowDialog(); //declare variables for maleBMR and femaleBMR double maleBMR; double femaleBMR; //calculate BMR for the genders, based on input from profile form maleBMR = 66 + (6.23 * profile.weight) +(12.7 * profile.height) -(6.8 * profile.age); femaleBMR = 655 + (4.35 * profile.weight) +(4.7 * profile.height) -(4.7 * profile.age); //display results of the calculation in respective lables lblMaleBMR.Text = maleBMR.ToString("n2"); lblFemaleBMR.Text = femaleBMR.ToString("n2"); }
/// <summary> /// click event for Calculate BMR button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnBMRCalc_Click(object sender, EventArgs e) { //call form's constructor and assign variable MyProfileForm profile = new MyProfileForm(); //display MyProfile form profile.ShowDialog(); //declare variables for maleBMR and femaleBMR double maleBMR; double femaleBMR; //calculate BMR for the genders, based on input from profile form maleBMR = MALE_ADDITION + (MALE_WEIGHT_MULTIPLIER * profile.WEIGHT) +(MALE_HEIGHT_MULTIPLIER * profile.HEIGHT) -(MALE_AGE_MULTIPLIER * profile.AGE); femaleBMR = FEMALE_ADDITION + (FEMALE_WEIGHT_MULTIPLIER * profile.WEIGHT) +(FEMALE_HEIGHT_MULTIPLIER * profile.HEIGHT) -(FEMALE_AGE_MULTIPLIER * profile.AGE); //display results of the calculation in respective lables lblMaleBMR.Text = maleBMR.ToString("n2"); lblFemaleBMR.Text = femaleBMR.ToString("n2"); }
/// <summary> /// click event for Calculate BMR button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnBMRCalc_Click(object sender, EventArgs e) { //call form's constructor and assign variable MyProfileForm profile = new MyProfileForm(); //display MyProfile form profile.ShowDialog(); //declare variables for maleBMR and femaleBMR double maleBMR; double femaleBMR; //calculate BMR for the genders, based on input from profile form maleBMR = MALE_ADDITION + (MALE_WEIGHT_MULTIPLIER * profile.WEIGHT) + (MALE_HEIGHT_MULTIPLIER * profile.HEIGHT) - (MALE_AGE_MULTIPLIER * profile.AGE); femaleBMR = FEMALE_ADDITION + (FEMALE_WEIGHT_MULTIPLIER * profile.WEIGHT) + (FEMALE_HEIGHT_MULTIPLIER * profile.HEIGHT) - (FEMALE_AGE_MULTIPLIER * profile.AGE); //display results of the calculation in respective lables lblMaleBMR.Text = maleBMR.ToString("n2"); lblFemaleBMR.Text = femaleBMR.ToString("n2"); }
/// <summary> /// click event for Calculate BMR button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnBMRCalc_Click(object sender, EventArgs e) { //call form's constructor and assign variable MyProfileForm profile = new MyProfileForm(); //display MyProfile form profile.ShowDialog(); //declare variables for maleBMR and femaleBMR double maleBMR; double femaleBMR; //calculate BMR for the genders, based on input from profile form maleBMR = 66 + (6.23 * profile.weight) + (12.7 * profile.height) - (6.8 * profile.age); femaleBMR = 655 + (4.35 * profile.weight) + (4.7 * profile.height) - (4.7 * profile.age); //display results of the calculation in respective lables lblMaleBMR.Text = maleBMR.ToString("n2"); lblFemaleBMR.Text = femaleBMR.ToString("n2"); }