private void btnBookDelete_Click(object sender, EventArgs e) { try { Book selectedBook = gridViewBook.SelectedRows[0].DataBoundItem as Book; if (selectedBook == null) { throw new Exception(); } bool deleteSuccessful = DbWriter.DeleteWriter(selectedBook.id); if (deleteSuccessful) { MessageBox.Show(this, "Silme başarılı", "Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information); gridViewBook.Rows.RemoveAt(gridViewBook.SelectedRows[0].Index); } else { MessageBox.Show(this, "Silme işleminde bir hata oldu", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch { MessageBox.Show(this, "Bir kitap seçiniz", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }