예제 #1
0
파일: Comments.cs 프로젝트: wenysky/itcaweb
 public static void CreateComment(CommentInfo info)
 {
     if (info != null)
     {
         DatabaseProvider.GetInstance().CreateComment(info);
     }
 }
예제 #2
0
 static CommentInfo DataReader2CommentInfo(IDataReader reader)
 {
     CommentInfo info = new CommentInfo();
     info.Commentid = Convert.ToInt32(reader["commentid"]);
     info.Articleid = Convert.ToInt32(reader["articleid"]);
     info.Articletitle = reader["articletitle"].ToString();
     info.Uid = Convert.ToInt32(reader["uid"]);
     info.Username = reader["username"].ToString();
     info.Postdate = Convert.ToDateTime(reader["postdate"]).ToString("yyyy-MM-dd");
     info.Del = Convert.ToInt32(reader["del"]);
     info.Content = reader["content"].ToString();
     info.Goodcount = Convert.ToInt32(reader["goodcount"]);
     info.Badcount = Convert.ToInt32(reader["badcount"]);
     return info;
 }
예제 #3
0
 public void CreateComment(CommentInfo commentinfo)
 {
     DbParameter[] dbparams =
     {
         DbHelper.MakeInParam("?articleid", (DbType)MySqlDbType.Int32, 4, commentinfo.Articleid),
         DbHelper.MakeInParam("?uid", (DbType)MySqlDbType.Int32, 4, commentinfo.Uid),
         DbHelper.MakeInParam("?username", (DbType)MySqlDbType.String, 50, commentinfo.Username),
         DbHelper.MakeInParam("?postdate", (DbType)MySqlDbType.Datetime, 8, commentinfo.Postdate),
         DbHelper.MakeInParam("?del", (DbType)MySqlDbType.Int32, 4, commentinfo.Del),
         DbHelper.MakeInParam("?content", (DbType)MySqlDbType.String, 1000, commentinfo.Content),
         DbHelper.MakeInParam("?goodcount", (DbType)MySqlDbType.Int32, 4, commentinfo.Goodcount),
         DbHelper.MakeInParam("?badcount", (DbType)MySqlDbType.Int32, 4, commentinfo.Badcount),
         DbHelper.MakeInParam("?articletitle", (DbType)MySqlDbType.String, 100, commentinfo.Articletitle)
     };
     DbHelper.ExecuteNonQuery(CommandType.Text, string.Format("INSERT INTO {0}comments(articleid,uid,username,postdate,del,content,goodcount,badcount,articletitle) VALUES(?articleid,?uid,?username,?postdate,?del,?content,?goodcount,?badcount,?articletitle)", BaseConfigs.GetConfig().Tableprefix), dbparams);
 }
예제 #4
0
 protected override void Page_Show()
 {
     UserInfo userinfo = GetUserInfo();
     if (userinfo == null)
     {
         ShowError("评论信息", "请登录后再留言评论.", "", "login.aspx");
     }
     string action = YRequest.GetQueryString("action");
     if (action == string.Empty)
     {
         currentcontext.Response.End();
     }
     if (action == "postcomment")
     {
         string content = YRequest.GetFormString("commentcontent");
         int articleid = YRequest.GetQueryInt("articleid", 0);
         if (content != string.Empty && articleid > 0)
         {
             if (content != string.Empty)
             {
                 CommentInfo info = new CommentInfo();
                 info.Articleid = articleid;
                 info.Uid = userinfo.Uid;
                 info.Username = userinfo.Username;
                 info.Postdate = DateTime.Now.ToString();
                 info.Del = 0;
                 info.Content = Utils.RemoveUnsafeHtml(content);
                 info.Goodcount = 0;
                 info.Badcount = 0;
                 info.Articletitle = Articles.GetArticleInfo(articleid).Title;
                 Comments.CreateComment(info);
                 Articles.ChangeCommentCount(articleid, 1, 1);
                 Articles.RemoveArtilceCache();
                 currentcontext.Response.Redirect(YRequest.GetUrlReferrer());
             }
         }
         else
         {
             currentcontext.Response.Write("参数为空.");
             currentcontext.Response.End();
             return;
         }
     }
     else if (action == "grade")
     {
         int commentid = YRequest.GetQueryInt("commentid", 0);
         if (commentid > 0)
         {
             int type = YRequest.GetQueryInt("type", 0);
             Comments.GradeComment(commentid, type);
             Articles.RemoveArtilceCache();
             currentcontext.Response.Redirect(YRequest.GetUrlReferrer());
         }
         else
         {
             ShowError("评论信息", "参数为空,请检查输入!", "", "");
         }
     }
     else if (action == "del")
     {
         int commentid = YRequest.GetQueryInt("commentid", 0);
         if (commentid > 0)
         {
             CommentInfo info = Comments.GetCommentInfo(commentid);
             Comments.DeleteComment(info.Commentid);
             Articles.ChangeCommentCount(info.Articleid, 1, -1);
             Articles.RemoveArtilceCache();
             currentcontext.Response.Redirect(YRequest.GetUrlReferrer());
         }
         else
         {
             ShowError("评论信息", "参数为空,请检查输入!", "", "");
         }
     }
     else
     {
         ShowError("评论信息", "非法的参数!", "", "");
     }
 }