温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:破竹CMS4.0免安装版源码
当前文件:
PozhuCMS/admin/Security/EditRoleGroups.aspx.cs,打开代码结构图
PozhuCMS/admin/Security/EditRoleGroups.aspx.cs,打开代码结构图1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Collections; 5
using System.Web; 6
using System.Web.Security; 7
using System.Web.UI; 8
using System.Web.UI.WebControls; 9
using System.Web.UI.WebControls.WebParts; 10
using System.Web.UI.HtmlControls; 11
using Pozhu.Security.Roles; 12
using Pozhu.Sites; 13
using Pozhu.UI.Utilities; 14
using Pozhu.CMS.Web; 15
16
public 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





}
}