private void btnDeletePro_Click(object sender, EventArgs e) { if(dgvProductInfo.SelectedRows.Count>0) { //提示 if(DialogResult.OK == MessageBox.Show("真的要删除吗","删除",MessageBoxButtons.OKCancel,MessageBoxIcon.Question)) { int id = Convert.ToInt32(dgvProductInfo.SelectedRows[0].Cells[0].Value.ToString()); ProductInfoBLL bll = new ProductInfoBLL(); if(bll.DeleteProductInfoByProId(id)) { MessageBox.Show("操作成功"); } else { MessageBox.Show("操作失败"); } LoadProductInfoByDelFlag(0); } } else { MessageBox.Show("请选择要删除的行"); } }