Exemplo n.º 1
0
        /// <summary>
        /// 将分类绑定到树上
        /// </summary>
        private void BindClass()
        {
            gsClass = new VipSoft.BLL.GoodsClass();
            dtClass = gsClass.GetList("ShopID="+PublicState.Master.ShopID).Tables[0];

            this.treeView_Class.Nodes.Clear();
            Function.BindGoodsClass(this.treeView_Class, dtClass);
        }
Exemplo n.º 2
0
        private void toolStripMenuItem_Item_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem item = (ToolStripMenuItem)sender;
            TreeNode node = this.treeView_Class.SelectedNode;
            int id = int.Parse(node.Name.Replace("class_", ""));
            switch (item.Name)
            {
                case "toolStripMenuItem_Edit":
                    this.label_ID.Text = node.Name.Replace("class_", "");
                    this.textBox_Parent.Text = node.Parent != null ? node.Parent.Text : "根类别";
                    this.textBox_ClassName.Text = node.Text;

                    this.button_Add.Text = "修改类别";
                    this.groupBox_manage.Text = "修改类别";

                    break;
                case "toolStripMenuItem_Delete":
                    if (this.treeView_Class.SelectedNode.Text == "根类别")
                        return;
                    DialogResult res = MessageBox.Show("您确定要删除这个分类么?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                    if (res == DialogResult.Yes)
                    {
                        VipSoft.BLL.GoodsClass gc = new VipSoft.BLL.GoodsClass();
                        DataTable listClass = gc.GetList("[ShopID]="+PublicState.Master.ShopID).Tables[0];
                        CheckHasGoods hasGoods = new CheckHasGoods();
                        if (hasGoods.Exist(listClass, id.ToString()) != 0)
                        {
                            MessageBox.Show("当前分类下面还有商品,要删除分类,请首先删除该分类下面的全部商品。");
                            return;
                        }
                        if (gc.Delete(id))
                        {
                            MessageBox.Show("分类删除成功。");
                            // 移除节点
                            node.Remove();
                            // 写入日志
                            VipSoft.BLL.SysLog log = new VipSoft.BLL.SysLog();
                            log.Add(new VipSoft.Model.SysLog(PublicState.Master, "商品分类管理",
                                string.Format("删除分类成功,名称:{0}父类:{1}", this.textBox_ClassName.Text, this.textBox_Parent.Text),
                                DateTime.Now));
                        }
                        else
                            MessageBox.Show("删除失败,请重试。");
                    }
                    break;
                case "toolStripMenuItem_Add":
                    this.label_ParentID.Text = id.ToString();

                    //查询该类别下是否有产品,如果有则不能再增加子类别
                    DataSet ds = new VipSoft.BLL.Goods().GetList("ClassId=" + id + "");
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        MessageBox.Show("该类别下已有产品!不能再添加子类别");
                        return;
                    }

                    this.textBox_Parent.Text = node.Text;
                    this.textBox_ClassName.Text = "新类别";
                    this.button_Add.Text = "增加分类";
                    this.groupBox_manage.Text = "增加下级分类";
                    break;
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 绑定产品分类树形菜单
 /// </summary>
 private void BindTree()
 {
     VipSoft.BLL.GoodsClass gc = new VipSoft.BLL.GoodsClass();
     listClass = gc.GetList("ShopID="+PublicState.Master.ShopID).Tables[0];
     Function.BindGoodsClass(this.treeView_Class, listClass);
 }
Exemplo n.º 4
0
        /// <summary>
        /// 绑定商品树
        /// </summary>
        private void BindGoodsTreeThread()
        {
            Thread.Sleep(50);    //延时100毫秒
            VipSoft.BLL.GoodsClass goodsC = new VipSoft.BLL.GoodsClass();
            VipSoft.BLL.Goods goods = new VipSoft.BLL.Goods();
            string where = "ShopID="+PublicState.Master.ID;
            DataTable dtClass = goodsC.GetList(where).Tables[0];
            DataTable dtGoods = goods.GetList(where).Tables[0];

            ExpenseGoodsTreeShowHandler goodsTreeHandler = new ExpenseGoodsTreeShowHandler(BindGoodsTreeInvoke);
            this.BeginInvoke(goodsTreeHandler, dtClass, dtGoods);
        }