private int SendComments() { if (txtcomment.Text.Trim() != "") { newcomment = new KLNewsComment(); try { newcomment.Comment = txtcomment.Text; newcomment.CreateDate = DateTime.Now; newcomment.Email = txtEmail.Text; newcomment.Name = txtFullName.Text; newcomment.UserID = currentUser.UserId; newcomment.NewsID = newsID; newcomment.Save(); KLNotify notify = new KLNotify(); KLAuthor author = new KLAuthor(news.AuthorID); notify.AuthorID = author.UserID; notify.UserName_Action = txtFullName.Text; notify.DateCreate = DateTime.Now; notify.NotifyType = "Comment"; notify.Viewed = false; News newsKL = new News(siteSettings.SiteId, news.NewsID); notify.Notify = ResourceFile.GetResourceString("CustomResources", "NotifyComment") + newsKL.Title; notify.NotifyLink = SiteRoot + "/news-detail?newsID=" + news.NewsID; notify.Save(); } catch (Exception ex) { log.Error(ex.Message); } return(newcomment.CommentID); } return(-1); }
protected void listviewComment_ItemCommand(object sender, ListViewCommandEventArgs e) { if (e.Item != null) { ListViewDataItem dataItem = (ListViewDataItem)e.Item; Label lbCommentID = (Label)e.Item.FindControl("CommentID"); try { KLNewsComment com = new KLNewsComment(int.Parse(lbCommentID.Text)); KLNews news = new KLNews(com.NewsID, 0); if (String.Equals(e.CommandName.ToLower(), "approve")) { news.CommentCount = news.CommentCount + 1; com.IsPublish = true; } else if (String.Equals(e.CommandName.ToLower(), "delete")) { int index = e.Item.DisplayIndex; listviewComment.DeleteItem(index); news.CommentCount = news.CommentCount - 1; com.IsPublish = false; com.ISDel = true; } news.Save(); com.Save(); } catch (Exception) { } } WebUtils.SetupRedirect(this, Request.RawUrl); }
protected void rptComments_ItemCommand(object source, RepeaterCommandEventArgs e) { TextBox txtsubname = (TextBox)e.Item.FindControl("txtsubname"); TextBox txtsubemail = (TextBox)e.Item.FindControl("txtsubemail"); TextBox txtsubcomment = (TextBox)e.Item.FindControl("txtsubcomment"); HiddenField commentid = (HiddenField)e.Item.FindControl("hdcommentid"); KLNewsComment subcomment = null; if (txtsubcomment.Text.Trim() != "") { subcomment = new KLNewsComment(); try { subcomment.Comment = txtsubcomment.Text; subcomment.CreateDate = DateTime.Now; subcomment.Email = txtsubemail.Text; subcomment.Name = txtsubname.Text; subcomment.UserID = currentUser.UserId; subcomment.NewsID = newsID; subcomment.CommentParentID = int.Parse(commentid.Value); subcomment.Save(); KLNotify notify = new KLNotify(); KLAuthor author = new KLAuthor(news.AuthorID); notify.AuthorID = author.UserID; notify.UserName_Action = txtsubname.Text; notify.DateCreate = DateTime.Now; notify.NotifyType = "Comment"; notify.Viewed = false; News newsKL = new News(siteSettings.SiteId, news.NewsID); notify.Notify = ResourceFile.GetResourceString("CustomResources", "NotifyComment") + newsKL.Title; notify.NotifyLink = SiteRoot + "/news-detail?newsID=" + news.NewsID; notify.Save(); divmessagecomment.InnerHtml = AlertSuccess(); } catch (Exception ex) { log.Error(ex.Message); } } }
protected virtual void LoadSettings() { current = SiteUtils.GetCurrentSiteUser(); if (current != null) { news = WebUtils.ParseInt32FromQueryString("NewsID", news); author = KLAuthor.GetKLAuthorByUserID(current.UserId); if (author == null) { WebUtils.SetupRedirect(this, SiteRoot); } listcomment = KLNewsComment.GetPageByAuthor(1, 10000, out totalpage, author.AuthorID, approved, news, -1, -1); listviewComment.DataSource = listcomment.OrderBy(com => com.IsPublish); listviewComment.DataBind(); GeneralVariables.NameAuthor = current.Name; GeneralVariables.Level = author.LevelAuthor; } else { WebUtils.SetupRedirect(this, SiteRoot); } }
private void PopulateControls() { rptCommentTop.DataSource = KLNewsComment.GetPageByAuthor(pagecomment, pagesizecomment, out totalpagecomment, -1, 1, newsID, -1, -1); rptCommentTop.DataBind(); }
protected string getimgURL(int CommentId) { KLNewsComment com = new KLNewsComment(CommentId); return(AuthorHepper.GetAvatarAuthor(siteSettings.SiteId, com.UserID)); }
protected List <KLNewsComment> GetChildComments(int commentid) { return(KLNewsComment.GetPageByAuthor(pagecomment, pagesizecomment, out totalpagecomment, -1, 1, newsID, -1, commentid)); }
protected int getcommentcount(int newsid) { return(KLNewsComment.GetCountByNewsID(newsid)); }