public IList<SoundBlog_NEW.Model.SB_Comment> GetList(Int32 TypeID, Int32 TargetID) { String SQLCmd = "select * from Comment where " + "Comment_TargetTypeID = @Comment_TargetTypeID and Comment_TargetID = @Comment_TargetID"; MySqlParameter[] parameters = new MySqlParameter[]{ new MySqlParameter("@Comment_TargetTypeID", MySqlDbType.Int32), new MySqlParameter("@Comment_TargetID", MySqlDbType.Int32) }; parameters[0].Value = TypeID; parameters[1].Value = TargetID; MySqlDataReader reader = MySqlHelper.ExecuteSQLDataReader(SQLCmd, parameters); IList<SoundBlog_NEW.Model.SB_Comment> models = new List<SoundBlog_NEW.Model.SB_Comment>(); while (reader.Read()) { SoundBlog_NEW.Model.SB_Comment model = new SoundBlog_NEW.Model.SB_Comment(); ; model.Comment_ID = (Int32)reader["Comment_ID"]; model.Comment_TargetTypeID = (Int32)reader["Comment_TargetTypeID"]; model.Comment_TargetID = (Int32)reader["Comment_TargetID"]; model.Comment_Content = (String)reader["Comment_Content"]; model.Comment_UserID = (Int32)reader["Comment_UserID"]; model.Comment_Datetime = (DateTime)reader["Comment_Datetime"]; models.Add(model); } return models; }
public Int32 uId; // 登录用户ID #endregion Fields #region Methods protected void btnPost_Click(object sender, EventArgs e) { Int32 ii = 343; Int32 cid = (Int32?)Session["logined"] ?? -1; if (cid != -1) { Int32 tId = Int32.Parse(Request.Params["id"]); SoundBlog_NEW.Model.SB_Comment comment = new SoundBlog_NEW.Model.SB_Comment(); comment.Comment_TargetTypeID = 0; // 类别号 comment.Comment_TargetID = tId; // 目标号 comment.Comment_UserID = cid; comment.Comment_Content = tbComment.Text; comment.Comment_Datetime = DateTime.Now; if (Factory.BLLFactory.CreateSB_CommentBLL().Add(comment) != 0) { Factory.BLLFactory.CreateSB_TextBLL().AddCommentCount(tId, 1); Response.Redirect(Request.UrlReferrer.PathAndQuery); // Response.Write("<script language='javascript'>alert('发布成功');</script>"); // Response.End(); // Response.Redirect("Home.aspx"); } else { Response.Write("<script language='javascript'>alert('发布失败');</script>"); } } else { Response.Write("<script language='javascript'>alert('请先登录');</script>"); Response.End(); Response.Redirect("Login.aspx"); } }
public SoundBlog_NEW.Model.SB_Comment GetByID(Int32 ID) { String SQLCmd = "select * from Comment where " + "Comment_ID = @Comment_ID"; MySqlParameter[] parameters = new MySqlParameter[]{ new MySqlParameter("@Comment_ID",MySqlDbType.Int32) }; parameters[0].Value = ID; MySqlDataReader reader = MySqlHelper.ExecuteSQLDataReader(SQLCmd, parameters); SoundBlog_NEW.Model.SB_Comment model = new SoundBlog_NEW.Model.SB_Comment(); ; while (reader.Read()) { model.Comment_ID = (Int32)reader["Comment_ID"]; model.Comment_TargetID = (Int32)reader["Comment_TargetID"]; model.Comment_TargetTypeID = (Int32)reader["Comment_TargetID"]; model.Comment_UserID = (Int32)reader["Comment_UserID"]; model.Comment_Content = (String)reader["Comment_Content"]; model.Comment_Datetime = (DateTime)reader["Comment_Datetime"]; } return model; }