private void btnAddHelp_Click(object sender, System.EventArgs e) { HelpInfo helpInfo = new HelpInfo(); if (!this.dropHelpCategory.SelectedValue.HasValue) { this.ShowMsg("请选择帮助分类", false); return; } helpInfo.AddedDate = System.DateTime.Now; helpInfo.CategoryId = this.dropHelpCategory.SelectedValue.Value; helpInfo.Title = this.txtHelpTitle.Text; helpInfo.MetaDescription = this.txtMetaDescription.Text; helpInfo.MetaKeywords = this.txtMetaKeywords.Text; helpInfo.Description = this.txtShortDesc.Text; helpInfo.Content = this.fcContent.Text; helpInfo.IsShowFooter = this.radioShowFooter.SelectedValue; ValidationResults validationResults = Validation.Validate <HelpInfo>(helpInfo, new string[] { "ValHelpInfo" }); 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 (this.radioShowFooter.SelectedValue) { HelpCategoryInfo helpCategory = SubsiteCommentsHelper.GetHelpCategory(helpInfo.CategoryId); if (!helpCategory.IsShowFooter) { this.ShowMsg("当选中的帮助分类设置不在底部帮助显示时,此分类下的帮助主题就不能设置在底部帮助显示", false); return; } } if (SubsiteCommentsHelper.CreateHelp(helpInfo)) { this.txtHelpTitle.Text = string.Empty; this.txtShortDesc.Text = string.Empty; this.fcContent.Text = string.Empty; this.ShowMsg("成功添加了一个帮助主题", true); return; } this.ShowMsg("添加帮助主题错误", false); }
private void btnAddHelp_Click(object sender, EventArgs e) { HelpInfo target = new HelpInfo(); if (!this.dropHelpCategory.SelectedValue.HasValue) { this.ShowMsg("请选择帮助分类", false); } else { target.AddedDate = DateTime.Now; target.CategoryId = this.dropHelpCategory.SelectedValue.Value; target.Title = this.txtHelpTitle.Text; target.MetaDescription = this.txtMetaDescription.Text; target.MetaKeywords = this.txtMetaKeywords.Text; target.Description = this.txtShortDesc.Text; target.Content = this.fcContent.Text; target.IsShowFooter = this.radioShowFooter.SelectedValue; ValidationResults results = Hishop.Components.Validation.Validation.Validate <HelpInfo>(target, new string[] { "ValHelpInfo" }); 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 (this.radioShowFooter.SelectedValue && !SubsiteCommentsHelper.GetHelpCategory(target.CategoryId).IsShowFooter) { this.ShowMsg("当选中的帮助分类设置不在底部帮助显示时,此分类下的帮助主题就不能设置在底部帮助显示", false); } else if (SubsiteCommentsHelper.CreateHelp(target)) { this.txtHelpTitle.Text = string.Empty; this.txtShortDesc.Text = string.Empty; this.fcContent.Text = string.Empty; this.ShowMsg("成功添加了一个帮助主题", true); } else { this.ShowMsg("添加帮助主题错误", false); } } }