protected void btnPost_Click(object sender, EventArgs e) { try { int id = int.Parse(Request.QueryString["ID"]); ArticleCategory cat = ArticleManager.GetArticleCategory(id); if (cat != null) { cat.Name = txtCategoryName.Text; cat.Description = txtCategoryDesc.Text; cat.DisplayOrder = int.Parse(txtDisplayOrder.Text); cat.ID = id; cat.UpdateTime = DateTime.Now; cat.UpdateUser = Profile.AccountInfo.UserID; DataActionStatus status = ArticleManager.UpdateArticleCategory(cat); if (status == DataActionStatus.Success) { base.ExecuteJs("msg('操作成功,已成功修改此资讯分类信息!',true);", false); } } } catch (System.Exception ex) { } mbMsg.ShowMsg("修改资讯分类信息失败,请联系管理员!"); }
void BindParentCategory(int id) { ArticleCategory category = ArticleManager.GetArticleCategory(id); ltParentCategory.Text = category.Name; ltParentCategoryDesc.Text = category.Description; }
private void BindArticleCategory(int id) { ArticleCategory cat = ArticleManager.GetArticleCategory(id); if (cat.ParentID.HasValue) { int parentID = cat.ParentID.Value; ArticleCategory parentCat = ArticleManager.GetArticleCategory(parentID); if (parentCat != null) { ltParentCategory.Text = parentCat.Name; ltParentCategoryDesc.Text = parentCat.Description; } } txtCategoryName.Text = cat.Name; txtCategoryDesc.Text = cat.Description; txtDisplayOrder.Text = cat.DisplayOrder.ToString(); }
/// <summary> /// 绑定文章列表 /// </summary> public void BindArticles() { // queryString中的参数: // cate: 分类id -1为最新分类 // p: 页码 // v: 查看方式, 0 详细资料 1 列表 int categoryID = -1; string categoryIDStr = Request.QueryString["cate"]; if (!string.IsNullOrEmpty(categoryIDStr)) { int.TryParse(HHOnline.Framework.GlobalSettings.Decrypt(categoryIDStr), out categoryID); } int pageIndex = 0; string pageIDStr = Request.QueryString["p"]; if (!string.IsNullOrEmpty(pageIDStr)) { int.TryParse(pageIDStr, out pageIndex); } int viewState = 0; string viewStateStr = Request.QueryString["v"]; if (!string.IsNullOrEmpty(viewStateStr)) { int.TryParse(viewStateStr, out viewState); } // 根据资讯分类绑定资讯 ArticleQuery query = new ArticleQuery(); if (categoryID == -1) { lblCategoryName.Text = "最新资讯"; query.CategoryID = null; } else { ArticleCategory cateInfo = ArticleManager.GetArticleCategory(categoryID); lblCategoryName.Text = cateInfo.Name; query.CategoryID = categoryID; } query.PageIndex = pageIndex; query.PageSize = pageSize; PagingDataSet <Article> articles = ArticleManager.GetArticles(query); if (null == articles || 0 == articles.TotalRecords) { msgBox.ShowMsg("没有符合条件的资讯存在!", System.Drawing.Color.Gray); } else { msgBox.HideMsg(); } // 绑定 repArticles.DataSource = articles.Records; repArticles.Visible = viewState == 0; repArticles.DataBind(); repArticlesList.DataSource = articles.Records; repArticlesList.Visible = viewState == 1; repArticlesList.DataBind(); }
private void BindData() { string articleIDStr = Request.QueryString["id"]; if (!string.IsNullOrEmpty(articleIDStr)) { int articleID; if (int.TryParse(HHOnline.Framework.GlobalSettings.Decrypt(articleIDStr), out articleID)) { // 增加点击率 //ArticleManager.IncreaseHitTimes(articleID); BaseViews views = ViewsFactory.GetViews(typeof(ArticleViews)); views.AddViewCount(articleID); Article article = ArticleManager.GetArticle(articleID); if (article != null) { lblAbstract.InnerHtml = article.Abstract; lblAuthor.Text = string.IsNullOrEmpty(article.Author) ? "匿名" : article.Author; lblDate.Text = article.Date.HasValue ? article.Date.Value.ToString() : DateTime.Now.ToString(); lblHitTimes.Text = article.HitTimes.ToString(); lblTitle.Text = article.Title; lblSubTitle.Text = article.SubTitle; lblKeywords.Text = string.IsNullOrEmpty(article.Keywords) ? "无" : article.Keywords; // 获取所有产品 ProductQuery pq = new ProductQuery(); pq.HasPublished = true; List <Product> products = Products.GetProductList(pq); List <ReplaceKeyValue> rkvs = new List <ReplaceKeyValue>(); foreach (Product item in products) { ReplaceKeyValue rkv = new ReplaceKeyValue(); rkv.Key = item.ProductName; rkv.Value = "<a style='color: blue; text-decoration:underline;' href=\"view.aspx?product-product&ID=" + HHOnline.Framework.GlobalSettings.Encrypt(item.ProductID.ToString()) + "\">" + item.ProductName + "</a>"; rkvs.Add(rkv); } FastReplace fr = new FastReplace(rkvs.ToArray()); lblContent.InnerHtml = fr.ReplaceAll(article.Content); // 查找分类 ArticleCategory ac = ArticleManager.GetArticleCategory(article.Category); if (ac != null) { btnCategory.Text = ac.Name; btnCategory.OnClientClick = "window.location.href='view.aspx?news-newslist&cate=" + HHOnline.Framework.GlobalSettings.Encrypt(ac.ID.ToString()) + "';return false;"; } if (!string.IsNullOrEmpty(article.CopyFrom)) { lblCopyForm.Text = "文章来源: " + article.CopyFrom; lblCopyForm.Visible = true; } else { lblCopyForm.Visible = false; } // 获取附件 ArticleAttachment attachment = ArticleAttachments.GetAttachment(article.Image); if (attachment != null) { if (attachment.IsRemote) { imgAttachment.ImageUrl = attachment.FileName; } else { imgAttachment.ImageUrl = attachment.GetDefaultImageUrl(100, 100); } imgAttachment.Visible = true; } else { imgAttachment.Visible = false; } this.ShortTitle = article.Title; } else { imgAttachment.Visible = false; } } this.SetTitle(); } }
private void BindData() { ascCategory.IsShowAllCategory = true; ArticleQuery query = ArticleQuery.GetQueryFromQueryString(Request.QueryString); btnAll.CssClass = string.Empty; lblTip.Text = string.Empty; // 判断标题 if (!string.IsNullOrEmpty(query.Title)) { lblTip.Text = "标题中包含“" + query.Title + "”"; } // 判断分类 if (query.CategoryID.HasValue) { if (!string.IsNullOrEmpty(lblTip.Text)) { lblTip.Text += ";"; } // 获取分类 ArticleCategory ac = ArticleManager.GetArticleCategory(query.CategoryID.Value); //ascCategory.SelectedCategoryID = query.CategoryID.Value; lblTip.Text += "分类为“" + ac.Name + "”"; } // 判断点击次数 if (query.HitStartTimes.HasValue) { if (!string.IsNullOrEmpty(lblTip.Text)) { lblTip.Text += ";"; } lblTip.Text += "访问量大于" + query.HitStartTimes.Value + "次"; } if (query.HitEndTimes.HasValue) { if (!string.IsNullOrEmpty(lblTip.Text)) { lblTip.Text += ";"; } lblTip.Text += "访问量小于" + query.HitEndTimes.Value + "次"; } // 判断日期 if (query.CreateStartTime.HasValue) { if (!string.IsNullOrEmpty(lblTip.Text)) { lblTip.Text += ";"; } lblTip.Text += "时间从“" + query.CreateStartTime.Value.ToShortDateString() + "”开始"; } if (query.CreateEndTime.HasValue) { if (!string.IsNullOrEmpty(lblTip.Text)) { lblTip.Text += ";"; } lblTip.Text += "时间到“" + query.CreateEndTime.Value.ToShortDateString() + "”截止"; } if (string.IsNullOrEmpty(lblTip.Text)) { lblTip.Text = "全部"; btnAll.CssClass = "active"; } query.PageSize = Int32.MaxValue; PagingDataSet <Article> products = ArticleManager.GetArticles(query); egvArticles.DataSource = products.Records; egvArticles.DataBind(); }