protected void btnSubmit_OnClick(object sender, EventArgs e) { string roleName = this.txtRoleName.Text.Trim(); string description = this.txtDescription.Text.Trim(); ADeeWu.HuoBi3J.Model.Admin_Roles ent = dalRoels.GetEntity(roleID); if (roleName == "") { ADeeWu.HuoBi3J.Libary.WebUtility.ShowMsg("角色名称不能为空!"); return; } if (ent.RoleName != roleName) { if (dalRoels.Exist("RoleName", roleName)) { ADeeWu.HuoBi3J.Libary.WebUtility.ShowMsg("角色已存在!"); return; } } ent.Description = description; ent.RoleName = roleName; if (dalRoels.Update(ent) <= 0) { ADeeWu.HuoBi3J.Libary.WebUtility.ShowMsg("修改失败!"); return; } dalRolePermissions.Delete("RoleID", ent.ID);//清除角色所有权限 long[] alowPageIDGroup = ADeeWu.HuoBi3J.Libary.WebUtility.GetRequestLongGroups("alowPageID", 0); foreach (long pageID in alowPageIDGroup)//设置角色所拥有的权限 { if (pageID > 0) { ADeeWu.HuoBi3J.Model.Admin_RolePermissions entRolePermission = new ADeeWu.HuoBi3J.Model.Admin_RolePermissions(); entRolePermission.CheckState = 0; entRolePermission.PageID = pageID; entRolePermission.RoleID = ent.ID; dalRolePermissions.Add(entRolePermission); } } long[] denyPageIDGroup = ADeeWu.HuoBi3J.Libary.WebUtility.GetRequestLongGroups("denyPageID", 0); foreach (long pageID in denyPageIDGroup)//设置角色所拒绝的权限 { if (pageID > 0) { ADeeWu.HuoBi3J.Model.Admin_RolePermissions entRolePermission = new ADeeWu.HuoBi3J.Model.Admin_RolePermissions(); entRolePermission.CheckState = 1; entRolePermission.PageID = pageID; entRolePermission.RoleID = ent.ID; dalRolePermissions.Add(entRolePermission); } } ADeeWu.HuoBi3J.Libary.WebUtility.ShowPageSelector(this, "修改成功!选择\"是\"继续操作,否则转跳到列表页", "Edit.aspx?id=" + ent.ID, "List.aspx"); }
protected void btnSubmit_OnClick(object sender, EventArgs e) { string roleName = this.txtRoleName.Text.Trim(); string description = this.txtDescription.Text.Trim(); if (roleName == "") { ADeeWu.HuoBi3J.Libary.WebUtility.ShowMsg("角色名称不能为空!"); return; } if (dalRoels.Exist("RoleName", roleName)) { ADeeWu.HuoBi3J.Libary.WebUtility.ShowMsg("角色已存在!"); return; } ADeeWu.HuoBi3J.Model.Admin_Roles ent = new ADeeWu.HuoBi3J.Model.Admin_Roles(); ent.RoleName = roleName; ent.Description = this.txtDescription.Text; if (dalRoels.Add(ent) <= 0) { ADeeWu.HuoBi3J.Libary.WebUtility.ShowMsg("添加失败!"); return; } long[] alowPageIDGroup = ADeeWu.HuoBi3J.Libary.WebUtility.GetRequestLongGroups("alowPageID", 0); foreach (long pageID in alowPageIDGroup)//设置角色所拥有的权限 { if (pageID > 0) { ADeeWu.HuoBi3J.Model.Admin_RolePermissions entRolePermission = new ADeeWu.HuoBi3J.Model.Admin_RolePermissions(); entRolePermission.CheckState = 0; entRolePermission.PageID = pageID; entRolePermission.RoleID = ent.ID; dalRolePermissions.Add(entRolePermission); } } long[] denyPageIDGroup = ADeeWu.HuoBi3J.Libary.WebUtility.GetRequestLongGroups("denyPageID", 0); foreach (long pageID in denyPageIDGroup)//设置角色所拒绝的权限 { if (pageID > 0) { ADeeWu.HuoBi3J.Model.Admin_RolePermissions entRolePermission = new ADeeWu.HuoBi3J.Model.Admin_RolePermissions(); entRolePermission.CheckState = 1; entRolePermission.PageID = pageID; entRolePermission.RoleID = ent.ID; dalRolePermissions.Add(entRolePermission); } } ADeeWu.HuoBi3J.Libary.WebUtility.ShowPageSelector(this, "添加成功!选择\"是\"继续操作,选择否修改该记录!", "add.aspx", "edit.aspx?id" + ent.ID); }
public ADeeWu.HuoBi3J.Model.Admin_RolePermissions[] GetEntityList(string orderBy,string[] columns,params object[] values) { StringBuilder builder = new StringBuilder(); builder.Append("select * from [Admin_RolePermissions] where 1=1"); db.Parameters.Clear(); for(int i=0;i<columns.Length;i++) { builder.AppendFormat(" and [{0}]=@{0}", columns[i]); db.Parameters.Append("@"+columns[i],values[i]); } if (!string.IsNullOrEmpty(orderBy)) { builder.AppendFormat(" order by {0}", orderBy); } DataTable dt = db.Select(builder.ToString()); ADeeWu.HuoBi3J.Model.Admin_RolePermissions[] EntityList = new ADeeWu.HuoBi3J.Model.Admin_RolePermissions[dt.Rows.Count]; if (dt.Rows.Count == 0) return EntityList; for (int i = 0; i < dt.Rows.Count; i++) { DataRow dr = dt.Rows[i]; ADeeWu.HuoBi3J.Model.Admin_RolePermissions Entity = new ADeeWu.HuoBi3J.Model.Admin_RolePermissions(); Entity.ID = long.Parse(dr["ID"].ToString()); Entity.RoleID = dr["RoleID"] as long?; Entity.PageID = dr["PageID"] as long?; Entity.CheckState = int.Parse(dr["CheckState"].ToString()); EntityList[i] = Entity; } return EntityList; }
public ADeeWu.HuoBi3J.Model.Admin_RolePermissions GetEntity(string where) { DataTable dt = this.Select(where,""); if(dt.Rows.Count==0) return null; DataRow dr = dt.Rows[0]; ADeeWu.HuoBi3J.Model.Admin_RolePermissions Entity = new ADeeWu.HuoBi3J.Model.Admin_RolePermissions(); Entity.ID = long.Parse(dr["ID"].ToString()); Entity.RoleID = dr["RoleID"] as long?; Entity.PageID = dr["PageID"] as long?; Entity.CheckState = int.Parse(dr["CheckState"].ToString()); return Entity; }
public ADeeWu.HuoBi3J.Model.Admin_RolePermissions GetEntity(long ID) { db.Parameters.Clear(); db.Parameters.Append("@ID",ID); DataTable dt = db.Select("select * from [Admin_RolePermissions] where 1=1 and [ID]=@ID"); if(dt.Rows.Count==0) return null; DataRow dr = dt.Rows[0]; ADeeWu.HuoBi3J.Model.Admin_RolePermissions Entity = new ADeeWu.HuoBi3J.Model.Admin_RolePermissions(); Entity.ID = long.Parse(dr["ID"].ToString()); Entity.RoleID = dr["RoleID"] as long?; Entity.PageID = dr["PageID"] as long?; Entity.CheckState = int.Parse(dr["CheckState"].ToString()); return Entity; }