public static bool DeleteHelpCategory(int categoryId) { HelpCategoryInfo helpCategory = new HelpCategoryInfo(); helpCategory.CategoryId = new int?(categoryId); return(CommentsProvider.Instance().CreateUpdateDeleteHelpCategory(helpCategory, DataProviderAction.Delete)); }
public override bool CreateUpdateDeleteHelpCategory(HelpCategoryInfo helpCategory, DataProviderAction action) { if (null == helpCategory) { return(false); } DbCommand storedProcCommand = this.database.GetStoredProcCommand("sub_HelpCategory_CreateUpdateDelete"); this.database.AddInParameter(storedProcCommand, "Action", DbType.Int32, (int)action); this.database.AddOutParameter(storedProcCommand, "Status", DbType.Int32, 4); if (action != DataProviderAction.Create) { this.database.AddInParameter(storedProcCommand, "CategoryId", DbType.Int32, helpCategory.CategoryId); } this.database.AddInParameter(storedProcCommand, "DistributorUserId", DbType.Int32, HiContext.Current.User.UserId); if (action != DataProviderAction.Delete) { this.database.AddInParameter(storedProcCommand, "Name", DbType.String, helpCategory.Name); this.database.AddInParameter(storedProcCommand, "IconUrl", DbType.String, helpCategory.IconUrl); this.database.AddInParameter(storedProcCommand, "IndexChar", DbType.String, helpCategory.IndexChar); this.database.AddInParameter(storedProcCommand, "Description", DbType.String, helpCategory.Description); this.database.AddInParameter(storedProcCommand, "IsShowFooter", DbType.Boolean, helpCategory.IsShowFooter); } this.database.ExecuteNonQuery(storedProcCommand); return(((int)this.database.GetParameterValue(storedProcCommand, "Status")) == 0); }
protected override void AttachChildControls() { this.rptHelps = (ThemedTemplatedRepeater)this.FindControl("rptHelps"); this.pager = (Pager)this.FindControl("pager"); this.lblCategory = (System.Web.UI.WebControls.Label) this.FindControl("lblCategory"); this.lblhelpName = (System.Web.UI.WebControls.Label) this.FindControl("lblhelpName"); this.lblhelpcontent = (System.Web.UI.WebControls.Literal) this.FindControl("lblhelpcontent"); if (!this.Page.IsPostBack) { if (!string.IsNullOrEmpty(this.Page.Request.QueryString["helpid"])) { int helpid = 0; int.TryParse(this.Page.Request.QueryString["helpid"], out helpid); HelpInfo helpInfo = CommentBrowser.GetHelp(helpid); if (helpInfo != null) { HelpCategoryInfo helpCategory = CommentBrowser.GetHelpCategory(helpInfo.CategoryId); PageTitle.AddSiteNameTitle(helpInfo.Title); this.lblCategory.Text = helpCategory.Name; this.lblhelpName.Text = helpInfo.Title; this.lblhelpcontent.Text = helpInfo.Content; } } this.BindList(); } }
public bool CreateUpdateDeleteHelpCategory(HelpCategoryInfo helpCategory, DataProviderAction action) { bool result; if (null == helpCategory) { result = false; } else { DbCommand storedProcCommand = this.database.GetStoredProcCommand("cp_HelpCategory_CreateUpdateDelete"); this.database.AddInParameter(storedProcCommand, "Action", DbType.Int32, (int)action); this.database.AddOutParameter(storedProcCommand, "Status", DbType.Int32, 4); if (action != DataProviderAction.Create) { this.database.AddInParameter(storedProcCommand, "CategoryId", DbType.Int32, helpCategory.CategoryId); } if (action != DataProviderAction.Delete) { this.database.AddInParameter(storedProcCommand, "Name", DbType.String, helpCategory.Name); this.database.AddInParameter(storedProcCommand, "IconUrl", DbType.String, helpCategory.IconUrl); this.database.AddInParameter(storedProcCommand, "IndexChar", DbType.String, helpCategory.IndexChar); this.database.AddInParameter(storedProcCommand, "Description", DbType.String, helpCategory.Description); this.database.AddInParameter(storedProcCommand, "IsShowFooter", DbType.Boolean, helpCategory.IsShowFooter); } this.database.ExecuteNonQuery(storedProcCommand); result = ((int)this.database.GetParameterValue(storedProcCommand, "Status") == 0); } return(result); }
public static bool DeleteHelpCategory(int categoryId) { HelpCategoryInfo helpCategoryInfo = new HelpCategoryInfo(); helpCategoryInfo.CategoryId = new int?(categoryId); return(new HelpCategoryDao().CreateUpdateDeleteHelpCategory(helpCategoryInfo, DataProviderAction.Delete)); }
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); } }
public static bool CreateHelpCategory(HelpCategoryInfo helpCategory) { if (null == helpCategory) { return(false); } Globals.EntityCoding(helpCategory, true); return(CommentsProvider.Instance().CreateUpdateDeleteHelpCategory(helpCategory, DataProviderAction.Create)); }
private void AddNewCategory(HelpCategoryInfo category) { if (SubsiteCommentsHelper.CreateHelpCategory(category)) { this.ShowMsg("成功添加了一个帮助分类", true); return; } this.ShowMsg("操作失败,未知错误", false); }
public static bool UpdateHelpCategory(HelpCategoryInfo helpCategory) { if (helpCategory == null) { return(false); } HiCache.Remove("DataCache-Helps"); Globals.EntityCoding(helpCategory, true); return(new HelpCategoryDao().Update(helpCategory, null)); }
private void UpdateCategory(HelpCategoryInfo category) { if (ArticleHelper.UpdateHelpCategory(category)) { this.CloseWindow(); } else { this.ShowMsg("操作失败,未知错误", false); } }
private void AddNewCategory(HelpCategoryInfo category) { if (ArticleHelper.CreateHelpCategory(category)) { ShowMsg("成功添加了一个帮助分类", true); } else { ShowMsg("操作失败,未知错误", false); } }
private void UpdateCategory(HelpCategoryInfo category) { if (ArticleHelper.UpdateHelpCategory(category)) { this.imgPic.ImageUrl = null; this.imgPic.Visible = !string.IsNullOrEmpty(this.imgPic.ImageUrl); this.btnPicDelete.Visible = !string.IsNullOrEmpty(this.imgPic.ImageUrl); this.CloseWindow(); return; } this.ShowMsg("操作失败,未知错误", false); }
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 UpdateCategory(HelpCategoryInfo category) { if (SubsiteCommentsHelper.UpdateHelpCategory(category)) { this.imgPic.ImageUrl = null; this.imgPic.Visible = !string.IsNullOrEmpty(this.imgPic.ImageUrl); this.btnPicDelete.Visible = !string.IsNullOrEmpty(this.imgPic.ImageUrl); this.ShowMsg("成功修改了帮助分类", true); return; } this.ShowMsg("操作失败,未知错误", false); }
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); } } } }
public static bool CreateHelpCategory(HelpCategoryInfo helpCategory) { if (helpCategory == null) { return(false); } HelpCategoryDao helpCategoryDao = new HelpCategoryDao(); helpCategory.DisplaySequence = helpCategoryDao.GetMaxDisplaySequence <HelpCategoryInfo>(); HiCache.Remove("DataCache-Helps"); Globals.EntityCoding(helpCategory, true); return(helpCategoryDao.Add(helpCategory, null) > 0); }
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 AddNewCategory(HelpCategoryInfo category) { if (!ArticleHelper.CreateHelpCategory(category)) { this.ShowMsg("操作失败,未知错误", false); return; } if (this.Page.Request.QueryString["source"] == "add") { this.CloseWindow(); return; } this.ShowMsg("成功添加了一个帮助分类", true); }
private void UpdateCategory(HelpCategoryInfo category) { if (ArticleHelper.UpdateHelpCategory(category)) { imgPic.ImageUrl = null; imgPic.Visible = !string.IsNullOrEmpty(imgPic.ImageUrl); btnPicDelete.Visible = !string.IsNullOrEmpty(imgPic.ImageUrl); ShowMsg("成功修改了帮助分类", true); } else { ShowMsg("操作失败,未知错误", false); } }
public override HelpCategoryInfo GetHelpCategory(int categoryId) { HelpCategoryInfo info = null; DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_HelpCategories WHERE CategoryId=@CategoryId"); this.database.AddInParameter(sqlStringCommand, "CategoryId", DbType.Int32, categoryId); using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand)) { if (reader.Read()) { info = DataMapper.PopulateHelpCategory(reader); } } return(info); }
public static bool CreateHelpCategory(HelpCategoryInfo helpCategory) { bool result; if (null == helpCategory) { result = false; } else { Globals.EntityCoding(helpCategory, true); result = new HelpCategoryDao().CreateUpdateDeleteHelpCategory(helpCategory, DataProviderAction.Create); } return(result); }
public static bool UpdateHelpCategory(HelpCategoryInfo helpCategory) { bool result; if (null == helpCategory) { result = false; } else { Globals.EntityCoding(helpCategory, true); result = SubsiteCommentsProvider.Instance().CreateUpdateDeleteHelpCategory(helpCategory, DataProviderAction.Update); } return(result); }
public override HelpCategoryInfo GetHelpCategory(int categoryId) { HelpCategoryInfo result = null; System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM distro_HelpCategories WHERE CategoryId=@CategoryId"); this.database.AddInParameter(sqlStringCommand, "CategoryId", System.Data.DbType.Int32, categoryId); using (System.Data.IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand)) { if (dataReader.Read()) { result = DataMapper.PopulateHelpCategory(dataReader); } } return(result); }
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); }
public void GetHelpContent(System.Web.HttpContext context) { string text = context.Request["helpid"].ToLower(); if (!string.IsNullOrEmpty(text)) { int helpid = 0; int.TryParse(text, out helpid); HelpInfo helpInfo = CommentBrowser.GetHelp(helpid); if (helpInfo != null) { HelpCategoryInfo helpCategory = CommentBrowser.GetHelpCategory(helpInfo.CategoryId); this.message = helpInfo.Content; } } }
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 == "SetYesOrNo") { HelpCategoryInfo helpCategory = SubsiteCommentsHelper.GetHelpCategory(categoryId); if (helpCategory.IsShowFooter) { helpCategory.IsShowFooter = false; } else { helpCategory.IsShowFooter = true; } SubsiteCommentsHelper.UpdateHelpCategory(helpCategory); this.BindHelpCategory(); return; } 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) { SubsiteCommentsHelper.SwapHelpCategorySequence(categoryId, num, displaySequence, replaceDisplaySequence); this.BindHelpCategory(); } }
private void btnSubmitHelpCategory_Click(object sender, EventArgs e) { string iconUrl = string.Empty; iconUrl = SubsiteCommentsHelper.GetHelpCategory(this.categoryId).IconUrl; if (this.fileUpload.HasFile) { try { if (!string.IsNullOrEmpty(iconUrl)) { ResourcesHelper.DeleteImage(iconUrl); } iconUrl = SubsiteCommentsHelper.UploadHelpImage(this.fileUpload.PostedFile); } catch { this.ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false); return; } } HelpCategoryInfo info2 = new HelpCategoryInfo(); info2.CategoryId = new int?(this.categoryId); info2.Name = this.txtHelpCategoryName.Text.Trim(); info2.IconUrl = iconUrl; info2.Description = this.txtHelpCategoryDesc.Text.Trim(); info2.IsShowFooter = this.radioShowFooter.SelectedValue; HelpCategoryInfo target = info2; ValidationResults results = Hishop.Components.Validation.Validation.Validate <HelpCategoryInfo>(target, new string[] { "ValHelpCategoryInfo" }); string msg = string.Empty; if (results.IsValid) { this.UpdateCategory(target); } else { foreach (ValidationResult result in (IEnumerable <ValidationResult>)results) { msg = msg + Formatter.FormatErrorMessage(result.Message); } this.ShowMsg(msg, 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 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); } }