Пример #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;
                        }
                    }
                }
            }
        }
Пример #2
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();
        }