예제 #1
0
        private void button11_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count <= 0)
            {
                new Warning("请选择一行数据进行删除", 图标.Erro).Show();
                return;
            }
            //删除
            DialogResult d = MessageBox.Show("是否确认删除", "温馨提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (d == DialogResult.Yes)
            {
                List <ProductsMDL> listP = ProductsBLL.selectProducts(Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[0].Value), "");
                if (listP.Count > 0)
                {
                    new Warning("请先移除此类型下的商品", 图标.Erro).Show();
                    return;
                }



                ProductTypeMDL p = new ProductTypeMDL();
                p.PTID = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[0].Value);

                if (ProductTypeBLL.DeleteProductType(p) > 0)
                {
                    new Warning("删除成功", 图标.Yes).Show();
                    List <ProductTypeMDL> list = ProductTypeBLL.selectProductType();
                    dataGridView1.DataSource = list;

                    List <ProductTypeMDL> list1 = ProductTypeBLL.selectProductType();
                    list1.Insert(0, (new ProductTypeMDL {
                        PTID = 0, PTName = "全部"
                    }));
                    comboBox2.DisplayMember = "PTName";
                    comboBox2.ValueMember   = "PTID";

                    comboBox2.DataSource = list1;
                }
                else
                {
                    MessageBox.Show("删除失败");
                }
            }
        }