Пример #1
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewBook.SelectedItems.Count == 1)
     {
         BookSet bookSet = listViewBook.SelectedItems[0].Tag as BookSet;
         bookSet.Name   = textBoxName.Text;
         bookSet.Genre  = textBoxGenre.Text;
         bookSet.Author = textBoxAuthor.Text;
         Program.wftDb.SaveChanges();
         ShowBook();
     }
 }
Пример #2
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            BookSet bookSet = new BookSet();

            bookSet.Name   = textBoxName.Text;
            bookSet.Genre  = textBoxGenre.Text;
            bookSet.Author = textBoxAuthor.Text;


            Program.wftDb.BookSet.Add(bookSet);

            Program.wftDb.SaveChanges();
            ShowBook();
        }
Пример #3
0
 private void listViewBook_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewBook.SelectedItems.Count == 1)
     {
         BookSet bookSet = listViewBook.SelectedItems[0].Tag as BookSet;
         bookSet.Name   = textBoxName.Text;
         bookSet.Genre  = textBoxGenre.Text;
         bookSet.Author = textBoxAuthor.Text;
     }
     else
     {
         textBoxName.Text   = "";
         textBoxGenre.Text  = "";
         textBoxAuthor.Text = "";
     }
 }
Пример #4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewBook.SelectedItems.Count == 1)
         {
             BookSet bookSet = listViewBook.SelectedItems[0].Tag as BookSet;
             Program.wftDb.BookSet.Remove(bookSet);
             Program.wftDb.SaveChanges();
             ShowBook();
         }
         textBoxName.Text   = "";
         textBoxGenre.Text  = "";
         textBoxAuthor.Text = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }