protected void BindArticle() { CMS_ArticleMod m_cms = CMS_ArticleBll.GetInstance().GetModel(sysno); SYS_ArticleMod m_article = SYS_ArticleBll.GetInstance().GetModel(m_cms.ArticleSysNo); Dictionary <int, SYS_ArticleContentMod> m_content = SYS_ArticleContentBll.GetInstance().GetContentByArticle(m_cms.ArticleSysNo); Dictionary <int, string[]> m_neighbour = CMS_ArticleBll.GetInstance().GetNeighbour(sysno, m_cms.CateSysNo); ltrTitle.Text = m_article.Title; ltrContent.Text = m_content[1].Context; #region 设置前一篇后一篇 switch (m_neighbour.Count) { case 0: ltrPre.Text = "已经是第一篇了"; ltrAft.Text = "已经是最后一篇了"; lnkPreTop.Enabled = false; lnkPreBtm.Enabled = false; lnkAftTop.Enabled = false; lnkAftBtm.Enabled = false; break; case 1: if (int.Parse(m_neighbour[0][2]) > m_cms.OrderID || (int.Parse(m_neighbour[0][2]) == m_cms.OrderID && int.Parse(m_neighbour[0][2]) < m_article.SysNo)) { ltrPre.Text = m_neighbour[0][1]; ltrAft.Text = "已经是最后一篇了"; lnkPreTop.NavigateUrl = "Content.aspx?id=" + m_neighbour[0][0]; lnkPreBtm.NavigateUrl = "Content.aspx?id=" + m_neighbour[0][0]; lnkAftTop.Enabled = false; lnkAftBtm.Enabled = false; } else { ltrPre.Text = "已经是第一篇了"; ltrAft.Text = m_neighbour[1][1]; lnkPreTop.Enabled = false; lnkPreBtm.Enabled = false; lnkAftTop.NavigateUrl = "Content.aspx?id=" + m_neighbour[1][0]; lnkAftBtm.NavigateUrl = "Content.aspx?id=" + m_neighbour[1][0]; } break; case 2: ltrPre.Text = m_neighbour[0][1]; ltrAft.Text = m_neighbour[1][1]; lnkPreTop.NavigateUrl = "Content.aspx?id=" + m_neighbour[0][0]; lnkPreBtm.NavigateUrl = "Content.aspx?id=" + m_neighbour[0][0]; lnkAftTop.NavigateUrl = "Content.aspx?id=" + m_neighbour[1][0]; lnkAftBtm.NavigateUrl = "Content.aspx?id=" + m_neighbour[1][0]; break; } #endregion }
protected void BindArticles() { int total = 0; DataTable dt = new DataTable(); if (HttpRuntime.Cache[AppConst.AstroDiceAricle] == null) { dt = CMS_ArticleBll.GetInstance().GetList(8, 1, "", 30, 0, ref total); HttpRuntime.Cache.Insert(AppConst.AstroDiceAricle, dt, null, DateTime.Now.AddMinutes(10), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.High, null); } dt = HttpRuntime.Cache[AppConst.AstroDiceAricle] as DataTable; Repeater3.DataSource = dt; Repeater3.DataBind(); }
/// <summary> /// 删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Delete() { try { CMS_ArticleMod m_famous = CMS_ArticleBll.GetInstance().GetModel(int.Parse(Request.QueryString["delete"])); m_famous.DR = (int)AppEnum.State.deleted; CMS_ArticleBll.GetInstance().Update(m_famous); ltrNotice.Text = "该记录已删除!"; this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('noticediv').style.display='';", true); } catch { ltrError.Text = "系统错误,删除失败!"; this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';", true); } }
protected void BindArticles() { int total = 0; DataTable m_dt = CMS_ArticleBll.GetInstance().GetList(pagesize, pageindex, "", 0, m_user.SysNo, ref total); m_dt.Columns.Add("KeyWordsShow"); for (int i = 0; i < m_dt.Rows.Count; i++) { string[] tmpkeys = m_dt.Rows[i]["KeyWords"].ToString().Split(new char[] { ' ' }); m_dt.Rows[i]["KeyWordsShow"] = ""; foreach (string tmpkey in tmpkeys) { m_dt.Rows[i]["KeyWordsShow"] += @"<a href=""" + AppConfig.HomeUrl() + @"Article/" + tmpkey + @""">" + tmpkey + "</a>"; } } rptArticle.DataSource = m_dt; rptArticle.DataBind(); }
protected void BindData() { int total = 0; DataTable m_dt = CMS_ArticleBll.GetInstance().GetList(pagesize, pageindex, txtName.Text, cate, 0, ref total); m_dt.Columns.Add("power"); m_dt.Columns.Add("Keys"); for (int i = 0; i < m_dt.Rows.Count; i++) { m_dt.Rows[i]["Description"] = CommonTools.CutStr(m_dt.Rows[i]["Description"].ToString(), 300); if (m_dt.Rows[i]["Cost"] != null && m_dt.Rows[i]["Cost"].ToString() != "" && m_dt.Rows[i]["Cost"].ToString() != "0") { m_dt.Rows[i]["power"] = "| 阅读需要支付积分:" + m_dt.Rows[i]["Cost"].ToString(); } else { m_dt.Rows[i]["power"] = ""; } string[] tmpkeys = m_dt.Rows[i]["keywords"].ToString().Trim().Split(new char[] { ' ' }); for (int j = 0; j < tmpkeys.Length; j++) { m_dt.Rows[i]["Keys"] += @"<a href=""" + AppConfig.HomeUrl() + @"Article/" + tmpkeys[j] + @""" title=""" + tmpkeys[j] + @""">" + tmpkeys[j] + @"</a> "; } } rptQuestion.DataSource = m_dt; rptQuestion.DataBind(); Pager1.url = AppConfig.HomeUrl() + "Article/" + cate + "/" + txtName.Text.Trim() + "/"; Pager1.totalrecord = total; if (total % AppConst.PageSize == 0) { this.Pager1.total = total / pagesize; } else { this.Pager1.total = total / pagesize + 1; } this.Pager1.index = pageindex; this.Pager1.numlenth = 3; }
protected void BindRecommend() { DataSet m_ds = CMS_ArticleBll.GetInstance().GetRecommendList(5); for (int i = 0; i < m_ds.Tables[0].Rows.Count; i++) { m_ds.Tables[0].Rows[i]["Description"] = CommonTools.CutStr(m_ds.Tables[0].Rows[i]["Description"].ToString(), 100); } rptNew.DataSource = m_ds.Tables[0]; rptNew.DataBind(); for (int i = 0; i < m_ds.Tables[1].Rows.Count; i++) { m_ds.Tables[1].Rows[i]["Description"] = CommonTools.CutStr(m_ds.Tables[1].Rows[i]["Description"].ToString(), 100); } rptGood.DataSource = m_ds.Tables[1]; rptGood.DataBind(); for (int i = 0; i < m_ds.Tables[2].Rows.Count; i++) { m_ds.Tables[2].Rows[i]["Description"] = CommonTools.CutStr(m_ds.Tables[2].Rows[i]["Description"].ToString(), 100); } rptHot.DataSource = m_ds.Tables[2]; rptHot.DataBind(); }
protected void BindContent() { DataTable m_dt = CMS_ArticleBll.GetInstance().GetList(AppConst.PageSize, pageindex, txtName.Text.Trim(), int.Parse(drpCate.SelectedValue), int.Parse(drpStatus.SelectedValue), 0, ref total); m_dt.Columns.Add("deleteurl"); for (int i = 0; i < m_dt.Rows.Count; i++) { m_dt.Rows[i]["deleteurl"] = urlnow + "&delete="; } rptFamous.DataSource = m_dt; rptFamous.DataBind(); Pager1.url = "Articles.aspx?name=" + txtName.Text.Trim() + "&cate=" + drpCate.SelectedValue + "&status=" + drpStatus.SelectedValue + "&pn="; if (total % AppConst.PageSize == 0) { this.Pager1.total = total / AppConst.PageSize; } else { this.Pager1.total = total / AppConst.PageSize + 1; } this.Pager1.index = pageindex; this.Pager1.numlenth = 3; }
protected void rptCMSCate_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Repeater rptQuest = (Repeater)e.Item.FindControl("rptArticle"); Repeater rptQuest1 = (Repeater)e.Item.FindControl("rptArticle1"); //找到分类Repeater关联的数据项 DataRowView rowv = (DataRowView)e.Item.DataItem; //提取分类ID int CateId = Convert.ToInt32(rowv["SysNo"]); //根据分类ID查询该分类下的产品,并绑定产品Repeater DataSet ds = new DataSet(); if (HttpRuntime.Cache[AppConst.HomePageArticle + CateId] == null) { DataTable dt = CMS_ArticleBll.GetInstance().GetIndexCateArticle(20, CateId); dt.Columns.Add("IsHot"); DataTable dt1 = dt.Copy(); dt1.TableName = dt1.TableName + "1"; for (int i = 0; i < dt.Rows.Count; i++) { if (i > 9) { dt.Rows.RemoveAt(i); i--; continue; } if (int.Parse(dt.Rows[i]["ReadCount"].ToString()) < 10) { dt.Rows[i]["IsHot"] = i + "' style='display:none;"; } } for (int i = dt1.Rows.Count - 1; i >= 0; i--) { if (i < 10) { dt1.Rows.RemoveAt(i); continue; } if (int.Parse(dt1.Rows[i]["ReadCount"].ToString()) < 10) { dt1.Rows[i]["IsHot"] = i + "' style='display:none;"; } } //dt.Columns.Add("keys"); //for (int i = 0; i < dt.Rows.Count; i++) //{ // dt.Rows[i]["keys"] = ""; // string[] tmps = dt.Rows[i]["KeyWords"].ToString().Split(new char[] { ',', ' ', '|' }); // if (tmps.Length > 0) // { // for (int j = 0; j < tmps.Length; j++) // { // dt.Rows[i]["keys"] += @"<a href='Article/Index.aspx?key=" + tmps[j] + "'>tmps[j]</a>"; // } // } //} ds.Tables.Add(dt); ds.Tables.Add(dt1); HttpRuntime.Cache.Insert(AppConst.HomePageArticle + CateId, ds, null, DateTime.Now.AddMinutes(10), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.High, null); } ds = HttpRuntime.Cache[AppConst.HomePageArticle + CateId] as DataSet; rptQuest.DataSource = ds.Tables[0]; rptQuest.DataBind(); rptQuest1.DataSource = ds.Tables[1]; rptQuest1.DataBind(); } }
protected void PrepareForm() { #region 项绑定 DataTable parent = CMS_CategoryBll.GetInstance().GetCates(0); DataTable m_dt = new DataTable(); m_dt.Columns.Add("SysNo"); m_dt.Columns.Add("Name"); for (int i = 0; i < parent.Rows.Count; i++) { DataTable tmp = CMS_CategoryBll.GetInstance().GetCates(int.Parse(parent.Rows[i]["SysNo"].ToString())); for (int j = 0; j < tmp.Rows.Count; j++) { DataTable tmpp = CMS_CategoryBll.GetInstance().GetCates(int.Parse(tmp.Rows[j]["SysNo"].ToString())); for (int k = 0; k < tmpp.Rows.Count; k++) { DataRow m_dr = m_dt.NewRow(); m_dr["SysNo"] = tmpp.Rows[k]["SysNo"]; m_dr["Name"] = parent.Rows[i]["Name"].ToString() + "-" + tmp.Rows[j]["Name"].ToString() + "-" + tmpp.Rows[k]["Name"].ToString(); m_dt.Rows.Add(m_dr); } } } drpCate.DataSource = m_dt; drpCate.DataTextField = "Name"; drpCate.DataValueField = "SysNo"; drpCate.DataBind(); drpCate.Items.Insert(0, new ListItem("请选择", "0")); #endregion if (type == "ADD") { } else if (type == "EDIT") { if (Request.QueryString["id"] != null && Request.QueryString["id"] != "") { try { SysNo = int.Parse(Request.QueryString["id"]); CMS_ArticleMod m_cms = CMS_ArticleBll.GetInstance().GetModel(SysNo); SYS_ArticleMod m_article = SYS_ArticleBll.GetInstance().GetModel(m_cms.ArticleSysNo); Dictionary <int, SYS_ArticleContentMod> m_content = SYS_ArticleContentBll.GetInstance().GetContentByArticle(m_cms.ArticleSysNo); txtSysNo.Text = m_cms.SysNo.ToString(); txtContext.Text = m_content[1].Context; txtDesc.Text = m_article.Description; txtKeyWords.Text = m_article.KeyWords; txtOrder.Text = m_cms.OrderID.ToString(); txtPoint.Text = m_article.Cost.ToString(); txtSource.Text = m_cms.Source; txtTitle.Text = m_article.Title; txtAuthor.Text = m_cms.Author; drpCate.SelectedIndex = drpCate.Items.IndexOf(drpCate.Items.FindByValue(m_cms.CateSysNo.ToString())); } catch { Response.Redirect("../Error.aspx?msg="); return; } } } else if (type == "INPUT") { if (Request.QueryString["id"] != null && Request.QueryString["id"] != "") { try { int articleSysno = int.Parse(Request.QueryString["id"]); SYS_ArticleMod m_article = SYS_ArticleBll.GetInstance().GetModel(articleSysno); SYS_ArticleContentMod m_content = SYS_ArticleContentBll.GetInstance().GetModel(articleSysno); txtSysNo.Text = "自动生成"; txtTitle.Text = m_article.Title; txtContext.Text = m_content.Context; txtDesc.Text = m_article.Description; txtKeyWords.Text = m_article.KeyWords; txtPoint.Text = m_article.Cost.ToString(); txtOrder.Text = "0"; txtTitle.Enabled = false; txtContext.Enabled = false; txtDesc.Enabled = false; txtKeyWords.Enabled = false; txtPoint.Enabled = false; } catch { Response.Redirect("../Error.aspx?msg="); return; } } } }
protected void Unnamed3_Click(object sender, EventArgs e) { SYS_ArticleMod m_article = new SYS_ArticleMod(); Dictionary <int, SYS_ArticleContentMod> m_content = new Dictionary <int, SYS_ArticleContentMod>(); CMS_ArticleMod m_cms = new CMS_ArticleMod(); if (type == "EDIT") { if (Request.QueryString["id"] != null && Request.QueryString["id"] != "") { SysNo = int.Parse(Request.QueryString["id"]); } m_cms = CMS_ArticleBll.GetInstance().GetModel(SysNo); m_article = SYS_ArticleBll.GetInstance().GetModel(m_cms.ArticleSysNo); m_content = SYS_ArticleContentBll.GetInstance().GetContentByArticle(m_cms.ArticleSysNo); } try { if (drpCate.SelectedValue == "0") { ltrError.Text = "请选择分类!"; this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true); return; } m_article.Title = txtTitle.Text; if (type == "EDIT") { m_content[1].Context = txtContext.Text; } m_article.Description = txtDesc.Text; m_article.KeyWords = txtKeyWords.Text; m_article.Cost = int.Parse(txtPoint.Text); m_cms.CateSysNo = int.Parse(drpCate.SelectedValue); m_cms.Source = txtSource.Text; m_cms.Author = txtAuthor.Text; if (txtOrder.Text.Trim() != "") { m_cms.OrderID = int.Parse(txtOrder.Text.Trim()); } else { m_cms.OrderID = 0; } } catch { ltrError.Text = "输入资料格式有误,请检查!"; this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true); return; } try { if (type == "ADD") { m_article.CustomerSysNo = GetSession().AdminEntity.CustomerSysNo; m_article.Limited = (int)AppEnum.ArticleLimit.everyone; m_article.ReadCount = 0; m_article.TS = DateTime.Now; m_article.DR = (int)AppEnum.State.normal; m_cms.ArticleSysNo = SYS_ArticleBll.GetInstance().Add(m_article); m_cms.TS = DateTime.Now; m_cms.DR = (int)AppEnum.State.normal; CMS_ArticleBll.GetInstance().Add(m_cms); SYS_ArticleContentMod m_newcontent = new SYS_ArticleContentMod(); m_newcontent.ArticleSysNo = m_cms.ArticleSysNo; m_newcontent.Context = txtContext.Text; m_newcontent.Page = 1; m_newcontent.TS = DateTime.Now; m_newcontent.DR = (int)AppEnum.State.normal; SYS_ArticleContentBll.GetInstance().Add(m_newcontent); LogManagement.getInstance().WriteTrace(m_cms.SysNo, "Article.Add", "IP:" + Request.UserHostAddress + "|AdminID:" + GetSession().AdminEntity.Username); } else if (type == "EDIT") { CMS_ArticleBll.GetInstance().Update(m_cms); SYS_ArticleBll.GetInstance().Update(m_article); SYS_ArticleContentBll.GetInstance().Update(m_content[1]); LogManagement.getInstance().WriteTrace(m_cms.SysNo, "Article.Edit", "IP:" + Request.UserHostAddress + "|AdminID:" + GetSession().AdminEntity.Username); } else if (type == "INPUT") { m_cms.ArticleSysNo = SYS_ArticleBll.GetInstance().Add(m_article); CMS_ArticleBll.GetInstance().Add(m_cms); LogManagement.getInstance().WriteTrace(m_cms.SysNo, "Article.Input", "IP:" + Request.UserHostAddress + "|AdminID:" + GetSession().AdminEntity.Username); } ltrNotice.Text = "该记录已保存成功!"; this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('noticediv').style.display='';", true); } catch (Exception ex) { ltrError.Text = "系统错误,保存失败!"; this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true); LogManagement.getInstance().WriteException(ex, "Article.Save", "IP:" + Request.UserHostAddress + "|AdminID:" + GetSession().AdminEntity.Username); } }