public void mapToTableAttribute() { this.bmi = new BodyMassIndex(); this.bmi.setDateBmi(DateTime.Now.Date); this.bmi.setWeight(FormUtils.convertDouble(txtWeight.Text)); this.bmi.setHeight(FormUtils.convertDouble(txtHeight.Text)); this.bmi.setResult(FormUtils.convertDouble(labResult.Text)); this.bmi.setEvaluation(bmi.evaluate()); }
private void btn_calculate_Click(object sender, EventArgs e) { string[] s = new string[] { txtHeight.Text, txtWeight.Text }; if (!FormUtils.ValidChamps(s)) { if (FormUtils.EmptyText(txtHeight.Text)) { errorProvider1.SetError(txtHeight, FormUtils.loadConfigs("EMPTY_HEIGHT")); } else if (FormUtils.EmptyText(txtWeight.Text)) { errorProvider1.SetError(txtWeight, FormUtils.loadConfigs("EMPTY_WEIGHT")); } else { try { btn_save.Enabled = true; mapping(); this.labResult.Text = "" + bmi.getBMI(bmi.getHeight(), bmi.getWeight()); switch (bmi.evaluate()) { case "Underweight": changeLabelColor(labResult, Color.Red); break; case "Normal": changeLabelColor(labResult, Color.Green); break; case "Overweight": changeLabelColor(labResult, Color.Red); break; case "Obese": changeLabelColor(labResult, Color.Red); break; case "Severly Obese": changeLabelColor(labResult, Color.Red); break; default: changeLabelColor(labResult, Color.Red); break; } } catch (Exception ex) { FormUtils.showErrorMessage("Error", ex.Message + "\n" + ex.StackTrace); } } } else { errorProvider1.SetError(txtHeight, "Please fill your height."); errorProvider1.SetError(txtWeight, "Please fill your weight."); } }