void dodajPerformans(Performance p)
 {   //dodawanie seansu do seansu
     try
     {
         using (var context = new KinoEntities())
         {
             context.Configuration.AutoDetectChangesEnabled = true;
             using (var transaction = context.Database.BeginTransaction())
             {
                 context.Performances.AddOrUpdate(p);
                 context.Entry(p).State = p.id > 0 ? EntityState.Modified : EntityState.Added;
                 MessageBox.Show("Stan bazy danych przed \n " + context.Entry(p).State.ToString());
                 context.SaveChanges();
                 transaction.Commit();
             }
         }
     }
     catch (Exception e) {
         MessageBox.Show("Sprawdź połączenie z Internetem!");
     }
 }
Ejemplo n.º 2
0
        public void deleteElement()
        {
            if (selectedElement != null)
            {
                context.Configuration.AutoDetectChangesEnabled = true;
                context.Timetables.Attach(selectedElement);

                context.Entry(selectedElement).State = EntityState.Deleted;
                context.SaveChanges();
                uzupelnianieDataGridView();
            }
        }