public ActionResult Create() { ViewBag.Donvi = new SelectList(db.getDonVi(true, Session["year"].ToString()), "MaDonVi", "TenDonVi"); ViewBag.LinhVuc = new SelectList(db.TD_LVKT, "MA", "TEN"); ViewBag.LoaiHinh = new SelectList(db.TD_LHKT, "MA", "TEN"); return(PartialView()); }
public ActionResult AjaxHandler(jQueryDataTableParamModel param) { var allResult = db.getDonVi(null, "").ToList(); IEnumerable <getDonVi_Result> filteredResult; //Check whether the companies should be filtered by keyword if (!string.IsNullOrEmpty(param.sSearch)) { //Optionally check whether the columns are searchable at all var Searchable_0 = Convert.ToBoolean(Request["bSearchable_0"]); var Searchable_1 = Convert.ToBoolean(Request["bSearchable_1"]); var Searchable_2 = Convert.ToBoolean(Request["bSearchable_2"]); int tmp = int.TryParse(param.sSearch, out tmp) ? tmp : 0; filteredResult = allResult .Where(c => Searchable_1 && c.MaDonVi.ToLower().Contains(param.sSearch.ToLower()) || Searchable_2 && c.TenDonVi.ToLower().Contains(param.sSearch.ToLower()) || Searchable_0 && c.STT.Equals(tmp) ); } else { filteredResult = allResult; } var Sortable_0 = Convert.ToBoolean(Request["bSortable_0"]); var Sortable_1 = Convert.ToBoolean(Request["bSortable_1"]); var Sortable_2 = Convert.ToBoolean(Request["bSortable_2"]); var sortColumnIndex = Convert.ToInt64(Request["iSortCol_0"]); Func <getDonVi_Result, string> orderingFunction = (c => sortColumnIndex == 1 && Sortable_1 ? c.MaDonVi : sortColumnIndex == 2 && Sortable_2 ? c.TenDonVi : ""); Func <getDonVi_Result, Int64> orderingFunction2 = (c => sortColumnIndex == 0 && Sortable_0 ? c.STT : 0); var sortDirection = Request["sSortDir_0"]; // asc or desc if (sortDirection == "asc") { filteredResult = filteredResult.OrderBy(orderingFunction).ThenBy(orderingFunction2); } else { filteredResult = filteredResult.OrderByDescending(orderingFunction).ThenByDescending(orderingFunction2); } var displayed = filteredResult.Skip(param.iDisplayStart).Take(param.iDisplayLength); var result = displayed.Select(c => new { col0 = c.STT, col1 = c.MaDonVi, col2 = c.TenDonVi, col3 = c.CanAudit ? "<span class='btn btn-md btn-success glyphicon glyphicon-ok-circle'></span>" : "<span class='btn btn-md btn-warning glyphicon glyphicon-remove-circle'></span>", col4 = (c.BeginDate != null) ? String.Format("{0: dd/MM/yyyy}", c.BeginDate) : "", col5 = (c.EndDate != null) ? String.Format("{0: dd/MM/yyyy}", c.EndDate) : "Đang hoạt động", }); return(Json(new { sEcho = param.sEcho, iTotalRecords = allResult.Count(), iTotalDisplayRecords = filteredResult.Count(), aaData = result }, JsonRequestBehavior.AllowGet)); }
// // GET: /Users/ public ActionResult Index() { ViewBag.Donvi = new SelectList(db.getDonVi(null, DateTime.Today.Year.ToString()), "MaDonVi", "TenDonVi"); return(View()); }