コード例 #1
0
 private void btnCalculate_Click(object sender, EventArgs e)
 {
     ClearResults();
     if (!UserInputValid())
     {
         return;
     }
     //Creating instance of Patient subclass
     if (rbtnFemale.Checked)
     {
         patient = new FemalePatient();
     }
     else
     {
         patient = new MalePatient();
     }
     //Setting patient properties with data from form
     patient.HeightInInches = (Convert.ToDouble(txtFeet.Text) * 12)
                              + Convert.ToDouble(txtInches.Text);
     patient.WeightInPounds = Convert.ToDouble(txtWeight.Text);
     patient.Age            = Convert.ToInt16(txtAge.Text);
     patient.SSN            = txtSSNFirstPart.Text +
                              txtSSNSecondPart.Text + txtSSNThirdPart.Text;
     patient.FirstName   = txtFirstName.Text;
     patient.LastName    = txtLastName.Text;
     txtCalories.Text    = patient.DailyCaloriesRecommended().ToString();
     txtIdealWeight.Text = patient.IdealBodyWeight().ToString();
     txtDistance.Text    = patient.DistanceFromIdealWeight().ToString();
 }
コード例 #2
0
 private void btnCalculate_Click(object sender, EventArgs e)
 {
     ClearResults();
     if (!UserInputValid())
     {
         return;
     }
     //Creating new instance of Patient class
     patient = new Patient();
     //Setting patient properties with data from form
     if (rbtnFemale.Checked)
     {
         patient.Gender = Gender.Female;
     }
     else
     {
         patient.Gender = Gender.Male;
     }
     patient.HeightInInches = (Convert.ToDouble(txtFeet.Text) * 12)
                              + Convert.ToDouble(txtInches.Text);
     patient.WeightInPounds = Convert.ToDouble(txtWeight.Text);
     patient.Age            = Convert.ToInt16(txtAge.Text);
     txtCalories.Text       = patient.DailyCaloriesRecommended().ToString();
     txtIdealWeight.Text    = patient.IdealBodyWeight().ToString();
     txtDistance.Text       = patient.DistanceFromIdealWeight().ToString();
 }
コード例 #3
0
        private void btnCalculate_Click(object sender, EventArgs e)
        {
            ClearResults();

            if (UserInputInvalid())
            {
                return;
            }

            //Patient = new Patient
            //{
            //    HeightInInches = Convert.ToDouble(txtFeet.Text) * 12 + Convert.ToDouble(txtInches.Text),
            //    WeightInPounds = Convert.ToDouble(txtWeight.Text),
            //    Age = Convert.ToDouble(txtAge.Text),
            //    Gender = rbtnMale.Checked ? Gender.Male : Gender.Female
            //};//使用时再初始化,初始化时赋值

            if (rbtnFemale.Checked)
            {
                Patient = new FemalePaient();
            }
            if (rbtnMale.Checked)
            {
                Patient = new MalePatient();
            }

            Patient.HeightInInches = Convert.ToDouble(txtFeet.Text) * 12 + Convert.ToDouble(txtInches.Text);
            Patient.WeightInPounds = Convert.ToDouble(txtWeight.Text);
            Patient.Age            = Convert.ToDouble(txtAge.Text);

            txtCalories.Text    = Patient.DailyCaloriesRecommended().ToString();
            txtIdealWeight.Text = Patient.IdealBodyWeight().ToString();
            txtDistance.Text    = Patient.DistanceFromIdealWeight().ToString();
        }
コード例 #4
0
 private void DisplayCalculationResult()
 {
     txtCalories.Text = patient.
                        DailyCaloriesRecommended().ToString();
     txtIdealWeight.Text = patient.
                           IdealBodyWeight().ToString();
     txtDistance.Text = patient.
                        DistanceFromIdealWeight().ToString();
 }
コード例 #5
0
 private void CreatePatientsHistoryXmlFirstTime()
 {
     document.LoadXml(
         "<PatientsHistory>" +
         "<patient ssn=\"" + patient.SSN + "\"" +
         " firstName=\"" + patient.FirstName + "\"" +
         " lastName=\"" + patient.LastName + "\"" + ">" +
         "<measurement date=\"" + DateTime.Now + "\"" + ">" +
         "<height>" + patient.HeightInInches + "</height>" +
         "<weight>" + patient.WeightInPounds + "</weight>" +
         "<age>" + patient.Age + "</age>" +
         "<dailyCaloriesRecommended>" +
         patient.DailyCaloriesRecommended() +
         "</dailyCaloriesRecommended>" +
         "<idealBodyWeight>" +
         patient.IdealBodyWeight() +
         "</idealBodyWeight>" +
         "<distanceFromIdealWeight>" +
         patient.DistanceFromIdealWeight() +
         "</distanceFromIdealWeight>" +
         "</measurement>" +
         "</patient>" +
         "</PatientsHistory>");
 }
コード例 #6
0
 private void btnCalculate_Click(object sender, EventArgs e)
 {
     ClearResults();
     if (!UserInputValid())
     {
         return;
     }
     //Creating new instance of Patient class
     patient = new Patient();
     //Setting patient properties with data from form
     if (rbtnFemale.Checked) {
         patient.Gender = Gender.Female;
     }else{
         patient.Gender = Gender.Male;
     }
     patient.HeightInInches = (Convert.ToDouble(txtFeet.Text) * 12)
         + Convert.ToDouble(txtInches.Text);
     patient.WeightInPounds = Convert.ToDouble(txtWeight.Text);
     patient.Age = Convert.ToInt16(txtAge.Text);
     txtCalories.Text = patient.DailyCaloriesRecommended().ToString();
     txtIdealWeight.Text = patient.IdealBodyWeight().ToString();
     txtDistance.Text = patient.DistanceFromIdealWeight().ToString();
 }