private void Add_Client(object sender, RoutedEventArgs e) { Patient tempPatient = new Patient(); Problem tempProblem = new Problem(); FCS_DBModel db = new FCS_DBModel(); Determine_AgeGroup(combobox_AgeGroup.SelectedIndex); Determine_EthnicGroup(combobox_ethnicity.SelectedIndex); Determine_Gender(combobox_Gender.SelectedIndex); var togglePatientProblems = PatientProblemsCheckBoxes.Children; try { // Check to see if there needs to be a new household made first if ((bool)check_FirstHouseholdMember.IsChecked) { Determine_Income(combobox_IncomeBracket.SelectedIndex); Determine_County(combobox_County.SelectedIndex); PatientHousehold household = new PatientHousehold(); household.HouseholdCounty = County; household.HouseholdIncomeBracket = Income; household.HouseholdPopulation = HouseholdPopulation; db.PatientHouseholds.Add(household); db.SaveChanges(); tempPatient.HouseholdID = household.HouseholdID; } else { tempPatient.HouseholdID = db.Patients.Where(x => x.PatientOQ == familyOQNumber).Select(x => x.HouseholdID).Distinct().First(); } bool isHeadOfHouse = (bool)check_HeadOfHousehold.IsChecked; tempPatient.PatientOQ = patientOQ; tempPatient.PatientFirstName = firstName; tempPatient.PatientLastName = lastName; tempPatient.PatientAgeGroup = ageGroup; tempPatient.PatientEthnicity = ethnicGroup; tempPatient.PatientGender = PatientGender; tempPatient.NewClientIntakeHour = DateTime.Now; tempPatient.IsHead = headOfHouse; tempPatient.RelationToHead = (headOfHouse) ? "Head" : relationToHead; db.Patients.Add(tempPatient); db.SaveChanges(); Determine_Problems(patientOQ, togglePatientProblems); this.Close(); } catch (Exception error) { MessageBox.Show("Something went wrong, please double check your entry values.\n\n"); MessageBox.Show("Error: " + error.ToString()); } }
private void Add_Client(object sender, RoutedEventArgs e) { Patient tempPatient = new Patient(); Problem tempProblem = new Problem(); FCS_DBModel db = new FCS_DBModel(); // Check to see if the OQ number is already taken try { string strPatientOQ = patientOQ.ToString(); string duplicateQO = db.Patients.Where(x => x.PatientOQ == patientOQ).Select(x => x.PatientOQ).Distinct().First(); if (!string.IsNullOrEmpty(duplicateQO)) { MessageBox.Show("The OQ Number is already taken, please enter a different OQ number."); return; } } catch { } ageGroup = combobox_AgeGroup.Text; ethnicGroup = combobox_ethnicity.Text; PatientGender = combobox_Gender.Text; try { // Check to see if there needs to be a new household made first if ((bool)check_FirstHouseholdMember.IsChecked) { Income = combobox_IncomeBracket.Text; County = combobox_County.Text; PatientHousehold household = new PatientHousehold(); household.HouseholdCounty = County; household.HouseholdIncomeBracket = Income; household.HouseholdPopulation = HouseholdPopulation; db.PatientHouseholds.Add(household); db.SaveChanges(); tempPatient.HouseholdID = household.HouseholdID; } else { try { tempPatient.HouseholdID = db.Patients.Where(x => x.PatientOQ == familyOQNumber).Select(x => x.HouseholdID).Distinct().First(); } catch (Exception error) { MessageBox.Show("The provided Family OQ Number does not exist. Please double-check the Family OQ Number.", "Family OQ Number Doesn't Exist", MessageBoxButton.OK, MessageBoxImage.Error); return; } } bool isHeadOfHouse = (bool)check_HeadOfHousehold.IsChecked; tempPatient.PatientOQ = patientOQ; tempPatient.PatientFirstName = firstName; tempPatient.PatientLastName = lastName; tempPatient.PatientAgeGroup = ageGroup; tempPatient.PatientEthnicity = ethnicGroup; tempPatient.PatientGender = PatientGender; DateTime ClientIntakeDateTime; bool result = DateTime.TryParse(date_ClientCreationDate.Text, out ClientIntakeDateTime); if (result == true) { tempPatient.NewClientIntakeHour = ClientIntakeDateTime; } else { MessageBox.Show("Please enter a valid Client Creation date"); return; } tempPatient.IsHead = headOfHouse; tempPatient.RelationToHead = (headOfHouse) ? "Head" : relationToHead; db.Patients.Add(tempPatient); db.SaveChanges(); Determine_Problems(patientOQ); this.Close(); } catch (Exception error) { MessageBox.Show("Something went wrong, please double check your entry values.\n\n"); MessageBox.Show("Error: " + error.ToString()); } }
private void button_AddPatient_Click(object sender, RoutedEventArgs e) { try { Patient tempPatient = new Patient(); Problem tempProblem = new Problem(); FCS_DBModel db = new FCS_DBModel(); if ((bool)check_NewHousehold.IsChecked) { int HouseholdPopulation = int.Parse(text_HouseholdPop.Text); string Income = text_Income.Text; string County = text_county.Text; PatientHousehold household = new PatientHousehold(); household.HouseholdCounty = County; household.HouseholdIncomeBracket = Income; household.HouseholdPopulation = HouseholdPopulation; db.PatientHouseholds.Add(household); db.SaveChanges(); tempPatient.HouseholdID = household.HouseholdID; } else { tempPatient.HouseholdID = int.Parse(text_HouseholdID.Text); } tempPatient.PatientOQ = text_PatientOQ.Text; tempPatient.PatientAgeGroup = text_AgeGroup.Text; tempPatient.PatientEthnicity = text_Ethnicity.Text; tempPatient.PatientFirstName = text_FirstName.Text; tempPatient.PatientGender = text_Gender.Text; tempPatient.PatientLastName = text_LastName.Text; tempPatient.RelationToHead = text_RelationToHEad.Text; tempPatient.IsHead = (bool)check_IsHead.IsChecked; tempPatient.NewClientIntakeHour = DateTime.Now; db.Patients.Add(tempPatient); db.SaveChanges(); } catch (Exception error) { } }