protected void Page_Load(object sender, EventArgs e) { this.btnSubmitHelpCategory.Click += new EventHandler(this.btnSubmitHelpCategory_Click); this.btnPicDelete.Click += new EventHandler(this.btnPicDelete_Click); if (!int.TryParse(base.Request.QueryString["CategoryId"], out this.categoryId)) { base.GotoResourceNotFound(); } else if (!base.IsPostBack) { HelpCategoryInfo helpCategory = ArticleHelper.GetHelpCategory(this.categoryId); if (helpCategory == null) { base.GotoResourceNotFound(); } else { Globals.EntityCoding(helpCategory, false); this.txtHelpCategoryName.Text = helpCategory.Name; this.txtHelpCategoryDesc.Text = helpCategory.Description; this.radioShowFooter.SelectedValue = helpCategory.IsShowFooter; this.imgPic.ImageUrl = helpCategory.IconUrl; this.imgPic.Visible = !string.IsNullOrEmpty(this.imgPic.ImageUrl); this.btnPicDelete.Visible = !string.IsNullOrEmpty(this.imgPic.ImageUrl); } } }
private void btnSubmitHelpCategory_Click(object sender, EventArgs e) { HelpCategoryInfo helpCategory = ArticleHelper.GetHelpCategory(this.categoryId); try { helpCategory.IconUrl = this.UploadImage(); } catch { this.ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false); return; } helpCategory.CategoryId = this.categoryId; helpCategory.Name = this.txtHelpCategoryName.Text.Trim(); helpCategory.Description = this.txtHelpCategoryDesc.Text.Trim(); helpCategory.IsShowFooter = this.ooShowFooter.SelectedValue; ValidationResults validationResults = Validation.Validate(helpCategory, "ValHelpCategoryInfo"); string text = string.Empty; if (!validationResults.IsValid) { foreach (ValidationResult item in (IEnumerable <ValidationResult>)validationResults) { text += Formatter.FormatErrorMessage(item.Message); } this.ShowMsg(text, false); } else { this.UpdateCategory(helpCategory); } }
private void grdHelpCategories_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e) { int rowIndex = ((System.Web.UI.WebControls.GridViewRow)((System.Web.UI.Control)e.CommandSource).NamingContainer).RowIndex; int categoryId = (int)this.grdHelpCategories.DataKeys[rowIndex].Value; if (e.CommandName == "Delete") { ArticleHelper.DeleteHelpCategory(categoryId); } else { if (e.CommandName == "SetYesOrNo") { HelpCategoryInfo helpCategory = ArticleHelper.GetHelpCategory(categoryId); if (helpCategory.IsShowFooter) { helpCategory.IsShowFooter = false; } else { helpCategory.IsShowFooter = true; } ArticleHelper.UpdateHelpCategory(helpCategory); } else { int displaySequence = int.Parse((this.grdHelpCategories.Rows[rowIndex].FindControl("lblDisplaySequence") as System.Web.UI.WebControls.Literal).Text); int num = 0; int replaceDisplaySequence = 0; if (e.CommandName == "Fall") { if (rowIndex < this.grdHelpCategories.Rows.Count - 1) { num = (int)this.grdHelpCategories.DataKeys[rowIndex + 1].Value; replaceDisplaySequence = int.Parse((this.grdHelpCategories.Rows[rowIndex + 1].FindControl("lblDisplaySequence") as System.Web.UI.WebControls.Literal).Text); } } else { if (e.CommandName == "Rise" && rowIndex > 0) { num = (int)this.grdHelpCategories.DataKeys[rowIndex - 1].Value; replaceDisplaySequence = int.Parse((this.grdHelpCategories.Rows[rowIndex - 1].FindControl("lblDisplaySequence") as System.Web.UI.WebControls.Literal).Text); } } if (num > 0) { ArticleHelper.SwapHelpCategorySequence(categoryId, num, displaySequence, replaceDisplaySequence); } } } base.Response.Redirect(System.Web.HttpContext.Current.Request.Url.ToString(), true); }
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); } } } }
private void btnEditHelp_Click(object sender, System.EventArgs e) { HelpInfo helpInfo = new HelpInfo(); if (!this.dropHelpCategory.SelectedValue.HasValue) { this.ShowMsg("请选择帮助分类", false); return; } helpInfo.HelpId = this.helpId; helpInfo.AddedDate = System.DateTime.Now; helpInfo.CategoryId = this.dropHelpCategory.SelectedValue.Value; helpInfo.Title = this.txtHelpTitle.Text.Trim(); helpInfo.MetaDescription = this.txtMetaDescription.Text.Trim(); helpInfo.MetaKeywords = this.txtMetaKeywords.Text.Trim(); helpInfo.Description = this.txtShortDesc.Text.Trim(); 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 = ArticleHelper.GetHelpCategory(helpInfo.CategoryId); if (!helpCategory.IsShowFooter) { this.ShowMsg("当选中的帮助分类设置不在底部帮助显示时,此分类下的帮助主题就不能设置在底部帮助显示", false); return; } } if (ArticleHelper.UpdateHelp(helpInfo)) { this.ShowMsg("已经成功修改当前帮助", true); return; } this.ShowMsg("编辑底部帮助错误", false); }
private void IsShow(HttpContext context) { int value = base.GetIntParam(context, "CategoryId", false).Value; HelpCategoryInfo helpCategory = ArticleHelper.GetHelpCategory(value); if (helpCategory.IsShowFooter) { helpCategory.IsShowFooter = false; } else { helpCategory.IsShowFooter = true; } ArticleHelper.UpdateHelpCategory(helpCategory); base.ReturnSuccessResult(context, "", 0, true); }
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); } } }
private void btnSubmitHelpCategory_Click(object sender, System.EventArgs e) { string text = string.Empty; text = ArticleHelper.GetHelpCategory(this.categoryId).IconUrl; if (this.fileUpload.HasFile) { try { if (!string.IsNullOrEmpty(text)) { ResourcesHelper.DeleteImage(text); } text = ArticleHelper.UploadHelpImage(this.fileUpload.PostedFile); } catch { this.ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false); return; } } HelpCategoryInfo helpCategoryInfo = new HelpCategoryInfo(); helpCategoryInfo.CategoryId = new int?(this.categoryId); helpCategoryInfo.Name = this.txtHelpCategoryName.Text.Trim(); helpCategoryInfo.IconUrl = text; helpCategoryInfo.Description = this.txtHelpCategoryDesc.Text.Trim(); helpCategoryInfo.IsShowFooter = this.radioShowFooter.SelectedValue; ValidationResults validationResults = Validation.Validate <HelpCategoryInfo>(helpCategoryInfo, new string[] { "ValHelpCategoryInfo" }); string text2 = string.Empty; if (validationResults.IsValid) { this.UpdateCategory(helpCategoryInfo); return; } foreach (ValidationResult current in (System.Collections.Generic.IEnumerable <ValidationResult>)validationResults) { text2 += Formatter.FormatErrorMessage(current.Message); } this.ShowMsg(text2, false); }
private void btnSubmitHelpCategory_Click(object sender, EventArgs e) { string iconUrl = string.Empty; iconUrl = ArticleHelper.GetHelpCategory(categoryId).IconUrl; if (fileUpload.HasFile) { try { if (!string.IsNullOrEmpty(iconUrl)) { ResourcesHelper.DeleteImage(iconUrl); } iconUrl = ArticleHelper.UploadHelpImage(fileUpload.PostedFile); } catch { ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false); return; } } HelpCategoryInfo info2 = new HelpCategoryInfo(); info2.CategoryId = new int?(categoryId); info2.Name = txtHelpCategoryName.Text.Trim(); info2.IconUrl = iconUrl; info2.Description = txtHelpCategoryDesc.Text.Trim(); info2.IsShowFooter = radioShowFooter.SelectedValue; HelpCategoryInfo target = info2; ValidationResults results = Hishop.Components.Validation.Validation.Validate <HelpCategoryInfo>(target, new string[] { "ValHelpCategoryInfo" }); string msg = string.Empty; if (results.IsValid) { UpdateCategory(target); } else { foreach (ValidationResult result in (IEnumerable <ValidationResult>)results) { msg = msg + Formatter.FormatErrorMessage(result.Message); } ShowMsg(msg, false); } }
private void btnPicDelete_Click(object sender, EventArgs e) { HelpCategoryInfo helpCategory = ArticleHelper.GetHelpCategory(this.categoryId); try { ResourcesHelper.DeleteImage(helpCategory.IconUrl); } catch { } helpCategory.IconUrl = this.imgPic.ImageUrl = string.Empty; if (ArticleHelper.UpdateHelpCategory(helpCategory)) { this.btnPicDelete.Visible = !string.IsNullOrEmpty(this.imgPic.ImageUrl); this.imgPic.Visible = !string.IsNullOrEmpty(this.imgPic.ImageUrl); } }
private void grdHelpCategories_RowCommand(object sender, GridViewCommandEventArgs e) { int rowIndex = ((GridViewRow)((Control)e.CommandSource).NamingContainer).RowIndex; int categoryId = (int)grdHelpCategories.DataKeys[rowIndex].Value; if (e.CommandName == "SetYesOrNo") { HelpCategoryInfo helpCategory = ArticleHelper.GetHelpCategory(categoryId); if (helpCategory.IsShowFooter) { helpCategory.IsShowFooter = false; } else { helpCategory.IsShowFooter = true; } ArticleHelper.UpdateHelpCategory(helpCategory); BindHelpCategory(); } else { int displaySequence = int.Parse((grdHelpCategories.Rows[rowIndex].FindControl("lblDisplaySequence") as Literal).Text); int replaceCategoryId = 0; int replaceDisplaySequence = 0; if (e.CommandName == "Fall") { if (rowIndex < (grdHelpCategories.Rows.Count - 1)) { replaceCategoryId = (int)grdHelpCategories.DataKeys[rowIndex + 1].Value; replaceDisplaySequence = int.Parse((grdHelpCategories.Rows[rowIndex + 1].FindControl("lblDisplaySequence") as Literal).Text); } } else if ((e.CommandName == "Rise") && (rowIndex > 0)) { replaceCategoryId = (int)grdHelpCategories.DataKeys[rowIndex - 1].Value; replaceDisplaySequence = int.Parse((grdHelpCategories.Rows[rowIndex - 1].FindControl("lblDisplaySequence") as Literal).Text); } if (replaceCategoryId > 0) { ArticleHelper.SwapHelpCategorySequence(categoryId, replaceCategoryId, displaySequence, replaceDisplaySequence); BindHelpCategory(); } } }
protected void Page_Load(object sender, EventArgs e) { this.btnSubmitHelpCategory.Click += this.btnSubmitHelpCategory_Click; if (!int.TryParse(base.Request.QueryString["CategoryId"], out this.categoryId)) { base.GotoResourceNotFound(); } else if (!base.IsPostBack) { HelpCategoryInfo helpCategory = ArticleHelper.GetHelpCategory(this.categoryId); if (helpCategory == null) { base.GotoResourceNotFound(); } else { Globals.EntityCoding(helpCategory, false); this.txtHelpCategoryName.Text = helpCategory.Name; this.txtHelpCategoryDesc.Text = helpCategory.Description; this.ooShowFooter.SelectedValue = helpCategory.IsShowFooter; this.hidOldImages.Value = helpCategory.IconUrl; } } }