Пример #1
0
 protected void grantButton_Click(object sender, EventArgs e)
 {
     foreach (GridViewRow row in DataRequestGrid.Rows)
     {
         CheckBox groupCheckBox = (CheckBox)row.FindControl("selectGroup");
         if (groupCheckBox.Checked)
         {
             AccessControl accessObj = new AccessControl();
             accessObj.SetUserAccess(row.Cells[3].Text.ToString(), Convert.ToInt16(row.Cells[5].Text), Convert.ToInt16(row.Cells[8].Text));
             DBLayer.DataRequest dataRequestObj = new DBLayer.DataRequest();
             dataRequestObj.ReleaseDataRequestRow(Convert.ToInt16(row.Cells[9].Text));
             DataRequestGridLoad();
         }
     }
 }
Пример #2
0
        protected void updateAccessControl_Click(object sender, EventArgs e)
        {
            List <int> userIdList    = new List <int>();
            List <int> userGroupList = new List <int>();
            List <KeyValuePair <string, int> > resourcePrivilegeList = new List <KeyValuePair <string, int> >();
            Privilege priv         = new Privilege();
            int       readPrivId   = priv.GetPrivilegeId("read");
            int       writePrivId  = priv.GetPrivilegeId("write");
            int       deletePrivId = priv.GetPrivilegeId("delete");
            int       createPrivId = priv.GetPrivilegeId("create");


            if (userCheckBox.Checked)
            {
                int selectUserRow = userGroupGridView.SelectedIndex;
                userIdList.Add(Convert.ToInt16(userGroupGridView.Rows[selectUserRow].Cells[2].Text.ToString()));

                //foreach (GridViewRow row in userGroupGridView.Rows)
                //{
                //    CheckBox box = (CheckBox)row.FindControl("selectUserGroupCheckBox");
                //    if (box.Checked)
                //    {
                //        int userid = Convert.ToInt16(row.Cells[2].Text.ToString());
                //        userIdList.Add(userid);
                //    }
                //}

                foreach (int userId in userIdList)
                {
                    AccessControl accessObj = new AccessControl();
                    accessObj.ReleaseUserRows(userId, DbListBox.SelectedValue.ToString());
                }

                foreach (GridViewRow row in odmInfoGridView.Rows)
                {
                    CheckBox readbox = (CheckBox)row.FindControl("readStatusCheckBox");
                    if (readbox.Checked)
                    {
                        resourcePrivilegeList.Add(new KeyValuePair <string, int>(row.Cells[15].Text.ToString(), readPrivId));
                    }

                    CheckBox updateBox = (CheckBox)row.FindControl("updateStatusCheckBox");
                    if (updateBox.Checked)
                    {
                        resourcePrivilegeList.Add(new KeyValuePair <string, int>(row.Cells[15].Text.ToString(), writePrivId));
                    }

                    CheckBox deleteBox = (CheckBox)row.FindControl("deleteStatusCheckBox");

                    if (deleteBox.Checked)
                    {
                        resourcePrivilegeList.Add(new KeyValuePair <string, int>(row.Cells[15].Text.ToString(), deletePrivId));
                    }
                }


                foreach (int userId in userIdList)
                {
                    foreach (KeyValuePair <string, int> kvp in resourcePrivilegeList)
                    {
                        string        resourceId  = kvp.Key;
                        int           privilegeId = kvp.Value;
                        AccessControl accessObj   = new AccessControl();
                        accessObj.SetUserAccess(resourceId, userId, privilegeId);
                    }
                }
            }

            TemplateGridDisplay();
        }