/// /// <summary> Updates a HoH contained within the databse. </summary> /// /// <remarks> 2019-04-20. </remarks> /// public void UpdateHoH() { patientHoh.FirstName = fNameTextBox.Text; patientHoh.LastName = lNameTextBox.Text; patientHoh.HCN = hcnTextBox.Text; patientHoh.MInitial = Gender.ToString(); patientHoh.DoB = dobPicker.DisplayDate; //Probs need validation here patientHoh.AddressLine1 = addressTextBox.Text; patientHoh.AddressLine2 = addressTwoTextbox.Text; patientHoh.City = cityTextBox.Text; patientHoh.Province = provComboBox.Text; patientHoh.PostalCode = pCodeTextBox.Text; patientHoh.Phone = pNumberTextBox.Text; patientHoh.Update(); }
/// /// <summary> Event handler. Called by SubmitBtn for click events. /// ensures all required items are valid and then submits the request to /// update the HoH or dependant</summary> /// /// <remarks> 2019-04-20. </remarks> /// /// <param name="sender"> Source of the event. </param> /// <param name="e"> Routed event information. </param> /// private void SubmitBtn_Click(object sender, RoutedEventArgs e) { bool passOrFail = false; if (CanSubmit()) //Ensure all required information was submitted. { //If any dependant information is not valid, set them to blank if (!addressBool) { addressTextBox.Text = ""; } if (!addressTwoBool) { addressTwoTextbox.Text = ""; } if (!cityBool) { cityTextBox.Text = ""; } if (provComboBox.SelectedIndex == 0) { provComboBox.Text = " "; } if (!pCodeBool) { pCodeTextBox.Text = ""; } if (!pNumberBool) { pNumberTextBox.Text = ""; } //Send either patient or dependent depending on type. //Send it to the factory if (patient.GetType() == typeof(Patient_HoH)) //patient is a hoh { //If patient is HOH... See if a HOH is entered... Make patient a depenendant.. Then HCN_To_Dependant... //Then update. if (hohTextBox.Text != "" && hohEnteredBool) //Change hohTo Dependant { hohToDependant[0] = hcnTextBox.Text; hohToDependant[1] = lNameTextBox.Text; hohToDependant[2] = fNameTextBox.Text; hohToDependant[3] = mInitialTextBox.Text; hohToDependant[4] = dobPicker.Text; hohToDependant[5] = Gender.ToString(); hohToDependant[6] = hohTextBox.Text; passOrFail = Database.HoH_To_Dependant(hohToDependant); //See if the cahnge is allowed, //Not allowed if the HoH has dependants themself if (passOrFail) { //Get a new patient and update.. patientDependant = (Patient_Dependant)PatientFactory.Create(hohToDependant); patientDependant.Update(); } else { UpdateHoH(); } } else { UpdateHoH(); //HoH info did not change.. Update HoH } } else { //If PAtietn is dependant... No HoH is entered... We use Dependant_To_Hoh()... Then update after.. Otherwise just update what has been updated. if (!hohEnteredBool) { dependantToHoh[2] = fNameTextBox.Text; dependantToHoh[1] = lNameTextBox.Text; dependantToHoh[0] = hcnTextBox.Text; dependantToHoh[3] = mInitialTextBox.Text; dependantToHoh[5] = Gender.ToString(); dependantToHoh[4] = dobPicker.Text; dependantToHoh[6] = addressTextBox.Text; dependantToHoh[7] = addressTwoTextbox.Text; dependantToHoh[8] = cityTextBox.Text; dependantToHoh[10] = provComboBox.SelectedValue.ToString(); dependantToHoh[9] = pCodeTextBox.Text; dependantToHoh[11] = pNumberTextBox.Text; //Make the dependent a HoH Database.Dependant_To_HoH(dependantToHoh); if (passOrFail) { //Create a new HoH patientHoh = (Patient_HoH)PatientFactory.Create(dependantToHoh); patientHoh.Update(); //Update the patient } else { UpdateDependant(); } } else //Hoh did not switch.. Update dependant. { UpdateDependant(); } } ResetBoxes(); //Reset all boxes StartNewSearch(); //Start a new search } }