private void SaveEditButton_Click(object sender, RoutedEventArgs e) { try { using (var context = new DataBaseContext()) { var names = FullNameTextBox.Text.Split(' '); if (names.Length != 2) { throw new Exception("Both names must be provided seperated by single space!"); } var currentPatient = context.Patients.SingleOrDefault(x => x.Id == Convert.ToInt32(IdHolderHack.Text)); currentPatient.FirstName = names[0]; currentPatient.LastName = names[1]; currentPatient.EmailAdress = EmailTextBox.Text; context.SaveChanges(); } foreach (Window window in Application.Current.Windows) { if (window.GetType() == typeof(MainWindow)) { MainWindow parentWindow = (window as MainWindow); foreach (UserControl control in parentWindow.ContentGrid.Children) { if (control.GetType() == typeof(PatientsTab)) { PatientsTab patientsTab = (control as PatientsTab); patientsTab.PatientsList = ShortPatientForPatientsTab.GetRepresentation(); } } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void ChosePatientButton_Click(object sender, RoutedEventArgs e) { foreach (Window window in Application.Current.Windows) { if (window.GetType() == typeof(MainWindow)) { MainWindow parentWindow = (window as MainWindow); foreach (UserControl control in parentWindow.ContentGrid.Children) { if (control.GetType() == typeof(PatientsTab)) { PatientsTab patientsTab = (control as PatientsTab); patientsTab.ChosenPatient = LongPatientForPatientsTab.GetRepresentation(Convert.ToInt32(IdHolderHack.Text)); patientsTab.VaccinationsList = VaccinationForPatientsTab.GetRepresentation(patientsTab.ChosenPatient.TreatmentHistoryId); patientsTab.VisitsList = VisitForVisitsEditorTab.GetRepresentation().Where(x => x.Patient == patientsTab.ChosenPatient.FullName).ToList(); DataHolderForMainWindow.PatientId = Convert.ToInt32(IdHolderHack.Text); patientsTab.IsPatientSelected = true; } } } } }
private void ReceptionListViewMenu_SelectionChanged(object sender, SelectionChangedEventArgs e) { int index = ReceptionListViewMenu.SelectedIndex; transitioningContentSlide.OnApplyTemplate(); menuPointer.Margin = new Thickness(0, menuPointerOffset + (60 * index), 0, 0); switch (index) { case 0: var registrationTab = new PatientsTab(); ContentGrid.Children.Clear(); ContentGrid.Children.Add(registrationTab); break; case 1: var visitsEditorTab = new VisitsEditorTab(); ContentGrid.Children.Clear(); ContentGrid.Children.Add(visitsEditorTab); break; case 2: var scheduleTab = new ScheduleTab(); ContentGrid.Children.Clear(); ContentGrid.Children.Add(scheduleTab); break; case 3: DataHolderForMainWindow.IsUserLogedIn = false; ContentGrid.Children.Clear(); ShowLoginForm(); break; default: break; } }