Esempio n. 1
0
 public bool CanClose()
 {
     if (ItemDB.ChangeTracker.HasChanges())
     {
         MessageBoxResult savechnages = MessageBox.Show("Do you want to save changes?", "Cognitivo", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
         if (savechnages == MessageBoxResult.Yes)
         {
             IEnumerable <DbEntityValidationResult> validationresult = ItemDB.GetValidationErrors();
             if (validationresult.Count() == 0)
             {
                 ItemDB.item_tag.Where(a => a.is_active == true && a.id_company == CurrentSession.Id_Company).Load();
                 ItemDB.SaveChanges();
                 return(true);
             }
             else
             {
                 MessageBox.Show("Some values are missing. Please fillup all the fields and try again.", "Cognitivo", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                 return(false);
             }
         }
         else if (savechnages == MessageBoxResult.No)
         {
             return(true);
         }
         else if (savechnages == MessageBoxResult.Cancel)
         {
             return(false);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(true);
     }
 }