private void btnAddAffiche_Click(object sender, System.EventArgs e) { AfficheInfo afficheInfo = new AfficheInfo(); afficheInfo.Title = this.txtAfficheTitle.Text.Trim(); afficheInfo.Content = this.fcContent.Text; afficheInfo.AddedDate = System.DateTime.Now; ValidationResults validationResults = Validation.Validate <AfficheInfo>(afficheInfo, new string[] { "ValAfficheInfo" }); string text = string.Empty; if (!validationResults.IsValid) { foreach (ValidationResult current in (System.Collections.Generic.IEnumerable <ValidationResult>)validationResults) { text += Formatter.FormatErrorMessage(current.Message); } this.ShowMsg(text, false); return; } if (SubsiteCommentsHelper.CreateAffiche(afficheInfo)) { this.txtAfficheTitle.Text = string.Empty; this.fcContent.Text = string.Empty; this.ShowMsg("成功发布了一条公告", true); return; } this.ShowMsg("添加公告失败", false); }
private void btnAddAffiche_Click(object sender, EventArgs e) { AfficheInfo target = new AfficheInfo(); target.Title = this.txtAfficheTitle.Text.Trim(); target.Content = this.fcContent.Text; target.AddedDate = DateTime.Now; ValidationResults results = Hishop.Components.Validation.Validation.Validate <AfficheInfo>(target, new string[] { "ValAfficheInfo" }); string msg = string.Empty; if (!results.IsValid) { foreach (ValidationResult result in (IEnumerable <ValidationResult>)results) { msg = msg + Formatter.FormatErrorMessage(result.Message); } this.ShowMsg(msg, false); } else if (SubsiteCommentsHelper.CreateAffiche(target)) { this.txtAfficheTitle.Text = string.Empty; this.fcContent.Text = string.Empty; this.ShowMsg("成功发布了一条公告", true); } else { this.ShowMsg("添加公告失败", false); } }