public ActionResult GetMaintenanceSchedule(MaintenanceScheduleSearchModel model, int searchPage) { SearchDataWithPagedDatas <MaintenanceScheduleSearchModel, MaintenanceScheduleListModel> result = new SearchDataWithPagedDatas <MaintenanceScheduleSearchModel, MaintenanceScheduleListModel>(); result.SearchModel = model; result.PagedDatas = MaintenanceScheduleBLL.GetPagedMaintenanceSchedule(result.SearchModel, searchPage, this.PageSize, CurrentStrucID); return(PartialView("_MaintenanceSchedulePagedGrid", result)); }
/// <summary> /// 获取当前单位及其子单位下的保养方案记录 /// </summary> /// <returns></returns> public static AsiatekPagedList <MaintenanceScheduleListModel> GetPagedMaintenanceSchedule(MaintenanceScheduleSearchModel model, int searchPage, int pageSize, int currentStrucID) { string joinStr = string.Format(@" INNER JOIN dbo.Users u ON u.ID = ms.CreateUser INNER JOIN Func_GetStrucAndSubStrucByUserAffiliatedStrucID({0}) st ON st.ID=u.StrucID LEFT JOIN (SELECT COUNT(*) AS BindVehicleNum,ScheduleID FROM dbo.VehicleMaintenance GROUP BY ScheduleID) num ON num.ScheduleID=ms.ID", currentStrucID); List <SqlParameter> paras = new List <SqlParameter>() { new SqlParameter("@tableName", "dbo.MaintenanceSchedule AS ms "), new SqlParameter("@joinStr", joinStr), new SqlParameter("@pageSize", pageSize), new SqlParameter("@currentPage", searchPage), new SqlParameter("@orderBy", "ms.ID DESC"), new SqlParameter("@showColumns", @" ms.ID,ms.ScheduleName,ms.RulesType,ms.Remark,st.StrucName,u.UserName AS CreateUser,num.BindVehicleNum "), }; #region 筛选条件 string conditionStr = " 1=1 "; if (!string.IsNullOrWhiteSpace(model.SearchScheduleName)) { conditionStr += " AND ms.ScheduleName LIKE '%" + model.SearchScheduleName + "%'"; } if (model.SearchStrucID != -1) { conditionStr += " AND u.StrucID = " + model.SearchStrucID + ""; } if (!string.IsNullOrWhiteSpace(conditionStr)) { paras.Add(new SqlParameter("@conditionStr", conditionStr)); } #endregion paras.Add(new SqlParameter() { ParameterName = "@totalItemCount", Direction = ParameterDirection.Output, SqlDbType = SqlDbType.Int }); paras.Add(new SqlParameter() { ParameterName = "@newCurrentPage", Direction = ParameterDirection.Output, SqlDbType = SqlDbType.Int }); List <MaintenanceScheduleListModel> list = ConvertToList <MaintenanceScheduleListModel> .Convert(MSSQLHelper.ExecuteDataTable(CommandType.StoredProcedure, "Proc_GetPagedDatas", paras.ToArray())); int totalItemCount = Convert.ToInt32(paras[paras.Count - 2].Value); int newCurrentPage = Convert.ToInt32(paras[paras.Count - 1].Value); return(list.ToPagedList(newCurrentPage, pageSize, totalItemCount)); }