private void EditPatientBtn_Click(object sender, RoutedEventArgs e)
        {
            if (PatientsListBox.SelectedItem == null)
            {
                return;
            }

            Models.Patient SelectedPatient = PatientsListBox.SelectedItem as Models.Patient;
            Models.Patient PatientCopy     = new Models.Patient();
            PatientCopy.SetTo(SelectedPatient);

            PatientDetails DetailsWindow = new PatientDetails();

            DetailsWindow.Title   = "Modifica paziente";
            DetailsWindow.Owner   = App.Current.MainWindow;
            DetailsWindow.Patient = PatientCopy;
            DetailsWindow.ShowDialog();

            if (DetailsWindow.Result == true)
            {
                PatientCopy.SSN = PatientCopy.SSN.ToUpper();
                SelectedPatient.SetTo(PatientCopy);
                Database.SaveChanges();
                RefreshPatientsList();
            }
        }
        private void NewExamBtn_Click(object sender, RoutedEventArgs e)
        {
            if (PatientsListBox.SelectedItem == null)
            {
                return;
            }

            Models.Patient    SelectedPatient = PatientsListBox.SelectedItem as Models.Patient;
            ExamRecordDetails DetailsWindow   = new ExamRecordDetails();

            DetailsWindow.Title = "Nuovo esame";
            DetailsWindow.Owner = App.Current.MainWindow;
            Models.ExamRecord NewRecord = new Models.ExamRecord();
            NewRecord.PatientId  = SelectedPatient.Id;
            NewRecord.Date       = DateTime.Now.Date;
            DetailsWindow.Record = NewRecord;
            DetailsWindow.ShowDialog();

            if (DetailsWindow.Result == true)
            {
                Database.ExamRecords.Add(NewRecord);
                Database.SaveChanges();
                RefreshRecordsList(SelectedPatient);
            }
        }
        private void PatientsListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (PatientsListBox.SelectedItem == null)
            {
                ExamsDataGrid.DataContext = new List <Models.ExamRecord>();
                return;
            }

            Models.Patient SelectedPatient = PatientsListBox.SelectedItem as Models.Patient;
            RefreshRecordsList(SelectedPatient);
        }
        private void RefreshRecordsList(Models.Patient SelectedPatient)
        {
            List <Models.ExamRecord> List;

            if (SelectedPatient == null || SelectedPatient.ExamRecords == null)
            {
                List = new List <Models.ExamRecord>();
            }
            else
            {
                List = (from d in SelectedPatient.ExamRecords orderby d.Date descending select d).ToList();
            }
            ExamsDataGrid.DataContext = List;
        }
        private void DeletePatientBtn_Click(object sender, RoutedEventArgs e)
        {
            if (PatientsListBox.SelectedItem == null)
            {
                return;
            }

            Models.Patient   SelectedPatient = PatientsListBox.SelectedItem as Models.Patient;
            MessageBoxResult Result          = MessageBox.Show("Eliminare il paziente selezionato?", "Conferma eliminazione", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (Result == MessageBoxResult.Yes)
            {
                Database.Patients.Remove(SelectedPatient);
                Database.SaveChanges();
                RefreshPatientsList();
            }
        }
        private void NewPatientBtn_Click(object sender, RoutedEventArgs e)
        {
            PatientDetails DetailsWindow = new PatientDetails();

            DetailsWindow.Title = "Nuovo paziente";
            DetailsWindow.Owner = App.Current.MainWindow;
            Models.Patient NewPatient = new Models.Patient();
            DetailsWindow.Patient = NewPatient;
            DetailsWindow.ShowDialog();

            if (DetailsWindow.Result == true)
            {
                NewPatient.SSN = NewPatient.SSN.ToUpper();
                Database.Patients.Add(NewPatient);
                Database.SaveChanges();
                RefreshPatientsList();
            }
        }
        private void NewPatientBtn_Click(object sender, RoutedEventArgs e)
        {
            PatientDetails DetailsWindow = new PatientDetails();
            DetailsWindow.Title = "Nuovo paziente";
            DetailsWindow.Owner = App.Current.MainWindow;
            Models.Patient NewPatient = new Models.Patient();
            DetailsWindow.Patient = NewPatient;
            DetailsWindow.ShowDialog();

            if (DetailsWindow.Result == true)
            {
                NewPatient.SSN = NewPatient.SSN.ToUpper();
                Database.Patients.Add(NewPatient);
                Database.SaveChanges();
                RefreshPatientsList();
            }
        }
        private void EditPatientBtn_Click(object sender, RoutedEventArgs e)
        {
            if (PatientsListBox.SelectedItem == null)
            {
                return;
            }

            Models.Patient SelectedPatient = PatientsListBox.SelectedItem as Models.Patient;
            Models.Patient PatientCopy = new Models.Patient();
            PatientCopy.SetTo(SelectedPatient);

            PatientDetails DetailsWindow = new PatientDetails();
            DetailsWindow.Title = "Modifica paziente";
            DetailsWindow.Owner = App.Current.MainWindow;
            DetailsWindow.Patient = PatientCopy;
            DetailsWindow.ShowDialog();

            if (DetailsWindow.Result == true)
            {
                PatientCopy.SSN = PatientCopy.SSN.ToUpper();
                SelectedPatient.SetTo(PatientCopy);
                Database.SaveChanges();
                RefreshPatientsList();
            }
        }
示例#9
0
 public void SetTo(Patient Input)
 {
     SSN = Input.SSN;
     FirstName = Input.FirstName;
     LastName = Input.LastName;
 }