Exemplo n.º 1
0
 public void ResetPatientsTab()
 {
     FirstNameSearchTextBox.Text = "";
     LastNameSearchTextBox.Text  = "";
     IsPatientSelected           = false;
     PatientsList = ShortPatientForPatientsTab.GetRepresentation();
 }
Exemplo n.º 2
0
 private void SearchButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         PatientsList = ShortPatientForPatientsTab.GetRepresentation().Where(x => x.FullName == $"{FirstNameSearchTextBox.Text} {LastNameSearchTextBox.Text}").ToList();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         MessageBox.Show(FirstNameSearchTextBox.Text + ", " + LastNameSearchTextBox.Text);
     }
 }
        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);
            }
        }