コード例 #1
0
        // Return Method - adds one to the copies of the selected book
        private void btnReturn_Click(object sender, EventArgs e)
        {
            Books myBook = (Books)lstBooks.SelectedItem;

            myBook.copies++;
            BookFile.SaveBook(myBook, cwid, "edit");
            LoadList();
        }
コード例 #2
0
        // Delete Method - Deletes the selected book after asking user to verify if they want to proceed
        private void button1_Click(object sender, EventArgs e)
        {
            Books myBook = (Books)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();
            }
        }
コード例 #3
0
        // Save Method - Saves the data and updates the book given the string input in the txt boxes
        private void btnSave_Click(object sender, EventArgs e)
        {
            myBook.title  = txtTitleData.Text;
            myBook.author = txtAuthorData.Text;
            myBook.genre  = txtGenreData.Text;
            myBook.copies = int.Parse(txtCopiesData.Text);
            myBook.isbn   = txtIsbnData.Text;
            myBook.length = int.Parse(txtLengthData.Text);
            myBook.cover  = txtCoverData.Text;
            myBook.cwid   = cwid;

            BookFile.SaveBook(myBook, cwid, mode);

            MessageBox.Show("Content was successfully saved", "Saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }
コード例 #4
0
 // Load Method - loads the books from the database
 private void LoadList()
 {
     myBooks             = BookFile.GetAllBooks(cwid);
     lstBooks.DataSource = myBooks;
 }