コード例 #1
0
        //删除菜
        private void btnDeletePro_Click(object sender, EventArgs e)
        {
            //有选中的行
            if (dgvProductInfo.SelectedRows.Count > 0)
            {
                if (DialogResult.OK == MessageBox.Show("是否删除", "删除", MessageBoxButtons.OKCancel))
                {
                    //获取id --去产品的表 删除这一行就可以了

                    string         strId = dgvProductInfo.SelectedRows[0].Cells[0].Value.ToString();
                    int            id    = Convert.ToInt32(strId);
                    ProductInfoBLL bll   = new ProductInfoBLL();
                    string         msg   = bll.DeleteProduct(id)?"操作成功":"操作失败";
                    MessageBox.Show(msg);
                    LoadProductInfoByDelFlag(0);
                }
            }
            else
            {
                MessageBox.Show("请选中删除的行");
            }
        }