예제 #1
0
 public void deleteRegistration(Registration r)
 {
     try
     {
         using (var db = new DataContext())
         {
             var orig = db.Registrations.Find(r.RegistrationID);
             if (orig != null)
             {
                 db.Registrations.Remove(orig);
                 db.SaveChanges();
             }
         }
     }
     catch (DbUpdateConcurrencyException)
     {
         throw;
     }
     catch (DbUpdateException)
     {
         MessageBox.Show("You can not delete used registartion.", "Registration Deletion Error");
         return;
     }
     catch (DbEntityValidationException)
     { throw; }
 }
예제 #2
0
 public void deleteRegistration(Registration r)
 {
     try
     {
         using (var db = new DataContext())
         {
             var orig = db.Registrations.Find(r.RegistrationID);
             if (orig != null)
             {
                 db.Registrations.Remove(orig);
                 db.SaveChanges();
             }
         }
     }
     catch (DbUpdateConcurrencyException)
     {
         throw new EresDataContextException("Blad polaczania z baza danych. Sprobuj jeszcze raz.", "Usuwanie rejestracji");
     }
     catch (DbUpdateException)
     {
         throw new EresDataContextException("Nie mozna usunac trwajacej rejestracji!", "Usuwanie rejestracji");
     }
     catch (DbEntityValidationException)
     {
         throw new EresDataContextException("Blad polaczania z baza danych.", "Usuwanie rejestracji");
     }
 }
예제 #3
0
 public void createRegistration(int realId, int studId)
 {
     try
     {
         using (var db = new DataContext())
         {
             var real = db.Realisations.Find(realId);
             var stud = db.Students.Find(studId);
             var reg = new Registration { Realisation = real, Student = stud };
             db.Registrations.Add(reg);
             db.SaveChanges();
         }
     }
     catch (DbEntityValidationException)
     { throw; }
 }
예제 #4
0
 public void createRegistration(int realId, int studId)
 {
     try
     {
         using (var db = new DataContext())
         {
             var real = db.Realisations.Find(realId);
             var stud = db.Students.Find(studId);
             var reg = new Registration { Realisation = real, Student = stud };
             db.Registrations.Add(reg);
             db.SaveChanges();
         }
     }
     catch (DbEntityValidationException)
     {
         throw new EresDataContextException("Blad polaczania z baza danych.", "Dodawanie rejestracji");
     }
 }