Ejemplo n.º 1
0
        }//-------------------------

        //#########################################END LINLLABEL lnkPersonArchive EVENTS###########################################################
        #endregion

        #region Programmer-Defined Void Procedures
        //this procedure will insert user access rights
        private void InsertUserAccessRights()
        {
            Int32 index = 0;

            _newUserInfo.AccessRightsGrantedList.Clear();

            foreach (DataGridViewRow dgvRow in this.dgvList.Rows)
            {
                this.SetDataGridViewDoEvents(index);

                if ((Boolean)dgvRow.Cells["checkbox_column"].Value && dgvRow.Cells["department_name"].Value != null)
                {
                    CommonExchange.AccessRightsGranted list = new CommonExchange.AccessRightsGranted();

                    list.AccessRightsInfo.AccessRights = _administarationManager.GetAccessRights(index);
                    list.DepartmentInfo.DepartmentId   = _administarationManager.GetDepartmentId(dgvRow.Cells["department_name"].Value.ToString());
                    list.ObjectState = DataRowState.Added;

                    _newUserInfo.AccessRightsGrantedList.Add(list);
                }

                index++;

                Application.DoEvents();
                this.Refresh();
            }
        }//----------------------------
Ejemplo n.º 2
0
        }//---------------------

        //###############################################END BUTTON btnUpdate EVENTS##################################################
        #endregion

        #region Programmer-Defined Void Procedures
        //this procedure will update user access rights
        private void UpdateUserAccessRights()
        {
            Int32 index = 0;

            foreach (DataGridViewRow dgvRow in this.dgvList.Rows)
            {
                this.SetDataGridViewDoEvents(index);

                if ((Boolean)dgvRow.Cells["checkbox_column"].Value && dgvRow.Cells["department_name"].Value != null)
                {
                    Boolean isExist     = false;
                    Int32   accessCount = 0;

                    foreach (CommonExchange.AccessRightsGranted list in _newUserInfo.AccessRightsGrantedList)
                    {
                        if (String.Equals(_administarationManager.GetAccessRights(index), list.AccessRightsInfo.AccessRights) &&
                            !String.Equals(_administarationManager.GetDepartmentId(dgvRow.Cells["department_name"].Value.ToString()),
                                           list.DepartmentInfo.DepartmentId))
                        {
                            _newUserInfo.AccessRightsGrantedList[accessCount].DepartmentInfo.DepartmentId =
                                _administarationManager.GetDepartmentId(dgvRow.Cells["department_name"].Value.ToString());
                            _newUserInfo.AccessRightsGrantedList[accessCount].ObjectState = DataRowState.Modified;

                            isExist = true;
                        }
                        else if (String.Equals(_administarationManager.GetAccessRights(index), list.AccessRightsInfo.AccessRights))
                        {
                            isExist = true;
                        }

                        accessCount++;
                    }

                    if (!isExist)
                    {
                        CommonExchange.AccessRightsGranted list = new CommonExchange.AccessRightsGranted();

                        list.AccessRightsInfo.AccessRights = _administarationManager.GetAccessRights(index);
                        list.DepartmentInfo.DepartmentId   = _administarationManager.GetDepartmentId(dgvRow.Cells["department_name"].Value.ToString());
                        list.ObjectState = DataRowState.Added;

                        _newUserInfo.AccessRightsGrantedList.Add(list);
                    }
                }
                else if (!(Boolean)dgvRow.Cells["checkbox_column"].Value)
                {
                    Int32 count = 0;

                    foreach (CommonExchange.AccessRightsGranted list in _newUserInfo.AccessRightsGrantedList)
                    {
                        if (String.Equals(_administarationManager.GetAccessRights(index), list.AccessRightsInfo.AccessRights))
                        {
                            list.ObjectState = DataRowState.Deleted;

                            break;
                        }

                        count++;
                    }
                }

                index++;

                Application.DoEvents();
                this.Refresh();
            }
        }//-------------------------------------