//Renting book button function method private void btnRent_Click(object sender, EventArgs e) { Book myBook = (Book)lstBooks.SelectedItem; myBook.copies--; BookFile.SaveBook(myBook, cwid, "edit"); LoadList(); }
//Deleting book button function method private void btnDelete_Click(object sender, EventArgs e) { Book myBook = (Book)lstBooks.SelectedItem; DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete?", "Delete", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { BookFile.DeleteBook(myBook, cwid); LoadList(); } }
//Method to save the edits made to books private void btnSave_Click(object sender, EventArgs e) { myBook.title = txtTitleData.Text; myBook.author = txtAuthorData.Text; myBook.genre = txtGenreData.Text; myBook.copies = int.Parse(txtCopies.Text); myBook.isbn = txtIsbn.Text; myBook.cover = txtCoverData.Text; myBook.length = int.Parse(txtLength.Text); myBook.cwid = cwid; BookFile.SaveBook(myBook, cwid, mode); MessageBox.Show("Content was saved", "Saved", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); }
//Method that loads the list of books private void LoadList() { myBooks = BookFile.GetAllBooks(cwid); lstBooks.DataSource = myBooks; }