示例#1
0
        private void RoleList_AfterRowColChange(object sender, RangeEventArgs e)
        {
            const string methodName = This + ".RoleList_AfterRowColChange()";

            try
            {
                if (RoleList.Cols.IndexOf(Sys_RoleTable.ROLEID_FLD) < 0)
                {
                    return;
                }

                // Get RoleID
                int intRowSel = RoleList.RowSel;
                // if user change selected row
                if (intRowSel <= 0 || e.OldRange.r1 == e.NewRange.r1)
                {
                    return;
                }
                // Get data display on column 1 of Role
                int roleId;
                if (int.TryParse(RoleList.GetDataDisplay(RoleList.RowSel, Sys_RoleTable.ROLEID_FLD), out roleId))
                {
                    _selectedRoleId = roleId;
                    BindRightList(_rightList.Where(r => r.RoleID == roleId), null);
                }
            }
            catch (PCSException ex)
            {
                // displays the error message.
                PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
                // log message.
                try
                {
                    Logger.LogMessage(ex.CauseException, methodName, Level.ERROR);
                }
                catch
                {
                    PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                // displays the error message.
                PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
                // log message.
                try
                {
                    Logger.LogMessage(ex, methodName, Level.ERROR);
                }
                catch
                {
                    PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
                }
            }
        }
示例#2
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            const string methodName = This + ".SaveButton_Click()";

            try
            {
                int roleId;
                if (!int.TryParse(RoleList.GetDataDisplay(RoleList.RowSel, Sys_RoleTable.ROLEID_FLD), out roleId))
                {
                    return;
                }
                var roleRights = _rightList.Where(r => r.RoleID == roleId).ToList();
                // update the right from the function list
                UpdateRight(roleId, roleRights, null);

                // save changes to database
                RightAssignmentBO.Instance.UpdateRight(roleRights);
                PCSMessageBox.Show(ErrorCode.MESSAGE_AFTER_SAVE_DATA, MessageBoxButtons.OK);
            }
            catch (PCSException ex)
            {
                // displays the error message.
                PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
                // log message.
                try
                {
                    Logger.LogMessage(ex.CauseException, methodName, Level.ERROR);
                }
                catch
                {
                    PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                // displays the error message.
                PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
                // log message.
                try
                {
                    Logger.LogMessage(ex, methodName, Level.ERROR);
                }
                catch
                {
                    PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
                }
            }
        }