protected void Page_Load(object sender, EventArgs e) { int classid = -1; if (Request.QueryString["classid"] != null) { classid = Convert.ToInt32(Request.QueryString["classid"]); } int totalNum = EispNewsBLL.GetRecordCountByClassid(lang, classid); if (VerifyTool.IsInt(Request.QueryString["page"])) { CurrentPage = Convert.ToInt32(Request.QueryString["page"]); //要减去的记录数 int subtract_number = 20 * (CurrentPage - 1); //要获取的记录数:记录总数-要减去的记录数 int number = -subtract_number; if (totalNum > 0) { BindNews(number, 20, totalNum, classid); } } else { if (totalNum > 0) { BindNews(totalNum, 20, totalNum, classid); } } //Page.Title = " 公司简介"; Page.Title = "新闻动态"; }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Request.QueryString["op"])) { #region 除 if (Request.QueryString["op"].ToString() == "del") { int id = Convert.ToInt32(Request.QueryString["id"]); if ((EispNewsClassBLL.IsSub(id)) > 0) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('该类包含子类,不能删除,请先删除子类!');location.href='NewsClassAdmin.aspx?lang=" + lang + "';", true); return; } if ((EispNewsBLL.HasNews(id)) > 0) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('该类别包含产品,请先删除该类别下的产品!');location.href='NewsClassAdmin.aspx?lang=" + lang + "';", true); return; } int res = EispNewsClassBLL.DeleteNewsClass(id); if (res > 0) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('删除成功!');location.href='NewsClassAdmin.aspx?lang=" + lang + "';", true); } else { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('删除失败!');", true); } } #endregion #region 排序 //升 if (Request.QueryString["op"].ToString() == "up") { int id = Convert.ToInt32(Request.QueryString["id"]); EispProClassBLL.UPSort(id, 0); } //降 if (Request.QueryString["op"].ToString() == "down") { int id = Convert.ToInt32(Request.QueryString["id"]); EispProClassBLL.UPSort(id, 1); } #endregion } listsort = NewsClassTreeBind(0); }
//绑定新闻 protected void BindNews(int number, int pagesize) { // AspNetPager1.RecordCount = recordcount; List <NewsModel> list = EispNewsBLL.GetArticleListPageNoByLang(Convert.ToInt32(lang), number, pagesize, -1); // AspNetPager1.RecordCount = 9; this.GridView1.DataSource = list; this.GridView1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (EispNewsBLL.GetRecordCountByLang(lang) > 0) { AspNetPager1.RecordCount = EispNewsBLL.GetRecordCountByLang(lang); BindNews(AspNetPager1.RecordCount, AspNetPager1.PageSize); } } }
protected void NewsBind(int id) { NewsModel a = EispNewsBLL.GetNewsByID(id); this.txtTitle.Text = a.F_Title; this.txtID.Value = a.ID.ToString(); this.content.Value = a.F_Content; this.txtLocation.Text = a.F_Location; this.txtKeyword.Text = a.F_Keyword; BindDrpClass(0, "-", a.F_ParentID); }
protected void Page_Load(object sender, EventArgs e) { List <NewsModel> list = EispNewsBLL.GetArticleListPageNoByLang(lang, 8, 10, -1); StringBuilder sb = new StringBuilder(); foreach (NewsModel n in list) { sb.Append("<div class=\"NewsRow\"><a href=\"NewsDetail.aspx?id=" + n.ID + "\" target=_blank Title='" + n.F_Title + "'>" + VerifyTool.CheckStringLength(n.F_Title, 16, false) + "</a></div>"); } NewsHtml = sb.ToString(); }
//5~1~a~s~p~x //绑定新闻 protected void BindNews(int number, int pagesize, int recordcount, int classid) { List <NewsModel> list = EispNewsBLL.GetArticleListPageNoByLang(lang, number, pagesize, classid); AspNetPager.RecordCount = recordcount; AspNetPager.CurrentPageIndex = number; AspNetPager.PageSize = pagesize; Records = recordcount; RecordsPage = int.Parse(pages); StringBuilder sb = new StringBuilder(); foreach (NewsModel n in list) { sb.Append("<div class=\"NewsRow\"><div class=\"NewsRowTitle\"><a href=\"NewsDetail.aspx?id=" + n.ID + "\" target=\"_blank\">" + n.F_Title + " </a>[" + n.F_Date.ToString("yyyy-MM-dd") + "]</div></div>"); } NewsHtml = sb.ToString(); }
protected void btnAdd_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.txtTitle.Text)) { Page.ClientScript.RegisterStartupScript(this.GetType(), "msg", "alert('标题不能为空!')", true); return; } if (string.IsNullOrEmpty(this.txtLocation.Text)) { Page.ClientScript.RegisterStartupScript(this.GetType(), "msg", "alert('新闻来源不能为空!')", true); return; } if (string.IsNullOrEmpty(this.content.Value)) { Page.ClientScript.RegisterStartupScript(this.GetType(), "msg", "alert('新闻内容不能为空!')", true); return; } NewsModel a = new NewsModel(); a.F_Title = VerifyTool.DeleteHtml(this.txtTitle.Text.Trim().ToString()); a.F_Location = VerifyTool.DeleteHtml(this.txtLocation.Text.Trim().ToString()); a.F_Content = VerifyTool.DeleteScript(this.content.Value); a.F_ParentID = Convert.ToInt32(drpClass.SelectedValue); a.F_Keyword = txtKeyword.Text.Trim(); a.F_Lang = Convert.ToInt32(lang); int res = EispNewsBLL.AddNew(a); if (res > 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "msg", "alert('添加成功!');location.href='NewsADD.aspx?lang=" + lang + "'", true); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "msg", "alert('添加失败!')", true); } Response.Write(drpClass.SelectedValue); }
// 删除 protected void btnDelete_Click(object sender, EventArgs e) { foreach (GridViewRow row in GridView1.Rows) { if (((CheckBox)row.FindControl("chk")).Checked) { int id = int.Parse(((Label)row.FindControl("id")).Text); // this.News_Delete(id); EispNewsBLL.DeleteNewByID(id); } } if (EispNewsBLL.GetRecordCountByLang(lang) > 0) { AspNetPager1.RecordCount = EispNewsBLL.GetRecordCountByLang(lang); BindNews(AspNetPager1.RecordCount, AspNetPager1.PageSize); } else { this.GridView1.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Request.QueryString["id"])) { if (VerifyTool.IsLong(Request.QueryString["id"])) { int id = Convert.ToInt32(Request.QueryString["id"]); NewsModel a = EispNewsBLL.GetNewsByID(id); NewsTitle = a.F_Title; date = a.F_Date.ToString(); NewsContent = VerifyTool.DeleteScript(a.F_Content); location = a.F_Location; NewsClass = a.F_ClassName; Page.Title = NewsTitle; } else { Response.Redirect("Error.aspx"); } } }