コード例 #1
0
ファイル: LeaveComments.cs プロジェクト: davinx/himedi
 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;
         }
     }
 }
コード例 #2
0
ファイル: DataMapper.cs プロジェクト: davinx/himedi
 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;
 }
コード例 #3
0
ファイル: CommentData.cs プロジェクト: davinx/himedi
 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);
 }
コード例 #4
0
ファイル: CommentProvider.cs プロジェクト: davinx/himedi
 public abstract bool InsertLeaveComment(LeaveCommentInfo leave);
コード例 #5
0
ファイル: CommentProcessor.cs プロジェクト: davinx/himedi
 public static bool InsertLeaveComment(LeaveCommentInfo leave)
 {
     Globals.EntityCoding(leave, true);
     return CommentProvider.Instance().InsertLeaveComment(leave);
 }