Ejemplo n.º 1
0
        public void testInit()
        {
            _storage = new Storage();
            _student = new Student();
            _group = new Group();
            _semestr = new Semester();

            _student.FirstName = "Testowy";
            _student.LastName = "Test";
            _student.IndexNo = "123456";

            _group.Name = "TstwGrp$#^134";

            _semestr.Name = "78Z";

        }
Ejemplo n.º 2
0
 public void deleteGroup(Group gr)
 {
     try
     {
         using (var db = new DataContext())
         {
             var original = db.Groups.Find(gr.GroupID);
             if (original != null)
             {
                 db.Groups.Remove(original);
                 db.SaveChanges();
             }
         }
     }
     catch (DbUpdateConcurrencyException)
     {
         throw;
     }
     catch (DbUpdateException)
     {
         MessageBox.Show("You can not delete group with students.", "Group Deletion Error");
         return;
     }
     catch (DbEntityValidationException)
     { throw; }
 }
Ejemplo n.º 3
0
 internal void createGroup(string NewGName)
 {
     try
     {
         using (var db = new DataContext())
         {
             var group = new Group { Name = NewGName};
             db.Groups.Add(group);
             db.SaveChanges();
         }
     }
     catch (DbEntityValidationException)
     { throw; }
 }
Ejemplo n.º 4
0
 public void deleteGroup(Group gr)
 {
     try
     {
         using (var db = new DataContext())
         {
             var original = db.Groups.Find(gr.GroupID);
             if (original != null)
             {
                 db.Groups.Remove(original);
                 db.SaveChanges();
             }
         }
     }
     catch (DbUpdateConcurrencyException)
     {
         throw new EresDataContextException("Blad polaczania z baza danych. Sprobuj jeszcze raz.", "Usuwanie grupy");
     }
     catch (DbUpdateException)
     {
         throw new EresDataContextException("Nie mozna usunac grupy ze studentami", "Usuwanie grupy");
     }
     catch (DbEntityValidationException)
     {
         throw new EresDataContextException("Blad polaczania z baza danych.", "Usuwanie grupy");
     }
 }
Ejemplo n.º 5
0
        public void createGroup(string NewGName)
        {
            try
            {
                using (var db = new DataContext())
                {
                    var group = new Group { Name = NewGName };
                    db.Groups.Add(group);
                    db.SaveChanges();
                }
            }
            catch (DbEntityValidationException)
            { throw new EresDataContextException("Blad polaczenia z baza danych", "Dodawanie grupy"); }

        }