private void btnLease_Click(object sender, EventArgs e) { book = new BookDTO(); foreach (DataGridViewRow row in dgvBooks.SelectedRows) { book.BookName = row.Cells[0].Value.ToString(); book.AuthorName = row.Cells[1].Value.ToString(); book.PublisherName = row.Cells[2].Value.ToString(); book.PublishingYear = (int)row.Cells[3].Value; book.PageCount = (int)row.Cells[4].Value; book.Summary = row.Cells[5].Value.ToString(); book.Price = (decimal)row.Cells[6].Value; book.IsAvailable = (bool)row.Cells[7].Value; } if (book.IsAvailable) { leasedBooks.Add(book); try { bool result = _orderController.Add(user.UserID); _orderID = _orderController.GetOrderOfUser(user.UserID); _bookID = _bookController.GetBookIDByName(book.BookName, book.AuthorName); _bookController.UpdateIsAvailable(_bookID); orderDetail = new OrderDetailDTO(); orderDetail.OrderID = _orderID; orderDetail.BookID = _bookID; orderDetail.PaymentID = 1; /////////////////// !!!!!!!!!!!!!!!!!!!!! _orderController.AddOrderDetail(orderDetail); if (result) { MessageBox.Show("Keyifli okumalar :)"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("Bu kitap zaten kirada"); } books = _bookController.GetBooks(); FillListBox(books); }