/// <summary> /// gv生成事件时触发 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvRole_RowCommand(object sender, GridViewCommandEventArgs e) { ExtendBLL.UserRole EUR=new ExtendBLL.UserRole(); int Userid = int.Parse(Request.QueryString["UserId"].ToString()); if (e.CommandName == "cancleRole") { int id = int.Parse(e.CommandArgument.ToString());//当前行号 int RoleID = id; try { EUR.DeleteByRoleIDUserID(RoleID, Userid); Common.JShelper.JSAlert(this.Page, "", "删除成功!"); InitRoleInfo(Userid); } catch(Exception ex) { throw ex; } } }
/// <summary> ///页面绑定 /// </summary> protected void InitBind(int RoleId) { DataSet ds = new DataSet(); ExtendBLL.UserRole EBUR = new ExtendBLL.UserRole(); try { ds = EBUR.GetUserInfoByRoleID(RoleId); } catch(Exception ex) { if (ex.Message == "2") { //Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"","<script type='text/javascript'>alert('该角色还没有分配给用户!');</script>"); Common.JShelper.JSAlert(this.Page, "", "该角色还没有分配给用户!"); return; } } ds=HandleDataSet(ds); gvRole.DataSource = ds.Tables[0].DefaultView; gvRole.DataBind(); }
/// <summary> /// 初始化绑定角色信息 /// </summary> /// <param name="UserId"></param> protected void InitRoleInfo(int UserId) { ExtendBLL.UserRole BUR = new ExtendBLL.UserRole(); try { gvRole.DataSource = BUR.GetUserRoleByUserID(UserId); gvRole.DataBind(); } catch(Exception ex) { if (ex.Message == "1") { Common.JShelper.JSAlert(this.Page,"","该用户不存在!"); gvRole.DataSource = ""; gvRole.DataBind(); } if (ex.Message == "2") { Common.JShelper.JSAlert(this.Page,"","该用户还没有分配角色!"); gvRole.DataSource = ""; gvRole.DataBind(); } } }
/// <summary> /// 页面初始化(已经添加的角色不显示) /// </summary> protected void InitBind(int UserID) { ExtendBLL.UserRole EBUR = new ExtendBLL.UserRole(); gvRole.DataSource = EBUR.GetRoleTableExpect(UserID); gvRole.DataBind(); }