/// <summary> /// 获取实体分页 /// </summary> public DataTable GetCall_VisitBillList(Call_VisitBillTO TO, int pageIndex, int pageSize, string orderBy, out int rowCount) { //string table = " [Call_VisitBill] "; //string pk = " CVB_ID "; //string fields = " * "; //string filter ="";// string.Format(" Status={0} ", ConstantsManager.JiLuZhuangTai.Normal); string table = @" Call_VisitBill a left join dbo.Call_Customer b on a.CVB_CCID=b.CC_ID left join dbo.[UserInfo] c1 on c1.UserCode=b.CC_Owner left join dbo.[UserInfo] c on c.UserCode=a.CVB_Creater left join dbo.[UserInfo] d on d.UserCode=a.CVB_ForUser left join Call_Category e on e.C_ID=a.CVB_Type and e.c_type=1 left join Call_Category f on f.C_ID=a.CVB_Status and f.c_type=3"; string pk = " CVB_ID "; string fields = @" CVB_ID,CVB_CCID,CVB_CWB_ID,CC_ID,CC_Name,CC_UserName,CC_Tel,CVB_Type,CVB_Creater,CVB_CreateTime, CVB_ForUser,CVB_OperationTime,c.UserName CreateUserName,d.UserName ServiceUserName,f.C_Name CVB_Status,e.C_Name "; string filter = "1=1";// string.Format(" Status={0} ", ConstantsManager.JiLuZhuangTai.Normal); #region 组织查询条件 if (TO.CVB_Type > 0) { filter += string.Format(" and CVB_Type = {0} ", TO.CVB_Type); } if (!string.IsNullOrEmpty(TO.CVB_Solution)) { filter += string.Format(" and c.UserName like '%{0}%' ", StringHelper.SQLFilter(TO.CVB_Solution)); } if (!string.IsNullOrEmpty(TO.CVB_Description)) { filter += string.Format(" and c1.UserName like '%{0}%' ", StringHelper.SQLFilter(TO.CVB_Description)); } if (!string.IsNullOrEmpty(TO.CVB_Remark)) { filter += string.Format(" and CC_Name like '%{0}%' ", StringHelper.SQLFilter(TO.CVB_Remark)); } if (TO.CVB_CreateTime > Convert.ToDateTime("1979-01-01")) { filter += string.Format(" and CVB_CreateTime >= '{0}' ", TO.CVB_CreateTime.ToString("yyyy-MM-dd")); } if (TO.CVB_OperationTime > Convert.ToDateTime("1979-01-01")) { filter += string.Format(" and CVB_CreateTime < '{0}' ", TO.CVB_OperationTime.AddDays(1).ToString("yyyy-MM-dd")); } #endregion string sort = " CVB_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_VisitBillList"); rowCount = (int)parameters[7].Value; return(ds.Tables[0]); }
/// <summary> /// 获得数据列表分页 /// </summary> /// <returns></returns> public DataTable GetCall_VisitBillList(Call_VisitBillTO TO, int pageIndex, int pageSize, string orderBy, out int rowCount) { return(service.GetCall_VisitBillList(TO, pageIndex, pageSize, orderBy, out rowCount)); }
private void DataBind() { Call_VisitBillTO sto = new Call_VisitBillTO(); #region 条件 if (!string.IsNullOrEmpty(Request["cname"])) { sto.CVB_Remark = Request["cname"].ToString().Trim();//存客户名称 } if (!string.IsNullOrEmpty(Request["uname"])) { sto.CVB_Solution = Request["uname"].ToString().Trim();//存用户名称 } else { sto.CVB_Solution = strLoginUserName; } if (!string.IsNullOrEmpty(Request["Owner"])) //存 客户所属工程师 { sto.CVB_Description = Request["Owner"].ToString().Trim(); } if (!string.IsNullOrEmpty(Request["stime"])) { DateTime dtStime = Convert.ToDateTime("1980-01-01"); DateTime.TryParse(Request["stime"].ToString().Trim(), out dtStime); sto.CVB_CreateTime = dtStime;//保存操作开始时间 } if (!string.IsNullOrEmpty(Request["etime"])) { DateTime dtEtime = Convert.ToDateTime("2250-01-01"); DateTime.TryParse(Request["etime"].ToString().Trim(), out dtEtime); sto.CVB_OperationTime = dtEtime;//保存操作结束时间 } if (!string.IsNullOrEmpty(Request["sltType"])) { sto.CVB_Type = Convert.ToInt16(Request["sltType"].ToString().Trim()); intSelected = sto.CVB_Type; } #endregion if (!string.IsNullOrEmpty(Request.QueryString["pageIndex"])) { int.TryParse(Request.QueryString["pageIndex"], out pageIndex); } HYTD.BLL.Call_VisitBillBLL bll = new HYTD.BLL.Call_VisitBillBLL(); DataTable dt = bll.GetCall_VisitBillList(sto, pageIndex, pageSize, "", out rowCount); //分页 string getUrl = ""; if (Request.Url.Query.Length > 0 && Request.Url.Query.IndexOf("pageIndex") > -1 && Request.Url.Query.IndexOf("&") > -1) { getUrl = Request.Url.Query.Substring(Request.Url.Query.IndexOf("&")); } else if (Request.Url.Query.Length > 0) { getUrl = Request.Url.Query.Substring(1); } string url = "VisitBillList.aspx?pageIndex={0}&" + getUrl.Trim('&'); strtt = DividePage.Pager(pageSize, rowCount, pageIndex, url); if (dt.Rows.Count > 0) { StringBuilder sbContent = new StringBuilder(); string strNew = string.Empty; string strEdit = string.Empty; foreach (DataRow dr in dt.Rows) { strNew = string.Empty;; strEdit = string.Format("<a href=\"#\" name=\"EditWorkBill\" onclick=\"EditWorkBill({0},{1})\">修改</a>", dr["CVB_ID"].ToString(), dr["CVB_CWB_ID"].ToString()); sbContent.AppendFormat("<tbody>"); sbContent.AppendFormat("<tr>"); sbContent.AppendFormat("<td class=\"num\" title=\"{0}\">{0} </td>", dr["C_Name"].ToString()); sbContent.AppendFormat("<td class=\"by\" style=\"width:120px;\" title=\"{0}\">{0} </td>", dr["CC_Name"]); sbContent.AppendFormat("<td class=\"num\" title=\"{0}\">{0} </td>", dr["CWB_CallInUserName"]); sbContent.AppendFormat("<td class=\"num\" title=\"{0}\">{0} </td>", dr["CWB_CallInTel"]); sbContent.AppendFormat("<td class=\"num\" title=\"{0}\">{0} </td>", dr["CreateUserName"]); sbContent.AppendFormat("<td class=\"num\" style=\"width:100px;\" title=\"{0}\">{0} </td>", getDataFormate(dr["CVB_CreateTime"].ToString())); sbContent.AppendFormat("<td class=\"num\" title=\"{0}\">{0} </td>", dr["ServiceUserName"]); sbContent.AppendFormat("<td class=\"num\" style=\"width:100px;\" title=\"{0}\">{0} </td>", getDataFormate(dr["CVB_OperationTime"].ToString())); sbContent.AppendFormat("<td class=\"num\" title=\"{0}\">{0} </td>", dr["CVB_Status"].ToString()); sbContent.AppendFormat("<td class=\"num\" title=\"{0}\">{0} </td>", "服务记录"); 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; //} }