Exemple #1
0
        public void NewPatientExecute(object param)
        {
            // New Button pressed
            var v  = new PatientDetails();  // new View
            var vm = new VMPatientEdit();   // new ViewModel

            vm.P             = new Patient();
            vm.IstInEditMode = false;
            v.DataContext    = vm;       //  view.DataContext = ViewModel
            v.ShowDialog();
            if (v.DialogResult == true)  // Save in Dialogbox clicked and inputs valid
            {
                SearchBoxText = "";
                using (KlinikDbEntities db = new KlinikDbEntities())
                {
                    db.Patients.Add(vm.P);
                    db.SaveChanges();
                    PropertyChanged(this, new PropertyChangedEventArgs("AllPatients"));
                }
            }
            else
            {
                PropertyChanged(this, new PropertyChangedEventArgs("AllPatients"));
            }
        }
Exemple #2
0
 public void EditExecute(Object param)
 {
     if (SelectedPatient != null)
     {
         SearchBoxText = "";
         var v = new PatientDetails();
         //v.SelectedDate = SelectedExam.Ex_Date;
         var vm = new VMPatientEdit();
         vm.P             = SelectedPatient;
         vm.IstInEditMode = true;
         v.DataContext    = vm;
         v.ShowDialog();
         if (v.DialogResult == true)  //save
         {
             using (KlinikDbEntities db = new KlinikDbEntities())
             {
                 //vm.P.Examinations = null; //wegen include
                 db.Entry(vm.P).State = EntityState.Modified;
                 db.SaveChanges();
                 PropertyChanged(this, new PropertyChangedEventArgs("AllPatients"));
             }
         }
         else
         {
             SearchBoxText = "";
             PropertyChanged(this, new PropertyChangedEventArgs("AllPatients"));
         }
     }
 }