private bool BindList() { bool ifOk = true; int pageIndex = 1; int pageSize = 30;//pager.PageSize;//每页显示20条信息 int totalRecord = 0; if (!string.IsNullOrEmpty(Request.QueryString["p"]) && MetarnetRegex.IsNumeric(Request.QueryString["p"])) { pageIndex = Convert.ToInt32(InText.SafeSql(InText.SafeStr(Request.QueryString["p"].ToString()))); } string where = " where 1=1"; if (html.Trim() != "") { where += " and html like '%" + html + "%'"; } if (update_date_min != "") { where += " and DateDiff( day, '" + update_date_min + "',t_article_pic.update_date) >=0 "; } if (update_date_max != "") { where += " and DateDiff( day, '" + update_date_max + "',t_article_pic.update_date) <=0 "; } string strSql = " Select t_article_pic.id as pic_id,t_article.title,t_article.html,t_article_pic.pic,t_article_pic.update_date " + " ,row_number() over(order by t_article_pic.id desc) as rowNumber " + " FROM t_article_pic " + " LEFT JOIN t_article ON t_article_pic.article_id=t_article.id "; DataTable dt = artBll.ExecutePager(strSql + where, pageSize, pageIndex, ref totalRecord); if (dt.Rows.Count > 0) { ifOk = true; pager.PageSize = pageSize; pager.RecordCount = totalRecord; this.repList_Img.DataSource = dt; this.repList_Img.DataBind(); this.labInfoCount.Text = totalRecord.ToString(); if (totalRecord <= pageSize)//只有一页,隐藏分页控件 { this.divFenye.Visible = false; } } else { this.divFenye.Visible = false; ifOk = false; } return(ifOk); }
int articleId = 0; //图片对应的文章ID protected void Page_Load(object sender, EventArgs e) { adminId = new AdminMethod().CheckAdminLogin();//----------------------------- if (!string.IsNullOrEmpty(Request.QueryString["a_id"]) && MetarnetRegex.IsNumeric(Request.QueryString["a_id"])) { articleId = Utils.CheckInt(Request.QueryString["a_id"]); } if (articleId != 0) { string artPic = ""; string fileName = ""; if (Request.Files.Count > 0) { fileName = Request.Files[0].FileName; fileName = Server.UrlDecode(fileName); string aLastName = fileName.Substring(fileName.LastIndexOf(".") + 1, (fileName.Length - fileName.LastIndexOf(".") - 1));//扩展名 if (aLastName.Trim().ToLower() == "gif") { artPic = imageNamePre + DateTime.Now.ToString("yyyyMMddHHmmss") + Guid.NewGuid().ToString("N") + ".gif"; } else { artPic = imageNamePre + DateTime.Now.ToString("yyyyMMddHHmmss") + Guid.NewGuid().ToString("N") + ".jpg"; } Request.Files[0].SaveAs(savePath + artPic); } else { System.Drawing.Image img = System.Drawing.Image.FromStream(Request.InputStream); fileName = Request.Headers["fileName"]; fileName = Server.UrlDecode(fileName); string aLastName = fileName.Substring(fileName.LastIndexOf(".") + 1, (fileName.Length - fileName.LastIndexOf(".") - 1));//扩展名 if (aLastName.Trim().ToLower() == "gif") { artPic = imageNamePre + DateTime.Now.ToString("yyyyMMddHHmmss") + Guid.NewGuid().ToString("N") + ".gif"; } else { artPic = imageNamePre + DateTime.Now.ToString("yyyyMMddHHmmss") + Guid.NewGuid().ToString("N") + ".jpg"; } img.Save(savePath + artPic); } //string sql = string.Format("insert into t_article_pic (article_id,pic,update_date,remark) values ({0},'{1}',now(),'{2}')", articleId, artPic, ""); //bool isOk = artBll.ExecuteSQLNonquery(sql); } }
protected void Page_Load(object sender, EventArgs e) { adminId = new AdminMethod().CheckAdminLogin();//----------------------------- if (!string.IsNullOrEmpty(Request.QueryString["t_id"]) && MetarnetRegex.IsNumeric(Request.QueryString["t_id"])) { tag_id = Utils.CheckInt(Request.QueryString["t_id"]); } if (!IsPostBack) { if (tag_id != 0) { SelectTagInfo(); } } }
protected void Page_Load(object sender, EventArgs e) { adminId = new AdminMethod().CheckAdminLogin();//----------------------------- if (!string.IsNullOrEmpty(Request.QueryString["admin_id"]) && MetarnetRegex.IsNumeric(Request.QueryString["admin_id"])) { admin_id = Convert.ToInt32(Request.QueryString["admin_id"].ToString()); } if (!Page.IsPostBack) { if (admin_id != 0) { InitAdminInfo();//初始化人员信息 } } }
private bool BindList() { bool ifOk = true; int pageIndex = 1; int pageSize = 100;//pager.PageSize;//每页显示20条信息 int totalRecord = 0; if (!string.IsNullOrEmpty(Request.QueryString["p"]) && MetarnetRegex.IsNumeric(Request.QueryString["p"])) { pageIndex = Convert.ToInt32(InText.SafeSql(InText.SafeStr(Request.QueryString["p"].ToString()))); } string strSql = " Select id,tag_name,tag_keyword,article_num " + " ,row_number() over(order by t_tag.article_num desc ) as rowNumber " + " FROM t_tag where t_tag.article_num>0 "; DataTable dt = artBll.ExecutePager(strSql, pageSize, pageIndex, ref totalRecord); if (dt.Rows.Count > 0) { ifOk = true; pager.PageSize = pageSize; pager.RecordCount = totalRecord; this.repList.DataSource = dt; this.repList.DataBind(); //this.labInfoCount.Text = totalRecord.ToString(); if (totalRecord <= pageSize)//只有一页,隐藏分页控件 { this.divFenye.Visible = false; } } else { this.divFenye.Visible = false; ifOk = false; } return(ifOk); }
protected void Page_Load(object sender, EventArgs e) { string host = HttpContext.Current.Request.Url.Host.ToString(); if (!host.Contains(".up927.com")) { Response.Redirect("http://www.up927.com/"); } else if (host.Contains("vhye.pw")) { Response.Redirect("http://www.up927.com/"); } if (!string.IsNullOrEmpty(Request.QueryString["a_t"]) && MetarnetRegex.IsNumeric(Request.QueryString["a_t"])) { articleType = Utils.CheckInt(Request.QueryString["a_t"].ToString()); string sql = "select type_name,type_keyword from t_article_type where id=" + articleType; DataTable dtType = artBll.SelectToDataTable(sql); if (dtType.Rows.Count > 0) { articleTypeName = dtType.Rows[0]["type_name"].ToString(); html_title = articleTypeName + "_" + html_title; } } if (!string.IsNullOrEmpty(Request.QueryString["tag"])) { tag_id = (Utils.CheckInt(Request.QueryString["tag"].ToString())); if (tag_id != 0) { tagName = this.SelectOneTagName(tag_id.ToString()); html_title = tagName + "_" + html_title; articleTypeName = tagName; } } BindList();//绑定列表 }
protected void Page_Load(object sender, EventArgs e) { adminId = new AdminMethod().CheckAdminLogin();//----------------------------- if (!string.IsNullOrEmpty(Request.QueryString["a_id"]) && MetarnetRegex.IsNumeric(Request.QueryString["a_id"])) { articleId = Utils.CheckInt(Request.QueryString["a_id"]); } //articleId = 0;//------------------------- if (articleId == 0) { string sql = "select max(id) as maxId from t_article"; DataTable dtMaxId = artBll.SelectToDataTable(sql); if (dtMaxId.Rows.Count > 0) { articleId_img = Convert.ToInt32(dtMaxId.Rows[0]["maxId"]) + 1; ////文章分类默认为与上一篇文章相同 //sql = "select * from t_article where id=" + dtMaxId.Rows[0]["maxId"].ToString(); //dtMaxId = artBll.SelectToDataTable(sql); //if (dtMaxId.Rows.Count > 0) //{ // this.ddl_articleType.SelectedValue = dtMaxId.Rows[0]["type"].ToString(); //} } } else { articleId_img = articleId; } if (!IsPostBack) { InitArticle(); InitImg(); } }
public string navStr = "";// ?at=1 ?tag=1 protected void Page_Load(object sender, EventArgs e) { CommonMethod.ValidUrl(); if (!string.IsNullOrEmpty(Request.QueryString["title"])) { title = InText.SafeSql(InText.SafeStr(Request.QueryString["title"].ToString())); //this.txt_search.Value = title; articleTypeName = "> " + "“" + title + "”的搜索结果"; html_title = "“" + title + "”" + "的搜索结果_好宝宝早教网"; tishi = title; this.div_tishi.Visible = true; description = "好宝宝早教网为您提供有关" + title + "_" + @ConfigurationManager.AppSettings["title"].ToString() + "的相关内容"; keywords = title + "_" + @ConfigurationManager.AppSettings["title"].ToString(); } if (!string.IsNullOrEmpty(Request.QueryString["tag"])) { tag_id = (Utils.CheckInt(Request.QueryString["tag"].ToString())); if (tag_id != 0) { tagName = this.SelectOneTagName(tag_id.ToString()); html_title = tagName + "_" + @ConfigurationManager.AppSettings["title"].ToString(); tishi = tagName; this.div_tishi.Visible = true; description = "好宝宝早教网为您提供有关" + tagName + "_" + @ConfigurationManager.AppSettings["title"].ToString() + "的相关内容"; keywords = tagName + "_" + @ConfigurationManager.AppSettings["title"].ToString(); navStr = "tag=" + tag_id.ToString(); this.div_nav.Visible = true; } } if (!string.IsNullOrEmpty(Request.QueryString["at"]) && MetarnetRegex.IsNumeric(Request.QueryString["at"])) { articleType = Utils.CheckInt(Request.QueryString["at"].ToString()); string sql = "select type_name,type_keyword from t_article_type where id=" + articleType; DataTable dtType = accessBll.SelectToDataTable(sql); if (dtType.Rows.Count > 0) { articleTypeName = "> <span style='color:#36648b'>" + dtType.Rows[0]["type_name"].ToString() + "</span>"; if (dtType.Rows[0]["type_keyword"].ToString().Trim() != "")//分类关键词 { html_title = dtType.Rows[0]["type_name"].ToString() + "_" + dtType.Rows[0]["type_keyword"].ToString() + "_好宝宝早教网"; description = "好宝宝早教网为您提供有关" + dtType.Rows[0]["type_name"].ToString() + "_" + dtType.Rows[0]["type_keyword"].ToString() + "_" + @ConfigurationManager.AppSettings["title"].ToString() + "的相关内容"; keywords = dtType.Rows[0]["type_name"].ToString() + "," + dtType.Rows[0]["type_keyword"].ToString() + "," + @ConfigurationManager.AppSettings["title"].ToString().Replace("|", ","); } else { html_title = dtType.Rows[0]["type_name"].ToString() + "_好宝宝早教网"; description = "好宝宝早教网为您提供有关" + dtType.Rows[0]["type_name"].ToString() + "_" + @ConfigurationManager.AppSettings["title"].ToString() + "的相关内容"; keywords = dtType.Rows[0]["type_name"].ToString() + "," + @ConfigurationManager.AppSettings["title"].ToString().Replace("|", ","); } tishi = dtType.Rows[0]["type_name"].ToString(); navStr = "at=" + articleType.ToString(); this.div_nav.Visible = true; } } if (html_title.Trim() == "") { html_title = @ConfigurationManager.AppSettings["title"].ToString(); } if (tishi.Trim() == "") { this.div_tishi.Visible = false; } if (!IsPostBack) { BindList();//绑定列表 //GetTypeList();//绑定文章分类 //BindHotList();//绑定热门文章 } }
private bool BindList() { bool ifOk = true; int pageIndex = 1; int pageSize = 20;//pager.PageSize;//每页显示10条信息 int totalRecord = 0; if (!string.IsNullOrEmpty(Request.QueryString["p"]) && MetarnetRegex.IsNumeric(Request.QueryString["p"])) { pageIndex = Convert.ToInt32(InText.SafeSql(InText.SafeStr(Request.QueryString["p"].ToString()))); } string where = " where 1=1"; if (articleId != 0) { where += " and articleId=" + articleId; } if (title.Trim() != "") { where += " and title like '%" + title + "%'"; } if (tag_id != 0) { where += " and tag_id like '%," + tag_id + ",%'"; } if (articleType != 0) { where += " and type=" + articleType; } if (where == " where 1=1") { where += " and daoyu<>'no' "; } //string strSql = " Select P.ProductID,P.ProClassID,P.ProductName,P.ProFlag,P.DateTime,P.ProductImage,C.ProClassName,C.ProClassKey,C.ProClassDes FROM ProductInfo P " + // " LEFT JOIN ProClass C ON P.ProClassID=C.ProClassID "; //string strShow = " ProductID,ProductName,DateTime,ProductImage,ProFlag,ProClassName,ProClassKey,ProClassDes "; //return ClassFile.AccessHelper.ExecutePager(PageIndex, PageSize, "ProductID", strShow, strSql, strWhere, " ProductID DESC ", out PageCount, out RecordCount); string strSql = " Select t_article.id as articleId,t_article.title,t_article.keyword,t_article.daoyu,t_article.content,t_article.type,t_article.update_date,t_article.declare_mark,t_article.pic,t_article.html,t_article.remark,t_article_type.type_name,tag,tag_id FROM t_article " + " LEFT JOIN t_article_type ON t_article.type=t_article_type.id "; string strShow = " articleId,title,keyword,daoyu,content,type,update_date,declare_mark,pic,remark,type_name,html,tag,tag_id ";//要显示的字段 int PageCount = 0; DataTable dt = accessBll.ExecutePager(pageIndex, pageSize, "articleId", strShow, strSql, where, " update_date DESC ", out PageCount, out totalRecord); string sqlCount = "select count(*) from t_article left join t_article_type on t_article.type=t_article_type.id " + where; //totalRecord = accessBll.MaxCount(sqlCount); if (dt.Rows.Count > 0) { ifOk = true; pager.PageSize = pageSize; pager.RecordCount = totalRecord; this.repList1.DataSource = dt; this.repList1.DataBind(); //this.labInfoCount.Text = totalRecord.ToString(); if (totalRecord <= pageSize)//只有一页,隐藏分页控件 { this.divFenye.Visible = false; } this.div_news.Visible = true; } else { this.divFenye.Visible = false; ifOk = false; //绑定最新发布的前N条文章 sql = "Select top 30 t_article.id as articleId,t_article.title,t_article.keyword,t_article.daoyu,t_article.content,t_article.type,t_article.update_date,t_article.declare_mark,t_article.pic,t_article.html,t_article.remark,t_article_type.type_name,source,tag,tag_id FROM t_article " + " LEFT JOIN t_article_type ON t_article.type=t_article_type.id "; sql += " where daoyu<>'no' "; sql += " order by update_date desc "; dt = accessBll.SelectToDataTable(sql); if (dt.Rows.Count > 0) { this.repList2.DataSource = dt; this.repList2.DataBind(); } this.div_nonews1.Visible = true; this.div_nonews2.Visible = true; } return(ifOk); }
protected void Page_Load(object sender, EventArgs e) { adminId = new AdminMethod().CheckAdminLogin();//----------------------------- if (!IsPostBack) { InitArticle(); } if (!string.IsNullOrEmpty(Request.QueryString["a_id"]) && MetarnetRegex.IsNumeric(Request.QueryString["a_id"])) { articleId = Utils.CheckInt(Request.QueryString["a_id"].ToString()); this.txt_article_id.Value = InText.SafeSql(InText.SafeStr(Request.QueryString["a_id"].ToString())); } if (!string.IsNullOrEmpty(Request.QueryString["title"])) { title = InText.SafeStr(Request.QueryString["title"].ToString()); this.txt_title.Value = title; } if (!string.IsNullOrEmpty(Request.QueryString["search_keyword"])) { search_keyword = InText.SafeStr(Request.QueryString["search_keyword"].ToString()); this.txt_search_keyword.Value = title; } if (!string.IsNullOrEmpty(Request.QueryString["a_t"]) && MetarnetRegex.IsNumeric(Request.QueryString["a_t"])) { articleType = Utils.CheckInt(Request.QueryString["a_t"].ToString()); this.ddl_articleType.SelectedValue = InText.SafeStr(Request.QueryString["a_t"].ToString()); } if (!string.IsNullOrEmpty(Request.QueryString["dateMin"])) { update_date_min = InText.SafeSql(InText.SafeStr(Request.QueryString["dateMin"].ToString())); this.txt_update_date_min.Value = update_date_min; } if (!string.IsNullOrEmpty(Request.QueryString["dateMax"])) { update_date_max = InText.SafeSql(InText.SafeStr(Request.QueryString["dateMax"].ToString())); this.txt_update_date_max.Value = update_date_max; } if (!string.IsNullOrEmpty(Request.QueryString["tag"])) { tag = InText.SafeStr(Request.QueryString["tag"].ToString()); this.txt_tag.Value = tag; } if (!string.IsNullOrEmpty(Request.QueryString["html"])) { html = InText.SafeStr(Request.QueryString["html"].ToString()); this.txt_html.Value = html; } if (!string.IsNullOrEmpty(Request.QueryString["hd1"]) && MetarnetRegex.IsNumeric(Request.QueryString["hd1"])) { isHuandeng1 = Utils.CheckInt(Request.QueryString["hd1"].ToString()); this.chkIsHuandeng1.Checked = true; } if (!string.IsNullOrEmpty(Request.QueryString["r_t"]) && MetarnetRegex.IsNumeric(Request.QueryString["r_t"])) { right_type = Utils.CheckInt(Request.QueryString["r_t"].ToString()); this.ddl_right_type.SelectedValue = InText.SafeStr(Request.QueryString["r_t"].ToString()); } if (!IsPostBack) { BindList();//绑定列表 } }
private bool BindList() { bool ifOk = true; int pageIndex = 1; int pageSize = 20;//pager.PageSize;//每页显示20条信息 int totalRecord = 0; if (!string.IsNullOrEmpty(Request.QueryString["p"]) && MetarnetRegex.IsNumeric(Request.QueryString["p"])) { pageIndex = Convert.ToInt32(InText.SafeSql(InText.SafeStr(Request.QueryString["p"].ToString()))); } string where = " where 1=1"; if (articleId != 0) { where += " and t_article.id=" + articleId; } if (title.Trim() != "") { where += " and title like '%" + title + "%'"; } if (search_keyword.Trim() != "") { where += " and search_keyword like '%" + search_keyword + "%'"; } if (articleType != 0) { where += " and type=" + articleType; } if (right_type != 0) { where += " and right_type=" + right_type; } if (update_date_min != "") { where += " and DateDiff( day, '" + update_date_min + "',update_date) >=0 "; } if (update_date_max != "") { where += " and DateDiff( day, '" + update_date_max + "',update_date) <=0 "; } if (tag.Trim() != "") { where += " and tag like '%" + tag + "%'"; } if (html.Trim() != "") { where += " and html like '%" + html + "%'"; } if (isHuandeng1 != 0) { where += " and huandeng1=1 "; } //string strSql = " Select P.ProductID,P.ProClassID,P.ProductName,P.ProFlag,P.DateTime,P.ProductImage,C.ProClassName,C.ProClassKey,C.ProClassDes FROM ProductInfo P " + // " LEFT JOIN ProClass C ON P.ProClassID=C.ProClassID "; //string strShow = " ProductID,ProductName,DateTime,ProductImage,ProFlag,ProClassName,ProClassKey,ProClassDes "; //return ClassFile.AccessHelper.ExecutePager(PageIndex, PageSize, "ProductID", strShow, strSql, strWhere, " ProductID DESC ", out PageCount, out RecordCount); string strSql = " Select t_article.id as articleId,t_article.title,t_article.keyword,t_article.search_keyword,t_article.daoyu,t_article.content,t_article.type,t_article.update_date,t_article.declare_mark,t_article.pic,t_article.html,t_article.remark,t_article_type.type_name,source,t_article.tag,t_article.tag_id,t_article.huandeng1,right_type,t_article.ts_baidu " + " ,row_number() over(order by t_article.id desc) as rowNumber " + " FROM t_article " + " LEFT JOIN t_article_type ON t_article.type=t_article_type.id "; DataTable dt = artBll.ExecutePager(strSql + where, pageSize, pageIndex, ref totalRecord); if (dt.Rows.Count > 0) { ifOk = true; pager.PageSize = pageSize; pager.RecordCount = totalRecord; this.repList.DataSource = dt; this.repList.DataBind(); this.labInfoCount.Text = totalRecord.ToString(); if (totalRecord <= pageSize)//只有一页,隐藏分页控件 { this.divFenye.Visible = false; } } else { this.divFenye.Visible = false; ifOk = false; } return(ifOk); }
protected void Page_Load(object sender, EventArgs e) { CommonMethod.ValidUrl(); if (!string.IsNullOrEmpty(Request.QueryString["title"])) { title = InText.SafeSql(InText.SafeStr(Request.QueryString["title"].ToString())); tishi = "“" + title + "”的搜索结果"; html_title = "“" + title + "”" + "的搜索结果_好宝宝早教网"; description = "好宝宝早教网为您提供有关" + title + "_" + @ConfigurationManager.AppSettings["title"].ToString() + "的相关内容"; keywords = title + "_" + @ConfigurationManager.AppSettings["title"].ToString(); } if (!string.IsNullOrEmpty(Request.QueryString["tag"])) { tag_id = (Utils.CheckInt(Request.QueryString["tag"].ToString())); if (tag_id != 0) { String sql = "select * from t_tag where id=" + tag_id; DataTable dt = artBll.SelectToDataTable(sql); if (dt.Rows.Count > 0) { tagName = dt.Rows[0]["tag_name"].ToString(); if (dt.Rows[0]["tag_keyword"].ToString().Trim() != "") { html_title = tagName + "_" + dt.Rows[0]["tag_keyword"].ToString() + "_好宝宝早教网"; description = "好宝宝早教网为您提供有关" + tagName + "_" + dt.Rows[0]["tag_keyword"].ToString() + "的相关内容"; keywords = tagName + "_" + dt.Rows[0]["tag_keyword"].ToString(); } else { html_title = tagName + "_好宝宝早教网";//+ "_" + @ConfigurationManager.AppSettings["title"].ToString(); description = "好宝宝早教网为您提供有关" + tagName + "_" + @ConfigurationManager.AppSettings["title"].ToString() + "的相关内容"; keywords = tagName + "_" + @ConfigurationManager.AppSettings["title"].ToString(); } tishi = tagName; miaoshu_pic = dt.Rows[0]["tag_pic"].ToString(); miaoshu = dt.Rows[0]["tag_miaoshu"].ToString(); miaoshu_title = tagName; if (miaoshu.Trim() != "") { this.div_miaoshu.Visible = true;//显示描述div } } } } if (!string.IsNullOrEmpty(Request.QueryString["at"]) && MetarnetRegex.IsNumeric(Request.QueryString["at"])) { articleType = Utils.CheckInt(Request.QueryString["at"].ToString()); this.hid_type.Value = Request.QueryString["at"].ToString(); string sql = "select type_name,type_keyword from t_article_type where id=" + articleType; DataTable dtType = artBll.SelectToDataTable(sql); if (dtType.Rows.Count > 0) { articleTypeName = dtType.Rows[0]["type_name"].ToString(); if (dtType.Rows[0]["type_keyword"].ToString().Trim() != "")//分类关键词 { html_title = dtType.Rows[0]["type_name"].ToString() + "_" + dtType.Rows[0]["type_keyword"].ToString() + "_好宝宝早教网"; description = "好宝宝早教网为您提供有关" + dtType.Rows[0]["type_name"].ToString() + "_" + dtType.Rows[0]["type_keyword"].ToString() + "_" + @ConfigurationManager.AppSettings["title"].ToString() + "的相关内容"; keywords = dtType.Rows[0]["type_name"].ToString() + "," + dtType.Rows[0]["type_keyword"].ToString() + "," + @ConfigurationManager.AppSettings["title"].ToString().Replace("|", ","); } else { html_title = dtType.Rows[0]["type_name"].ToString() + "_好宝宝早教网"; description = "好宝宝早教网为您提供有关" + dtType.Rows[0]["type_name"].ToString() + "_" + @ConfigurationManager.AppSettings["title"].ToString() + "的相关内容"; keywords = dtType.Rows[0]["type_name"].ToString() + "," + @ConfigurationManager.AppSettings["title"].ToString().Replace("|", ","); } tishi = dtType.Rows[0]["type_name"].ToString(); } } if (html_title.Trim() == "") { html_title = @ConfigurationManager.AppSettings["title"].ToString(); } if (!string.IsNullOrEmpty(Request.QueryString["p"]) && MetarnetRegex.IsNumeric(Request.QueryString["p"])) { int p = Convert.ToInt32(InText.SafeSql(InText.SafeStr(Request.QueryString["p"].ToString()))); if (p > 1) { html_title += "_第" + p + "页"; } } if (!IsPostBack) { BindList();//绑定列表 } }
private bool BindList() { bool ifOk = true; int pageIndex = 1; int pageSize = 30;//pager.PageSize;//每页显示10条信息 int totalRecord = 0; if (!string.IsNullOrEmpty(Request.QueryString["p"]) && MetarnetRegex.IsNumeric(Request.QueryString["p"])) { pageIndex = Convert.ToInt32(InText.SafeSql(InText.SafeStr(Request.QueryString["p"].ToString()))); } string where = " where 1=1"; if (articleId != 0) { where += " and articleId=" + articleId; } if (title.Trim() != "") { where += " and (title like '%" + title + "%' or keyword like '%" + title + "%' or tag_name like '%" + title + "%' or search_keyword like '%" + title + "%')"; } if (tag_id != 0) { where += " and tag_id like '%," + tag_id + ",%'"; } if (articleType != 0) { where += " and type=" + articleType; } if (where == " where 1=1") { //where += " and daoyu<>'no' "; } string strSql = " Select t_article.id as articleId,t_article.title,t_article.keyword,t_article.daoyu,t_article.content,t_article.type,t_article.update_date,t_article.declare_mark,t_article.pic,t_article.html,t_article.remark,t_article_type.type_name,tag,tag_id,tag_name " + " ,row_number() over(order by t_article.id desc) as rowNumber " + " FROM t_article " + " LEFT JOIN t_article_type ON t_article.type=t_article_type.id " + " LEFT JOIN t_tag ON replace(t_article.tag_id,',','')=t_tag.id "; DataTable dt = artBll.ExecutePager(strSql + where, pageSize, pageIndex, ref totalRecord); //string strShow = " articleId,title,keyword,daoyu,content,type,update_date,declare_mark,pic,remark,type_name,html,tag,tag_id ";//要显示的字段 //int PageCount = 0; //DataTable dt = artBll.ExecutePager(strSql, pageSize, pageIndex, ref totalRecord); //string sqlCount = "select count(*) from t_article left join t_article_type on t_article.type=t_article_type.id " + where; //totalRecord = accessBll.MaxCount(sqlCount); if (dt.Rows.Count > 0) { ifOk = true; pager.PageSize = pageSize; pager.RecordCount = totalRecord; this.repList1.DataSource = dt; this.repList1.DataBind(); //this.labInfoCount.Text = totalRecord.ToString(); if (totalRecord <= pageSize)//只有一页,隐藏分页控件 { this.divFenye.Visible = false; } //this.div_news.Visible = true; } else { this.divFenye.Visible = false; ifOk = false; //绑定最新发布的前N条文章 sql = "Select top 20 t_article.id as articleId,t_article.title,t_article.keyword,t_article.daoyu,t_article.content,t_article.type,t_article.update_date,t_article.declare_mark,t_article.pic,t_article.html,t_article.remark,t_article_type.type_name,source,tag,tag_id FROM t_article " + " LEFT JOIN t_article_type ON t_article.type=t_article_type.id "; sql += " where daoyu<>'no' "; sql += " order by update_date desc "; dt = artBll.SelectToDataTable(sql); if (dt.Rows.Count > 0) { this.repList2.DataSource = dt; this.repList2.DataBind(); } this.div_nonews1.Visible = true; this.div_nonews2.Visible = true; } return(ifOk); }