public ActionResult Search(STCheckPeopleSearchModel model) { var data = GetSearchResult(model); DhtmlxGrid grid = new DhtmlxGrid(); int pos = model.posStart.HasValue ? model.posStart.Value : 0; grid.AddPaging(data.TotalCount, pos); var buttons = GetCurrentUserPathActions(); var allSTUnit = GetCurrentInstsST(); var compayTypes = sysDictServcie.GetDictsByKey("customStatus"); for (int i = 0; i < data.Results.Count; i++) { var people = data.Results[i]; DhtmlxGridRow row = new DhtmlxGridRow(people.Id.ToString()); row.AddCell(""); row.AddCell(pos + i + 1); row.AddCell(people.Name); row.AddCell(sTCustomService.GetSTUnitByIdFromAll(allSTUnit, people.Customid)); row.AddCell(people.SelfNum); row.AddCell(people.PostNum); row.AddCell(people.Tel); row.AddCell(SysDictUtility.GetKeyFromDic(compayTypes, people.Approvalstatus)); Dictionary <string, string> dict = new Dictionary <string, string>(); if (HaveButtonFromAll(buttons, "ApplyChange") && sTCheckPeopleService.CanApplyChangeCustom(people.Approvalstatus)) { dict.Add("[申请修改]", "applyChange({0},\"{1}\")".Fmt(people.Id, people.Name)); } if (HaveButtonFromAll(buttons, "ConfirmApplyChange") && (people.Approvalstatus == "5")) { dict.Add("[审核申请修改]", "confirmApplyChange({0},\"{1}\")".Fmt(people.Id, people.Name)); } row.AddLinkJsCells(dict); if (HaveButtonFromAll(buttons, "Edit") && (people.Approvalstatus == "0" || people.Approvalstatus == "6"))// && checkUnitService.CanEditCustom(custom.APPROVALSTATUS)) { row.AddCell(new DhtmlxGridCell("编辑", false).AddCellAttribute("title", "编辑")); } else { row.AddCell(string.Empty); } row.AddCell(new DhtmlxGridCell("查看", false).AddCellAttribute("title", "查看")); grid.AddGridRow(row); } string str = grid.BuildRowXml().ToString(System.Xml.Linq.SaveOptions.DisableFormatting); return(Content(str, "text/xml")); }
public SearchResult <STCheckPeopleUIModel> GetSearchResult(STCheckPeopleSearchModel model) { var predicate = PredicateBuilder.True <t_bp_People_ST>(); //过滤已经删除的机构 predicate = predicate.And(tp => tp.data_status == null || tp.data_status != "-1"); if (!model.Name.IsNullOrEmpty()) { predicate = predicate.And(t => t.Name.Contains(model.Name)); } if (!model.CheckUnitName.IsNullOrEmpty()) { predicate = predicate.And(t => t.Customid == model.CheckUnitName); } if (!model.Status.IsNullOrEmpty()) { predicate = predicate.And(t => t.Approvalstatus == model.Status); } if (model.AgeStart.HasValue) { var ageStarDateTime = DateTime.Now.AddYears(0 - model.AgeStart.Value); predicate = predicate.And(t => t.Birthday.HasValue && t.Birthday.Value <= ageStarDateTime); } if (model.AgeEnd.HasValue) { var ageEndDateTime = DateTime.Now.AddYears(0 - model.AgeEnd.Value); predicate = predicate.And(t => t.Birthday.HasValue && t.Birthday.Value >= ageEndDateTime); } //if (!model.AgeStart.IsNullOrEmpty())// string.IsNullOrEmpty(model.AgeStart.ToString())) // !model.AgeStart.IsNullOrEmpty()) //{ // predicate = predicate.And(t => t.Birthday >=DateTime.Parse(model.AgeStart)); //} //if (!model.AgeEnd.IsNullOrEmpty())// string.IsNullOrEmpty(model.AgeEnd.ToString())) // !model.AgeStart.IsNullOrEmpty()) //{ // predicate = predicate.And(t => t.Birthday <=DateTime.Parse(model.AgeEnd)); //} if (!model.PositionCategory.IsNullOrEmpty()) { predicate = predicate.And(t => t.PostType.Contains(model.PositionCategory));// model.PositionCategory.Contains(t.PostType)); } if (!model.PostCertNum.IsNullOrEmpty()) { predicate = predicate.And(t => t.PostNum.Contains(model.PostCertNum)); } if (!model.TechTitle.IsNullOrEmpty()) { predicate = predicate.And(t => t.postname.Contains(model.TechTitle)); } if (!model.IDnum.IsNullOrEmpty()) { predicate = predicate.And(t => t.SelfNum.Contains(model.IDnum)); } #region 设备查看人员新增此部分 if (model.IsAdmin) { predicate = predicate.And(testc => testc.ismanager == "1"); } if (model.IsCheck) { predicate = predicate.And(t => t.issy == "1"); } if (model.IsTitle) { predicate = predicate.And(t => t.isjs == "1"); } #endregion int pos = model.posStart.HasValue ? model.posStart.Value : 0; int count = model.count.HasValue ? model.count.Value : 30; PagingOptions <t_bp_People_ST> pagingOption = new PagingOptions <t_bp_People_ST>(pos, count, t => new { t.Id }); var people = rep.GetByConditonPage <STCheckPeopleUIModel>(predicate, r => new { r.Id, r.Name, r.Customid, r.SelfNum, r.PostNum, r.Tel, r.Approvalstatus }, pagingOption); return(new SearchResult <STCheckPeopleUIModel>(pagingOption.TotalItems, people)); }