示例#1
0
        /// <summary>
        /// 更新部門資料
        /// </summary>
        public bool UpdateDepartmentData(DeptParams param)
        {
            bool result = false;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                Department entity = empAuthDao.GetEmptyEntity <Department>(new DepartmentRequiredPropValues()
                {
                    DeptId   = param.DeptId,
                    DeptName = ""
                });

                entity.DeptName   = param.DeptName;
                entity.SortNo     = param.SortNo;
                entity.MdfAccount = param.PostAccount;
                entity.MdfDate    = DateTime.Now;

                result   = empAuthDao.UpdateDepartmentData(entity);
                dbErrMsg = empAuthDao.GetErrMsg();

                if (!result && empAuthDao.GetSqlErrNumber() == 50000 && empAuthDao.GetSqlErrState() == 2)
                {
                    param.HasDeptNameBeenUsed = true;
                }
            }

            return(result);
        }
示例#2
0
        /// <summary>
        /// 新增部門資料
        /// </summary>
        public bool InsertDepartmentData(DeptParams param)
        {
            InsertResult insResult = new InsertResult()
            {
                IsSuccess = false
            };

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                Department entity = new Department()
                {
                    DeptName    = param.DeptName,
                    SortNo      = param.SortNo,
                    PostAccount = param.PostAccount,
                    PostDate    = DateTime.Now
                };

                insResult = empAuthDao.InsertDepartmentData(entity);
                dbErrMsg  = empAuthDao.GetErrMsg();

                if (insResult.IsSuccess)
                {
                    param.DeptId = (int)insResult.NewId;
                }
                else if (empAuthDao.GetSqlErrNumber() == 50000 && empAuthDao.GetSqlErrState() == 2)
                {
                    param.HasDeptNameBeenUsed = true;
                }
            }

            return(insResult.IsSuccess);
        }
示例#3
0
        /// <summary>
        /// 新增員工身分資料
        /// </summary>
        public bool InsertEmployeeRoleData(RoleParams param)
        {
            InsertResult insResult = new InsertResult()
            {
                IsSuccess = false
            };

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                EmployeeRole entity = new EmployeeRole()
                {
                    RoleName        = param.RoleName,
                    RoleDisplayName = param.RoleDisplayName,
                    SortNo          = param.SortNo,
                    PostAccount     = param.PostAccount,
                    PostDate        = DateTime.Now
                };

                insResult = empAuthDao.InsertEmployeeRoleData(entity, param.CopyPrivilegeFromRoleName);
                dbErrMsg  = empAuthDao.GetErrMsg();

                if (insResult.IsSuccess)
                {
                    param.RoleId = entity.RoleId;
                }
                else if (empAuthDao.GetSqlErrNumber() == 50000 && empAuthDao.GetSqlErrState() == 2)
                {
                    param.HasRoleBeenUsed = true;
                }
            }

            return(insResult.IsSuccess);
        }
示例#4
0
        /// <summary>
        /// 刪除後端作業選項
        /// </summary>
        public bool DeleteOperationData(OpParams param)
        {
            bool result = false;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                result   = empAuthDao.DeleteOperationData(param.OpId);
                dbErrMsg = empAuthDao.GetErrMsg();

                if (!result && empAuthDao.GetSqlErrNumber() == 50000 && empAuthDao.GetSqlErrState() == 2)
                {
                    param.IsThereSubitemOfOp = true;
                }
            }

            return(result);
        }
示例#5
0
        /// <summary>
        /// 刪除部門資料
        /// </summary>
        public bool DeleteDepartmentData(DeptParams param)
        {
            bool result = false;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                result   = empAuthDao.DeleteDepartmentData(param.DeptId);
                dbErrMsg = empAuthDao.GetErrMsg();

                if (!result && empAuthDao.GetSqlErrNumber() == 50000 && empAuthDao.GetSqlErrState() == 2)
                {
                    param.IsThereAccountsOfDept = true;
                }
            }

            return(result);
        }