protected void Page_Load(object sender, EventArgs e) { string strCid = ""; int ls_page = 1, ls_pagesize = 10; string strType = ""; TPortalClass.JpCommon JpCommon = new TPortalClass.JpCommon(); //获取参数 if (this.Request.QueryString["cid"] != null) { strCid = this.Request.QueryString["cid"].ToString(); } if (this.Request.QueryString["page"] != null) { ls_page = Convert.ToInt32(this.Request.QueryString["page"].ToString()); } if (this.Request.QueryString["pagesize"] != null) { ls_pagesize = Convert.ToInt32(this.Request.QueryString["pagesize"].ToString()); } if (this.Request.QueryString["type"] != null) { strType = this.Request.QueryString["type"].ToString(); } JpGoods jpGoods = new JpGoods(); string strWhere = " and hy_cid like '" + strCid + "%' and hy_ifsh='2' "; if (strType == "0") { strWhere = " and hy_cid like '" + strCid + "%' and hy_ifsh='2' "; } else if (strType == "1") { strWhere = " and (hy_cid = '006001001' or hy_cid='006002001' or hy_cid='006003001' or hy_cid='006004001') and hy_ifsh='2' "; } else if (strType == "2") { strWhere = " and (hy_cid = '006001002' or hy_cid='006002002' or hy_cid='006003002' or hy_cid='006004002') and hy_ifsh='2' "; } else if (strType == "3") { strWhere = " and (hy_cid = '006001003' or hy_cid='006002003' or hy_cid='006003003' or hy_cid='006004003') and hy_ifsh='2' "; } string orderby = " order by hy_addtime desc "; //获取数据 DataTable dt = jpGoods.SearchdocsByKey(strWhere, orderby, ls_page, ls_pagesize); //复制一个DataTalbe DataTable tempTable = dt.Clone(); //在现有的DatatTable增加一列 DataColumn col = new DataColumn("showImg", typeof(String)); //将列添加到DataTable中去 tempTable.Columns.Add(col); DataColumn col2 = new DataColumn("showTime", typeof(String)); //将列添加到DataTable中去 tempTable.Columns.Add(col2); //循环 对DataTable重新赋值 for (int i = 0; i < dt.Rows.Count; i++) { DataRow dr = tempTable.NewRow(); for (int j = 0; j < dt.Columns.Count; j++) { dr[tempTable.Columns[j].ColumnName] = dt.Rows[i][j]; } //获得间隔的时间 HyFileatt hyFileatt = new HyFileatt(); DataTable dt_img = hyFileatt.Getdocsfm(dt.Rows[i]["docid"].ToString()); if (dt_img.Rows.Count > 0) { dr["showImg"] = dt_img.Rows[0]["hy_filepath"].ToString(); } dr["showTime"] = JpCommon.DateDiff(DateTime.Now, Convert.ToDateTime(dt.Rows[i]["hy_addtime"].ToString())); tempTable.Rows.Add(dr); } //转换成json格式 string strJson = JsonConvert.SerializeObject(tempTable); //数据抛出 Response.Write(strJson); }
private void RptBind() { if (this.Request.QueryString["page"] != null) this.page = int.Parse(this.Request.QueryString["page"].ToString()); else this.page = 1; this.txtKeywords.Text = this.keywords; txtPageNum.Text = this.pageSize.ToString(); txtPage.Text = this.page.ToString(); TPortalClass.JpGoods JpGoods = new TPortalClass.JpGoods(); TPortalClass.JpCommon JpCommon = new TPortalClass.JpCommon(); string ls_key = JpCommon.Filter(this.txtKeywords.Text.Trim()); DataTable dt = new DataTable(); string ls_where = " and hy_goodsname like '%" + ls_key + "%' "; ls_where += " and ( hy_ifsh=1 or hy_ifsh=0 )"; ls_where += " and hy_cid like '" + txtcid.Value.Trim() + "%'"; dt = JpGoods.SearchdocsByKey(ls_where, " order by hy_sort desc ", Convert.ToInt32(txtPage.Text), 10); this.totalCount = JpGoods.SearchdocsByKeyNum(ls_where); rptList.DataSource = dt; rptList.DataBind(); string pageUrl = JpCommon.CombUrlTxt("list_shop_tg.aspx", "page={0}&rnd={1}&keywords={2}&cid={3}", "__id__", "" + System.Guid.NewGuid().ToString() + "", "" + this.txtKeywords.Text + "", "" + txtcid.Value + ""); PageContent.InnerHtml = JpCommon.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }