protected void btnSave_Click(object sender, EventArgs e) { int roleid = Convert.ToInt32(rblRole.SelectedValue); int masterid = Convert.ToInt32(Request.QueryString["MasterId"].ToString()); MasterInfo master = new MasterInfo(masterid); if (rblIsOver.SelectedItem.Text == "通过") { master.State = 2; master.Save(); try { //添加角色 if (RoleInfo.isRoleMaster(masterid)) { RoleInfo.UpdateRoleMasters(masterid); } else { RoleMasterInfo rm = new RoleMasterInfo(); rm.RoleId = roleid; rm.MasterId = masterid; rm.IsPass = 1; rm.Save(); } //添加权限 if (RoleInfo.isActionMaster(masterid)) { RoleInfo.DelActionMaster(masterid); AddActionMaster(masterid); } else { AddActionMaster(masterid); } master.IsApply = 1; master.Save(); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('权限配置成功!');</script>"); } catch (Exception Ex) { ClientScript.RegisterStartupScript(this.GetType(), "Save", "alert('配置失败:" + Ex.Message + "');", true); } } else { master.State = 3; master.Save(); } }
protected void AddRoleMaster(int masterid) { for (int i = 0; i < ckblRole.Items.Count; i++) { if (ckblRole.Items[i].Selected && !RoleInfo.IsRoleMasters(masterid, Convert.ToInt32(ckblRole.Items[i].Value))) {//选中且rolemaster表中不存在 RoleMasterInfo role = new RoleMasterInfo(); role.MasterId = masterid; role.RoleId = Convert.ToInt32(ckblRole.Items[i].Value); role.Save(); } else if (!ckblRole.Items[i].Selected && RoleInfo.IsRoleMasters(masterid, Convert.ToInt32(ckblRole.Items[i].Value))) { RoleInfo.DelRoles(masterid, Convert.ToInt32(ckblRole.Items[i].Value)); } } }