BackTerminal.frmBookMan.DeleteBook C# (CSharp) Method

DeleteBook() private method

private DeleteBook ( ) : void
return void
        private void DeleteBook()
        {
            string ISBN = (string)dgvBook.SelectedRows[0].Cells[0].Value;
            string bookName = (string)dgvBook.SelectedRows[0].Cells[1].Value;
            string message = "你确定要删除“" + bookName + "”吗?";
            const string caption = "删除书目";
            var result = MessageBox.Show(message, caption,
                                         MessageBoxButtons.YesNo,
                                         MessageBoxIcon.Question);
            if (result == DialogResult.No) return;

            string str;
            str = "DELETE FROM dbo.book WHERE isbn=@ISBN";

            SqlConnection connection = Library.Connection.Instance();
            SqlCommand command = new SqlCommand(str, connection);
            command.Parameters.AddWithValue("@ISBN", ISBN);
            command.ExecuteNonQuery();
            command.Dispose();
            refreshDGV();
        }