您目前尚未登陆,请选择【登陆】或【注册
首页->新闻文章->破竹CMS4.0免安装版源码>>admin/Security/EditRoleGroups.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:破竹CMS4.0免安装版源码
当前文件:文件类型 PozhuCMS/admin/Security/EditRoleGroups.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.Security.Roles; 12using Pozhu.Sites; 13using Pozhu.UI.Utilities; 14using Pozhu.CMS.Web; 15 16public partial class admin_Security_EditRoleGroups : AdminPageBase 17{ 18 protected void Page_Load(object sender, EventArgs e) 19 { 20 if (!Page.IsPostBack) 21 { 22 rptRoleGroups.DataSource = RoleController.GetRoleGroups(SiteController.GetCurrentSite().SiteID); 23 rptRoleGroups.DataBind(); 24 } 25 } 26 protected void rptRoleGroups_ItemCommand(object source, RepeaterCommandEventArgs e) 27 { 28 string commandName = e.CommandName; 29 if (commandName == "add") 30 { 31 if (e.Item.ItemType == ListItemType.Footer) 32 { 33 TextBox tbRoleGroupName; 34 TextBox tbDescription; 35 tbRoleGroupName = (TextBox)e.Item.FindControl("tbRoleGroupName"); 36 tbDescription = (TextBox)e.Item.FindControl("tbDescription"); 37 38 RoleGroupInfo roleGroupInfo = new RoleGroupInfo(); 39 roleGroupInfo.SiteID = SiteController.GetCurrentSite().SiteID; 40 roleGroupInfo.RoleGroupName = tbRoleGroupName.Text; 41 roleGroupInfo.Description = tbDescription.Text; 42 43 try 44 { 45 RoleController.AddRoleGroup(roleGroupInfo); 46 Response.Redirect("editRoleGroups.aspx"); 47 } 48 catch 49 { 50 plState.CssClass = "warning"; 51 plState.Controls.Add(new LiteralControl("角色组未能添加:该角色组已存在!")); 52 } 53 54 } 55 } 56 else if (commandName == "edit") 57 { 58 if ((e.Item.ItemType == ListItemType.Item) || ((e.Item.ItemType == ListItemType.AlternatingItem))) 59 { 60 TextBox tbRoleGroupName; 61 TextBox tbDescription; 62 Label lblRoleGroupName; 63 Label lblDescription; 64 LinkButton lbtnEdit; 65 LinkButton lbtnUpdate; 66 LinkButton lbtnCancel; 67 LinkButton lbtnDelete; 68 tbRoleGroupName = (TextBox)e.Item.FindControl("tbRoleGroupName"); 69 tbDescription = (TextBox)e.Item.FindControl("tbDescription"); 70 lblRoleGroupName = (Label)e.Item.FindControl("lblRoleGroupName"); 71 lblDescription = (Label)e.Item.FindControl("lblDescription"); 72 lbtnEdit = (LinkButton)e.Item.FindControl("lbtnEdit"); 73 lbtnUpdate = (LinkButton)e.Item.FindControl("lbtnUpdate"); 74 lbtnCancel = (LinkButton)e.Item.FindControl("lbtnCancel"); 75 lbtnDelete = (LinkButton)e.Item.FindControl("lbtnDelete"); 76 77 // 78 tbRoleGroupName.Visible = true; 79 tbDescription.Visible = true; 80 lblRoleGroupName.Visible = false; 81 lblDescription.Visible = false; 82 lbtnEdit.Visible = false; 83 lbtnUpdate.Visible = true; 84 lbtnCancel.Visible = true; 85 lbtnDelete.Visible = false; 86 } 87 } 88 else if (commandName == "update") 89 { 90 if ((e.Item.ItemType == ListItemType.Item) || ((e.Item.ItemType == ListItemType.AlternatingItem))) 91 { 92 TextBox tbRoleGroupName; 93 TextBox tbDescription; 94 tbRoleGroupName = (TextBox)e.Item.FindControl("tbRoleGroupName"); 95 tbDescription = (TextBox)e.Item.FindControl("tbDescription"); 96 97 int roleGroupID = int.Parse(e.CommandArgument.ToString()); 98 RoleGroupInfo roleGroupInfo = RoleController.GetRoleGroup(SiteController.GetCurrentSite().SiteID, roleGroupID); 99 roleGroupInfo.RoleGroupName = tbRoleGroupName.Text; 100 roleGroupInfo.Description = tbDescription.Text; 101 102 try{ 103 RoleController.UpdateRoleGroup(roleGroupInfo); 104 // 105 Response.Redirect("editRoleGroups.aspx"); 106 } 107 catch 108 { 109 plState.CssClass = "warning"; 110 plState.Controls.Add(new LiteralControl("角色组未能成功更新:该角色组已存在!")); 111 } 112 113 114 } 115 } 116 else if (commandName == "cancel") 117 { 118 // 119 Response.Redirect("editRoleGroups.aspx"); 120 } 121 else if (commandName == "delete") 122 { 123 int roleGroupID = int.Parse(e.CommandArgument.ToString()); 124 RoleController.DeleteRoleGroup(SiteController.GetCurrentSite().SiteID, roleGroupID); 125 // 126 Response.Redirect("editRoleGroups.aspx"); 127 } 128 } 129 protected void rptRoleGroups_ItemDataBound(object source, RepeaterItemEventArgs e) 130 { 131 if ((e.Item.ItemType == ListItemType.Item) || ((e.Item.ItemType == ListItemType.AlternatingItem))) 132 { 133 LinkButton lbtnDelete; 134 lbtnDelete = (LinkButton)e.Item.FindControl("lbtnDelete"); 135 136 //如果该行的角色组名称为System Groups那么不允许删除和更新; 137 RoleGroupInfo group = ((RoleGroupInfo)(e.Item.DataItem)); 138 if (group.RoleGroupName == "System Groups") 139 { 140 lbtnDelete.Enabled = false; 141 ((LinkButton)(e.Item.FindControl("lbtnEdit"))).Enabled = false; 142 } 143 else 144 { 145 ClientAPI.AddButtonConfirm(lbtnDelete, "确定删除该角色组吗?"); 146 } 147 } 148 } 149 150} 151
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:破竹CMS4.0免安装版源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号