Esempio n. 1
0
        private void AccessDisplay()
        {
            Privilege priv         = new Privilege();
            int       readPrivId   = priv.GetPrivilegeId("read");
            int       writePrivId  = priv.GetPrivilegeId("write");
            int       deletePrivId = priv.GetPrivilegeId("delete");
            int       createPrivId = priv.GetPrivilegeId("create");

            foreach (GridViewRow resRow in odmInfoGridView.Rows)
            {
                CheckBox readbox = (CheckBox)resRow.FindControl("readStatusCheckBox");
                readbox.Checked = false;

                CheckBox updateBox = (CheckBox)resRow.FindControl("updateStatusCheckBox");
                readbox.Checked = false;

                CheckBox deleteBox = (CheckBox)resRow.FindControl("deleteStatusCheckBox");
                readbox.Checked = false;
            }

            int selectedUserRow = userGroupGridView.SelectedIndex;

            userIdSelected = Convert.ToInt16(userGroupGridView.Rows[selectedUserRow].Cells[2].Text.ToString());
            AccessControl accessObj   = new AccessControl();
            DataTable     accessTable = new DataTable();

            accessTable = accessObj.AccessData(userIdSelected);
            foreach (DataRow row in accessTable.Rows)
            {
                foreach (GridViewRow resRow in odmInfoGridView.Rows)
                {
                    string dbrow   = row["resourcesid"].ToString();
                    string gridRow = resRow.Cells[15].Text.ToString();
                    if (row["resourcesid"].ToString() == resRow.Cells[15].Text.ToString())
                    {
                        if (row["privilegeid"].ToString() == readPrivId.ToString())
                        {
                            CheckBox readbox = (CheckBox)resRow.FindControl("readStatusCheckBox");
                            readbox.Checked = true;
                        }
                        if (row["privilegeid"].ToString() == writePrivId.ToString())
                        {
                            CheckBox readbox = (CheckBox)resRow.FindControl("updateStatusCheckBox");
                            readbox.Checked = true;
                        }
                        if (row["privilegeid"].ToString() == deletePrivId.ToString())
                        {
                            CheckBox readbox = (CheckBox)resRow.FindControl("deleteStatusCheckBox");
                            readbox.Checked = true;
                        }
                    }
                }
            }
        }
Esempio n. 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();
        }
Esempio n. 3
0
        protected void userGroupGridView_SelectedIndexChanged(object sender, EventArgs e)
        {
            foreach (GridViewRow row in userGroupGridView.Rows)
            {
                row.BackColor = System.Drawing.Color.White;
            }
            GridViewRow selectedRow = userGroupGridView.SelectedRow;

            selectedRow.BackColor = System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.LightBlue);


            Privilege priv         = new Privilege();
            int       readPrivId   = priv.GetPrivilegeId("read");
            int       writePrivId  = priv.GetPrivilegeId("write");
            int       deletePrivId = priv.GetPrivilegeId("delete");
            int       createPrivId = priv.GetPrivilegeId("create");

            foreach (GridViewRow resRow in odmInfoGridView.Rows)
            {
                CheckBox readbox = (CheckBox)resRow.FindControl("readStatusCheckBox");
                readbox.Checked = false;

                CheckBox updateBox = (CheckBox)resRow.FindControl("updateStatusCheckBox");
                updateBox.Checked = false;

                CheckBox deleteBox = (CheckBox)resRow.FindControl("deleteStatusCheckBox");
                deleteBox.Checked = false;
            }

            GridViewRow selRow = userGroupGridView.Rows[userGroupGridView.SelectedIndex];

            userIdSelected = Convert.ToInt16(selRow.Cells[2].Text.ToString());
            AccessControl accessObj   = new AccessControl();
            DataTable     accessTable = new DataTable();

            accessTable = accessObj.AccessData(userIdSelected);
            foreach (DataRow row in accessTable.Rows)
            {
                foreach (GridViewRow resRow in odmInfoGridView.Rows)
                {
                    string dbrow   = row["resourcesid"].ToString();
                    string gridRow = resRow.Cells[15].Text.ToString();
                    if (row["resourcesid"].ToString() == resRow.Cells[15].Text.ToString())
                    {
                        if (row["privilegeid"].ToString() == readPrivId.ToString())
                        {
                            CheckBox readbox = (CheckBox)resRow.FindControl("readStatusCheckBox");
                            readbox.Checked = true;
                        }
                        if (row["privilegeid"].ToString() == writePrivId.ToString())
                        {
                            CheckBox readbox = (CheckBox)resRow.FindControl("updateStatusCheckBox");
                            readbox.Checked = true;
                        }
                        if (row["privilegeid"].ToString() == deletePrivId.ToString())
                        {
                            CheckBox readbox = (CheckBox)resRow.FindControl("deleteStatusCheckBox");
                            readbox.Checked = true;
                        }
                    }
                }
            }

            TemplateGridDisplay();
        }