Exemplo n.º 1
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);
     }
 }
Exemplo n.º 2
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);
     }
 }
Exemplo n.º 3
0
        private void bEdit_Click(object sender, EventArgs e)
        {
            if (dGVAvtorList.SelectedRows.Count > 0)
            {
                int  index     = dGVAvtorList.SelectedRows[0].Index;
                int  id        = 0;
                bool converted = Int32.TryParse(dGVAvtorList[0, index].Value.ToString(), out id);
                if (converted == false)
                {
                    return;
                }

                Authors    author   = TabCon.Authors.Find(id);
                FormAuthor editForm = new FormAuthor(author, sess);

                DialogResult result = editForm.ShowDialog(this);

                switch (result)
                {
                case DialogResult.Cancel:
                    return;

                case DialogResult.Abort:
                    dbDelete.AuthorDel(editForm.author, TabCon);
                    dGVAvtorList.Refresh();
                    break;

                case DialogResult.OK:
                    dbEdit.AuthorEdit(author, editForm.author, TabCon);
                    dGVAvtorList.Refresh();
                    break;

                default:
                    Console.WriteLine("Ой-ой");
                    break;
                }
            }
        }