public void Save(Patient patient)
 {
     this.patient = patient;
     bool fileCrated = true;
     try
     {
         LoadPatientsHistoryFile();
     }
     catch (FileNotFoundException)
     {
         fileCrated = false;
     }
     if (!fileCrated)
     {
         CreatePatientsHistoryXmlFirstTime();
     }
     else
     {
         XmlNode patientNode = FindPatientNode();
         if (patientNode == null)
         {
             AddNewPatient();
         }
         else
         {
             XmlNode measurement = patientNode.FirstChild.CloneNode(true);
             measurement = SetMeasurementValues(measurement);
             patientNode.AppendChild(measurement);
         }
     }
     document.Save(PatientsHistoryFileLocation);
 }
 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();
 }
 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();
 }