예제 #1
0
        private void BorrowBookButton_Click(object sender, EventArgs e)
        {
            if (tableStatus == TableStatus.All)
            {
                var row = BooksDataGridView.Rows[currentIndex];

                var idBook       = int.Parse(row.Cells[0].Value.ToString());
                var idSubscriber = idCurrentSubscriber;
                service.AddBorrowedBook(new BorrowedBook(idBook, idSubscriber));
                if (int.Parse(row.Cells[4].Value.ToString()) == 1)
                {
                    service.DeleteBook(idBook);
                }
                else
                {
                    var book = new Book(int.Parse(row.Cells[0].Value.ToString()), row.Cells[1].Value.ToString(), row.Cells[2].Value.ToString(), row.Cells[3].Value.ToString(), int.Parse(row.Cells[4].Value.ToString()) - 1);
                    service.UpdateBook(book);
                }
                ClearLabels();
                DisplayBooks();
            }
            else
            {
                MessageBox.Show("You can't borrow a borrowed or reserved book!");
            }
        }