public MasterJobList GetListForGrid(int RecCount, int PageNo, string OrderBy) { strSql = "WITH TempTable AS (Select JobDetails.JobCode,JobDetails.CurrentStatus,MasterModel.Name As ModelNumber,MasterModel.Code As ModelCode,MasterBrand.Code As BrandCode,MasterBrand.Name As BrandName,MasterDeviceType.Code As DeviceCode,MasterDeviceType.Name As DType From JobDetails JobDetails Inner Join MasterDeviceType On JobDetails.DType=MasterDeviceType.Code Inner Join MasterBrand On JobDetails.BCode=MasterBrand.Code Inner join MasterModel on JobDetails.ModelNumber=MasterModel.Code, ROW_NUMBER() OVER (ORDER BY '" + OrderBy + "') AS 'RowNumber' FROM JobDetails WHERE 1 = 1 " + strFilter + ") SELECT * FROM TempTable WHERE RowNumber BETWEEN " + ((PageNo == 1) ? 1 : ((PageNo - 1) * RecCount) + 1).ToString() + " AND " + ((PageNo == 1) ? RecCount : (PageNo * RecCount)).ToString().ToString(); MasterJobList objList = new MasterJobList(); DataTable dt = new DataTable(); dt = objDB.GetDataTableFromSQL(strSql); if (dt != null) { foreach (DataRow Dr in dt.Rows) { jobs obj = new jobs(); obj.JobCode =Convert.ToInt32(Dr["JobCode"].ToString()); if (Dr["DType"] != DBNull.Value) obj.DType = Dr["DType"].ToString(); else obj.DType = ""; if (Dr["BrandName"] != DBNull.Value) obj.BrandName = Dr["BrandName"].ToString(); else obj.BrandName = ""; if (Dr["ModelNumber"] != DBNull.Value) obj.ModelNumber = Dr["ModelNumber"].ToString(); else obj.ModelNumber = ""; if (Dr["CurrentStatus"] != DBNull.Value) obj.CurrentStatus = Dr["CurrentStatus"].ToString(); else obj.CurrentStatus = ""; objList.Add(obj); } } return objList; }
(ORDER BY '" + OrderBy + "')
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)