Пример #1
0
    /// <summary>
    /// 添加栏目
    /// </summary>
    public static int Insert(Exhibition channel)
    {
        if (channel.ParentID == 0)
        {
            channel.Depth    = 0;
            channel.ParentID = 0;
            channel.Path     = "0~";
            channel.NamePath = "所有栏目~";
            channel.AddInsert("RootID", "IDENT_CURRENT('Exhibition')");
        }
        else
        {
            Exhibition condition = new Exhibition();
            condition.ID = channel.ParentID;
            Exhibition parentChannel = TableOperate <Exhibition> .GetRowData(condition);

            string path     = Convert.ToString(parentChannel.Path) + channel.ParentID + "~";
            string namePath = Convert.ToString(parentChannel.NamePath) + Convert.ToString(parentChannel.Name) + "~";
            channel.Depth    = parentChannel.Depth + 1;
            channel.Path     = path;
            channel.RootID   = parentChannel.RootID;
            channel.NamePath = namePath;
        }
        return(TableOperate <Exhibition> .InsertReturnID(channel));
    }
Пример #2
0
    /// <summary>
    /// 修改栏目
    /// </summary>
    public static int Update(Exhibition channel)
    {
        //修改信息

        Exhibition condition = new Exhibition();

        condition.ID = channel.ID;
        Exhibition oldChannel = TableOperate <Exhibition> .GetRowData(condition);


        if (channel.ParentID != oldChannel.ParentID)
        {
            if (channel.ParentID == 0)
            {
                channel.Depth    = 0;
                channel.ParentID = 0;
                channel.Path     = "0~";
                channel.NamePath = "所有栏目~";
                channel.AddInsert("RootID", "IDENT_CURRENT('Exhibition')");
            }
            else
            {
                condition    = new Exhibition();
                condition.ID = channel.ParentID;
                Exhibition parentChannel = TableOperate <Exhibition> .GetRowData(condition);

                string path     = Convert.ToString(parentChannel.Path) + channel.ParentID + "~";
                string namePath = Convert.ToString(parentChannel.NamePath) + Convert.ToString(parentChannel.Name) + "~";
                channel.Depth    = parentChannel.Depth + 1;
                channel.Path     = path;
                channel.RootID   = parentChannel.RootID;
                channel.NamePath = namePath;
            }
        }
        else
        {
            channel.Depth    = oldChannel.Depth;
            channel.Path     = oldChannel.Path;
            channel.NamePath = oldChannel.NamePath;
            channel.RootID   = oldChannel.RootID;
        }
        //修改下面是有的子项的Depth, Path, RootID, NamePath
        UpdateChild(channel, oldChannel);

        return(TableOperate <Exhibition> .Update(channel));
    }