예제 #1
0
파일: frmMain.cs 프로젝트: jcrooks1223/PA6
        private void btnReturn_Click(object sender, EventArgs e)
        {
            Book myBook = (Book)listBooks.SelectedItem;

            myBook.copies++;
            BookFile.SaveBook(myBook, cwid, "edit");
            LoadList();
        }
예제 #2
0
        private void btnRent_Click(object sender, EventArgs e)
        {
            Book myBook = (Book)lstBooks.SelectedItem;

            myBook.copies--;
            BookFile.SaveBook(myBook, CWID, "edit");
            LoadList();
        }
예제 #3
0
        private void btnRent_Click(object sender, EventArgs e)
        {
            Book myBook = (Book)lstBooks.SelectedItem;
            int  temp   = lstBooks.SelectedIndex;

            myBook.copies--;
            BookFile.SaveBook(myBook, cwid, "edit");
            LoadList();
            lstBooks.SelectedIndex = temp;
        }
예제 #4
0
파일: frmEdit.cs 프로젝트: jcrooks1223/PA6
        private void button1_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   = txtIbsnData.Text;
            myBook.cover  = txtCoverData.Text;
            myBook.length = int.Parse(txtCopiesData.Text);
            myBook.cwid   = cwid;

            BookFile.SaveBook(myBook, cwid, mode);
            MessageBox.Show("Content was saved", "Save", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }
예제 #5
0
        private void btnReturn_Click(object sender, EventArgs e)
        {
            try
            {
                var book = (Book)lbBooks.SelectedItem;

                book.copies++;

                BookFile.SaveBook(book, cwid, "edit");

                LoadBooks();
            }
            catch (Exception exc)
            {
            }
        }
예제 #6
0
        //saves the edit
        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.cover  = txtCoverData.Text;
            myBook.length = int.Parse(txtLengthData.Text);
            myBook.cwid   = cwid;

            BookFile.SaveBook(myBook, cwid, mode);

            //displays a message box showing the user that their book was saved
            MessageBox.Show("The Book Was Saved!", "Saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }
예제 #7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            myBook.title  = txtTitleData.Text;
            myBook.author = txtAuthorData.Text;
            myBook.genre  = txtGeneData.Text;
            myBook.copies = int.Parse(txtCopiesData.Text); //number of copies is and int so you have to use a ToString
            myBook.isbn   = txtISBNData.Text;
            myBook.cover  = txtCoverData.Text;
            myBook.length = int.Parse(txtLengthData.Text); //number of copies is and int so you have to use a ToString

            myBook.cwid = cwid;

            BookFile.SaveBook(myBook, cwid, mode);

            MessageBox.Show("Content was saved", "Saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }
예제 #8
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            try
            {
                var book = (Book)lbBooks.SelectedItem;

                frmEdit editForm = new frmEdit(book, cwid);
                if (editForm.ShowDialog() == DialogResult.OK)
                {
                    var editedBook = (Book)editForm.Tag;

                    BookFile.SaveBook(editedBook, cwid, "edit");

                    LoadBooks();
                }
            }
            catch (Exception exc) { }
        }
예제 #9
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            try
            {
                var book = new Book();

                frmEdit newForm = new frmEdit(book, cwid);
                if (newForm.ShowDialog() == DialogResult.OK)
                {
                    var editedBook = (Book)newForm.Tag;

                    BookFile.SaveBook(editedBook, cwid, "");

                    LoadBooks();
                }
            }
            catch (Exception exc) { }
        }
예제 #10
0
        //rents a book
        private void btnRent_Click(object sender, EventArgs e)
        {
            Book myBook = (Book)lstBooks.SelectedItem;

            //the user cannot rent books if their are 0 copies
            if (myBook.copies <= 0)
            {
                MessageBox.Show("Sorry, this book is currently unavailable.", "Unavailable", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            else
            {
                myBook.copies--;
                BookFile.SaveBook(myBook, cwid, "edit");
            }

            LoadList();
        }
예제 #11
0
        private void BtnSave_Click(object sender, EventArgs e) //closes the form, saving all data that was changed
        {
            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;
            //Console.WriteLine(cwid);
            //Console.ReadKey();
            myBook.cwid = cwid;

            BookFile.SaveBook(myBook, cwid, mode);

            MessageBox.Show("Content was saved", "Saved", MessageBoxButtons.OK, MessageBoxIcon.Information); //saved message
            this.Close();
        }
예제 #12
0
        private void btnNew_Click(object sender, System.EventArgs e)
        {
            var upsertBook = new UpsertBook();

            upsertBook.ShowDialog();

            if (upsertBook.IsCanceled)
            {
                return;
            }

            var book = upsertBook.NewOrUpdatedBook;

            book.CWID = cwid;
            var mode = upsertBook.Mode;

            BookFile.SaveBook(book, cwid, mode);

            this.lstBooks.Items.Add(book);
        }