Exemplo n.º 1
0
 public void btnRefer_Click(object sender, EventArgs e)
 {
     if (!HiContext.Current.CheckVerifyCode(this.txtLeaveCode.Value))
     {
         this.ShowMessage("验证码不正确", false);
     }
     else if (this.ValidateConvert() && (((HiContext.Current.User.UserRole == UserRole.Member) || (HiContext.Current.User.UserRole == UserRole.Underling)) || this.userRegion(this.txtLeaveUserName.Value, this.txtLeavePsw.Value)))
     {
         LeaveCommentInfo target = new LeaveCommentInfo();
         target.UserName = Globals.HtmlEncode(this.txtUserName.Text);
         target.Title = Globals.HtmlEncode(this.txtTitle.Text);
         target.PublishContent = Globals.HtmlEncode(this.txtContent.Text);
         ValidationResults results = Hishop.Components.Validation.Validation.Validate<LeaveCommentInfo>(target, new string[] { "Refer" });
         string msg = string.Empty;
         if (!results.IsValid)
         {
             foreach (ValidationResult result in (IEnumerable<ValidationResult>) results)
             {
                 msg = msg + Formatter.FormatErrorMessage(result.Message);
             }
             this.ShowMessage(msg, false);
         }
         else
         {
             if (CommentProcessor.InsertLeaveComment(target))
             {
                 this.Page.ClientScript.RegisterClientScriptBlock(base.GetType(), "success", string.Format("<script>alert(\"{0}\");window.location.href=\"{1}\"</script>", "留言成功,管理员回复后即可显示", Globals.GetSiteUrls().UrlData.FormatUrl("LeaveComments")));
             }
             else
             {
                 this.ShowMessage("留言失败", false);
             }
             this.txtTitle.Text = string.Empty;
             this.txtContent.Text = string.Empty;
         }
     }
 }
Exemplo n.º 2
0
 public static LeaveCommentInfo PopulateLeaveComment(IDataReader reader)
 {
     if (null == reader)
     {
         return null;
     }
     LeaveCommentInfo info = new LeaveCommentInfo();
     info.LeaveId = (long) reader["LeaveId"];
     if (reader["UserId"] != DBNull.Value)
     {
         info.UserId = new int?((int) reader["UserId"]);
     }
     if (reader["UserName"] != DBNull.Value)
     {
         info.UserName = (string) reader["UserName"];
     }
     info.Title = (string) reader["Title"];
     info.PublishContent = (string) reader["PublishContent"];
     info.PublishDate = (DateTime) reader["PublishDate"];
     info.LastDate = (DateTime) reader["LastDate"];
     return info;
 }
Exemplo n.º 3
0
 public override bool InsertLeaveComment(LeaveCommentInfo leave)
 {
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("Insert into Hishop_LeaveComments(UserId,UserName,Title,PublishContent,PublishDate,LastDate)  values(@UserId,@UserName,@Title,@PublishContent,@PublishDate,@LastDate)");
     this.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, leave.UserId);
     this.database.AddInParameter(sqlStringCommand, "UserName", DbType.String, leave.UserName);
     this.database.AddInParameter(sqlStringCommand, "Title", DbType.String, leave.Title);
     this.database.AddInParameter(sqlStringCommand, "PublishContent", DbType.String, leave.PublishContent);
     this.database.AddInParameter(sqlStringCommand, "PublishDate", DbType.DateTime, DataHelper.GetSafeDateTimeFormat(DateTime.Now));
     this.database.AddInParameter(sqlStringCommand, "LastDate", DbType.DateTime, DataHelper.GetSafeDateTimeFormat(DateTime.Now));
     return (this.database.ExecuteNonQuery(sqlStringCommand) > 0);
 }
Exemplo n.º 4
0
 public abstract bool InsertLeaveComment(LeaveCommentInfo leave);
Exemplo n.º 5
0
 public static bool InsertLeaveComment(LeaveCommentInfo leave)
 {
     Globals.EntityCoding(leave, true);
     return CommentProvider.Instance().InsertLeaveComment(leave);
 }