⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 manageblogroll.cs

📁 本系统是在asp版《在线文件管理器》的基础上设计制作
💻 CS
📖 第 1 页 / 共 2 页
字号:
                    Button saveLink = e.Item.FindControl( "SaveLink" ) as Button;
                    if ( saveLink != null ) 
                    {
                        saveLink.Text = ResourceManager.GetString( "Save" );
                        saveLink.CommandName = "SaveLink";
                        saveLink.CommandArgument = commandArg;
                    }

                    Button deleteLink = e.Item.FindControl( "DeleteLink" ) as Button;
                    if ( deleteLink != null ) 
                    {
                        deleteLink.Text = ResourceManager.GetString( "Delete" );
                        deleteLink.Attributes.Add("onclick",string.Format("return confirm('{0}');",ResourceManager.GetString("ManageLinks_ConfirmDeleteLink")));
                        deleteLink.CommandName = "DeleteLink";
                        deleteLink.CommandArgument = commandArg;
                    }

                    ThemedImageButton moveUp = e.Item.FindControl( "MoveLinkUp" ) as ThemedImageButton;
                    if ( moveUp != null ) 
                    {
                        moveUp.CommandName = "MoveUp";
                        moveUp.CommandArgument = commandArg;
                    }

                    ThemedImageButton moveDown = e.Item.FindControl( "MoveLinkDown" ) as ThemedImageButton;
                    if ( moveDown != null ) 
                    {
                        moveDown.CommandName = "MoveDown";
                        moveDown.CommandArgument = commandArg;
                    }

                    break;
            }
        }

        #endregion

        #region Button Click Handlers

        private void LinkCategoriesList_ItemCommand(object source, RepeaterCommandEventArgs e) 
        {
            Int32 linkCategoryID = Int32.Parse( e.CommandArgument.ToString() );
			
            switch( e.CommandName ) 
            {
                case "MoveUp":
                    MoveCategoryUp( linkCategoryID );
                    break;
                case "MoveDown":
                    MoveCategoryDown( linkCategoryID );
                    break;
                case "SaveLinkCategory":
                    SaveLinkCategory( linkCategoryID, ((Control)e.CommandSource).NamingContainer );
                    break;
                case "DeleteLinkCategory":
                    DeleteLinkCategory( linkCategoryID );
                    break;
            }

            CleanData();
        }

        private void LinksList_ItemCommand(object source, RepeaterCommandEventArgs e) 
        {
            String[] args = e.CommandArgument.ToString().Split( ':' );
            if ( args.Length != 2 ) 
            {
                return;
            }

            Int32 linkID = Int32.Parse( args[ 0 ] );
            Int32 linkCategoryID = Int32.Parse( args[ 1 ] );

            switch ( e.CommandName ) 
            {
                case "MoveUp":
                    MoveLinkUp( linkID, linkCategoryID );
                    break;
                case "MoveDown":
                    MoveLinkDown( linkID, linkCategoryID );
                    break;
                case "SaveLink":
                    SaveLink( linkID, linkCategoryID, ((Control)e.CommandSource).NamingContainer );
                    break;
                case "DeleteLink":
                    DeleteLink( linkID, linkCategoryID );
                    break;
            }

            CleanData();
        }

        private void CreateNewLinkCategory_Click(object sender, EventArgs e) 
        {
            CreateLinkCategory( ((Control)sender).NamingContainer );
            CleanData();
        }

        private void CreateNewLink_Click(object sender, EventArgs e) 
        {
            Button newLinkButton = sender as Button;
            CreateLink( Int32.Parse( newLinkButton.CommandArgument.ToString() ), newLinkButton.NamingContainer );
            CleanData();
        }

        #endregion

        #region Command Implementors

        private void MoveLinkUp( Int32 linkID, Int32 linkCategoryID ) 
        {
            Links.ChangeLinkSortOrder( linkID, linkCategoryID, true );
        }

        private void MoveLinkDown( Int32 linkID, Int32 linkCategoryID ) 
        {
            Links.ChangeLinkSortOrder( linkID, linkCategoryID, false );
        }

        private void MoveCategoryUp( Int32 linkCategoryID ) 
        {
            LinkCategories.ChangeCategorySortOrder( linkCategoryID, CurrentWeblog.SectionID, true );
        }

        private void MoveCategoryDown( Int32 linkCategoryID ) 
        {
            LinkCategories.ChangeCategorySortOrder( linkCategoryID, CurrentWeblog.SectionID, false );
            
        }


        private void CreateLinkCategory( Control namingContainer ) 
        {
            TextBox NewLinkCategoryName = namingContainer.FindControl( "NewLinkCategoryName" ) as TextBox;
            TextBox NewLinkCategoryDescription = namingContainer.FindControl( "NewLinkCategoryDescription" ) as TextBox;

            if(NewLinkCategoryName.Text.Trim().Length == 0)
                return;

            LinkCategory newCategory = new LinkCategory();
            newCategory.Name = NewLinkCategoryName.Text;
            newCategory.Description = NewLinkCategoryDescription.Text;
            newCategory.ForumID = CurrentWeblog.SectionID;
            newCategory.IsEnabled = true;
            newCategory.SortOrder = 0;

            LinkCategories.CreateCategory( newCategory );
        }
        private void SaveLinkCategory( Int32 linkCategoryID, Control namingContainer ) 
        {

            TextBox LinkCategoryName = namingContainer.FindControl( "LinkCategoryName" ) as TextBox;
            TextBox LinkCategoryDescription = namingContainer.FindControl( "LinkCategoryDescription" ) as TextBox;
            CheckBox LinkCategoryIsEnabled = namingContainer.FindControl( "LinkCategoryIsEnabled" ) as CheckBox;

            if(LinkCategoryName.Text.Trim().Length == 0)
                return;

            LinkCategory category = LinkCategories.GetCategory( linkCategoryID, CurrentWeblog.SectionID, true );
			
            category.Name = LinkCategoryName.Text;
            category.Description = LinkCategoryDescription.Text;
            category.IsEnabled = LinkCategoryIsEnabled.Checked;

            LinkCategories.UpdateCategory( category );
			
        }

        private void DeleteLinkCategory( Int32 linkCategoryID ) 
        {
            LinkCategories.DeleteCategory( linkCategoryID, CurrentWeblog.SectionID );
        }

		
        private bool ValidateLink(TextBox title, TextBox url)
        {
            return title.Text.Trim().Length > 0 && url.Text.Trim().Length > 0;
        }

        private void CreateLink( Int32 linkCategoryID, Control namingContainer ) 
        {
            TextBox NewLinkTitle = namingContainer.FindControl( "NewLinkTitle" ) as TextBox;
            TextBox NewLinkUrl = namingContainer.FindControl( "NewLinkUrl" ) as TextBox;

            if(!ValidateLink(NewLinkTitle,NewLinkUrl))
                return;
            

            Link newLink = new Link();
            newLink.Title = NewLinkTitle.Text;
            newLink.Url = NewLinkUrl.Text;
            newLink.LinkCategoryID = linkCategoryID;
            newLink.IsEnabled = true;
            newLink.SortOrder = 0;

            Links.CreateLink( newLink );
        }
        private void SaveLink( Int32 linkID, Int32 linkCategoryID, Control namingContainer ) 
        {
			
            TextBox LinkTitle = namingContainer.FindControl( "LinkTitle" ) as TextBox;
            TextBox LinkUrl = namingContainer.FindControl( "LinkUrl" ) as TextBox;
            CheckBox LinkIsEnabled = namingContainer.FindControl( "LinkIsEnabled" ) as CheckBox;

            if(!ValidateLink(LinkTitle,LinkUrl))
                return;

            Link link = Links.GetLink( linkID, linkCategoryID, true );

            link.Title = LinkTitle.Text;
            link.Url = LinkUrl.Text;
            link.IsEnabled = LinkIsEnabled.Checked;
			
            Links.UpdateLink( link );
        }

        private void DeleteLink( Int32 linkID, Int32 linkCategoryID ) 
        {
            Links.DeleteLink( linkID, linkCategoryID );
        }


        #endregion

        protected string ResourceName
        {
            get
            {
                return "WeblogManageLinks_About";
            }
        }


	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -