public Dictionary <String, Object> parametres(BodyMassIndex bmi) { Dictionary <String, object> d = new Dictionary <String, Object>() { { "@Date_Bmi", DateTime.Now.Date }, { "@Weight", bmi.getWeight() }, { "@Height", bmi.getHeight() }, { "@Value", bmi.getResult() }, { "@Evaluation", bmi.getEvaluation() }, }; return(d); }
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."); } }