コード例 #1
0
        /// <summary>
        /// 确定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonOK_Click(object sender, EventArgs e)
        {
            //解决确定后窗体关闭问题
            DialogResult = DialogResult.None;
            //用户组名称
            string name = _txtGroupName.Text.ToString().Trim();

            //检查用户组名称不能为空,不能重复
            if (LibCommon.Validator.checkSpecialCharacters(name) || LibCommon.Validator.IsEmpty(name) || UserGroupInformationManagementBLL.FindTheSameGroupName(name))
            {
                Alert.alert(LibCommon.Const.USER_GROUP_NAME_IS_WRONG, LibCommon.Const.NOTES, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                //设置焦点
                _txtGroupName.Focus();
                return;
            }
            //选择用户的数量
            int userCount = _lstSelUserName.Items.Count;

            //定义用户组信息实体
            LibEntity.UserGroup ent = new LibEntity.UserGroup();
            //组名
            ent.GroupName = _txtGroupName.Text.ToString().Trim();
            //人数
            ent.UserCount = userCount.ToString();
            //备注
            ent.Remark = _rtxtRemarks.Text.ToString().Trim();
            //插入数据库
            UserGroupInformationManagementBLL.InsertRecordIntoTableUserGroupInformation(ent);

            //修改用户登录信息表中记录的组名
            for (int i = 0; i < userCount; i++)
            {
                UserGroupInformationManagementBLL.ChangeUserGroup(ent.GroupName, _lstSelUserName.Items[i].ToString());
            }

            DataTable dt = UserGroupInformationManagementBLL.GetUserGroupInformation();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                UserGroupInformationManagementBLL.UpdateUserCountFromUserGroup(dt.Rows[i][UserGroupInformationMangementDbConstNames.USER_GROUP_NAME].ToString());
            }
            this.Close();
        }
コード例 #2
0
        /// <summary>
        /// 属性值更改
        /// </summary>
        /// <param name="s"></param>
        /// <param name="e"></param>
        private void _propInfo_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
        {
            //获取当前行的行索引
            int n = this._fpUserGroupInfo.ActiveSheet.ActiveCell.Row.Index;

            //选择表题时,返回
            if (n < 2)
            {
                return;
            }

            //定义接收变化的值
            string changeValue = "";

            if (e.ChangedItem.Value != null)
            {
                //若易报错,则首先检查fp中columns的tag是否与ss相同
                //获取更改值的Label
                string ss = e.ChangedItem.Label.ToString();
                //获取列索引
                int columnIndex = this._fpUserGroupInfo.ActiveSheet.Columns[ss].Index;
                //获取修改的值
                changeValue = e.ChangedItem.Value.ToString();

                if (ss == _strUserGroupNameLable)
                {
                    //检测特殊字符、是否为空、是否重复
                    if (LibCommon.Validator.checkSpecialCharacters(changeValue) ||
                        LibCommon.Validator.IsEmpty(changeValue) ||
                        UserGroupInformationManagementBLL.FindTheSameGroupName(changeValue))
                    {
                        Alert.alert(LibCommon.Const.USER_GROUP_NAME_IS_WRONG, LibCommon.Const.NOTES, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        fpUserInfo_SelectionChanged(null, null);
                        return;
                    }

                    //检查字符串的长度
                    if (changeValue.Length > _iUserGroupNameLength)
                    {
                        Alert.alert(LibCommon.Const.TXT_IS_WRONG1 + _iUserGroupNameLength + LibCommon.Const.TXT_IS_WRONG2, LibCommon.Const.NOTES, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        fpUserInfo_SelectionChanged(null, null);
                        return;
                    }
                }

                #region 获取旧值
                //定义组名称
                string groupName = "";
                //人数
                string userCount = "";
                //备注
                string remark = "";

                //从farpoint取值时,检查是否为空
                if (this._fpUserGroupInfo.ActiveSheet.Cells[n, 1].Value != null)
                {
                    groupName = this._fpUserGroupInfo.ActiveSheet.Cells[n, 1].Value.ToString();
                }
                if (this._fpUserGroupInfo.ActiveSheet.Cells[n, 2].Value != null)
                {
                    userCount = this._fpUserGroupInfo.ActiveSheet.Cells[n, 2].Value.ToString();
                }
                if (this._fpUserGroupInfo.ActiveSheet.Cells[n, 3].Value != null)
                {
                    remark = this._fpUserGroupInfo.ActiveSheet.Cells[n, 3].Value.ToString();
                }

                //用户组名称旧值
                string oldName = groupName;

                if (ss == _strUserGroupNameLable)
                {
                    oldName = e.OldValue.ToString();
                }
                #endregion

                //修改farpoint的显示值
                this._fpUserGroupInfo.ActiveSheet.Cells[n, columnIndex].Text = changeValue;

                //定义用户组信息实体,接收新值
                LibEntity.UserGroup userGroupInfo = new LibEntity.UserGroup();
                userGroupInfo.GroupName = groupName;
                userGroupInfo.UserCount = userCount;
                userGroupInfo.Remark    = remark;

                //更新数据库
                UserGroupInformationManagementBLL.UpdateUserGroupInfomationDatabase(userGroupInfo, oldName);
            }
        }