public IActionResult LoadData() { try { var parms = DatatableHelper.GetDatatableParms(Request.Form); int recordsTotal = 0; var data = _depManageBll.Find(z => string.IsNullOrEmpty(parms.searchValue) || z.Name.Contains(parms.searchValue) || z.Address.Contains(parms.searchValue)); recordsTotal = data.Count(); var list = data .Skip(parms.skip) .Take(parms.pageSize) .ToList(); if (!string.IsNullOrEmpty(parms.sortColumn)) { bool isDesc = parms.sortColumnDirection == "desc"; list = OrderDynamicaly.OrderByDynamic <DepartmentMangers>(list.AsQueryable(), parms.sortColumn, isDesc).ToList(); } return(Json(new { parms.draw, recordsFiltered = recordsTotal, recordsTotal, data = list })); } catch (Exception x) { return(Json(new { draw = 0, recordsFiltered = 0, recordsTotal = 0, data = string.Empty })); } }
/// <summary> /// 获取房间信息 /// </summary> private void Getroominfo() { List <Roomtype> lst_roomtype = new List <Roomtype>(); List <Room> lst_room = new List <Room>(); // 获取房间类型 lst_roomtype = (List <Roomtype>)DatatableHelper.ConvertTo <Roomtype>(bll_room.Getroomtype()); for (int i = 0; i < lst_roomtype.Count; i++) { //每一种房间类型作为一个tab添加至tabcontrol tab_roomtype.TabPages.Add(lst_roomtype[i].dmsm1); //每一个tab中的房间自动排列 FlowLayoutPanel flp = new FlowLayoutPanel(); flp.Name = "flp" + i; tab_roomtype.TabPages[i].Controls.Add(flp); //在这一个tab中添加此种类型的所有房间 lst_room = (List <Room>)DatatableHelper.ConvertTo <Room>(bll_room.Getroom(lst_roomtype[i].dmz)); for (int j = 0; j < lst_room.Count; j++) { Button btn = new Button(); btn.Name = lst_room[j].kfbh; //不同状态的房间设置不同的背景图片 switch (lst_room[j].zt) { case "0": btn.Image = Properties.Resources.room0; break; case "1": btn.Image = Properties.Resources.room1; break; case "2": btn.Image = Properties.Resources.room2; break; case "3": btn.Image = Properties.Resources.room3; break; case "4": btn.Image = Properties.Resources.room0; break; } //btn.Image = Properties.Resources.room0; btn.Height = 70; btn.Width = 70; btn.Text = lst_room[j].kfbh; btn.TextAlign = ContentAlignment.BottomCenter; flp.Controls.Add(btn); btn.Click += new EventHandler(aBtn_Click); } } }
public JsonResult Datatable(RoleRequest request) { #region 自定义动作 if (!string.IsNullOrEmpty(request.customActionType)) { List <int> ids = DatatableHelper.ArrayStringToListInt(Request.Params.GetValues("id[]")); switch (request.customActionType) { case "group_action": switch (request.customActionName) { case "delete": this.AccountService.DeleteRole(ids); break; } break; case "delete": this.AccountService.DeleteRole(ids); break; } } #endregion var allRoles = this.AccountService.GetRoleList(null); IEnumerable <Role> filterRoles = allRoles; #region 搜索 if (!string.IsNullOrEmpty(request.search)) { var isNameSearchable = Convert.ToBoolean(Request["columns[0][searchable]"]); } else if (request.action == "filter") { var NameFilter = Convert.ToString(Request["name"]); var isNameSearchable = string.IsNullOrEmpty(Request["columns[1][searchable]"].ToString()) ? false : true; if (isNameSearchable) { filterRoles = filterRoles.Where(c => c.Name.ToLower().Contains(NameFilter)); } } else if (request.action == "filter_cancel") { filterRoles = allRoles; } else { filterRoles = allRoles; } #endregion #region 排序 var isNameSortable = Convert.ToBoolean(Request["columns[1][orderable]"]); var sortColumnIndex = Convert.ToInt32(Request["order[0][column]"]); Func <Role, string> orderingFunction = (c => sortColumnIndex == 1 && isNameSortable ? c.Name : ""); var sortDirection = Request["order[0][dir]"]; // asc or desc if (sortDirection == "asc") { filterRoles = filterRoles.OrderBy(orderingFunction); } if (sortDirection == "desc") { filterRoles = filterRoles.OrderByDescending(orderingFunction); } #endregion var displayedRoles = filterRoles.Skip(request.start).Take(request.length); var result = from c in displayedRoles select new[] { Convert.ToString(c.ID) , c.Name , c.Info , StringUtil.CutString(string.Join(",", c.BusinessPermissionList.Select(r => Evisou.Framework.Utility.EnumHelper.GetEnumTitle(r))), 40) , Convert.ToString(c.ID) }; return(Json(new { draw = request.draw, //param.sEcho, recordsTotal = allRoles.Count(), //alltransactions.Count(), recordsFiltered = filterRoles.Count(), data = result }, JsonRequestBehavior.AllowGet)); }