您目前尚未登陆,请选择【登陆】或【注册
首页->新闻文章->破竹CMS4.0免安装版源码>>admin/Categories/Relationships.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:破竹CMS4.0免安装版源码
当前文件:文件类型 PozhuCMS/admin/Categories/Relationships.aspx.cs打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Collections; 5using System.Web; 6using System.Web.Security; 7using System.Web.UI; 8using System.Web.UI.WebControls; 9using System.Web.UI.WebControls.WebParts; 10using System.Web.UI.HtmlControls; 11using Pozhu.Sites; 12using Pozhu.CMS.Categories; 13using Pozhu.UI.Utilities; 14using Pozhu.CMS.Web; 15 16public partial class admin_Categories_Relationships : AdminPageBase 17{ 18 protected void Page_Load(object sender, EventArgs e) 19 { 20 if (!Page.IsPostBack) 21 { 22 this.BindRelations(); 23 } 24 } 25 26 void BindRelations() 27 { 28 string path = CategoryPath.CheckRepairPath(Request.QueryString["path"]); 29 int siteID = SiteController.GetCurrentSite().SiteID; 30 31 Category c = CategoryController.GetCategory(siteID, path); 32 33 this.rptRelationships.DataSource = c.GetRelations(); 34 this.rptRelationships.DataBind(); 35 } 36 37 protected void rptRelationships_ItemCommand(object source, RepeaterCommandEventArgs e) 38 { 39 string path = CategoryPath.CheckRepairPath(Request.QueryString["path"]); 40 int siteID = SiteController.GetCurrentSite().SiteID; 41 Category category = CategoryController.GetCategory(siteID, path); 42 43 string commandName = e.CommandName; 44 if (commandName == "add") 45 { 46 DropDownList ddlChilds = (DropDownList)e.Item.FindControl("ddlChilds"); 47 CheckBox cbCascaded = (CheckBox)e.Item.FindControl("cbCascaded"); 48 category.AddRelation(int.Parse(ddlChilds.SelectedValue), cbCascaded.Checked); 49 BindRelations(); 50 } 51 else if (commandName == "cancel") 52 { 53 // 54 BindRelations(); 55 } 56 else if (commandName == "delete") 57 { 58 if ((e.Item.ItemType == ListItemType.Item) || ((e.Item.ItemType == ListItemType.AlternatingItem))) 59 { 60 category.DeleteRelation(Convert.ToInt32(e.CommandArgument.ToString())); 61 BindRelations(); 62 } 63 } 64 } 65 protected void rptRelationships_ItemDataBound(object sender, RepeaterItemEventArgs e) 66 { 67 if (e.Item.ItemType == ListItemType.Header) 68 { 69 string path = CategoryPath.CheckRepairPath(Request.QueryString["path"]); 70 int siteID = SiteController.GetCurrentSite().SiteID; 71 Category category = CategoryController.GetCategory(siteID, path); 72 73 // 74 DropDownList ddlChilds = (DropDownList)e.Item.FindControl("ddlChilds"); 75 76 foreach (Category c in CategoryController.GetSiblingCategories(siteID, path)) 77 { 78 //if (int.Parse(ddlChilds.Items[i].Value) == category.CategoryID) 79 //{ 80 // ddlChilds.Items.RemoveAt(i); 81 //} 82 83 // 84 bool add = true; 85 foreach (CategoryRelation relation in category.GetRelations()) 86 { 87 if (c.CategoryID == relation.ChildID) 88 { 89 add = false; 90 break; 91 } 92 } 93 foreach (CategoryRelation relation in category.GetPrimaryRelations()) 94 { 95 if (c.CategoryID == relation.ParentID) 96 { 97 add = false; 98 break; 99 } 100 } 101 if (add) 102 { 103 ddlChilds.Items.Add(new ListItem(c.Title, c.CategoryID.ToString())); 104 } 105 } 106 for (int i = 0; i < ddlChilds.Items.Count; i++) 107 { 108 if (int.Parse(ddlChilds.Items[i].Value) == category.CategoryID) 109 { 110 ddlChilds.Items.RemoveAt(i); 111 } 112 } 113 114 115 if (ddlChilds.Items.Count == 0) 116 { 117 LinkButton lbtnSave = ((LinkButton)e.Item.FindControl("lbtnSave")); 118 lbtnSave.Enabled = false; 119 ddlChilds.Items.Add(new ListItem("没有可关联的栏目")); 120 } 121 } 122 123 if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem)) 124 { 125 Label lblParent = (Label)e.Item.FindControl("lblParent"); 126 Label lblChild = (Label)e.Item.FindControl("lblChild"); 127 CheckBox cbCascaded = (CheckBox)e.Item.FindControl("cbCascaded"); 128 LinkButton lbtnDelete = ((LinkButton)e.Item.FindControl("lbtnDelete")); 129 130 CategoryRelation relation = (CategoryRelation)e.Item.DataItem; 131 132 lblParent.Text = CategoryController.GetCategory(relation.ParentID).Path; 133 lblChild.Text = CategoryController.GetCategory(relation.ChildID).Path; 134 cbCascaded.Checked = relation.DeleteCascaded; 135 136 137 ClientAPI.AddButtonConfirm(lbtnDelete, string.Format("确定删除此关联吗?")); 138 } 139 } 140} 141
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:破竹CMS4.0免安装版源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号