private void benDeleteCategory_Click(object sender, EventArgs e) { if (dgvCategoryInfo.SelectedRows.Count <= 0) { MessageBox.Show("请选定后再删除"); return; } if (DialogResult.OK == MessageBox.Show("你舍得删除么", "删除类别", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)) { int r = -1; int id = Convert.ToInt32(dgvCategoryInfo.SelectedRows[0].Cells[0].Value.ToString()); ProductInfoBll bll = new ProductInfoBll(); List <ProductInfo> list = bll.GetProductInfoByCatid(id); r = list.Count; if (r > 0) { MessageBox.Show("该类别下有产品,不能删除,如想强制删除,请联系售后"); } else { CategoryInfoBll bll_c = new CategoryInfoBll(); string msg4 = bll_c.SoftDeleteCategoryInfoByCatId(id) ? "删除好了" : "删除出错了"; MessageBox.Show(msg4); LoadCategoryInfoByDelFlag(0); } } }
private void LoadProductInfoByCatId(int p, TreeNodeCollection tnc) { ProductInfoBll bll = new ProductInfoBll(); List <ProductInfo> list = bll.GetProductInfoByCatid(p); for (int i = 0; i < list.Count; i++) { tnc.Add(list[i].ProName + "====" + list[i].ProPrice + "元"); } }
private void cmbCategory_SelectedIndexChanged(object sender, EventArgs e) { if (cmbCategory.SelectedIndex != 0) { int id = Convert.ToInt32(cmbCategory.SelectedValue); ProductInfoBll bll = new ProductInfoBll(); dgvProductInfo.DataSource = bll.GetProductInfoByCatid(id); dgvProductInfo.AutoGenerateColumns = false; if (dgvProductInfo.SelectedRows.Count > 0) { dgvProductInfo.SelectedRows[0].Selected = false; } } else { LoadProductInfoByDelFlag(0); } }