/// <summary> /// 获取实体分页 /// </summary> public DataTable GetCall_CustomerList(Call_CustomerTO TO, int pageIndex, int pageSize, string orderBy, out int rowCount) { string table = " [Call_Customer] left join UserInfo on UserCode=CC_Owner"; string pk = " CC_ID "; string fields = " * "; string filter = "1=1";// string.Format(" Status={0} ", ConstantsManager.JiLuZhuangTai.Normal); #region 组织查询条件 if (TO.CC_Type > 0) { filter += string.Format(" and CC_Type = {0} ", TO.CC_Type); } if (!string.IsNullOrEmpty(TO.CC_Name)) { filter += string.Format(" and CC_Name like '%{0}%' ", StringHelper.SQLFilter(TO.CC_Name)); } if (!string.IsNullOrEmpty(TO.CC_UserName)) { filter += string.Format(" and CC_UserName like '%{0}%' ", StringHelper.SQLFilter(TO.CC_UserName)); } if (!string.IsNullOrEmpty(TO.CC_Owner)) { filter += string.Format(" and UserName like '%{0}%' ", StringHelper.SQLFilter(TO.CC_Owner)); } #endregion string sort = " CC_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, "Call_CustomerList"); rowCount = (int)parameters[7].Value; return(ds.Tables[0]); }
private void DataBind() { Call_CustomerTO sto = new Call_CustomerTO(); #region 条件 if (!string.IsNullOrEmpty(Request["cname"])) { sto.CC_Name = Request["cname"].ToString().Trim();//存客户名称 } if (!string.IsNullOrEmpty(Request["uname"])) { sto.CC_UserName = Request["uname"].ToString().Trim(); //存用户名称 } if (!string.IsNullOrEmpty(Request["Owner"])) //存 客户所属工程师 { sto.CC_Owner = Request["Owner"].ToString().Trim(); } #endregion if (!string.IsNullOrEmpty(Request.QueryString["pageIndex"])) { pageIndex = int.Parse(Request.QueryString["pageIndex"]); } HYTD.BLL.Call_CustomerBLL bll = new HYTD.BLL.Call_CustomerBLL(); DataTable dt = bll.GetCall_CustomerList(sto, pageIndex, pageSize, "", out rowCount); //分页 string url = "CustomerList.aspx?pageIndex={0}&cname=" + sto.CC_Name + "&uname=" + sto.CC_UserName + "&owner=" + sto.CC_Owner; strtt = DividePage.Pager(pageSize, rowCount, pageIndex, url); if (dt.Rows.Count > 0) { StringBuilder sbContent = new StringBuilder(); string strNew = string.Empty; string strEdit = string.Empty; sbContent.AppendFormat("<tbody>"); foreach (DataRow dr in dt.Rows) { //strNew = string.Format("<a href=\"javascript:;\" onclick=\"EditCustomerInfo({0})\" target=\"_block\">新建</a>", dr["CC_ID"].ToString()); strEdit = string.Format("<a href=\"javascript:void(0);\" onclick=\"EditCustomerInfo({0})\">修改</a>", dr["CC_ID"].ToString()); sbContent.AppendFormat("<tr>"); sbContent.AppendFormat("<td class=\"num\" title=\"{0}\">{0} </td>", dr["UserName"]); sbContent.AppendFormat("<td class=\"by\" title=\"{0}\">[{0}]{1} </td>", dr["CC_ID"], dr["CC_Name"]); sbContent.AppendFormat("<td class=\"num\" title=\"{0}\">{0} </td>", dr["CC_UserName"]); sbContent.AppendFormat("<td class=\"num\" title=\"{0}\">{0} </td>", dr["CC_Tel"]); sbContent.AppendFormat("<td class=\"num\" title=\"{0}\">{0} </td>", getDateTime(dr["CC_CreateTime"].ToString(), 0)); sbContent.AppendFormat("<td class=\"num\" title=\"{0}\">{0} </td>", getDateTime(dr["CC_ServiceStartTime"].ToString(), 1)); sbContent.AppendFormat("<td class=\"num\" title=\"{0}\">{0} </td>", getDateTime(dr["CC_ServiceEndTime"].ToString(), 1)); //sbContent.AppendFormat("<td class=\"num\" title=\"{0}\">{0} </td>", dr["CC_Url"]); //sbContent.AppendFormat("<td class=\"num\" title=\"{0}\">{0} </td>", dr["CC_Remark"]); sbContent.AppendFormat("<td class=\"num\" title=\"{0}\">{0} </td>", getStatusName(dr["CC_Status"].ToString().Trim())); sbContent.AppendFormat("<td class=\"num\" >{0} </td>", strNew + strEdit); sbContent.AppendFormat("</tr>"); } sbContent.AppendFormat("</tbody>"); script = sbContent.ToString(); } else { script = "没有搜索到相关内容!"; } //获取当前页 if (rowCount % pageSize == 0) { pageNum = rowCount / pageSize; } else { pageNum = (rowCount / pageSize) + 1; } }
/// <summary> /// 获得数据列表分页 /// </summary> /// <returns></returns> public DataTable GetCall_CustomerList(Call_CustomerTO TO, int pageIndex, int pageSize, string orderBy, out int rowCount) { return(service.GetCall_CustomerList(TO, pageIndex, pageSize, orderBy, out rowCount)); }