コード例 #1
0
        private void btnDeleteCategory_Click(object sender, EventArgs e)
        {
            CategoryInfoBLL bll = new CategoryInfoBLL();

            if (dgvCategory.SelectedRows.Count <= 0)
            {
                msg.MsgDivShow("请选择要删除的项", 1);
                return;
            }
            if (MessageBox.Show("确定删除该产品吗?", "删除商品", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
            {
                int            id   = ((CategoryInfo)dgvCategory.SelectedRows[0].DataBoundItem).CId;
                ProductInfoBLL pbll = new ProductInfoBLL();
                if (pbll.GetProCountByCId(id) > 0)
                {
                    msg.MsgDivShow("该类别下有很多商品部能删除", 1);
                    return;
                }
                string strMsg = bll.SoftDeleteCategoryInfo(id) ? "删除成功" : "删除失败";
                msg.MsgDivShow(strMsg, 1);
                LoadCategoryInfoByDelFlag(0);
            }
            else
            {
                msg.MsgDivShow("您已经取消删除", 1);
            }
        }