/// <summary> /// 职位列表 /// </summary> private void GetPositionList() { PositionTO to = new PositionTO(); if (!string.IsNullOrEmpty(Request.Form["PositName"])) { to.Name = pName = Request.Form["PositName"]; } string orderBy = ""; if (!string.IsNullOrEmpty(Request.Form["hidPosit"])) { pageIndex = Convert.ToInt32(Request.Form["hidPosit"]); } else { if (!string.IsNullOrEmpty(Request.QueryString["pageIndex"])) { pageIndex = Convert.ToInt32(Request.QueryString["pageIndex"]); } } DataTable dt = new PositionBLL().GetPositionList(to, pageIndex, pageSize, orderBy, out rowCount); StringBuilder sb = new StringBuilder(); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { DataRow dr = dt.Rows[i]; if (i % 2 == 0) { sb.Append("<tr bgcolor=\"#f8f8f8\">"); } else { sb.Append("<tr>"); } sb.AppendFormat("<td height=\"40\" align=\"center\"><span class=\"line\" style=\"COLOR: #666;\">{0}</span></td>", i + 1); sb.AppendFormat("<td><span class=\"line cl_sp\" style=\"COLOR: #666;\">{0}</span><span class=\"line cl_inp\" style=\"COLOR: #666;display:none;\"><input type=\"text\" value=\"{0}\" style=\"width:120px;\"/></span></td>", dr["Name"]); sb.AppendFormat("<td><span class=\"bottom cl_block\"><a style=\"color:#3B96D3;\" href=\"javascript:void(0)\" onclick=\"UpdatePosit({0})\">修改</a>   <a style=\"color:#3B96D3;\" onclick=\"delPosition('{1}')\" href=\"javascript:void(0)\">删除</a></span> <span class=\"bottom cl_none\" style=\"display:none;\"><a style=\"color:#3B96D3;\" href=\"javascript:void(0)\" onclick=\"SavePosit({0},'{1}')\">保存</a>   <a style=\"color:#3B96D3;\" href=\"javascript:void(0)\" onclick=\"CanclePosit({0})\">取消</a></span> </td></tr>", i, dr["ID"]); } } else { sb.Append("<tr bgcolor=\"#f8f8f8\"><td colspan=\"10\"><span class=\"line\">没有相关信息!</span></td></tr>"); } positList = sb.ToString(); string url = "PositionList.aspx?pageIndex={0}"; if (!string.IsNullOrEmpty(pName)) { url += "&PositName=" + pName; } PageList = DivPage.Pager(pageSize, rowCount, pageIndex, url); }
/// <summary> /// 获取实体分页 /// </summary> public DataTable GetPositionList(PositionTO TO, int pageIndex, int pageSize, string orderBy, out int rowCount) { string table = " [Position] "; string pk = " ID "; string fields = " * "; string filter = " 1=1 ";// string.Format(" Status={0} ", ConstantsManager.JiLuZhuangTai.Normal); #region 组织查询条件 if (!string.IsNullOrEmpty(TO.Name)) { filter += string.Format(" and Name like '%{0}%' ", StringHelper.SQLFilter(TO.Name)); } #endregion string sort = " ID DESC ";//排序 if (!string.IsNullOrEmpty(orderBy)) { sort = orderBy; } SqlParameter[] parameters = { new SqlParameter("@Tables", SqlDbType.VarChar, 1000), new SqlParameter("@PK", SqlDbType.VarChar, 100), new SqlParameter("@Fields", SqlDbType.VarChar, 1000), new SqlParameter("@Pageindex", SqlDbType.Int), new SqlParameter("@PageSize", SqlDbType.Int), new SqlParameter("@Filter", SqlDbType.VarChar, 1000), new SqlParameter("@Sort", SqlDbType.VarChar, 200), new SqlParameter("@RowCount", SqlDbType.Int) }; parameters[0].Value = table; parameters[1].Value = pk; parameters[2].Value = fields; parameters[3].Value = pageIndex; parameters[4].Value = pageSize; parameters[5].Value = filter; parameters[6].Value = sort; parameters[7].Direction = ParameterDirection.Output; DataSet ds = SqlHelper.RunProcedure("SP_DividePage", parameters, "PositionList"); rowCount = (int)parameters[7].Value; return(ds.Tables[0]); }
/// <summary> /// 获得数据列表分页 /// </summary> /// <returns></returns> public DataTable GetPositionList(PositionTO TO, int pageIndex, int pageSize, string orderBy, out int rowCount) { return(service.GetPositionList(TO, pageIndex, pageSize, orderBy, out rowCount)); }