Ejemplo n.º 1
0
 /// <summary>
 /// 根据选中的角色初始化具有的权限选项为选中状态
 /// </summary>
 private void InitPermission()
 {
     if (roleId > 0)
     {
         using (DataTable dt = new PermBLL().GetPurviewCodeListByRoleId(roleId))
         {
             if (dt != null && dt.Rows.Count > 0)
             {
                 var query = dt.AsEnumerable();
                 foreach (GridRow row in Grid2.Rows)
                 {
                     AspNet.CheckBoxList cblPurviewCodes = (AspNet.CheckBoxList)Grid2.Rows[row.RowIndex].FindControl("cblPurviewCodes");
                     foreach (AspNet.ListItem item in cblPurviewCodes.Items)
                     {
                         item.Selected = query.Where(dr => dr.Field <string>("MPC_CODE") == item.Value).Count() > 0;
                     }
                 }
                 Grid2.UpdateTemplateFields();
             }
             else
             {
                 SelectAll(false);
             }
         }
     }
 }
Ejemplo n.º 2
0
 protected void btnGroupUpdate_Click(object sender, EventArgs e)
 {
     //更新权限
     if (!VerifyPurview(",SR-UPDATEMENU,"))
     {
         Alert.ShowInParent(CHECK_POWER_FAIL_ACTION_MESSAGE);
         return;
     }
     if (roleId > 0)
     {
         using (DataTable dt = new DataTable())
         {
             dt.Columns.Add("r_id", typeof(int));
             dt.Columns.Add("mpc_code", typeof(string));
             foreach (GridRow row in Grid2.Rows)
             {
                 AspNet.CheckBoxList cblPurviewCodes = (AspNet.CheckBoxList)Grid2.Rows[row.RowIndex].FindControl("cblPurviewCodes");
                 foreach (AspNet.ListItem item in cblPurviewCodes.Items)
                 {
                     if (item.Selected)
                     {
                         DataRow dr = dt.NewRow();
                         dr[0] = roleId;
                         dr[1] = item.Value;
                         dt.Rows.Add(dr);
                     }
                 }
             }
             int result = new PermBLL().BatchSave(dt, roleId);
             if (result > 0)
             {
                 Alert.ShowInParent("更新角色权限成功!", String.Empty, ActiveWindow.GetHideReference());
             }
             else
             {
                 Alert.ShowInParent("更新角色权限失败");
             }
         }
     }
 }