private void BuildTree(ECCategory root, ItemsControl tvRoot)
        {
            TreeViewItem tvItem = new TreeViewItem();

            tvItem.Header = (root.SysNo.HasValue && root.SysNo.Value > 0 ? "[" + root.SysNo.Value + "]" : "") + root.Name;
            tvItem.Tag    = root;
            //只展开Root节点
            bool isRoot = root.SysNo.HasValue && root.SysNo.Value == 0;

            tvItem.IsExpanded = isRoot;
            tvItem.IsSelected = isRoot;
            if (!isRoot)
            {
                ToolTipService.SetToolTip(tvItem, string.Format(ResECCategory.TextBlock_TreeNodeTip, root.Priority));
            }
            Color foreColor = Colors.Black;

            if (root.Status == ADStatus.Deactive)
            {
                foreColor = Colors.Red;
            }
            tvItem.Foreground = new SolidColorBrush(foreColor);

            tvRoot.Items.Add(tvItem);
            if (root.ChildrenList != null)
            {
                foreach (var c in root.ChildrenList)
                {
                    BuildTree(c, tvItem);
                }
            }
        }
Beispiel #2
0
        private void Validate(ECCategory entity)
        {
            entity.CompanyCode = "8601";
            string parentSysnoList = "-1";

            if (entity.ParentList != null && entity.ParentList.Count > 0)
            {
                foreach (var item in entity.ParentList)
                {
                    parentSysnoList += "," + item.RSysNo;
                }
            }
            if (_ecCategoryDA.CheckNameDuplicate(entity.Name, entity.SysNo ?? 0, entity.Level, entity.CompanyCode, entity.WebChannel.ChannelID, parentSysnoList))
            {
                //throw new BizException("类别名称已存在,请检查。");
                throw new BizException(ResouceManager.GetMessageString("MKT.ECCategory", "ECCategory_ExistsSameName"));
            }
            if (entity.Level != ECCategoryLevel.Category1)
            {
                if (entity.ParentList == null || entity.ParentList.Count == 0)
                {
                    //throw new BizException("父类数量不能为0。");
                    throw new BizException(ResouceManager.GetMessageString("MKT.ECCategory", "ECCategory_MustHaveParents"));
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// 更新前台显示分类
        /// </summary>
        /// <param name="entity">前台显示分类</param>
        public void Update(ECCategory entity)
        {
            DataCommand cmd = DataCommandManager.GetDataCommand("ECCategory_Update");

            cmd.SetParameterValue(entity);

            cmd.ExecuteNonQuery();
        }
Beispiel #4
0
 private void BuildTree(ECCategory parent, List<ECCategory> list)
 {
     parent.ChildrenList = list.Where(item => (item.RParentSysNo ?? 0) == parent.RSysNo).OrderByDescending(item => item.Priority).ToList();
     foreach (var c in parent.ChildrenList)
     {
         BuildTree(c, list);
     }
 }
Beispiel #5
0
        /// <summary>
        /// 插入前台显示分类
        /// </summary>
        /// <param name="entity">前台显示分类</param>
        public void Insert(ECCategory entity)
        {
            DataCommand cmd = DataCommandManager.GetDataCommand("ECCategory_Insert");

            cmd.SetParameterValue(entity);

            cmd.ExecuteNonQuery();
            entity.SysNo = Convert.ToInt32(cmd.GetParameterValue("@SysNo"));
        }
Beispiel #6
0
 public virtual ECCategory GetECCategoryTree(ECCategoryQueryFilter filter)
 {
     var list = _ecCategoryQueryDA.GetECCategoryTree(filter);
     ECCategory root = new ECCategory();
     root.Name = "Root";
     root.SysNo = 0;
     root.RParentSysNo = 0;
     root.Status = ADStatus.Active;
     BuildTree(root, list);
     return root;
 }
Beispiel #7
0
        /// <summary>
        /// 插入前台显示分类
        /// </summary>
        /// <param name="entity">前台显示分类</param>
        public ECCategory Insert(ECCategory entity)
        {
            Validate(entity);
            using (TransactionScope ts = new TransactionScope())
            {
                _ecCategoryDA.Insert(entity);
                if (entity.Level == ECCategoryLevel.Category1)
                {
                    ECCategoryRelation r = new ECCategoryRelation();
                    r.ECCategorySysNo = entity.SysNo.Value;
                    r.ParentSysNo     = null;
                    _ecCategoryDA.InsertRelation(r);
                }
                else
                {
                    if (entity.ParentList != null)
                    {
                        foreach (var p in entity.ParentList)
                        {
                            if (p.RSysNo > 0)
                            {
                                ECCategoryRelation r = new ECCategoryRelation();
                                r.ECCategorySysNo = entity.SysNo.Value;
                                r.ParentSysNo     = p.RSysNo;
                                _ecCategoryDA.InsertRelation(r);
                            }
                            else
                            {
                                ECCategory parentItem = _ecCategoryDA.Load(p.SysNo.Value);
                                if (parentItem == null || parentItem.RSysNo <= 0)
                                {
                                    throw new BizException(string.Format("节点{1}为无效节点!", p.Name));
                                }
                                ECCategoryRelation r = new ECCategoryRelation();
                                r.ECCategorySysNo = entity.SysNo.Value;
                                r.ParentSysNo     = parentItem.RSysNo;
                                _ecCategoryDA.InsertRelation(r);
                            }
                        }
                    }
                }


                ts.Complete();
            }

            return(entity);
        }
Beispiel #8
0
        /// <summary>
        /// 更新前台显示分类
        /// </summary>
        /// <param name="entity">前台显示分类</param>
        public void Update(ECCategory entity)
        {
            Validate(entity);
            using (TransactionScope ts = new TransactionScope())
            {
                _ecCategoryDA.Update(entity);
                //2.删除不在当前父类列表中的层级关系
                List <int> rParentSysNoList = entity.ParentList.ConvertAll(p => p.RSysNo);
                _ecCategoryDA.DeleteOldRelation(entity.SysNo.Value, rParentSysNoList);
                //3.重新插入层级关系
                foreach (var rSysNo in rParentSysNoList)
                {
                    if (!_ecCategoryDA.ExistsRelation(entity.SysNo.Value, rSysNo))
                    {
                        ECCategoryRelation r = new ECCategoryRelation();
                        r.ECCategorySysNo = entity.SysNo.Value;
                        r.ParentSysNo     = rSysNo;
                        _ecCategoryDA.InsertRelation(r);
                    }
                }

                ts.Complete();
            }
        }
Beispiel #9
0
        public void UpdateECCategoryManage(ECCategoryMange entity)
        {
            ECCategory model = new ECCategory();
            model = _ecCategoryAppService.Load(entity.SysNo.Value);
            model.Name = entity.CategoryName;
            if (entity.Status == ECCCategoryManagerStatus.Active)
            {
                model.Status = ADStatus.Active;
            }
            else
            {
                model.Status = ADStatus.Deactive;
            }

            if (model.ParentList == null)
            {
                model.ParentList = new List<ECCategory>();
            }
            else
            {
                model.ParentList.Clear();
            }


            if (entity.Type == ECCCategoryManagerType.ECCCategoryType2 && entity.Category1SysNo.HasValue)
            {
                model.ParentList.Add(_ecCategoryAppService.Load(entity.Category1SysNo.Value));

            }
            if (entity.Type == ECCCategoryManagerType.ECCCategoryType3 && entity.Category2SysNo.HasValue)
            {
                model.ParentList.Add(_ecCategoryAppService.Load(entity.Category2SysNo.Value));
            }

            _ecCategoryAppService.Update(model);
        }
Beispiel #10
0
 /// <summary>
 /// 更新前台显示分类
 /// </summary>
 /// <param name="entity">前台显示分类</param>
 public void Update(ECCategory entity)
 {
     _ecCategoryProcessor.Update(entity);
 }
Beispiel #11
0
 /// <summary>
 /// 插入前台显示分类
 /// </summary>
 /// <param name="entity">前台显示分类</param>
 public ECCategory Insert(ECCategory entity)
 {
     return(_ecCategoryProcessor.Insert(entity));
 }
Beispiel #12
0
 public void UpdateECCategory(ECCategory entity)
 {
     _ecCategoryAppService.Update(entity);
 }
Beispiel #13
0
 public ECCategory InsertECCategory(ECCategory entity)
 {
     return _ecCategoryAppService.Insert(entity);
 }