// 更新角色 public bool Update(M_RoleInfo roleInfo) { string sqlStr = "UPDATE ZL_Role SET RoleName=@RoleName,Description=@Description WHERE RoleID=@RoleId"; SqlParameter[] Params = roleInfo.GetParameters(); return(SqlHelper.ExecuteSql(sqlStr, Params)); }
protected void Page_Load(object sender, EventArgs e) { B_Admin badmin = new B_Admin(); badmin.CheckMulitLogin(); if (!badmin.ChkPermissions("RoleEdit")) { function.WriteErrMsg("没有权限进行此项操作"); } if (!Page.IsPostBack) { ViewState["RoleID"] = Request.QueryString["RoleID"]; //判断当前管理员是否存在 if (B_Admin.IsExist(DataConverter.CLng(ViewState["RoleID"]))) { this.LblTitle.Text = "修改角色"; this.Literal1.Text = "修改角色"; role = B_Role.GetRoleById(DataConverter.CLng(ViewState["RoleID"])); this.txbRoleName.Text = role.RoleName; this.tbRoleInfo.Text = role.Description; } else { this.LblTitle.Text = "添加角色"; this.Literal1.Text = "添加角色"; } } }
private void MyBind() { //后期改为XML存储或Json存储 M_RoleInfo roleMod = roleBll.SelReturnModel(RoleID); RoleName_L.Text = roleMod.RoleName; string json = SafeSC.ReadFileStr("/Config/AuthList.config"); AuthDT = JsonConvert.DeserializeObject <DataTable>(json); //AuthDT = SqlHelper.ExecuteTable(CommandType.Text, "SELECT layer,[name],[text],owner,[desc] FROM ZL_AuthList"); DataTable tabDT = GetAuthModel(); TabRPT.DataSource = tabDT; TabRPT.DataBind(); ownerRPT.DataSource = tabDT; ownerRPT.DataBind(); M_ARoleAuth authMod = authBll.SelModelByRid(RoleID); if (authMod != null) { function.Script(this, "SetChkVal('model','" + authMod.model + "');"); function.Script(this, "SetChkVal('content','" + authMod.content + "');"); function.Script(this, "SetChkVal('crm','" + authMod.crm + "');"); function.Script(this, "SetChkVal('label','" + authMod.label + "');"); function.Script(this, "SetChkVal('shop','" + authMod.shop + "');"); function.Script(this, "SetChkVal('store','" + authMod.store + "');"); function.Script(this, "SetChkVal('page','" + authMod.page + "');"); function.Script(this, "SetChkVal('user','" + authMod.user + "');"); function.Script(this, "SetChkVal('other','" + authMod.other + "');"); function.Script(this, "SetChkVal('pub','" + authMod.pub + "');"); } //AuthDT=AuthDT.DefaultView.ToTable(false, "layer,name,text,owner,desc".Split(',')); //string json = JsonConvert.SerializeObject(AuthDT,Formatting.Indented); //SafeSC.WriteFile("/test/AuthList.config", json); }
/// <summary> /// 从DataReader中读取管理员记录 /// </summary> /// <param name="rdr">DataReader</param> /// <returns>M_RoleInfo 角色</returns> private static M_RoleInfo GetRoleInfoFromReader(SqlDataReader rdr) { M_RoleInfo info = new M_RoleInfo(); info.RoleID = Convert.ToInt32(rdr["RoleID"]); info.RoleName = rdr["RoleName"].ToString(); info.Description = rdr["Description"].ToString(); rdr.Close(); return(info); }
/// <summary> /// 传递参数 /// </summary> /// <param name="adminInfo"></param> /// <returns></returns> private static SqlParameter[] GetParameters(M_RoleInfo roleInfo) { SqlParameter[] parameter = new SqlParameter[3]; parameter[0] = new SqlParameter("@RoleID", SqlDbType.Int, 4); parameter[0].Value = roleInfo.RoleID; parameter[1] = new SqlParameter("@RoleName", SqlDbType.NVarChar, 50); parameter[1].Value = roleInfo.RoleName; parameter[2] = new SqlParameter("@Description", SqlDbType.NVarChar, 255); parameter[2].Value = roleInfo.Description; return(parameter); }
/// <summary> /// 增加新的角色到数据库中 /// </summary> /// <param name="RoleInfo">角色</param> /// <returns>增加结果状态 成功为true 反之 false</returns> public bool Add(M_RoleInfo RoleInfo) { string strSql = "INSERT INTO ZL_Role(RoleName,Description)VALUES(@RoleName,@Description)"; SqlParameter[] parameter = new SqlParameter[2]; parameter[0] = new SqlParameter("@RoleName", SqlDbType.NVarChar, 20); parameter[0].Value = RoleInfo.RoleName; parameter[1] = new SqlParameter("@Description", SqlDbType.NVarChar, 255); parameter[1].Value = RoleInfo.Description; return(SqlHelper.ExecuteSql(strSql, parameter)); }
protected void Page_Load(object sender, EventArgs e) { if (function.isAjax()) { string action = Request.Form["action"]; string result = ""; switch (action) { case "checkname": if (B_Role.IsExit(Request.Form["name"])) { result = "-1"; } else { result = "1"; } break; default: break; } Response.Write(result); Response.Flush(); Response.End(); } Call.SetBreadCrumb(Master, "<li><a href='" + CustomerPageAction.customPath2 + "Main.aspx'>工作台</a></li><li><a href='UserManage.aspx'>用户管理</a></li><li> <a href='AdminManage.aspx'>管理员管理</a></li><li><a href=\"RoleManage.aspx\">角色管理</a></li><li><asp:Literal Text='添加角色'>" + Literal1_Hid.Value + "</asp:Literal></li>"); B_Admin badmin = new B_Admin(); if (!B_ARoleAuth.Check(ZoomLa.Model.ZLEnum.Auth.user, "RoleEdit")) { function.WriteErrMsg("没有权限进行此项操作"); } if (!Page.IsPostBack) { ViewState["RoleID"] = Request.QueryString["RoleID"]; //判断当前角色是否存在 if (B_Role.IsExit(DataConverter.CLng(ViewState["RoleID"]))) { this.LblTitle.Text = "修改角色"; this.Literal1_Hid.Value = "修改角色"; role = B_Role.GetRoleById(DataConverter.CLng(ViewState["RoleID"])); this.txbRoleName.Text = role.RoleName; this.tbRoleInfo.Text = role.Description; EditRoleName_Hid.Value = role.RoleName; } else { this.LblTitle.Text = "添加角色"; this.Literal1_Hid.Value = "添加角色"; } } }
//string[] powerList = string.Empty; //StringBuilder sb = new StringBuilder(); protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { B_Admin badmin = new B_Admin(); badmin.CheckMulitLogin(); ViewState["roleid"] = Request.QueryString["id"]; //默认显示该角色信息 M_RoleInfo role = B_Role.GetRoleById(DataConverter.CLng(ViewState["roleid"])); this.LblRoleName.Text = role.RoleName; this.LblDescription.Text = role.Description; //填充该角色所具有的权限 string Power = ""; string RoleStr = B_Role.GetPowerInfo(role.RoleID); for (int t = 0; t < this.CheckBoxList1.Items.Count; t++) { Power = this.CheckBoxList1.Items[t].Value; if (RoleStr.IndexOf(Power) >= 0) { this.CheckBoxList1.Items[t].Selected = true; } } for (int y = 0; y < this.CheckBoxList2.Items.Count; y++) { Power = this.CheckBoxList2.Items[y].Value; if (RoleStr.IndexOf(Power) >= 0) { this.CheckBoxList2.Items[y].Selected = true; } } for (int x = 0; x < this.CheckBoxList3.Items.Count; x++) { Power = this.CheckBoxList3.Items[x].Value; if (RoleStr.IndexOf(Power) >= 0) { this.CheckBoxList3.Items[x].Selected = true; } } for (int s = 0; s < this.CheckBoxList4.Items.Count; s++) { Power = this.CheckBoxList4.Items[s].Value; if (RoleStr.IndexOf(Power) >= 0) { this.CheckBoxList4.Items[s].Selected = true; } } } }
public int Insert(M_RoleInfo model) { return(DBCenter.Insert(model)); }
public bool UpdateByID(M_RoleInfo model) { return(DBCenter.UpdateByID(model, model.RoleID)); }
public int insert(M_RoleInfo model) { return(Sql.insert(strTableName, model.GetParameters(), BLLCommon.GetParas(model), BLLCommon.GetFields(model))); }
/// <summary> /// 根据ID更新 /// </summary> public bool UpdateByID(M_RoleInfo model) { return(Sql.UpdateByIDs(strTableName, PK, model.RoleID.ToString(), BLLCommon.GetFieldAndPara(model), model.GetParameters())); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (!B_ARoleAuth.Check(ZLEnum.Auth.user, "AdminEdit")) { function.WriteErrMsg("没有权限进行此项操作"); } M_AdminInfo adminMod = B_Admin.GetAdminByID(Mid); if (adminMod == null) { function.WriteErrMsg("指定的管理员不存在"); } tbdName.Text = adminMod.AdminName; txtAdminTrueName.Text = adminMod.AdminTrueName; tbdName.Enabled = false; DefaultStart1.Text = B_Content.GetStatusStr(adminMod.DefaultStart); string[] arr = adminMod.RoleList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string roleName = ""; for (int i = 0; i < arr.Length; i++) { int roleId = DataConverter.CLng(arr[i]); M_RoleInfo m_role = B_Role.GetRoleById(roleId); roleName += " " + m_role.RoleName; } cblRoleList1.Text = roleName; //单选框设置 if (adminMod.EnableMultiLogin) { cb1.Text = "允许多人同时使用此帐号登录"; cb1.Visible = true; } else { cb1.Visible = false; } if (adminMod.EnableModifyPassword) { this.cb2.Text = "允许管理员修改密码"; cb2.Visible = true; } else { this.cb2.Visible = false; } if (adminMod.IsLock) { this.cb3.Text = "是否锁定"; cb3.Visible = true; } else { this.cb3.Visible = false; } if (adminMod.PubRole == 1) { this.CheckBox1.Text = "是"; } else { this.CheckBox1.Text = "否"; } int roId = adminMod.NodeRole; if (roId == 0) { DropDownList11.Text = "管理所有节点"; } else { M_RoleInfo role = B_Role.GetRoleById(roId); DropDownList11.Text = role.RoleName; } Call.SetBreadCrumb(Master, "<li>后台管理</li><li><a href='AdminManage.aspx'>管理员管理</a></li><li>管理员预览</li>"); } }
// 更新角色 public static bool Update(M_RoleInfo role) { return(roleMethod.Update(role)); }
// 增加角色 public static bool Add(M_RoleInfo role) { return(roleMethod.Add(role)); }
protected void Page_Load(object sender, EventArgs e) { ZoomLa.Common.function.AccessRulo(); B_Admin badmin = new B_Admin(); if (!Page.IsPostBack) { if (!B_ARoleAuth.Check(ZLEnum.Auth.user, "RoleMange")) { function.WriteErrMsg("没有权限进行此项操作"); } else if (string.IsNullOrEmpty(Request.QueryString["id"])) { function.WriteErrMsg("未选择操作角色"); } int RoleID = DataConverter.CLng(Request.QueryString["id"]); ViewState["roleid"] = Request.QueryString["id"]; PubManageBind(); //默认显示该角色信息 M_RoleInfo role = B_Role.GetRoleById(DataConverter.CLng(ViewState["roleid"])); this.LblRoleName.Text = role.RoleName; this.LblDescription.Text = role.Description; //填充该角色所具有的权限 string Power = ""; string RoleStr = B_Role.GetPowerInfo(role.RoleID); for (int t = 0; t < this.CheckBoxList1.Items.Count; t++) { Power = this.CheckBoxList1.Items[t].Value; if (RoleStr.IndexOf(Power) >= 0) { this.CheckBoxList1.Items[t].Selected = true; } } for (int y = 0; y < this.CheckBoxList2.Items.Count; y++) { Power = this.CheckBoxList2.Items[y].Value; if (RoleStr.IndexOf(Power) >= 0) { this.CheckBoxList2.Items[y].Selected = true; } } for (int x = 0; x < this.CheckBoxList3.Items.Count; x++) { Power = this.CheckBoxList3.Items[x].Value; if (RoleStr.IndexOf(Power) >= 0) { this.CheckBoxList3.Items[x].Selected = true; } } for (int s = 0; s < this.CheckBoxList4.Items.Count; s++) { Power = this.CheckBoxList4.Items[s].Value; if (RoleStr.IndexOf(Power) >= 0) { this.CheckBoxList4.Items[s].Selected = true; } } for (int s = 0; s < this.CheckBoxList5.Items.Count; s++) { Power = this.CheckBoxList5.Items[s].Value; if (RoleStr.IndexOf(Power) >= 0) { this.CheckBoxList5.Items[s].Selected = true; } } for (int s = 0; s < this.CheckBoxList6.Items.Count; s++) { Power = this.CheckBoxList6.Items[s].Value; if (RoleStr.IndexOf(Power) >= 0) { this.CheckBoxList6.Items[s].Selected = true; } } for (int s = 0; s < this.CheckBoxList7.Items.Count; s++) { Power = this.CheckBoxList7.Items[s].Value; if (RoleStr.IndexOf(Power) >= 0) { this.CheckBoxList7.Items[s].Selected = true; } } for (int s = 0; s < this.CheckBoxList8.Items.Count; s++) { Power = this.CheckBoxList8.Items[s].Value; if (RoleStr.IndexOf(Power) >= 0) { this.CheckBoxList8.Items[s].Selected = true; } } for (int s = 0; s < this.CheckBoxList9.Items.Count; s++) { Power = this.CheckBoxList9.Items[s].Value; if (RoleStr.IndexOf(Power) >= 0) { this.CheckBoxList9.Items[s].Selected = true; } } for (int s = 0; s < this.PubManage.Items.Count; s++) { Power = this.PubManage.Items[s].Value; if (RoleStr.IndexOf(Power) >= 0) { this.PubManage.Items[s].Selected = true; } } if (crmBll.IsExist(RoleID)) { crmModel = crmBll.GetSelect(RoleID); crmAuthChk.Items[0].Selected = crmModel.AllowOption == "1" ? true : false; crmAuthChk.Items[1].Selected = crmModel.AllowOptionValue == "1" ? true : false; crmAuthChk.Items[2].Selected = crmModel.AllowExcel == "1" ? true : false; crmAuthChk.Items[3].Selected = crmModel.AllowAddClient == "1" ? true : false; crmAuthChk.Items[4].Selected = crmModel.AllCustomer == "1" ? true : false; crmAuthChk.Items[5].Selected = crmModel.AssignFPMan == "1" ? true : false; crmAuthChk.Items[6].Selected = crmModel.AllowFPAll == "1" ? true : false; crmAuthChk.Items[7].Selected = crmModel.IsSalesMan == "1" ? true : false; } } Call.SetBreadCrumb(Master, "<li>后台管理</li><li><a href='AdminManage.aspx'>管理员管理</a></li><li><a href='RoleManage.aspx'>角色管理</a></li><li><a href='RoleManager.aspx?ID=<%= Request.QueryString[" + ID + "] %>'>权限管理</a></li>"); }