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"]); }
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"]); }
//评论的添加 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));//插入一条评论 }
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)); }
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")); } }
//根据新闻的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); }
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); }
public bool InsertEntityModel(T_NewComment newCommentInfo) { return(NewCommentDal.InsertEntityModel(newCommentInfo) > 0); }
public bool InsertComments(T_NewComment newCommentInfo) { return(comments.InsertNewsComments(newCommentInfo) > 0);//插入评论 }