public List <CommentModel> CommentList(CommentListPostModel model) { int totalcount; if (model.articleId == 0 || model.pageSize == 0) { throw new Exception("获取失败,传输参数有误!"); } BLL.article_comment bll = new BLL.article_comment(); DataSet ds = bll.GetList(model.pageSize, model.pageIndex, string.Format("is_lock=0 and article_id={0}", model.articleId.ToString()), "add_time asc", out totalcount); var list = new List <CommentModel>(); //如果记录存在 if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { DataRow dr = ds.Tables[0].Rows[i]; var comment = new CommentModel(); comment.user_id = int.Parse(dr["user_id"].ToString()); comment.user_name = dr["user_name"].ToString(); if (Convert.ToInt32(dr["user_id"]) > 0) { Model.users userModel = new BLL.users().GetModel(Convert.ToInt32(dr["user_id"])); if (userModel != null) { comment.avatar = userModel.avatar; } } comment.content = dr["content"].ToString(); } } return(list); }
private void RptBind(string _strWhere, string _orderby) { this.page = DTRequest.GetQueryInt("page", 1); this.ddlProperty.SelectedValue = this.property; this.txtKeywords.Text = this.keywords; BLL.article_comment bll = new BLL.article_comment(); this.rptList.DataSource = bll.GetList(this.pageSize, this.page, _strWhere, _orderby, out this.totalCount); this.rptList.DataBind(); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("comment_list.aspx", "channel_id={0}&keywords={1}&property={2}&page={3}", this.channel_id.ToString(), this.keywords, this.property, "__id__"); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
private void RptBind(string _strWhere, string _orderby) { this.page = DTRequest.GetQueryInt("page", 1); this.ddlProperty.SelectedValue = this.property; this.txtKeywords.Text = this.keywords; BLL.article_comment bll = new BLL.article_comment(); this.rptList.DataSource = bll.GetList(this.pageSize, this.page, _strWhere, _orderby, out this.totalCount); this.rptList.DataBind(); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("comment_list.aspx", "channel_id={0}&keywords={1}&property={2}&page={3}", this.channel_id.ToString(), this.keywords, this.property, "__id__"); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
private void comment_list(HttpContext context) { int article_id = DTRequest.GetQueryInt("article_id"); int page_index = DTRequest.GetQueryInt("page_index"); int page_size = DTRequest.GetQueryInt("page_size"); int totalcount; StringBuilder strTxt = new StringBuilder(); if (article_id == 0 || page_size == 0) { context.Response.Write("获取失败,传输参数有误!"); return; } BLL.article_comment bll = new BLL.article_comment(); DataSet ds = bll.GetList(page_size, page_index, string.Format("is_lock=0 and article_id={0}", article_id.ToString()), "add_time asc", out totalcount); //如果记录存在 if (ds.Tables[0].Rows.Count > 0) { strTxt.Append("["); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { DataRow dr = ds.Tables[0].Rows[i]; //strTxt.Append("<li>\n"); //strTxt.Append("<div class=\"title\"><span>" + dr["add_time"] + "</span>" + dr["user_name"] + "</div>"); //strTxt.Append("<div class=\"box\">" + dr["content"] + "</div>"); //if (Convert.ToInt32(dr["is_reply"]) == 1) //{ // strTxt.Append("<div class=\"reply\">"); // strTxt.Append("<strong>管理员回复:</strong>" + dr["reply_content"].ToString()); // strTxt.Append("<span class=\"time\">" + dr["reply_time"].ToString() + "</span>"); // strTxt.Append("</div>"); //} //strTxt.Append("</li>\n"); strTxt.Append("{"); strTxt.Append("\"user_id\":" + dr["user_id"]); strTxt.Append(",\"user_name\":\"" + dr["user_name"] + "\""); if (Convert.ToInt32(dr["user_id"]) > 0) { Model.users userModel = new BLL.users().GetModel(Convert.ToInt32(dr["user_id"])); if (userModel != null) { strTxt.Append(",\"avatar\":\"" + userModel.avatar + "\""); } } strTxt.Append(""); strTxt.Append(",\"content\":\"" + Microsoft.JScript.GlobalObject.escape(dr["content"]) + "\""); strTxt.Append(",\"add_time\":\"" + dr["add_time"] + "\""); strTxt.Append(",\"is_reply\":" + dr["is_reply"]); if (Convert.ToInt32(dr["is_reply"]) == 1) { strTxt.Append(",\"reply_content\":\"" + Microsoft.JScript.GlobalObject.escape(dr["reply_content"]) + "\""); strTxt.Append(",\"reply_time\":\"" + dr["reply_time"] + "\""); } strTxt.Append("}"); //是否加逗号 if (i < ds.Tables[0].Rows.Count - 1) { strTxt.Append(","); } } strTxt.Append("]"); } //else //{ // strTxt.Append("<p>暂无评论,快来抢沙发吧!</p>"); //} context.Response.Write(strTxt.ToString()); }
protected void ListComment() { BLL.article_comment bll = new BLL.article_comment(); this.rptList.DataSource = bll.GetList(10, " is_reply=1 and article_id=" + id + "", " add_time desc"); this.rptList.DataBind(); }