您目前尚未登陆,请选择【登陆】或【注册
首页->新闻文章->破竹CMS4.0免安装版源码>>admin/Categories/EditCategory.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:破竹CMS4.0免安装版源码
当前文件:文件类型 PozhuCMS/admin/Categories/EditCategory.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.Common; 12using Pozhu.CMS; 13using Pozhu.CMS.Categories; 14using Pozhu.Sites; 15using Pozhu.UI.WebControls; 16using Pozhu.CMS.PropertyDefinitions.PropertyControls; 17using Pozhu.CMS.PropertyDefinitions; 18using Pozhu.CMS.Web; 19 20public partial class admin_Categories_EditCategory : AdminPageBase 21{ 22 23 protected override bool IsAuthenticated() 24 { 25 if (base.IsAuthenticated()) 26 return true; 27 28 if (base.IsEditor()) 29 return true; 30 31 return false; 32 } 33 34 protected void Page_Load(object sender, EventArgs e) 35 { 36 if (!Page.IsPostBack) 37 { 38 string path = CategoryPath.CheckRepairPath(Request.QueryString["path"]); 39 int siteID = SiteController.GetCurrentSite().SiteID; 40 Category category = CategoryController.GetCategory(siteID,path); 41 42 string action = Request.QueryString["action"]; 43 if (action == "add") 44 { 45 lblParentPath.Text = path; 46 this.lbtnUpdate.Visible = false; 47 } 48 else if(action == "edit") 49 { 50 lblParentPath.Text = CategoryPath.GetParentPath(category.Path); 51 tbName.Text = CategoryPath.GetPathName(category.Path); 52 tbTitle.Text = category.Title; 53 54 lbtnAdd.Visible = false; 55 } 56 57 //验证权限 58 if (!category.IsAuthorization(CategoryController.PermissionCreateCategory)) 59 { 60 lbtnAdd.Visible = false; 61 } 62 if (!category.IsAuthorization(CategoryController.PermissionUpdateCategory)) 63 { 64 lbtnUpdate.Visible = false; 65 } 66 } 67 } 68 protected void lbtnCancel_Click(object sender, EventArgs e) 69 { 70 string path = CategoryPath.CheckRepairPath(Request.QueryString["path"]); 71 string action = Request.QueryString["action"]; 72 if (action == "add") 73 { 74 Response.Redirect(Globals.ApplicationPath + "/admin/path" + path + "categoryList.aspx"); 75 } 76 else if (action == "edit") 77 { 78 Response.Redirect(Globals.ApplicationPath + "/admin/path" + CategoryPath.GetParentPath(path) + "categoryList.aspx"); 79 } 80 } 81 protected void lbtnAdd_Click(object sender, EventArgs e) 82 { 83 string path = CategoryPath.CheckRepairPath(lblParentPath.Text + tbName.Text); 84 int siteID = SiteController.GetCurrentSite().SiteID; 85 if (!CategoryController.Exists(siteID, path)) 86 { 87 Category category = new Category(); 88 category.Title = tbTitle.Text; 89 category.Path = path; 90 category.SiteID = siteID; 91 CategoryController.CreateCategory(category); 92 UpdatePropertyValues(category); 93 94 Response.Redirect(Globals.ApplicationPath + "/admin/path" + CategoryPath.CheckRepairPath(lblParentPath.Text) + "categoryList.aspx"); 95 } 96 else 97 { 98 plState.CssClass = "warning"; 99 plState.Controls.Add(new LiteralControl("栏目未能成功添加:该栏目已存在!")); 100 } 101 } 102 protected void lbtnUpdate_Click(object sender, EventArgs e) 103 { 104 string newPath = CategoryPath.CheckRepairPath(lblParentPath.Text + tbName.Text); 105 int siteID = SiteController.GetCurrentSite().SiteID; 106 string oldPath = CategoryPath.CheckRepairPath(Request.QueryString["path"]); 107 108 if (newPath.ToLower() != oldPath.ToLower()) 109 { 110 if (CategoryController.Exists(siteID, newPath)) 111 { 112 plState.CssClass = "warning"; 113 plState.Controls.Add(new LiteralControl("栏目未能更新:修改后的栏目路径已存在!")); 114 115 return; 116 } 117 } 118 119 Category category = CategoryController.GetCategory(siteID,oldPath); 120 category.Path = newPath; 121 category.Title = tbTitle.Text; 122 UpdatePropertyValues(category); 123 CategoryController.UpdateCategory(category); 124 125 Response.Redirect(Globals.ApplicationPath + "/admin/path" + CategoryPath.CheckRepairPath(lblParentPath.Text) + "categoryList.aspx"); 126 127 } 128 void UpdatePropertyValues(Category category) 129 { 130 WrappedRepeater rptPropertyCategories = (WrappedRepeater)PropertyDefinitions2.FindControl("rptPropertyCategories"); 131 foreach (RepeaterItem ri in rptPropertyCategories.Items) 132 { 133 if ((ri.ItemType == ListItemType.Item) || (ri.ItemType == ListItemType.AlternatingItem)) 134 { 135 WrappedRepeater rptProperties = (WrappedRepeater)ri.FindControl("rptProperties"); 136 foreach (RepeaterItem riProperty in rptProperties.Items) 137 { 138 if ((riProperty.ItemType == ListItemType.Item) || (riProperty.ItemType == ListItemType.AlternatingItem)) 139 { 140 PlaceHolder phControl = (PlaceHolder)riProperty.FindControl("phControl"); 141 if (phControl.HasControls()) 142 { 143 if (!(phControl.Controls[0] is LiteralControl)) 144 { 145 PropertyControlBase tb = (PropertyControlBase)phControl.Controls[0]; 146 category.Profile.SetProperty(((PropertyDefinition)riProperty.DataItem).Name, tb.GetValue()); 147 } 148 } 149 } 150 } 151 } 152 } 153 CategoryPropertyController.UpdatePropertyValues(category); 154 } 155} 156
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:破竹CMS4.0免安装版源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号