示例#1
0
        public bool AddNoticeCmnt(NoticeCmnt cmnt)
        {
            String sql = @"INSERT INTO [notice_cmnt]([notice_id], [user_id], [contents], [cmnt_date])
                          VALUES(@notice_id, @user_id, @contents, @cmnt_date)";

            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@notice_id", cmnt.NoticeId),
                new SqlParameter("@user_id", cmnt.UserId),
                new SqlParameter("@contents", cmnt.Contents),
                new SqlParameter("@cmnt_date", cmnt.CmntDate)
            };

            Int32 line = (Int32)connector.Execute("non", sql, parameters); // 可以重复评论

            return(line <= 0 ? false : true);
        }
示例#2
0
        /// <summary>
        /// 评论按钮点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void CmntBtn_Click(object sender, EventArgs e)
        {
            try
            {
                string cmntText = CmntText.Text.ToString();
                Int64  noticeId = GetNoticeId();

                if (!IsSignIn())
                {
                    Response.Redirect(URL_SIGNIN);
                    return;
                }

                User user = (User)Session["User"];

                if (noticeId != 0)
                {
                    // 构建待插入对象
                    NoticeCmnt cmnt = new NoticeCmnt()
                    {
                        NoticeId = noticeId,
                        UserId   = user.Id,
                        Contents = cmntText,
                        CmntDate = DateTime.Now.ToLocalTime()
                    };

                    bool isOk = NoticeCmntService.AddNoticeCmnt(cmnt);

                    if (isOk)
                    {
                        DisplayNoticeCmnt(); // 从新显示评论区
                    }
                }
            }
            catch (Exception ex)
            {
                PromptInfo.Text = ex.Message;
            }
        }
示例#3
0
 /// <summary>
 /// 添加启示评论记录
 /// </summary>
 /// <param name="cmnt">实体对象:NoticeCmnt</param>
 /// <returns>布尔值:是否添加成功</returns>
 public static Boolean AddNoticeCmnt(NoticeCmnt cmnt)
 {
     return(iNoticeCmntDao.AddNoticeCmnt(cmnt));
 }