Esempio n. 1
0
        //
        //Удаление картины через контекстное меню
        //
        private void contMenuPicDel_Click(object sender, EventArgs e)
        {
            int id = IdConverter(dGVPicturesList);

            if (id > 0)
            {
                MessageBoxButtons msb     = MessageBoxButtons.YesNo;
                String            message = "Вы действительно хотите удалить картину?";
                String            caption = "Удаление";
                if (MessageBox.Show(message, caption, msb) == DialogResult.Yes)
                {
                    Pictures pictures = db.Pictures.Find(id);
                    dbDelete.PictureDel(pictures, db);
                }
            }
        }
Esempio n. 2
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. 3
0
        //УДАЛИТЬ КАРТИНУ
        public static bool PictureDel(Pictures pic, TableContext tableContext)
        //public static bool GenreDel(int id)
        {
            try
            {
                //TableContext tableContext = new TableContext();

                if (pic != null)
                {
                    tableContext.Pictures.Remove(pic);
                    tableContext.SaveChanges();
                    return(true);
                }
                return(false);
            }
            catch (Exception)
            {
                MessageBox.Show("Потеряно соеденение с сервером.");
                return(false);
            }
        }