Ejemplo n.º 1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            BooksSet booksSet = new BooksSet();

            booksSet.Name   = textBoxName.Text;
            booksSet.Year   = textBoxYear.Text;
            booksSet.Author = textBoxAuthor.Text;
            Program.qwer.BooksSet.Add(booksSet);
            Program.qwer.SaveChanges();
            ShowBooks();
        }
Ejemplo n.º 2
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewBooks.SelectedItems.Count == 1)
     {
         BooksSet booksSet = listViewBooks.SelectedItems[0].Tag as BooksSet;
         booksSet.Name   = textBoxName.Text;
         booksSet.Year   = textBoxYear.Text;
         booksSet.Author = textBoxAuthor.Text;
         Program.qwer.SaveChanges();
         ShowBooks();
     }
 }
Ejemplo n.º 3
0
 private void listViewBooks_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewBooks.SelectedItems.Count == 1)
     {
         BooksSet booksSet = listViewBooks.SelectedItems[0].Tag as BooksSet;
         textBoxName.Text   = booksSet.Name;
         textBoxAuthor.Text = booksSet.Author;
         textBoxYear.Text   = booksSet.Year;
     }
     else
     {
         textBoxName.Text   = "";
         textBoxAuthor.Text = "";
         textBoxYear.Text   = "";
     }
 }
Ejemplo n.º 4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewBooks.SelectedItems.Count == 1)
         {
             BooksSet booksSet = listViewBooks.SelectedItems[0].Tag as BooksSet;
             Program.qwer.BooksSet.Remove(booksSet);
             Program.qwer.SaveChanges();
             ShowBooks();
         }
         textBoxName.Text   = "";
         textBoxAuthor.Text = "";
         textBoxYear.Text   = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, запись используется!", "Ошибка!",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }