Beispiel #1
0
        private void btnOk_Click_1(object sender, EventArgs e)
        {
            if (CheckEmpty())//判断所有的文本框不为空
            {
                CategoryInfoBll cBll = new CategoryInfoBll();
                CategoryInfo    c    = new CategoryInfo();
                c.CName   = txtCName.Text;   //名字
                c.CNum    = txtCNum.Text;    //编号
                c.CRemark = txtCRemark.Text; //备注

                //判断是新增还是修改
                if (Temp == 1)//新增
                {
                    c.DelFlag = 0;
                    c.SubBy   = 1;
                    c.SubTime = System.DateTime.Now;//提交时间
                }//修改
                else if (Temp == 2)
                {
                    c.CId = Convert.ToInt32(labId.Text);//id类别
                }
                string msg = cBll.AddOrUpdateCategoryInfo(c, Temp) ? "操作成功" : "操作失败";
                md.MsgDivShow(msg, 1, Bind);
                // md.MsgDivShow(msg, 1);
            }
        }
 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 LoadAllCategoryInfoByDelFlag(int p)
        {
            CategoryInfoBll cBll = new CategoryInfoBll();

            dgvCategory.AutoGenerateColumns = false;//禁止自动生成列
            dgvCategory.DataSource          = cBll.GetAllCategoryInfoByDelFlag(p);
            dgvCategory.ClearSelection();
        }
        public void LoadCategoryInfoByDelFlag(int p)
        {
            CategoryInfoBll bll = new CategoryInfoBll();

            dgvCategoryInfo.AutoGenerateColumns      = false;
            dgvCategoryInfo.DataSource               = bll.GetAllCategoryInfoByDelFlag(p);
            dgvCategoryInfo.SelectedRows[0].Selected = false;
        }
        //节点树绑定数据
        private void LoadTvCategoryByDelFlag(int p)
        {
            CategoryInfoBll     cbll = new CategoryInfoBll();
            List <CategoryInfo> list = cbll.GetAllCategoryInfoByDelFlag(p);

            for (int i = 0; i < list.Count; i++)
            {
                TreeNode tn = tvCategory.Nodes.Add(list[i].CName);
                //根据商品类别id查找该类别下的所有产品
                LoadProductInfoByCId(tn.Nodes, list[i].CId);
            }
        }
Beispiel #6
0
        //加载节点树
        private void LoadCategoryInfoByDelFlag(int p)
        {
            //先加载商品类别
            CategoryInfoBll     bll  = new CategoryInfoBll();
            List <CategoryInfo> list = bll.GetAllCategoryInfoByDelFlag(p);

            for (int i = 0; i < list.Count; i++)
            {
                TreeNode tn = tvCategory.Nodes.Add(list[i].Catname);
                // tn.Tag = list[i].CatId;//存类别id
                LoadProductInfoByCatId(list[i].Catid, tn.Nodes);
            }
        }
        //绑定下拉框的类别数据
        private void LoadCategoryInfoByDelFlag(int p)
        {
            CategoryInfoBll     cBll = new CategoryInfoBll();
            List <CategoryInfo> list = cBll.GetAllCategoryInfoByDelFlag(p);

            list.Insert(0, new CategoryInfo()
            {
                CName = "请选择", CId = -1
            });
            cmbCategory.DataSource    = list;
            cmbCategory.DisplayMember = "CName";
            cmbCategory.ValueMember   = "CId";
        }
        private void LoadCategoryInfoByDelFlag_cmb(int p)
        {
            CategoryInfoBll bll = new CategoryInfoBll();

            List <CategoryInfo> list = new List <CategoryInfo>();

            list = bll.GetAllCategoryInfoByDelFlag(p);
            list.Insert(0, new CategoryInfo()
            {
                Catid = -1, Catname = "请选择"
            });
            cmbCategory.DataSource    = list;
            cmbCategory.DisplayMember = "Catname";
            cmbCategory.ValueMember   = "Catid";
            //dgvCategoryInfo.SelectedRows[0].Selected = false;
        }
 private void btnUpdateCategory_Click(object sender, EventArgs e)
 {
     if (dgvCategoryInfo.SelectedRows.Count > 0)
     {
         int             id  = Convert.ToInt32(dgvCategoryInfo.SelectedRows[0].Cells[0].Value.ToString());
         CategoryInfoBll bll = new CategoryInfoBll();
         CategoryInfo    ct  = bll.GetCategoryInfoById(id);
         if (ct != null)
         {
             mea.Obj = ct;
             LoadChangeCategoryInfo(2);
         }
     }
     else
     {
         MessageBox.Show("请重新选中");
     }
 }
 private void btnOk_Click(object sender, EventArgs e)
 {
     if (CheckBox2())
     {
         CategoryInfo cat = new CategoryInfo();
         cat.Catname = txtCName.Text;
         cat.Catnum  = txtCNum.Text;
         cat.Remark  = txtCRemark.Text;
         if (this.TP == 1)
         {
             cat.Delflag = 0;
             cat.Subtime = System.DateTime.Now;
             cat.Subby   = 1;
         }
         else if (this.TP == 2)
         {
             cat.Catid = Convert.ToInt32(labId.Text);
         }
         CategoryInfoBll bll  = new CategoryInfoBll();
         string          msg2 = bll.SaveCategoryInfo(cat, this.TP)?"操作成功":"操作失败";
         MessageBox.Show(msg2);
         this.Close();
     }
 }
 //注销商品类别
 private void btnDeleteCategory_Click(object sender, EventArgs e)
 {
     if (dgvCategory.SelectedRows.Count <= 0)
     {
         md.MsgDivShow("请选择要注销的商品类别");
         return;
     }
     if (MessageBox.Show("确定删除该类别吗", "删除商品类别", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
     {
         //获取类别ID
         int            cId    = ((CategoryInfo)dgvCategory.SelectedRows[0].DataBoundItem).CId;
         ProductInfoBll proBll = new ProductInfoBll();
         if (proBll.GetProductInfoCountByCId(cId) > 0)
         {
             md.MsgDivShow("抱歉,该类别下有产品,不能删除");
             return;
         }
         CategoryInfoBll cBll = new CategoryInfoBll();
         md.MsgDivShow(cBll.SoftDeleteCategoryByCId(cId) ? "操作成功" : "操作失败", 1);
         LoadAllCategoryInfoByDelFlag(0);
         return;
     }
     md.MsgDivShow("取消了", 1);
 }