Esempio n. 1
0
 //ДОБАВИТЬ  Выставку
 public static bool ExpositionAdd(Expositions exp, TableContext tableContext)
 {
     try
     {
         tableContext.Expositions.Add(exp);
         tableContext.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         MessageBox.Show("Потеряно соеденение с сервером.");
         return(false);
     }
 }
Esempio n. 2
0
 //ДОБАВИТЬ КАРТИНУ
 public static bool PictureAdd(Pictures pic, TableContext tableContext)
 {
     try
     {
         tableContext.Pictures.Add(pic);
         tableContext.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         MessageBox.Show("Потеряно соеденение с сервером.");
         return(false);
     }
 }
Esempio n. 3
0
 //ДОБАВИТЬ Автора
 public static bool AuthorAdd(Authors aut, TableContext tableContext)
 {
     try
     {
         tableContext.Authors.Add(aut);
         tableContext.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         MessageBox.Show("Потеряно соеденение с сервером.");
         return(false);
     }
 }
Esempio n. 4
0
 //ДОБАВИТЬ пользователя
 public static bool UserAdd(Users usr, TableContext tableContext)
 {
     try
     {
         tableContext.Users.Add(usr);
         tableContext.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         MessageBox.Show("Потеряно соеденение с сервером.");
         return(false);
     }
 }
Esempio n. 5
0
 //ДОБАВИТЬ ЖАНР
 public static bool GenreAdd(Genres gen, TableContext tableContext)
 {
     try
     {
         tableContext.Genres.Add(gen);
         tableContext.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         MessageBox.Show("Потеряно соеденение с сервером.");
         return(false);
     }
 }
Esempio n. 6
0
 //РЕДАКТИРОВАТЬ ЖАНР
 public static bool GenreEdit(Genres genreEdit, Genres genreEditor, TableContext tableContext)
 {
     try
     {
         if (genreEdit != genreEditor)
         {
             genreEdit = genreEditor;
         }
         tableContext.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         MessageBox.Show("Потеряно соеденение с сервером.");
         return(false);
     }
 }
Esempio n. 7
0
 //УДАЛИТЬ Выставку
 public static bool ExpositionDel(Expositions exposition, TableContext tableContext)
 {
     try
     {
         if (exposition != null)
         {
             tableContext.Expositions.Remove(exposition);
             tableContext.SaveChanges();
             return(true);
         }
         return(false);
     }
     catch (Exception)
     {
         MessageBox.Show("Потеряно соеденение с сервером.");
         return(false);
     }
 }
Esempio n. 8
0
 //УДАЛИТЬ Автора
 public static bool AuthorDel(Authors author, TableContext tableContext)
 {
     try
     {
         if (author != null)
         {
             tableContext.Authors.Remove(author);
             tableContext.SaveChanges();
             return(true);
         }
         return(false);
     }
     catch (Exception)
     {
         MessageBox.Show("Потеряно соеденение с сервером.");
         return(false);
     }
 }
Esempio n. 9
0
 public static bool ExpositionEdit(Expositions expEdit, Expositions expEditor, TableContext tableContext)
 {
     try
     {
         if (expEdit != expEditor)
         {
             expEdit = expEditor;
         }
         tableContext.Entry(expEdit).State = EntityState.Modified;
         tableContext.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         MessageBox.Show("Потеряно соеденение с сервером.");
         return(false);
     }
 }
Esempio n. 10
0
 //РЕДАКТИРОВАТЬ Автора
 public static bool AuthorEdit(Authors authorEdit, Authors authorEditor, TableContext tableContext)
 {
     try
     {
         if (authorEdit != authorEditor)
         {
             authorEdit = authorEditor;
         }
         tableContext.Entry(authorEdit).State = EntityState.Modified;
         tableContext.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         MessageBox.Show("Потеряно соеденение с сервером.");
         return(false);
     }
 }
Esempio n. 11
0
 //РЕДАКТИРОВАТЬ КАРТИНУ
 public static bool PicturesEdit(Pictures picturesEdit, Pictures picturesEditor, TableContext tableContext)
 {
     try
     {
         if (picturesEdit != picturesEditor)
         {
             picturesEdit = picturesEditor;
         }
         tableContext.Entry(picturesEdit).State = EntityState.Modified;
         tableContext.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         MessageBox.Show("Потеряно соеденение с сервером.");
         return(false);
     }
 }
Esempio n. 12
0
 //ДОБАВИТЬ Cвязь Экспозиция - выставка
 public static bool ExpToPicAdd(int expId, int picId, TableContext tableContext)
 {
     try
     {
         ExpToPic expToPic = new ExpToPic
         {
             IdExp = expId,
             IdPic = picId
         };
         tableContext.ExpToPics.Add(expToPic);
         tableContext.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         MessageBox.Show("Потеряно соеденение с сервером.");
         return(false);
     }
 }
Esempio n. 13
0
        //УДАЛИТЬ ЖАНР
        public static bool GenreDel(Genres genre, TableContext tableContext)
        //public static bool GenreDel(int id)
        {
            try
            {
                //TableContext tableContext = new TableContext();

                if (genre != null)
                {
                    tableContext.Genres.Remove(genre);
                    tableContext.SaveChanges();
                    return(true);
                }
                return(false);
            }
            catch (Exception)
            {
                MessageBox.Show("Потеряно соеденение с сервером.");
                return(false);
            }
        }
Esempio n. 14
0
        //УДАЛИТЬ ПОЛЬЗОВАТЕЛЯ
        public static bool DelExpToPic(int idExp, int idPic, TableContext tableContext)
        //public static bool GenreDel(int id)
        {
            try
            {
                //TableContext tableContext = new TableContext();

                if (idExp != 0 && idPic != 0)
                {
                    ExpToPic expToPic = tableContext.ExpToPics.Where(c => c.IdExp == idExp).Where(c => c.IdPic == idPic).FirstOrDefault();
                    tableContext.ExpToPics.Remove(expToPic);
                    tableContext.SaveChanges();
                    return(true);
                }
                return(false);
            }
            catch (Exception)
            {
                MessageBox.Show("Ошибка удаления.");
                return(false);
            }
        }