Пример #1
0
 internal void deleteSubject(Subject sub)
 {
     try
     {
         using (var db = new DataContext())
         {
             var original = db.Subjects.Find(sub.SubjectID);
             if (original != null)
             {
                 db.Subjects.Remove(original);
                 db.SaveChanges();
             }
         }
     }
     catch (DbUpdateConcurrencyException)
     {
         throw;
     }
     catch (DbUpdateException)
     {
         MessageBox.Show("You can not delete subject which has realisation.", "Subject Deletion Error");
         return;
     }
     catch (DbEntityValidationException)
     { throw; }
 }
Пример #2
0
 public void deleteSubject(Subject sub)
 {
     try
     {
         using (var db = new DataContext())
         {
             var original = db.Subjects.Find(sub.SubjectID);
             if (original != null)
             {
                 db.Subjects.Remove(original);
                 db.SaveChanges();
             }
         }
     }
     catch (DbUpdateConcurrencyException)
     {
         throw new EresDataContextException("Blad polaczania z baza danych. Sprobuj jeszcze raz.", "Usuwanie przedmiotu");
     }
     catch (DbUpdateException)
     {
         throw new EresDataContextException("Nie mozna usunac przedmiotu z realizacja!", "Usuwanie przedmiotu");
     }
     catch (DbEntityValidationException)
     {
         throw new EresDataContextException("Blad polaczania z baza danych.", "Usuwanie przedmiotu");
     }
 }
Пример #3
0
 public void createSubject(string newName, string newConspect, string newUrl)
 {
     try
     {
         using (var db = new DataContext())
         {
             var subject = new Subject { Name = newName, Conspect = newConspect, url = newUrl };
             db.Subjects.Add(subject);
             db.SaveChanges();
         }
     }
     catch (DbEntityValidationException)
     { throw; }
 }
Пример #4
0
 public void createSubject(string newName, string newConspect, string newUrl)
 {
     try
     {
         using (var db = new DataContext())
         {
             var subject = new Subject { Name = newName, Conspect = newConspect, url = newUrl };
             db.Subjects.Add(subject);
             db.SaveChanges();
         }
     }
     catch (DbEntityValidationException)
     { 
         throw new EresDataContextException("Blad polaczenia z baza danych" ,"Dodawanie przedmiotu");
     }
 }