private void GetPaged() { int recordCount = 0; ProjectFilter filter = new ProjectFilter(); string name = GetRequest("name"); string adress = GetRequest("adress"); if(!string.IsNullOrEmpty(name)){ filter.ProjName = name; } if(!string.IsNullOrEmpty(adress)){ filter.ProjAddress = adress; } List<Project> projects = _ProjectService.GetProjectList(filter,PageSize,PageIndex,ref recordCount); EasyUiGrid<Project> data = new EasyUiGrid<Project>(); data.total = recordCount; data.rows = projects; Json(data); }
public List<Project> GetProjects(ProjectFilter filter,int pageSize,int pageIndex,ref int recordCount) { SqlParameter[] parameters = { SqlParamHelper.MakeParam("@RecordNum",SqlDbType.Int,4,ParameterDirection.InputOutput,recordCount), SqlParamHelper.MakeInParam("@SelectList",SqlDbType.VarChar,2000,PROJECT_FIELDS), SqlParamHelper.MakeInParam("@TableSource",SqlDbType.VarChar,100,"[GES_Project]"), SqlParamHelper.MakeInParam("@SearchCondition",SqlDbType.VarChar,2000,GetSearchCondition(filter)), SqlParamHelper.MakeInParam("@OrderExpression",SqlDbType.VarChar,1000,"[ProjCreateTime] DESC"), SqlParamHelper.MakeInParam("@PageSize",SqlDbType.Int,4,pageSize), SqlParamHelper.MakeInParam("@PageIndex",SqlDbType.Int,4,pageIndex) }; List<Project> list = new List<Project>(); using (IDataReader dr = SqlHelper.ExecuteReader(ReadConnectionString,CommandType.StoredProcedure,"PR_GetDataByPageIndex",parameters)){ while(dr.Read()){ list.Add(BindProject(dr)); } } recordCount = Convert.ToInt32(parameters[0].Value); return list; }
public List<Project> GetProjects(ProjectFilter filter,int uid,int pageSize,int pageIndex,ref int recordCount) { return _ProjectRepository.GetProjects(filter,uid,pageSize,pageIndex,ref recordCount); }
public List<Project> GetProjects(ProjectFilter filter,int uid,int pageSize,int pageIndex,ref int recordCount) { SqlParameter[] parameters = { SqlParamHelper.MakeInParam("@Uid",SqlDbType.Int,4,uid), SqlParamHelper.MakeInParam("@ps",SqlDbType.Int,4,pageSize), SqlParamHelper.MakeInParam("@pi",SqlDbType.Int,4,pageIndex) }; string cmdText = string.Format(@" select count(1) from GES_Project where ProjId in ( select ProjId from RolesProjRight where RolesId in ( select RolesId from UserRoles where Uid=@Uid ) ) and {0}",GetSearchCondition(filter)); object obj = SqlHelper.ExecuteScalar(ReadConnectionString,CommandType.Text,cmdText,parameters); recordCount = Convert.ToInt32(obj); List<Project> list = new List<Project>(); if(recordCount > 0){ cmdText = string.Format(@" select top (@ps) * from ( select ROW_NUMBER() over(order by ProjId) as Rownum,{0} from GES_Project where ProjId in ( select ProjId from RolesProjRight where RolesId in ( select RolesId from UserRoles where Uid=@Uid ) ) ) a where Rownum>@ps*(@pi-1) and {1}",PROJECT_FIELDS,GetSearchCondition(filter)); using (IDataReader dr = SqlHelper.ExecuteReader(ReadConnectionString,CommandType.Text,cmdText,parameters)){ while(dr.Read()){ list.Add(BindProject(dr)); } } } return list; }
private string GetSearchCondition(ProjectFilter filter) { StringBuilder condition = new StringBuilder("1=1"); if(!filter.ProjName.IsNullOrEmpty()){ condition.Append(string.Format(" and projname like '%{0}%'",filter.ProjName.Trim().ToSafeSql())); } if(!filter.ProjAddress.IsNullOrEmpty()){ condition.Append(string.Format(" and ProjAddress like '%{0}%'",filter.ProjAddress.Trim().ToSafeSql())); } return condition.ToString(); }
private void GetProjects() { int recordCount = 0; ProjectFilter filter = new ProjectFilter(); List<Project> list = _ProjectService.GetProjects(filter,UserContext.Instance.CurrentUser.Uid,int.MaxValue,1,ref recordCount); EasyUiGrid<Project> data = new EasyUiGrid<Project>(); data.total = recordCount; data.rows = list; Json(data); }
private void GetProRight() { int roleId = GetRequest("roleId").ToInt32(); ProjectFilter filter = new ProjectFilter(); int recordCount = 0; List<Project> list = _ProjectService.GetProjects(filter,UserContext.Instance.CurrentUser.Uid,PageSize,PageIndex,ref recordCount); EasyUiGrid<Project> data = new EasyUiGrid<Project>(); data.total = recordCount; data.rows = list; Json(data); }