diff --git a/SGGL/BLL/Person/Person_ShuntService.cs b/SGGL/BLL/Person/Person_ShuntService.cs index 0eb63821..842db6be 100644 --- a/SGGL/BLL/Person/Person_ShuntService.cs +++ b/SGGL/BLL/Person/Person_ShuntService.cs @@ -38,67 +38,65 @@ namespace BLL /// public static IEnumerable getListData(string workPostId, string postTitleId, string name, string certificateId, Grid Grid1) { - using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) + Model.SGGLDB db = Funs.DB; + IQueryable getDataList = from x in db.Person_Persons + where x.PersonId != Const.sysglyId && x.PersonId != Const.hfnbdId && x.UnitId == Const.UnitId_SEDIN + && x.DepartId == Const.Depart_constructionId + && x.CurrentProjectId == null && (!x.IsOffice.HasValue || x.IsOffice == false) + select x; + if (!string.IsNullOrEmpty(workPostId) && workPostId != Const._Null) { - IQueryable getDataList = from x in db.Person_Persons - where x.PersonId != Const.sysglyId && x.PersonId != Const.hfnbdId && x.UnitId == Const.UnitId_SEDIN - && x.DepartId == Const.Depart_constructionId - && x.CurrentProjectId == null && (!x.IsOffice.HasValue || x.IsOffice == false) - select x; - if (!string.IsNullOrEmpty(workPostId) && workPostId != Const._Null) - { - getDataList = getDataList.Where(e => e.WorkPostId == workPostId); - } - if (!string.IsNullOrEmpty(postTitleId) && postTitleId != Const._Null) - { - getDataList = getDataList.Where(e => e.PostTitleId == postTitleId); - } - - if (!string.IsNullOrEmpty(name)) - { - getDataList = getDataList.Where(e => e.PersonName.Contains(name)); - } - if (!string.IsNullOrEmpty(certificateId) && postTitleId != Const._Null) - { - getDataList = getDataList.Where(e => e.CertificateId.Contains(certificateId)); - } - - count = getDataList.Count(); - if (count == 0) - { - return null; - } - getDataList = SortConditionHelper.SortingAndPaging(getDataList, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize); - return from x in getDataList - select new - { - x.PersonId, - x.PersonName, - x.JobNum, - x.Account, - x.IdentityCard, - Sex = x.Sex ?? "1", - x.Birthday, - x.UnitId, - x.DepartId, - x.WorkPostId, - WorkPostName = WorkPostService.getWorkPostNamesWorkPostIds(db, x.WorkPostId), - x.Major, - x.PostTitleId, - PostTitleName = PostTitleService.getPostTitleNameById(db, x.PostTitleId), - x.IsOffice, - x.RoleIds, - RoleName = RoleService.getRoleNamesRoleIds(db, x.RoleIds), - x.CurrentProjectId, - LastProjectName = getCurrentProjectName(db, x.PersonId), - x.CurrentProjectWorkPostId, - LastWorkPostName = getCurrentProjectWorkPostName(db, x.PersonId), - IsPost = x.IsPost ?? true, - IsPostName = x.IsPost == false ? "否" : "是", - x.SignatureUrl, - x.CertificateId, - }; + getDataList = getDataList.Where(e => e.WorkPostId == workPostId); } + if (!string.IsNullOrEmpty(postTitleId) && postTitleId != Const._Null) + { + getDataList = getDataList.Where(e => e.PostTitleId == postTitleId); + } + + if (!string.IsNullOrEmpty(name)) + { + getDataList = getDataList.Where(e => e.PersonName.Contains(name)); + } + if (!string.IsNullOrEmpty(certificateId) && postTitleId != Const._Null) + { + getDataList = getDataList.Where(e => e.CertificateId.Contains(certificateId)); + } + + count = getDataList.Count(); + if (count == 0) + { + return null; + } + getDataList = SortConditionHelper.SortingAndPaging(getDataList, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize); + return from x in getDataList + select new + { + x.PersonId, + x.PersonName, + x.JobNum, + x.Account, + x.IdentityCard, + Sex = x.Sex ?? "1", + x.Birthday, + x.UnitId, + x.DepartId, + x.WorkPostId, + WorkPostName = WorkPostService.getWorkPostNamesWorkPostIds(db, x.WorkPostId), + x.Major, + x.PostTitleId, + PostTitleName = PostTitleService.getPostTitleNameById(db, x.PostTitleId), + x.IsOffice, + x.RoleIds, + RoleName = RoleService.getRoleNamesRoleIds(db, x.RoleIds), + x.CurrentProjectId, + LastProjectName = getCurrentProjectName(db, x.PersonId), + x.CurrentProjectWorkPostId, + LastWorkPostName = getCurrentProjectWorkPostName(db, x.PersonId), + IsPost = x.IsPost ?? true, + IsPostName = x.IsPost == false ? "否" : "是", + x.SignatureUrl, + x.CertificateId, + }; } #endregion