示例#1
0
        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);
        }
示例#2
0
        public double BmiCalculator(BmiCal bmi)
        {
            int witght = bmi.weight;
            int hight  = bmi.height;

            double bMI = 0;

            bMI = ((hight * hight) / witght);

            return(bMI);
        }
示例#3
0
文件: DB.cs 项目: voljin2/bmiprojekt
        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");
            }
        }