Example #1
0
        public int AddTag(string parentId, string tagName, string code, string description)
        {
            using (var context = new WSI.DataAccess.WSICmsContext())
            {
                Tag tag = new Tag();
                tag.TagName = tagName;
                tag.TagCode = code;
                tag.Description = description;

                //父标签
                Guid pid;
                if (Guid.TryParse(parentId, out pid))
                {
                    tag.Parent = context.Tags.Find(pid);
                }

                tag.CreateTime = DateTime.Now;
                tag.State = (int)EnumHelper.State.Enable;//默认启用

                context.Tags.Add(tag);

                context.LogChangesDuringSave = true;
                return context.SaveChanges();
            }
        }
Example #2
0
        //修改状态
        public int ChangeState(Tag item, int state)
        {
            using (var context = new WSI.DataAccess.WSICmsContext())
            {
                context.Tags.Attach(item);

                item.State = state;

                context.LogChangesDuringSave = true;
                return context.SaveChanges();
            }
        }
Example #3
0
        private string getTreeItemText(Tag tag, int indent)
        {
            //0 标签名称
            //1 编号
            //2 编码
            //3 描述
            //4 显示标签名称的span的宽度
            //5 编辑和添加页的路径
            //6 关联管理的路径
            //7 当前的关联个数
            //8 状态
            //9 command url

            string command_url = "/handler/command/TagCommand.ashx";
            string item_format = @"
            <span title='{3}' class='nav_name' style='width:{4}px' >
            <span>{0}</span>
            </span>
            <span class='nav_url'>编码:{2}</span>
            <a class='active' href='{5}?pid={1}'>添加子标签</a>
            <a class='active' href='{6}?tid={1}'>关联管理【{7}】</a>
            <a class='active' href='{5}?tid={1}'><img src='/!images/icon_edit.png' title='点击编辑' alt='编辑' /></a>
            <span class='command'>
            <!--JS调用在default.js中-->
            <!--参数-->
            <input name='entity_state' type='hidden' value='{8}' />
            <input name='command_url' type='hidden' value='{9}' />
            <input name='command_argument' type='hidden' value='{1}' />
            <!--修改状态-->
            <a href='javascript:void()' name='disable'>
            <img alt='禁用' src='/!images/icon_enable.png' title='点击禁用' /></a> <a href='javascript:void()'
            name='enable'>
            <img alt='启用' src='/!images/icon_disable.png' title='点击启用' /></a>
            <!--删除-->
            <a href='javascript:void()' name='delete'>
            <img alt='删除' src='/!images/icon_delete.png' title='点击删除' />
            </a>
            </span>
            ";
            //手动解决TreeView缩进对样式的影响
            int width = 300;
            int name_width = width - indent;

            return string.Format(item_format, tag.TagName, tag.TagId, tag.TagCode, tag.Description, name_width,
                "TagAdd.aspx", "TagInformationRela.aspx", service.GetInformationCountByTagCode(tag.TagCode), tag.State, command_url);
        }