private void Button_Click(object sender, RoutedEventArgs e) { BmiCal BMI = new BmiCal(int.Parse(WightBox.Text), int.Parse(HightBox.Text)); InfoBox.Text = BMI.BmiCalculator(BMI).ToString(); InfoBox1.Text = DB.InsertBmi(BMI); }
public double BmiCalculator(BmiCal bmi) { int witght = bmi.weight; int hight = bmi.height; double bMI = 0; bMI = ((hight * hight) / witght); return(bMI); }
static public string InsertBmi(BmiCal bmi) { string message = "Weight and Height saved without problems"; try { XmlDocument Xml = new XmlDocument(); XmlSerializer Ser = new XmlSerializer(bmi.GetType()); MemoryStream stream = new MemoryStream(); Ser.Serialize(stream, bmi); stream.Position = 0; Xml.Load(stream); Xml.Save("BMINumbers"); return(message); } catch (Exception khf) { return("Error, Weight and Height not saved"); } }