Example #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string ls_page = "1", ls_pagesize = "10";
        TPortalClass.JpCommon JpCommon = new TPortalClass.JpCommon();
        //获取参数
        if (this.Request.QueryString["page"] != null)
        {
            ls_page = this.Request.QueryString["page"].ToString();
        }
        if (this.Request.QueryString["pagesize"] != null)
        {
            ls_pagesize = this.Request.QueryString["pagesize"].ToString();
        }

        string ls_where = " and hy_ifsh ='2' ";
        string ls_orderby = " order by hy_addtime desc ";
        JpPhotography jpPhotography = new JpPhotography();
        //获取数据
        string test = "";
        DataTable dt = jpPhotography.SearchdocsByKey(ls_where,ls_orderby, int.Parse(ls_page), int.Parse(ls_pagesize));
        Response.Write(test);
        //复制一个DataTalbe
        DataTable tempTable = dt.Clone();
        //在现有的DatatTable增加一列
        DataColumn col = new DataColumn("showTime", typeof(String));
        //将列添加到DataTable中去
        tempTable.Columns.Add(col);
        //在现有的DatatTable增加一列
        DataColumn co2 = new DataColumn("showImg", typeof(String));
        //将列添加到DataTable中去
        tempTable.Columns.Add(co2);
        //循环  对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];
            }
            //获得间隔的时间
            dr["showTime"] = JpCommon.DateDiff(DateTime.Now, Convert.ToDateTime(dt.Rows[i]["hy_addtime"].ToString()));
            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();
            }
            tempTable.Rows.Add(dr);
        }
        //转换成json格式
        string strJson = JsonConvert.SerializeObject(tempTable);
        //数据抛出
        Response.Write(strJson);
    }
Example #2
0
    public void showData(string strOrder)
    {
        string ls_where = " and hy_ifsh ='2'  ";
        string ls_orderby = " ";
        if (strOrder == "1")
        {
            ls_orderby += " order by praiseCount desc  ";
        }
        else
        {
            ls_orderby += " order by hy_addtime desc  ";
        }
        JpPhotography JpPhotography = new JpPhotography();
        int colcous = 1;
        //获取数据
        StringBuilder stringBuilder = new StringBuilder();
        DataTable dt = JpPhotography.SearchdocsByKey(ls_where, ls_orderby, 1, 10);
        string strTitle = "";
        if (dt.Rows.Count > 0)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                strTitle = dt.Rows[i]["hy_content"].ToString();
                if (strTitle.Length > 10)
                {
                    strTitle = strTitle.Substring(0, 10) + "...";
                }
                stringBuilder.Append("<li><a onclick=\"locationDetail('photo_detail.aspx?aid=" + dt.Rows[i]["id"].ToString() + "&rend=" + System.Guid.NewGuid().ToString() + "','" + locationType + "','2')\"><div class='pplist'><p class=\"ico-tx\"><img src=\"images/321tx.png\" style='width: 30px;height: 30px; display:block; float:left;'><span>" + dt.Rows[i]["hy_uid"].ToString() + "</span></p><p>" + strTitle + "</p>");
                HyFileatt hyFileatt = new HyFileatt();
                DataTable dt_img = hyFileatt.Getdocsfm(dt.Rows[i]["docid"].ToString());
                if (dt_img.Rows.Count > 0)
                {
                    stringBuilder.Append("<img src=\"" + dt_img.Rows[0]["hy_filepath"].ToString() + "\">");
                }

                stringBuilder.Append("</div>点攒数:" + dt.Rows[i]["praiseCount"].ToString() + "</a></li>");
            }
        }
        this.lb_show.Text = stringBuilder.ToString();
    }
Example #3
0
    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.JpPhotography JpPhotography = new TPortalClass.JpPhotography();
        TPortalClass.JpCommon JpCommon = new TPortalClass.JpCommon();
        string ls_key = JpCommon.Filter(this.txtKeywords.Text.Trim());

        DataTable dt = new DataTable();
        string ls_where = "  and   hy_content  like '%" + ls_key + "%' ";
        dt = JpPhotography.SearchdocsByKey(ls_where, "   order by hy_ifsh ", Convert.ToInt32(txtPage.Text), 10);
        this.totalCount = JpPhotography.SearchdocsByKeyNum(ls_where);

        rptList.DataSource = dt;

        rptList.DataBind();

        string pageUrl = JpCommon.CombUrlTxt("list_photo.aspx", "page={0}&rnd={1}&keywords={2}",
            "__id__", "" + System.Guid.NewGuid().ToString() + "", "" + this.txtKeywords.Text + "");
        PageContent.InnerHtml = JpCommon.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8);
    }