Пример #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("删除失败");
                }
            }
        }
Пример #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text.Trim().Length <= 0)
     {
         new Warning("请输入类型名称", 图标.Erro).Show();
         return;
     }
     try
     {
         //执行添加
         if (type == 1)
         {
             this.Text = "添加商品类型";
             ProductTypeMDL p = new ProductTypeMDL();
             p.PTName = textBox1.Text;
             int count = ProductTypeBLL.AddProductType(p);
             if (count > 0)
             {
                 this.Close();
             }
         }
         //执行修改
         else
         {
             this.Text = "修改商品类型";
             ProductTypeMDL p = new ProductTypeMDL();
             p.PTName = textBox1.Text;
             p.PTID   = Convert.ToInt32(Product.ID);
             int count = ProductTypeBLL.AlterProductType(p);
             if (count > 0)
             {
                 this.Close();
             }
         }
     }
     catch (Exception)
     {
         MessageBox.Show("发生未只的异常,请联系开发者", "未知异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #3
0
 /// <summary>
 /// 删除商品类型
 /// </summary>
 /// <param name="p">房间类型对象</param>
 /// <returns>受影响的行数</returns>
 public static int DeleteProductType(ProductTypeMDL p)
 {
     return(ProductTypeDAL.DeleteProductType(p));
 }
Пример #4
0
 /// <summary>
 /// 修改商品类型
 /// </summary>
 /// <param name="p"></param>
 /// <returns></returns>
 public static int AlterProductType(ProductTypeMDL p)
 {
     return(ProductTypeDAL.AlterProductType(p));
 }