public ActionResult GetRepairRecordInfo(RepairRecordSearchModel model, int searchPage) { SearchDataWithPagedDatas <RepairRecordSearchModel, RepairRecordModel> result = new SearchDataWithPagedDatas <RepairRecordSearchModel, RepairRecordModel>(); result.SearchModel = model; //时间搜索设置不正确直接返回count为0 result.PagedDatas = RepairRecordBLL.GetPagedRepairRecord(model, searchPage, this.PageSize, this.CurrentStrucID); return(PartialView("_RepairRecordPageGrid", result)); }
public static AsiatekPagedList <RepairRecordModel> GetPagedRepairRecord(RepairRecordSearchModel model, int searchPage, int pageSize, int currentStrucID) { string joinStr = string.Format(@" INNER JOIN dbo.Vehicles v ON v.ID = r.LinkedVehicleID INNER JOIN Func_GetStrucAndSubStrucByUserAffiliatedStrucID({0}) s ON v.StrucID = s.ID", currentStrucID); List <SqlParameter> paras = new List <SqlParameter>() { new SqlParameter("@tableName", "RepairRecord r"), new SqlParameter("@joinStr", joinStr), new SqlParameter("@pageSize", pageSize), new SqlParameter("@currentPage", searchPage), new SqlParameter("@orderBy", "r.ID"), new SqlParameter("@showColumns", @"r.ID,r.PlateNum,r.DriverName,r.DriverPhone,r.RepairStartTime,r.RepairEndTime ,r.RepairType ,r.TotalPrice,r.Status,(select NickName from Users where ID=r.OperateUserID) AS OperateUserName,(select NickName from Users where ID=r.AuditUserID) AS AuditUserName"), }; string conditionStr = " 1=1 ";//不查询删除和报废的 if (!string.IsNullOrWhiteSpace(model.PlateNum)) { conditionStr += " AND r.PlateNum LIKE '%" + model.PlateNum + "%'"; } if (!string.IsNullOrWhiteSpace(model.Status) && model.Status != "-1") { conditionStr += " AND r.Status='" + model.Status + "'"; } if (model.RepairStartTimestart != DateTime.MinValue && model.RepairStartTimeend != DateTime.MinValue && model.RepairStartTimeend >= model.RepairStartTimestart) { conditionStr += " AND r.RepairStartTime Between '" + model.RepairStartTimestart + "' and '" + model.RepairStartTimeend.AddDays(1) + "'"; } else if (model.RepairStartTimestart != DateTime.MinValue && model.RepairStartTimeend != DateTime.MinValue && model.RepairStartTimeend < model.RepairStartTimestart) { return(new AsiatekPagedList <RepairRecordModel>(new List <RepairRecordModel>(), 1, 10, 0)); } else if (model.RepairStartTimestart == DateTime.MinValue && model.RepairStartTimeend != DateTime.MinValue) { conditionStr += " AND r.RepairStartTime< '" + model.RepairStartTimeend.AddDays(1) + "'"; } else if (model.RepairStartTimestart != DateTime.MinValue && model.RepairStartTimeend == DateTime.MinValue) { conditionStr += " AND r.RepairStartTime> '" + model.RepairStartTimestart + "'"; } if (!string.IsNullOrWhiteSpace(conditionStr)) { paras.Add(new SqlParameter("@conditionStr", conditionStr)); } 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 <RepairRecordModel> list = ConvertToList <RepairRecordModel> .Convert(MSSQLHelper.ExecuteDataTable(CommandType.StoredProcedure, "Proc_GetPagedDatas", paras.ToArray())); foreach (var recordmodel in list) { recordmodel.RepairStartTime = Convert.ToDateTime(recordmodel.RepairStartTime).ToString("yyyy-MM-dd"); recordmodel.RepairEndTime = Convert.ToDateTime(recordmodel.RepairEndTime).ToString("yyyy-MM-dd"); } int totalItemCount = Convert.ToInt32(paras[paras.Count - 2].Value); int newCurrentPage = Convert.ToInt32(paras[paras.Count - 1].Value); return(list.ToPagedList(newCurrentPage, pageSize, totalItemCount)); }