//Calculate button event private void CalculateButton_Click(object sender, EventArgs e) { try { // Weight in kg double weight = GetWeight(); // Height in cm double height = GetHeight(); double bmi = BMIUtility.calculateBmi(weight, height); bmiTextBox.Text = Convert.ToString(Math.Round(bmi, 2)); Gender gender = GetGender(); double idealWeight = BMIUtility.calculateIdealBodyWeight(gender, height); recommendationTextBox.Text = $"Your ideal weight is {idealWeight}"; List <BMIData> bmiDataList = BMIData.getBMIDataList(); BMIData resultBmiData = GetBmiData(bmi, bmiDataList); resultsTextBox.Text = resultBmiData.Category; unfocusResultInDataGrid(); focusResultInDataGrid(bmiDataList, resultBmiData); } catch (Exception ex) { MessageBox.Show("Exception occurred: " + ex.Message); } }
public BMIForm() { InitializeComponent(); bmiChartGridView.DataSource = BMIData.getBMIDataList(); }