예제 #1
0
        private void btnDeleteCategory_Click(object sender, EventArgs e)
        {
            string msg = null;

            if (dgvCategory.SelectedRows.Count <= 0)
            {
                md.MsgDivShow("请选择要注销的商品类别", 1);
                return;
            }
            if (MessageBox.Show("亲,真的要注销这个商品类别吗?", "注销提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                //判断该类别下是否有产品,提示删除吗?
                ProductInfoBLL  pbll = new ProductInfoBLL();
                CategoryInfoBLL cbll = new CategoryInfoBLL();
                CategoryInfo    c    = (CategoryInfo)dgvCategory.SelectedRows[0].DataBoundItem;
                if (pbll.GetProductInfoCountByCid((int)c.CId) > 0)
                {
                    if (MessageBox.Show("该类别下有若干产品,产品会随之一起注销,真的要注销吗?", "注销提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        msg = cbll.SoftDeleteCategoryInfoByCId((int)c.CId) > 0 ? "操作成功" : "操作失败";
                        md.MsgDivShow(msg, 1);
                        //刷新
                        LoadCategory();
                        LoadProduct();
                        return;
                    }
                    md.MsgDivShow("您已经取消了注销", 1);
                    return;
                }
                //无产品,删除
                msg = cbll.SoftDeleteCategoryInfoByCId((int)c.CId) > 0 ? "操作成功" : "操作失败";
                md.MsgDivShow(msg, 1);
                //刷新
                LoadCategory();
                return;
            }
            //提示取消删除
            md.MsgDivShow("您已经取消了注销", 1);
        }