Exemplo n.º 1
0
        /// <summary>
        /// 按条件分页查询
        /// </summary>
        /// <param name="userId">查看用户</param>
        /// <param name="auditStatus">审核状态</param>
        /// <param name="searchValue">查询字段</param>
        /// <param name="recordCount">记录数</param>
        /// <param name="pageIndex">当前页</param>
        /// <param name="pageSize">每页显示</param>
        /// <param name="sortExpression">排序字段</param>
        /// <param name="sortDire">排序方向</param>
        /// <returns>数据表</returns>
        public DataTable GetDataTableByPage(string userId, string searchValue, out int recordCount, int pageIndex = 1, int pageSize = 20, string sortExpression = "CreateOn", string sortDire = "DESC")
        {
            string whereConditional = CustomerTable.FieldDeleteMark + " = 0 ";
            // 可以看自己公司的数据
            // whereConditional += " AND " + CustomerEntity.FieldCompanyId + " = '" + this.UserInfo.CompanyId + "'";
            // 用户在某个部门
            PiUserManager userManager = new PiUserManager(this.UserInfo);

            if (userManager.IsInOrganize(this.UserInfo.Id, "技术组") || userManager.IsInOrganize(this.UserInfo.Id, "管理组"))
            {
                // 可以看全部
            }
            else if (!string.IsNullOrEmpty(userId))
            {
                // 只能看自己的
                whereConditional += " AND (" + CustomerTable.FieldCreateUserId + " = '" + userId + "')";
            }
            else
            {
                // 可以看自己部门的数据
                // whereConditional += " AND " + CustomerEntity.FieldDepartmentId + " = '" + this.UserInfo.DepartmentId + "'";
            }

            //auditStatus = auditStatus.Trim();
            //if (!string.IsNullOrEmpty(auditStatus))
            //{
            //    auditStatus = this.DBProvider.SqlSafe(auditStatus);
            //    whereConditional += " AND (" + CustomerTable.FieldAuditStatus + " = '" + auditStatus + "')";
            //}

            searchValue = searchValue.Trim();
            if (!string.IsNullOrEmpty(searchValue))
            {
                searchValue = this.DBProvider.SqlSafe(searchValue);
                if (searchValue.IndexOf("%") < 0)
                {
                    searchValue = "'%" + searchValue + "%'";
                }
                whereConditional += " AND (" + CustomerTable.FieldCreateBy + " LIKE " + searchValue;

                whereConditional += " OR " + CustomerTable.FieldFullName + " LIKE " + searchValue;
                whereConditional += " OR " + CustomerTable.FieldShortName + " LIKE " + searchValue;
                whereConditional += " OR " + CustomerTable.FieldCompanyName + " LIKE " + searchValue;
                whereConditional += " OR " + CustomerTable.FieldCompanyAddress + " LIKE " + searchValue;
                whereConditional += " OR " + CustomerTable.FieldPostalCode + " LIKE " + searchValue;
                whereConditional += " OR " + CustomerTable.FieldCompanyPhone + " LIKE " + searchValue;
                whereConditional += " OR " + CustomerTable.FieldCompanyFax + " LIKE " + searchValue;
                whereConditional += " OR " + CustomerTable.FieldWebAddress + " LIKE " + searchValue;
                whereConditional += " OR " + CustomerTable.FieldLicenceNo + " LIKE " + searchValue;
                whereConditional += " OR " + CustomerTable.FieldChieftain + " LIKE " + searchValue;
                whereConditional += " OR " + CustomerTable.FieldBank + " LIKE " + searchValue;
                whereConditional += " OR " + CustomerTable.FieldBankAccount + " LIKE " + searchValue;
                whereConditional += " OR " + CustomerTable.FieldLocalTaxNo + " LIKE " + searchValue;
                whereConditional += " OR " + CustomerTable.FieldNationalTaxNo + " LIKE " + searchValue;
                whereConditional += " OR " + CustomerTable.FieldDescription + " LIKE " + searchValue;

                whereConditional += " OR " + CustomerTable.FieldModifiedBy + " LIKE " + searchValue + ")";
            }
            return(GetDTByPage(out recordCount, pageIndex, pageSize, sortExpression, sortDire, this.CurrentTableName, whereConditional, "*"));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 按条件分页查询
        /// </summary>
        /// <param name="userId">查看用户</param>
        /// <param name="searchValue">查询字段</param>
        /// <param name="recordCount">记录数</param>
        /// <param name="pageIndex">当前页</param>
        /// <param name="pageSize">每页显示</param>
        /// <param name="sortExpression">排序字段</param>
        /// <param name="sortDire">排序方向</param>
        /// <returns>数据表</returns>
        public DataTable GetDataTableByPage(string userId, string searchValue, out int recordCount, int pageIndex = 1, int pageSize = 20, string sortExpression = "CreateOn", string sortDire = "DESC")
        {
            string whereConditional = LinkManTable.FieldDeleteMark + " = 0 ";
            // 可以看自己公司的数据
            // whereConditional += " AND " + LinkManTable.FieldCompanyId + " = '" + this.UserInfo.CompanyId + "'";
            // 用户在某个部门
            PiUserManager userManager = new PiUserManager(this.UserInfo);

            if (userManager.IsInOrganize(this.UserInfo.Id, "技术组") || userManager.IsInOrganize(this.UserInfo.Id, "管理组"))
            {
                // 可以看全部
            }
            else if (!string.IsNullOrEmpty(userId))
            {
                // 只能看自己的
                whereConditional += " AND (" + LinkManTable.FieldCreateUserId + " = '" + userId + "')";
            }
            else
            {
                // 可以看自己部门的数据
                // whereConditional += " AND " + LinkManEntity.FieldDepartmentId + " = '" + this.UserInfo.DepartmentId + "'";
            }

            //auditStatus = auditStatus.Trim();
            //if (!string.IsNullOrEmpty(auditStatus))
            //{
            //    auditStatus = this.DBProvider.SqlSafe(auditStatus);
            //    whereConditional += " AND (" + LinkManTable.FieldAuditStatus + " = '" + auditStatus + "')";
            //}

            searchValue = searchValue.Trim();
            if (!string.IsNullOrEmpty(searchValue))
            {
                searchValue = this.DBProvider.SqlSafe(searchValue);
                if (searchValue.IndexOf("%") < 0)
                {
                    searchValue = "'%" + searchValue + "%'";
                }
                whereConditional += " AND (" + LinkManTable.FieldCreateBy + " LIKE " + searchValue;

                whereConditional += " OR " + LinkManTable.FieldName + " LIKE " + searchValue;
                whereConditional += " OR " + LinkManTable.FieldSex + " LIKE " + searchValue;
                whereConditional += " OR " + LinkManTable.FieldPostion + " LIKE " + searchValue;
                whereConditional += " OR " + LinkManTable.FieldDepartment + " LIKE " + searchValue;
                whereConditional += " OR " + LinkManTable.FieldMobilePhone + " LIKE " + searchValue;
                whereConditional += " OR " + LinkManTable.FieldTelephone + " LIKE " + searchValue;
                whereConditional += " OR " + LinkManTable.FieldShortNumber + " LIKE " + searchValue;
                whereConditional += " OR " + LinkManTable.FieldIDCard + " LIKE " + searchValue;
                whereConditional += " OR " + LinkManTable.FieldOfficeAddress + " LIKE " + searchValue;
                whereConditional += " OR " + LinkManTable.FieldOfficeFax + " LIKE " + searchValue;
                whereConditional += " OR " + LinkManTable.FieldHomePhone + " LIKE " + searchValue;
                whereConditional += " OR " + LinkManTable.FieldEducation + " LIKE " + searchValue;
                whereConditional += " OR " + LinkManTable.FieldSchool + " LIKE " + searchValue;
                whereConditional += " OR " + LinkManTable.FieldDegree + " LIKE " + searchValue;
                whereConditional += " OR " + LinkManTable.FieldHomeZipCode + " LIKE " + searchValue;
                whereConditional += " OR " + LinkManTable.FieldHomeAddress + " LIKE " + searchValue;
                whereConditional += " OR " + LinkManTable.FieldHomeFax + " LIKE " + searchValue;
                whereConditional += " OR " + LinkManTable.FieldNativePlace + " LIKE " + searchValue;
                whereConditional += " OR " + LinkManTable.FieldParty + " LIKE " + searchValue;
                whereConditional += " OR " + LinkManTable.FieldNation + " LIKE " + searchValue;
                whereConditional += " OR " + LinkManTable.FieldNationality + " LIKE " + searchValue;
                whereConditional += " OR " + LinkManTable.FieldMajor + " LIKE " + searchValue;
                whereConditional += " OR " + LinkManTable.FieldEducationalBackground + " LIKE " + searchValue;
                whereConditional += " OR " + LinkManTable.FieldBloodType + " LIKE " + searchValue;
                whereConditional += " OR " + LinkManTable.FieldQQ + " LIKE " + searchValue;
                whereConditional += " OR " + LinkManTable.FieldEmail + " LIKE " + searchValue;
                whereConditional += " OR " + LinkManTable.FieldInterest + " LIKE " + searchValue;
                whereConditional += " OR " + LinkManTable.FieldDescription + " LIKE " + searchValue;

                whereConditional += " OR " + LinkManTable.FieldModifiedBy + " LIKE " + searchValue + ")";
            }

            return(GetDTByPage(out recordCount, pageIndex, pageSize, sortExpression, sortDire, this.CurrentTableName, whereConditional, "*"));
        }
    // 用户是否在某个部门(按编号,按名称的,按简称的)

    #region public bool UserIsInOrganize(string organizeName)
    /// <summary>
    /// 用户是否在某个组织架构里的判断
    /// </summary>
    /// <param name="organizeName">角色编号</param>
    /// <returns>是否在某个角色里</returns>
    public bool UserIsInOrganize(string organizeName)
    {
        var userManager = new PiUserManager(this.RDIFrameworkDbProvider, userInfo);

        return(userManager.IsInOrganize(this.UserInfo.Id, organizeName));
    }