Ejemplo n.º 1
0
        private void btnAddHelp_Click(object sender, EventArgs e)
        {
            HelpInfo helpInfo = new HelpInfo();

            if (!this.dropHelpCategory.SelectedValue.HasValue)
            {
                this.ShowMsg("请选择帮助分类", false);
            }
            else
            {
                helpInfo.AddedDate        = DateTime.Now;
                helpInfo.CategoryId       = this.dropHelpCategory.SelectedValue.Value;
                helpInfo.Title            = this.txtHelpTitle.Text.Trim();
                helpInfo.Meta_Description = this.txtMetaDescription.Text.Trim();
                helpInfo.Meta_Keywords    = this.txtMetaKeywords.Text.Trim();
                helpInfo.Description      = this.txtShortDesc.Text.Trim();
                helpInfo.Content          = this.fcContent.Text;
                helpInfo.IsShowFooter     = this.ooShowFooter.SelectedValue;
                ValidationResults validationResults = Validation.Validate(helpInfo, "ValHelpInfo");
                string            text = string.Empty;
                if (!validationResults.IsValid)
                {
                    foreach (ValidationResult item in (IEnumerable <ValidationResult>)validationResults)
                    {
                        text += Formatter.FormatErrorMessage(item.Message);
                    }
                    this.ShowMsg(text, false);
                }
                else
                {
                    if (this.ooShowFooter.SelectedValue)
                    {
                        HelpCategoryInfo helpCategory = ArticleHelper.GetHelpCategory(helpInfo.CategoryId);
                        if (!helpCategory.IsShowFooter)
                        {
                            this.ShowMsg("当选中的帮助分类设置不在底部帮助显示时,此分类下的帮助主题就不能设置在底部帮助显示", false);
                            return;
                        }
                    }
                    if (ArticleHelper.CreateHelp(helpInfo))
                    {
                        this.txtHelpTitle.Text = string.Empty;
                        this.txtShortDesc.Text = string.Empty;
                        this.fcContent.Text    = string.Empty;
                        this.ShowMsg("成功添加了一个帮助主题", true);
                    }
                    else
                    {
                        this.ShowMsg("添加帮助主题错误", false);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void btnAddHelp_Click(object sender, EventArgs e)
        {
            HelpInfo target = new HelpInfo();

            if (!dropHelpCategory.SelectedValue.HasValue)
            {
                ShowMsg("请选择帮助分类", false);
            }
            else
            {
                target.AddedDate       = DateTime.Now;
                target.CategoryId      = dropHelpCategory.SelectedValue.Value;
                target.Title           = txtHelpTitle.Text.Trim();
                target.MetaDescription = txtMetaDescription.Text.Trim();
                target.MetaKeywords    = txtMetaKeywords.Text.Trim();
                target.Description     = txtShortDesc.Text.Trim();
                target.Content         = fcContent.Text;
                target.IsShowFooter    = 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);
                    }
                    ShowMsg(msg, false);
                }
                else if (!(!radioShowFooter.SelectedValue || ArticleHelper.GetHelpCategory(target.CategoryId).IsShowFooter))
                {
                    ShowMsg("当选中的帮助分类设置不在底部帮助显示时,此分类下的帮助主题就不能设置在底部帮助显示", false);
                }
                else if (ArticleHelper.CreateHelp(target))
                {
                    txtHelpTitle.Text = string.Empty;
                    txtShortDesc.Text = string.Empty;
                    fcContent.Text    = string.Empty;
                    ShowMsg("成功添加了一个帮助主题", true);
                }
                else
                {
                    ShowMsg("添加帮助主题错误", false);
                }
            }
        }