Beispiel #1
0
 public void LoadEntity(DataRow row, T_NewComment commentInfo)
 {
     commentInfo.Id             = Convert.ToInt32(row["Id"]);
     commentInfo.NewId          = Convert.ToInt32(row["Id"]);
     commentInfo.Msg            = row["Msg"] != DBNull.Value ? row["Msg"].ToString() : string.Empty;
     commentInfo.CreateDateTime = Convert.ToDateTime(row["CreateDateTime"]);
 }
Beispiel #2
0
 public void LoadEntity(DataRow row, T_NewComment temp)
 {
     temp.Id             = Convert.ToInt32(row["id"]);
     temp.NewId          = Convert.ToInt32(row["NewId"]);
     temp.Msg            = row["Msg"] != null ? row["Msg"].ToString() : string.Empty;
     temp.CreateDateTime = Convert.ToDateTime(row["CreateDateTime"]);
 }
Beispiel #3
0
        //评论的添加
        public int InsertNewsComments(T_NewComment comment)
        {
            string sql = "insert into T_NewComments(NewId,Msg,CreateDateTime) values(@NewId,@New,@CreateDateTime)";

            SqlParameter[] paras =
            {
                new SqlParameter("@NewId",          SqlDbType.Int, 4),//长度为4
                new SqlParameter("@New",            SqlDbType.NVarChar),
                new SqlParameter("@CreateDateTime", SqlDbType.DateTime)
            };
            paras[0].Value = comment.NewId;
            paras[1].Value = comment.Msg;
            paras[2].Value = comment.CreateDateTime;
            return(SqlHelper.ExecuteNonquery(sql, CommandType.Text, paras));//插入一条评论
        }
Beispiel #4
0
        public int InsertEntityModel(T_NewComment newCommentInfo)
        {
            string sql = "insert into T_NewComments(NewId,Msg,CreateDateTime) values(@NewId,@Msg,@CreateDateTime)";

            SqlParameter[] pars =
            {
                new SqlParameter("@NewId",          SqlDbType.Int,       4),
                new SqlParameter("@Msg",            SqlDbType.NVarChar),

                new SqlParameter("@CreateDateTime", SqlDbType.DateTime)
            };
            pars[0].Value = newCommentInfo.NewId;
            pars[1].Value = newCommentInfo.Msg;
            pars[2].Value = newCommentInfo.CreateDateTime;
            return(SqlHelper.ExecuteNonQuery(sql, CommandType.Text, pars));
        }
Beispiel #5
0
        public ActionResult AddComment()
        {
            int          id      = int.Parse(Request["id"]);
            string       msg     = Request["msg"];
            T_NewComment comment = new T_NewComment();

            comment.Msg            = msg;
            comment.NewId          = id;
            comment.CreateDateTime = DateTime.Now;
            if (NewCommentService.InsertEntityModel(comment))
            {
                return(Content("ok"));
            }
            else
            {
                return(Content("no"));
            }
        }
Beispiel #6
0
        //根据新闻的id查找新闻的评论
        public List <T_NewComment> GetNewCommentList(int Newsid)
        {
            string              sql         = "select * from T_NewComments where NewId=@NewId";
            DataTable           dt          = SqlHelper.GetTable(sql, CommandType.Text, new SqlParameter("@NewId", Newsid));
            List <T_NewComment> commentList = null;//评论的列表

            if (dt.Rows.Count > 0)
            {
                commentList = new List <T_NewComment>();
                foreach (DataRow row in dt.Rows)
                {
                    T_NewComment temp = new T_NewComment();//临时存放每一条评论记录
                    LoadEntity(row, temp);
                    commentList.Add(temp);
                }
            }
            return(commentList);
        }
Beispiel #7
0
        public List <T_NewComment> GetNewCommentList(int newId)
        {
            string              sql         = "select * from T_NewComments where NewId=@NewId";
            DataTable           da          = SqlHelper.GetTable(sql, CommandType.Text, new SqlParameter("@NewId", newId));
            List <T_NewComment> CommentList = null;

            if (da.Rows.Count > 0)
            {
                CommentList = new List <T_NewComment>();
                T_NewComment Comment = null;
                foreach (DataRow row in da.Rows)
                {
                    Comment = new T_NewComment();
                    LoadEntity(row, Comment);
                    CommentList.Add(Comment);
                }
            }
            return(CommentList);
        }
Beispiel #8
0
 public bool InsertEntityModel(T_NewComment newCommentInfo)
 {
     return(NewCommentDal.InsertEntityModel(newCommentInfo) > 0);
 }
Beispiel #9
0
 public bool InsertComments(T_NewComment newCommentInfo)
 {
     return(comments.InsertNewsComments(newCommentInfo) > 0);//插入评论
 }