Ejemplo n.º 1
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="dataRow">数据表</param>
 public FrmRoleEdit(DataRow dataRow)
     : this()
 {
     this.drRole = dataRow;
     roleEntity = new BaseRoleEntity(this.drRole);
     this.EntityId = roleEntity.Id.ToString();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 添加角色
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="roleEntity">实体</param>
        /// <param name="statusCode">返回状态码</param>
        /// <param name="statusMessage">返回状态信息</param>
        /// <returns>主键</returns>
        public string Add(BaseUserInfo userInfo, BaseRoleEntity roleEntity, out string statusCode, out string statusMessage)
        {
            // 写入调试信息
            #if (DEBUG)
                int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

            // 加强安全验证防止未授权匿名调用
            #if (!DEBUG)
                LogOnService.UserIsLogOn(userInfo);
            #endif

            string returnValue = string.Empty;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    dbHelper.BeginTransaction();
                    string tableName = BaseRoleEntity.TableName;
                    if (!string.IsNullOrEmpty(BaseSystemInfo.SystemCode))
                    {
                        tableName = BaseSystemInfo.SystemCode + "Role";
                    }
                    BaseRoleManager roleManager = new BaseRoleManager(dbHelper, userInfo, tableName);
                    returnValue = roleManager.Add(roleEntity, out statusCode);
                    statusMessage = roleManager.GetStateMessage(statusCode);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, serviceName, AppMessage.RoleService_Add, MethodBase.GetCurrentMethod());
                    dbHelper.CommitTransaction();
                }
                catch (Exception ex)
                {
                    dbHelper.RollbackTransaction();
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

            // 写入调试信息
            #if (DEBUG)
                BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
            #endif

            return returnValue;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="roleEntity">实体</param>
        /// <param name="statusCode">返回状态码</param>
        /// <returns>主键</returns>
        public string Add(BaseRoleEntity roleEntity, out string statusCode)
        {
            string returnValue = string.Empty;
            // 检查名称是否重复
            List<KeyValuePair<string, object>> parameters = new List<KeyValuePair<string, object>>();
            parameters.Add(new KeyValuePair<string, object>(BaseRoleEntity.FieldSystemId, roleEntity.SystemId));
            parameters.Add(new KeyValuePair<string, object>(BaseRoleEntity.FieldRealName, roleEntity.RealName));
            parameters.Add(new KeyValuePair<string, object>(BaseRoleEntity.FieldDeletionStateCode, 0));

            if (this.Exists(parameters))
            {
                // 名称是否重复
                statusCode = StatusCode.ErrorNameExist.ToString();
            }
            else
            {
                returnValue = this.AddEntity(roleEntity);
                // 运行成功
                statusCode = StatusCode.OKAdd.ToString();
            }
            return returnValue;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 保存数据
 /// </summary>
 private void Save()
 {
     // 设置鼠标繁忙状态,并保留原先的状态
     Cursor holdCursor = this.Cursor;
     this.Cursor = Cursors.WaitCursor;
     try
     {
         this.btnOK.Enabled = false;
         // 将原来的角色移出,获取当前角色中的用户
         string[] roleIds = DotNetService.Instance.UserService.GetUserRoleIds(this.UserInfo, this.TargetUserId);
         DotNetService.Instance.UserService.RemoveUserFromRole(this.UserInfo, this.TargetUserId, roleIds);
         // 将新的角色添加到用户
         List<BaseRoleEntity> roleEntites = new List<BaseRoleEntity>();
         for (int i = 0; i < this.cklstRole.CheckedItems.Count; i++)
         {
             BaseRoleEntity roleEntity = new BaseRoleEntity(((System.Data.DataRowView)this.cklstRole.CheckedItems[i]).Row);
             roleEntites.Add(roleEntity);
         }
         string[] addRoleIds = new string[roleEntites.Count];
         for (int i = 0; i < roleEntites.Count; i++)
         {
             addRoleIds[i] = roleEntites[i].Id.ToString();
         }
         // 添加用户到角色
         DotNetService.Instance.UserService.AddUserToRole(this.UserInfo, this.TargetUserId, addRoleIds);
         this.btnOK.Enabled = true;
     }
     catch (Exception ex)
     {
         this.ProcessException(ex);
     }
     finally
     {
         // 设置鼠标默认状态,原来的光标状态
         this.Cursor = holdCursor;
     }
 }
        private void btnCopy_Click(object sender, EventArgs e)
        {
            UserPermission userPermission = new UserPermission();
            // 读取角色数据
            List<BaseRoleEntity> roleEntites = new List<BaseRoleEntity>();
            for (int i = 0; i < this.cklstRole.CheckedItems.Count; i++)
            {
                BaseRoleEntity roleEntity = new BaseRoleEntity(((System.Data.DataRowView)this.cklstRole.CheckedItems[i]).Row);
                roleEntites.Add(roleEntity);
            }
            // 角色复制到剪切板
            userPermission.RoleEntites = roleEntites;
            // 模块访问权限复制到剪切板
            string[] grantModuleIds = this.GetGrantModuleIds();
            userPermission.GrantModuleIds = grantModuleIds;
            // 操作权限复制到剪切板
            string[] grantPermissionIds = this.GetGrantPermissionIds();
            userPermission.GrantPermissionIds = grantPermissionIds;

            Clipboard.SetData("userPermission", userPermission);
            this.btnPaste.Enabled = true;
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 获取实体
 /// </summary>
 /// <param name="id">主键</param>
 public BaseRoleEntity GetEntity(string id)
 {
     BaseRoleEntity roleEntity = new BaseRoleEntity(this.GetDataTable(new KeyValuePair<string, object>(BaseRoleEntity.FieldId, id)));
     return roleEntity;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="roleEntity">实体</param>
 /// <returns>主键</returns>
 public string Add(BaseRoleEntity roleEntity)
 {
     return this.AddEntity(roleEntity);
 }
        private void btnCopy_Click(object sender, EventArgs e)
        {
            PermissionScopes permissionScopes = new PermissionScopes();
            // 模块访问权限复制到剪切板
            for (int i = 0; i < this.cklstUser.CheckedItems.Count; i++)
            {
                BaseUserEntity userEntity = new BaseUserEntity(((System.Data.DataRowView)this.cklstUser.CheckedItems[i]).Row);
                this.GrantUsers += userEntity.Id.ToString() + ";";
            }
            string[] grantUserIds = this.GrantUsers.Split(';');
            permissionScopes.GrantUserIds = grantUserIds;

            for (int i = 0; i < this.cklstRole.CheckedItems.Count; i++)
            {
                BaseRoleEntity roleEntity = new BaseRoleEntity(((System.Data.DataRowView)this.cklstRole.CheckedItems[i]).Row);
                this.GrantRoles += roleEntity.Id.ToString() + ";";
            }
            string[] grantRoleIds = this.GrantRoles.Split(';');
            permissionScopes.GrantRoleIds = grantRoleIds;

            string[] grantOrganizeIds = this.GetGrantOrganizeIds();
            permissionScopes.GrantOrganizeIds = grantOrganizeIds;
            string[] grantModuleIds = this.GetGrantModuleIds();
            permissionScopes.GrantModuleIds = grantModuleIds;
            string[] grantPermissionIds = this.GetGrantPermissionIds();
            permissionScopes.GrantPermissionIds = grantPermissionIds;
            Clipboard.SetData("permissionScopes", permissionScopes);
            this.btnPaste.Enabled = true;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 检查批量删除
        /// </summary>
        /// <returns>允许删除</returns>
        public override bool CheckInput()
        {
            bool returnValue = true;
            foreach (DataGridViewRow dgvRow in grdRole.Rows)
            {
                DataRow dataRow = (dgvRow.DataBoundItem as DataRowView).Row;
                if ((System.Boolean)(dgvRow.Cells["colSelected"].Value??false))
                {
                    BaseRoleEntity roleEntity = new BaseRoleEntity(dataRow);
                    if (roleEntity.AllowDelete == 0)
                    {
                        // 有不允许删除的数据
                        MessageBox.Show(AppMessage.Format(AppMessage.MSG0018, roleEntity.RealName), AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        returnValue = false;
                        break;
                    }
                }
            }

            //foreach (DataRowView dataRowView in this.DTRole.DefaultView)
            //{
            //    if (dataRowView.Row[BaseBusinessLogic.SelectedColumn].ToString().ToUpper().Equals(true.ToString().ToUpper()))
            //    {
            //        BaseRoleEntity roleEntity = new BaseRoleEntity(dataRowView.Row);
            //        if (roleEntity.AllowDelete == 0)
            //        {
            //            // 有不允许删除的数据
            //            MessageBox.Show(AppMessage.Format(AppMessage.MSG0018, roleEntity.RealName), AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
            //            returnValue = false;
            //            break;
            //        }
            //    }
            //}
            return returnValue;
        }
Ejemplo n.º 10
0
        private void btnRole_Click(object sender, EventArgs e)
        {
            string txtButton = ((Button)sender).Text;
            Button btnRole = (Button)sender;
            string roldId = GetRoleId(btnRole);
            if (string.IsNullOrEmpty(roldId))
            {
                BaseRoleEntity roleEntity = new BaseRoleEntity();
                roleEntity.OrganizeId = this.EntityId;
                roleEntity.Code = ((Button)sender).Name.Substring(3).Replace("Delete", "");
                roleEntity.RealName = this.txtFullName.Text + "_" + txtButton;
                roleEntity.Description = ((Button)sender).Text;
                roleEntity.CategoryCode = "Duty";
                roleEntity.Enabled = 1;
                roleEntity.DeletionStateCode = 0;
                BaseRoleManager roleManager = new BaseRoleManager(this.UserInfo);
                roldId = roleManager.Add(roleEntity);
                btnRole.Tag = roldId;
            }
            FrmRoleUserAdmin frmRoleUserAdmin = new FrmRoleUserAdmin(roldId);
            frmRoleUserAdmin.ShowDialog(this);

            this.GetRoleUser(btnRole);
        }
Ejemplo n.º 11
0
 /// <summary>
 /// 读取屏幕数据
 /// </summary>
 /// <returns>角色实体</returns>
 private BaseRoleEntity GetEntity()
 {
     roleEntity = new BaseRoleEntity();
     roleEntity.RealName = this.txtRealName.Text;
     roleEntity.Code = this.txtCode.Text;
     roleEntity.Description = this.txtDescription.Text;
     roleEntity.Enabled = this.chkEnabled.Checked ? 1 : 0;
     roleEntity.CategoryCode = this.cmbRoleCategory.SelectedValue.ToString();
     roleEntity.AllowDelete = 1;
     roleEntity.AllowEdit = 1;
     roleEntity.DeletionStateCode = 0;
     roleEntity.IsVisible = 1;
     return roleEntity;
 }
Ejemplo n.º 12
0
partial         void SetEntityExpand(SQLBuilder sqlBuilder, BaseRoleEntity roleEntity);
Ejemplo n.º 13
0
        /// <summary>
        /// 加载角色
        /// </summary>
        private void LoadUserGroup()
        {
            // 开始更新控件,屏幕不刷新,提高效率。
            this.tvUserGroup.BeginUpdate();
            this.tvUserGroup.Nodes.Clear();

            BaseRoleEntity roleEntity = null;
            foreach (DataRow dataRow in this.DTUserGroup.Rows)
            {
                roleEntity = new BaseRoleEntity(dataRow);
                // 当前节点的子节点, 加载根节点
                TreeNode treeNode = new TreeNode();
                treeNode.Text = roleEntity.RealName;
                treeNode.Tag = roleEntity.Id;
                // treeNode.Tag = roleEntity;
                this.tvUserGroup.Nodes.Add(treeNode);
            }
            this.tvUserGroup.EndUpdate();
        }
Ejemplo n.º 14
0
 /// <summary>
 /// 设置实体
 /// </summary>
 /// <param name="roleEntity">实体</param>
 private void SetEntity(SQLBuilder sqlBuilder, BaseRoleEntity roleEntity)
 {
     sqlBuilder.SetValue(BaseRoleEntity.FieldSystemId, roleEntity.SystemId);
     sqlBuilder.SetValue(BaseRoleEntity.FieldOrganizeId, roleEntity.OrganizeId);
     sqlBuilder.SetValue(BaseRoleEntity.FieldCode, roleEntity.Code);
     sqlBuilder.SetValue(BaseRoleEntity.FieldRealName, roleEntity.RealName);
     sqlBuilder.SetValue(BaseRoleEntity.FieldCategoryCode, roleEntity.CategoryCode);
     sqlBuilder.SetValue(BaseRoleEntity.FieldAllowEdit, roleEntity.AllowEdit);
     sqlBuilder.SetValue(BaseRoleEntity.FieldAllowDelete, roleEntity.AllowDelete);
     sqlBuilder.SetValue(BaseRoleEntity.FieldSortCode, roleEntity.SortCode);
     sqlBuilder.SetValue(BaseRoleEntity.FieldDeletionStateCode, roleEntity.DeletionStateCode);
     sqlBuilder.SetValue(BaseRoleEntity.FieldEnabled, roleEntity.Enabled);
     sqlBuilder.SetValue(BaseRoleEntity.FieldDescription, roleEntity.Description);
     SetEntityExpand(sqlBuilder, roleEntity);
 }
Ejemplo n.º 15
0
 /// <summary>
 /// 更新实体
 /// </summary>
 /// <param name="roleEntity">实体</param>
 public int UpdateEntity(BaseRoleEntity roleEntity)
 {
     SQLBuilder sqlBuilder = new SQLBuilder(DbHelper);
     sqlBuilder.BeginUpdate(this.CurrentTableName);
     this.SetEntity(sqlBuilder, roleEntity);
     if (UserInfo != null)
     {
         sqlBuilder.SetValue(BaseRoleEntity.FieldModifiedUserId, UserInfo.Id);
         sqlBuilder.SetValue(BaseRoleEntity.FieldModifiedBy, UserInfo.RealName);
     }
     sqlBuilder.SetDBNow(BaseRoleEntity.FieldModifiedOn);
     sqlBuilder.SetWhere(BaseRoleEntity.FieldId, roleEntity.Id);
     return sqlBuilder.EndUpdate();
 }
Ejemplo n.º 16
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="roleEntity">实体</param>
 public int Update(BaseRoleEntity roleEntity)
 {
     return this.UpdateEntity(roleEntity);
 }
Ejemplo n.º 17
0
 /// <summary>
 /// 加载窗体
 /// </summary>
 public override void FormOnLoad()
 {
     // 绑定下拉筐数据
     this.BindItemDetails();
     // 获取数据
     if (this.roleEntity == null && !string.IsNullOrEmpty(this.EntityId))
     {
         this.roleEntity = DotNetService.Instance.RoleService.GetEntity(this.UserInfo, this.EntityId);
     }
     // 显示实体
     this.ShowEntity();
 }
Ejemplo n.º 18
0
 /// <summary>
 /// 获得已被选择的权限主键数组
 /// <param name="dataRow">数据行</param>
 /// </summary>
 private void GetSelectedId(DataRow dataRow)
 {
     // 获得当前选中的行
     BaseRoleEntity roleEntity = new BaseRoleEntity();
     roleEntity.GetFrom(dataRow);
     // 获得具体选中的内容
     if (roleEntity.Id > 0)
     {
         this.SelectedId = roleEntity.Id.ToString();
         this.SelectedFullName = roleEntity.RealName;
     }
 }
Ejemplo n.º 19
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="roleEntity">实体</param>
 /// <param name="identity">自增量方式</param>
 /// <param name="returnId">返回主鍵</param>
 /// <returns>主键</returns>
 public string Add(BaseRoleEntity roleEntity, bool identity, bool returnId)
 {
     this.Identity = identity;
     this.ReturnId = returnId;
     return this.AddEntity(roleEntity);
 }
Ejemplo n.º 20
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="roleEntity">实体</param>
        /// <param name="statusCode">返回状态码</param>
        /// <returns>影响行数</returns>
        public int Update(BaseRoleEntity roleEntity, out string statusCode)
        {
            int returnValue = 0;
            // 检查是否已被其他人修改

            if (DbLogic.IsModifed(DbHelper, this.CurrentTableName, roleEntity.Id, roleEntity.ModifiedUserId, roleEntity.ModifiedOn))
            {
                // 数据已经被修改
                statusCode = StatusCode.ErrorChanged.ToString();
            }
            else
            {
                // 检查名称是否重复
                List<KeyValuePair<string, object>> parameters = new List<KeyValuePair<string, object>>();
                parameters.Add(new KeyValuePair<string, object>(BaseRoleEntity.FieldSystemId, roleEntity.SystemId));
                parameters.Add(new KeyValuePair<string, object>(BaseRoleEntity.FieldRealName, roleEntity.RealName));
                parameters.Add(new KeyValuePair<string, object>(BaseRoleEntity.FieldDeletionStateCode, 0));
                if (this.Exists(parameters, roleEntity.Id))
                {
                    // 名称已重复
                    statusCode = StatusCode.ErrorNameExist.ToString();
                }
                else
                {
                    returnValue = this.UpdateEntity(roleEntity);
                    if (returnValue == 1)
                    {
                        statusCode = StatusCode.OKUpdate.ToString();
                    }
                    else
                    {
                        statusCode = StatusCode.ErrorDeleted.ToString();
                    }
                }
            }
            return returnValue;
        }
Ejemplo n.º 21
0
 public FrmRoleWithUser(BaseRoleEntity entity)
     : this()
 {
     this.roleEntity = entity;
 }
Ejemplo n.º 22
0
 /// <summary>
 /// 批量保存
 /// </summary>
 private int BatchSave()
 {
     this.btnBatchSave.Enabled = false;
     int returnValue = 0;
     // 这里需要把没有变动的数据删除掉,这样可以提高效率
     // 去掉未修改的数据,提高运行速度
     for (int i = this.DTRole.Rows.Count - 1; i >= 0; i--)
     {
         if (this.DTRole.Rows[i].RowState == DataRowState.Unchanged)
         {
             this.DTRole.Rows.RemoveAt(i);
         }
     }
     // 泛型化
     List<BaseRoleEntity> roleEntites = new List<BaseRoleEntity>();
     for (int i = 0; i < this.DTRole.Rows.Count; i++)
     {
         BaseRoleEntity roleEntity = new BaseRoleEntity(this.DTRole.Rows[i]);
         roleEntites.Add(roleEntity);
     }
     // 调用后台的批量保存功能
     returnValue = DotNetService.Instance.RoleService.BatchSave(this.UserInfo, roleEntites);
     // 绑定屏幕数据
     this.FormOnLoad(false);
     if (BaseSystemInfo.ShowInformation)
     {
         // 批量保存,进行提示
         MessageBox.Show(AppMessage.MSG0011, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     return returnValue;
 }
Ejemplo n.º 23
0
        private void btnCopy_Click(object sender, EventArgs e)
        {
            // 读取数据
            List<BaseRoleEntity> roleEntites = new List<BaseRoleEntity>();

            for (int i = 0; i < this.DTRole.Rows.Count; i++)
            {
                BaseRoleEntity roleEntity = new BaseRoleEntity(this.DTRole.Rows[i]);
                roleEntites.Add(roleEntity);
            }
            // 复制到剪切板
            Clipboard.SetData("roleEntites", roleEntites);
            this.btnPaste.Enabled = true;
        }
Ejemplo n.º 24
0
 /// <summary>
 /// 读取屏幕数据
 /// </summary>
 /// <returns>岗位实体</returns>
 private BaseRoleEntity GetEntity()
 {
     roleEntity = new BaseRoleEntity();
     roleEntity.OrganizeId = this.ucOrganize.SelectedId;
     roleEntity.Code = this.txtCode.Text;
     roleEntity.RealName = this.txtRealName.Text;
     roleEntity.CategoryCode = "Duty";
     roleEntity.Description = this.txtDescription.Text;
     roleEntity.Enabled = this.chkEnabled.Checked ? 1 : 0;
     roleEntity.AllowDelete = 1;
     roleEntity.AllowEdit = 1;
     roleEntity.DeletionStateCode = 0;
     return roleEntity;
 }
Ejemplo n.º 25
0
        /// <summary>
        /// 设置控件状态
        /// </summary>
        public override void SetControlState()
        {
            this.SetSortButton(false);

            this.btnAdd.Enabled = false;
            this.btnEdit.Enabled = false;
            this.btnExport.Enabled = false;
            this.btnBatchDelete.Enabled = false;
            this.btnRoleUser.Enabled = false;
            this.btnBatchSave.Enabled = false;
            this.btnRoleUserBatchSet.Enabled = false;
            this.btnSelectAll.Enabled = false;
            this.btnInvertSelect.Enabled = false;

            // 检查添加组织机构
            this.btnAdd.Enabled = this.permissionAdd;
            if ((this.DTRole.DefaultView.Count >= 1))
            {
                this.btnEdit.Enabled = this.permissionEdit;
                this.btnExport.Enabled = this.permissionExport;
                this.btnBatchDelete.Enabled = this.permissionDelete;
                this.btnRoleUser.Enabled = this.permissionRoleUser;
                this.btnBatchSave.Enabled = this.permissionEdit;
                this.btnRoleUserBatchSet.Enabled = this.permissionEdit;
            }
            // 位置顺序改变按钮部分
            if (this.DTRole.DefaultView.Count > 1)
            {
                this.SetSortButton(this.permissionEdit);
            }
            if (!this.permissionEdit)
            {
                // 只读属性设置
                this.grdRole.Columns["colSelected"].ReadOnly = !this.permissionEdit;
                this.grdRole.Columns["colEnabled"].ReadOnly = !this.permissionEdit;
                this.grdRole.Columns["colDescription"].ReadOnly = !this.permissionEdit;
                // 修改背景颜色
                this.grdRole.Columns["colEnabled"].DefaultCellStyle.BackColor = Color.White;
                this.grdRole.Columns["colDescription"].DefaultCellStyle.BackColor = Color.White;
            }
            // 用户组是不需要进行权限配置的
            DataRow dataRow = BaseInterfaceLogic.GetDataGridViewEntity(this.grdRole);
            if (dataRow != null)
            {
                BaseRoleEntity roleEntity = new BaseRoleEntity(dataRow);
                // 超级管理员没必要设置权限,设置了权限反而增加误解了
                if (roleEntity.Code != null && roleEntity.Code.Equals(DefaultRole.Administrators.ToString()))
                {
                    this.btnEdit.Enabled = false;
                    this.btnBatchDelete.Enabled = false;
                }
            }
            // 检查委托是否为空
            if (OnButtonStateChange != null)
            {
                bool setTop = this.ucTableSort.SetTopEnabled;
                bool setUp = this.ucTableSort.SetUpEnabled;
                bool setDown = this.ucTableSort.SetDownEnabled;
                bool setBottom = this.ucTableSort.SetBottomEnabled;
                bool add = this.btnAdd.Enabled;
                bool edit = this.btnEdit.Enabled;
                bool batchDelete = this.btnBatchDelete.Enabled;
                bool batchSave = this.btnBatchSave.Enabled;
                OnButtonStateChange(setTop, setUp, setDown, setBottom, add, edit, batchDelete, batchSave);
            }

            if ((this.grdRole .RowCount >= 1))
            {
                this.btnSelectAll.Enabled = this.permissionEdit || this.permissionDelete;
                this.btnInvertSelect.Enabled = this.permissionEdit || this.permissionDelete;
            }
        }
Ejemplo n.º 26
0
 /// <summary>
 /// 添加实体
 /// </summary>
 /// <param name="roleEntity">实体</param>
 public string AddEntity(BaseRoleEntity roleEntity)
 {
     string sequence = string.Empty;
     if (roleEntity.SortCode == 0)
     {
         BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
         sequence = sequenceManager.GetSequence(this.CurrentTableName);
         roleEntity.SortCode = int.Parse(sequence);
     }
     SQLBuilder sqlBuilder = new SQLBuilder(DbHelper, this.Identity, this.ReturnId);
     sqlBuilder.BeginInsert(this.CurrentTableName, BaseRoleEntity.FieldId);
     if (!this.Identity)
     {
         sqlBuilder.SetValue(BaseRoleEntity.FieldId, roleEntity.Id);
     }
     else
     {
         if (!this.ReturnId && (DbHelper.CurrentDbType == DbTypes.Oracle || DbHelper.CurrentDbType == DbTypes.DB2))
         {
             if (DbHelper.CurrentDbType == DbTypes.Oracle)
             {
                 sqlBuilder.SetFormula(BaseRoleEntity.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
             }
             if (DbHelper.CurrentDbType == DbTypes.DB2)
             {
                 sqlBuilder.SetFormula(BaseRoleEntity.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
             }
         }
         else
         {
             if (this.Identity && (DbHelper.CurrentDbType == DbTypes.Oracle || DbHelper.CurrentDbType == DbTypes.DB2))
             {
                 if (roleEntity.Id == null)
                 {
                     if (string.IsNullOrEmpty(sequence))
                     {
                         BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                         sequence = sequenceManager.GetSequence(this.CurrentTableName);
                     }
                     roleEntity.Id = int.Parse(sequence);
                 }
                 sqlBuilder.SetValue(BaseRoleEntity.FieldId, roleEntity.Id);
             }
         }
     }
     this.SetEntity(sqlBuilder, roleEntity);
     if (UserInfo != null)
     {
         sqlBuilder.SetValue(BaseRoleEntity.FieldCreateUserId, UserInfo.Id);
         sqlBuilder.SetValue(BaseRoleEntity.FieldCreateBy, UserInfo.RealName);
     }
     sqlBuilder.SetDBNow(BaseRoleEntity.FieldCreateOn);
     if (UserInfo != null)
     {
         sqlBuilder.SetValue(BaseRoleEntity.FieldModifiedUserId, UserInfo.Id);
         sqlBuilder.SetValue(BaseRoleEntity.FieldModifiedBy, UserInfo.RealName);
     }
     sqlBuilder.SetDBNow(BaseRoleEntity.FieldModifiedOn);
     if (DbHelper.CurrentDbType == DbTypes.SqlServer && this.Identity)
     {
         sequence = sqlBuilder.EndInsert().ToString();
     }
     else
     {
         sqlBuilder.EndInsert();
     }
     return sequence;
 }
Ejemplo n.º 27
0
        /// <summary>
        /// 从Excel文件导入(角色)
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        private bool DoImport(string filePath)
        {
            bool returnValue = false;
            // 鼠标忙碌状态
            this.Cursor = Cursors.WaitCursor;
            try
            {
                //将Excel表转换为DataTable
                string error = "";
                DataTable dataTable = new DataTable();
                AsposeExcelTools.ExcelFileToDataTable(filePath, out dataTable, out error);
                //检查Excell转为DataTable是否成功
                if (error != "")
                {
                    MessageBox.Show(error, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return false;
                }
                //是否有记录
                if (dataTable.Rows.Count > 0)
                {
                    //将第一行数据给数据列置名称,以便于识别和调用数据。
                    int columnsCount = 0;
                    for (columnsCount = 0; columnsCount < dataTable.Columns.Count; columnsCount++)
                    {
                        dataTable.Columns[columnsCount].ColumnName = dataTable.Rows[0][columnsCount].ToString().Trim();
                    }

                    //循环处理每行数据
                    int rowsCount = 0;
                    int errorCount = 0;
                    BaseRoleEntity tempentity;
                    string statusCode = string.Empty;
                    string statusMessage = string.Empty;
                    DataTable dt = DotNetService.Instance .RoleService .GetDataTable (UserInfo);
                    for (rowsCount = 1; rowsCount < dataTable.Rows.Count; rowsCount++)
                    {

                        //角色名称不允许导入重复项
                        bool exists = BaseBusinessLogic.Exists(dt,BaseRoleEntity .FieldRealName , dataTable.Rows[rowsCount ][BaseRoleEntity .FieldRealName ].ToString());
                        if (!exists)
                        {
                            //清空实体
                            tempentity = new BaseRoleEntity();
                            //给实体赋值
                            tempentity.RealName = dataTable.Rows[rowsCount][BaseRoleEntity.FieldRealName].ToString();
                            tempentity.Code = dataTable.Rows[rowsCount][BaseRoleEntity.FieldCode].ToString();
                            tempentity.Description = dataTable.Rows[rowsCount][BaseRoleEntity.FieldDescription].ToString();
                            tempentity.Enabled = int.Parse(dataTable.Rows[rowsCount][BaseRoleEntity.FieldEnabled ].ToString());
                            tempentity.CategoryCode = dataTable.Rows[rowsCount][BaseRoleEntity.FieldCategoryCode ].ToString();
                            tempentity.AllowDelete = 1;
                            tempentity.AllowEdit = 1;
                            tempentity.DeletionStateCode = 0;
                            tempentity.IsVisible = 1;

                            DotNetService.Instance.RoleService.Add(UserInfo, tempentity, out statusCode, out statusMessage);
                        }
                        else
                        {
                            errorCount++;
                        }
                    }
                    this.Changed = true;
                    returnValue = true;
                    MessageBox.Show("共有" + (dataTable.Rows.Count - 1) + "条记录,"
                        + (dataTable.Rows.Count - 1 - errorCount ).ToString()
                        + "条记录被成功导入!", "提示信息",
                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                this.ProcessException(ex);
            }
            finally
            {
                // 设置鼠标默认状态
                this.Cursor = Cursors.Default;
            }
            return returnValue;
        }
Ejemplo n.º 28
0
 public FrmRoleAdd(BaseRoleEntity entity)
     : this()
 {
     this.roleEntity = entity;
 }
Ejemplo n.º 29
0
 private void btnCopy_Click(object sender, EventArgs e)
 {
     // 读取数据
     List<BaseRoleEntity> roleEntites = new List<BaseRoleEntity>();
     for (int i = 0; i < this.cklstRole.CheckedItems.Count; i++)
     {
         BaseRoleEntity roleEntity = new BaseRoleEntity(((System.Data.DataRowView)this.cklstRole.CheckedItems[i]).Row);
         roleEntites.Add(roleEntity);
     }
     // 复制到剪切板
     Clipboard.SetData("roleEntites", roleEntites);
     this.btnPaste.Enabled = true;
 }
Ejemplo n.º 30
0
        /// <summary>
        /// 添加角色
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="role">角色</param>
        /// <returns>主键</returns>
        public string AddRole(BaseUserInfo userInfo, string role)
        {
            // 加强安全验证防止未授权匿名调用
            #if (!DEBUG)
                LogOnService.UserIsLogOn(userInfo);
            #endif

            string returnValue = string.Empty;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseRoleManager roleManager = new BaseRoleManager(dbHelper, userInfo);
                    string statusCode = string.Empty;
                    BaseRoleEntity roleEntity = new BaseRoleEntity();
                    roleEntity.RealName = role;
                    roleEntity.Enabled = 1;
                    returnValue = roleManager.Add(roleEntity, out statusCode);
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

            return returnValue;
        }