protected void AddNewQuestion(object sender, EventArgs e) { if (tbxQuestion.Text == "" || tbxAnswer.Text == "") { return; } if (hdnEditFaq.Value != "") { currentfaq = Convert.ToInt32(hdnEditFaq.Value); if (currentfaq > 0) { SaveFAQ(sender, e); } } string category = ddlCategory.SelectedValue; string question = tbxQuestion.Text; string answer = tbxAnswer.Text; FaqInfo faq = new FaqInfo { CatId = Convert.ToInt32(category), Language = CultureInfo.CurrentCulture.TwoLetterISOLanguageName, Link = String.Empty, LinkTitle = question, LinkBody = answer, Order = tbxQorder.Text == "" ? 0 : Convert.ToInt32(tbxQorder.Text) }; SnitzFaq.AddFaqQuestion(faq); Response.Redirect(this.Request.RawUrl); }
public Dictionary <int, string> GetQuestions(int catid, string filter, string lang) { string strSql = "SELECT FI_ID,FI_CAT,FI_ORDER,FI_LANG_ID,FI_LINK,FI_LINK_TITLE,FI_LINK_BODY FROM " + Config.ForumTablePrefix + "FAQ_INFO WHERE FI_CAT = @CatId AND FI_LANG_ID = @Lang ORDER BY FI_ORDER, FI_LINK_TITLE"; Dictionary <int, string> questions = new Dictionary <int, string>(); List <OleDbParameter> parms = new List <OleDbParameter> { new OleDbParameter("@CatId", OleDbType.Integer) { Value = catid }, new OleDbParameter("@Lang", OleDbType.VarChar) { Value = lang } }; //Execute a query to read the products using (OleDbDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnString, CommandType.Text, strSql, parms.ToArray())) { while (rdr.Read()) { FaqInfo faq = new FaqInfo { Id = rdr.SafeGetInt32("FI_ID"), Link = rdr.SafeGetString("FI_LINK"), LinkTitle = rdr.SafeGetString("FI_LINK_TITLE") }; questions.Add(faq.Id, faq.LinkTitle); } } return(questions); }
public int Update(FaqInfo item) { return(new SqlUpdateBuild(null, item.Id.Value) .SetFaqtype_id(item.Faqtype_id) .SetCreate_time(item.Create_time) .SetTitle(item.Title).ExecuteNonQuery()); }
public FaqInfo GetFaqItem(int faqid, string lang) { List <OleDbParameter> parms = new List <OleDbParameter>(); FaqInfo faq = null; string strSql = "SELECT FI_ID,FI_LINK,FI_LINK_TITLE,FI_LINK_BODY,FI_CAT,FI_LANG_ID,FI_ORDER FROM " + Config.ForumTablePrefix + "FAQ_INFO WHERE FI_ID = @FaqId AND FI_LANG_ID = @Lang ORDER BY FI_ORDER, FI_LINK_TITLE"; parms.Add(new OleDbParameter("@FaqId", OleDbType.Integer) { Value = faqid }); parms.Add(new OleDbParameter("@Lang", OleDbType.VarChar) { Value = lang }); //Execute a query to read the products using (OleDbDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnString, CommandType.Text, strSql, parms.ToArray())) { while (rdr.Read()) { faq = BoHelper.CopyFaqQuestionsToBO(rdr); } } return(faq); }
private static void RemoveCache(FaqInfo item) { if (item == null) { return; } RedisHelper.Remove(string.Concat("pifa_BLL_Faq_", item.Id)); }
public static pifa.DAL.Faq.SqlUpdateBuild UpdateDiy(FaqInfo item, uint Id) { if (itemCacheTimeout > 0) { RemoveCache(item != null ? item : GetItem(Id)); } return(new pifa.DAL.Faq.SqlUpdateBuild(item, Id)); }
public static int Update(FaqInfo item) { if (itemCacheTimeout > 0) { RemoveCache(item); } return(dal.Update(item)); }
public void Delete(FaqInfo faq) { string strSql = "DELETE FROM " + Config.ForumTablePrefix + "FAQ_INFO WHERE FI_ID=@FaqId"; SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql, new OleDbParameter("@FaqId", OleDbType.Integer) { Value = faq.Id }); }
public static FaqInfo Insert(FaqInfo item) { item = dal.Insert(item); if (itemCacheTimeout > 0) { RemoveCache(item); } return(item); }
protected static MySqlParameter[] GetParameters(FaqInfo item) { return(new MySqlParameter[] { GetParameter("?id", MySqlDbType.UInt32, 10, item.Id), GetParameter("?faqtype_id", MySqlDbType.UInt32, 10, item.Faqtype_id), GetParameter("?create_time", MySqlDbType.DateTime, -1, item.Create_time), GetParameter("?title", MySqlDbType.VarChar, 255, item.Title) }); }
public APIReturn _Add([FromForm] uint?Faqtype_id, [FromForm] string Title) { FaqInfo item = new FaqInfo(); item.Faqtype_id = Faqtype_id; item.Create_time = DateTime.Now; item.Title = Title; item = Faq.Insert(item); return(APIReturn.成功.SetData("item", item.ToBson())); }
public FaqInfo Insert(FaqInfo item) { uint loc1; if (uint.TryParse(string.Concat(SqlHelper.ExecuteScalar(TSQL.Insert, GetParameters(item))), out loc1)) { item.Id = loc1; } return(item); }
public static void UpdateFaqQuestion(int id, string question, string answer, string lang) { IFaqQuestion dal = Factory <IFaqQuestion> .Create("Faq"); FaqInfo faq = dal.GetById(id); faq.LinkTitle = question; faq.LinkBody = answer; faq.Language = lang; dal.Update(faq); }
public ActionResult Edit([FromQuery] uint Id) { FaqInfo item = Faq.GetItem(Id); if (item == null) { return(APIReturn.记录不存在_或者没有权限); } ViewBag.item = item; return(View()); }
protected void ToggleEdit(object sender, ImageClickEventArgs e) { int id = Convert.ToInt32(faqId.Value); FaqInfo faq = SnitzFaq.GetFaqQuestion(id, CultureInfo.CurrentCulture.TwoLetterISOLanguageName); faqId.Value = id.ToString(); tbxQuestion.Text = faq.LinkTitle; tbxAnswer.Text = faq.LinkBody; FaqViews.ActiveViewIndex = 1; hdnEditFaq.Value = id.ToString(); tbxQorder.Text = faq.Order.ToString(); ddlCategory.SelectedValue = faq.CatId.ToString(); }
protected void ViewAnswer(object source, RepeaterCommandEventArgs e) { int question = Convert.ToInt32(e.CommandArgument); faqId.Value = question.ToString(); FaqInfo faq = SnitzFaq.GetFaqQuestion(question, CultureInfo.CurrentCulture.TwoLetterISOLanguageName); faqQuestion.Text = "<h1>" + faq.LinkTitle + "</h1>"; faqAnswer.Text = faq.LinkBody.ReplaceNoParseTags().ParseVideoTags().ParseWebUrls(); btnDeleteFaq.OnClientClick = "confirmPostBack('Do you want to delete Question and answer?','DeleteFaq'," + faqId.Value + ");return false;"; btnEdit.Visible = IsAdministrator || Roles.IsUserInRole("FAQEditor"); btnDeleteFaq.Visible = IsAdministrator || Roles.IsUserInRole("FAQEditor"); }
public static FaqInfo CopyFaqQuestionsToBO(SqlDataReader rdr) { FaqInfo faqquestion = new FaqInfo { Id = rdr.GetInt32(0), Link = rdr.SafeGetString(1), LinkTitle = rdr.SafeGetString(2), LinkBody = rdr.SafeGetString(3), CatId = rdr.GetInt32(4), Language = rdr.SafeGetString(5), Order = rdr.GetInt32(6) }; return(faqquestion); }
private void SaveFAQ(object sender, EventArgs eventArgs) { int id = Convert.ToInt32(hdnEditFaq.Value); string category = ddlCategory.SelectedValue; string question = tbxQuestion.Text; string answer = tbxAnswer.Text; int order = tbxQorder.Text == "" ? 0 : Convert.ToInt32(tbxQorder.Text); FaqInfo faq = SnitzFaq.GetFaqQuestion(id, CultureInfo.CurrentCulture.TwoLetterISOLanguageName); faq.Order = order; faq.CatId = Convert.ToInt32(category); faq.LinkTitle = question; faq.LinkBody = answer; SnitzFaq.UpdateFaqQuestion(faq); Response.Redirect(this.Request.RawUrl); }
public APIReturn _Edit([FromQuery] uint Id, [FromForm] uint?Faqtype_id, [FromForm] string Title) { FaqInfo item = Faq.GetItem(Id); if (item == null) { return(APIReturn.记录不存在_或者没有权限); } item.Faqtype_id = Faqtype_id; item.Create_time = DateTime.Now; item.Title = Title; int affrows = Faq.Update(item); if (affrows > 0) { return(APIReturn.成功.SetMessage($"更新成功,影响行数:{affrows}")); } return(APIReturn.失败); }
public void Update(FaqInfo faq) { StringBuilder updateFaq = new StringBuilder(""); updateFaq.AppendFormat("UPDATE {0}FAQ_INFO SET ", Config.ForumTablePrefix).AppendLine(); updateFaq.AppendLine("FI_CAT=@CatId,"); updateFaq.AppendLine("FI_LINK_TITLE=@LinkTitle,"); updateFaq.AppendLine("FI_LINK_BODY=@LinkBody,"); updateFaq.AppendLine("FI_LANG_ID=@Lang,"); updateFaq.AppendLine("FI_ORDER=@Order "); updateFaq.AppendLine("WHERE FI_ID=@FaqId"); List <OleDbParameter> parms = new List <OleDbParameter> { new OleDbParameter("@CatId", OleDbType.Integer) { Value = faq.CatId }, new OleDbParameter("@LinkTitle", OleDbType.VarChar) { Value = faq.LinkTitle }, new OleDbParameter("@LinkBody", OleDbType.VarChar) { Value = faq.LinkBody }, new OleDbParameter("@Lang", OleDbType.VarChar, 6) { Value = faq.Language }, new OleDbParameter("@Order", OleDbType.Integer) { Value = faq.Order }, new OleDbParameter("@FaqId", OleDbType.Integer) { Value = faq.Id } }; SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, updateFaq.ToString(), parms.ToArray()); }
protected void Save(object sender, ImageClickEventArgs e) { int id = Convert.ToInt32(hdnFaqId.Value); string category = feCategory.SelectedValue; string question = feTitle.Text; string answer = feBody.Text; int order = feOrder.Text == "" ? 0 : Convert.ToInt32(feOrder.Text); FaqInfo faq = SnitzFaq.GetFaqQuestion(id, CultureInfo.CurrentCulture.TwoLetterISOLanguageName); faq.Order = order; faq.CatId = Convert.ToInt32(category); faq.Link = String.Format("/{0}/{1}", feCategory.SelectedItem.Text, question); faq.LinkTitle = question; faq.LinkBody = answer; SnitzFaq.UpdateFaqQuestion(faq); Response.Redirect(this.Request.RawUrl); }
IEnumerable <FaqInfo> IBaseObject <FaqInfo> .GetByName(string name) { List <OleDbParameter> parms = new List <OleDbParameter>(); FaqInfo faq = null; string strSql = "SELECT FI_ID,FI_LINK,FI_LINK_TITLE,FI_LINK_BODY,FI_CAT,FI_LANG_ID,FI_ORDER FROM " + Config.ForumTablePrefix + "FAQ_INFO WHERE FI_LINK = @FaqLink ORDER BY FI_ORDER, FI_LINK_TITLE"; parms.Add(new OleDbParameter("@FaqLink", OleDbType.VarChar) { Value = name }); //Execute a query to read the products using (OleDbDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnString, CommandType.Text, strSql, parms.ToArray())) { while (rdr.Read()) { faq = BoHelper.CopyFaqQuestionsToBO(rdr); } } return(new[] { faq }); }
FaqInfo IBaseObject <FaqInfo> .GetById(int id) { List <SqlParameter> parms = new List <SqlParameter>(); FaqInfo faq = null; string strSql = "SELECT FI_ID,FI_LINK,FI_LINK_TITLE,FI_LINK_BODY,FI_CAT,FI_LANG_ID,FI_ORDER FROM " + Config.ForumTablePrefix + "FAQ_INFO WHERE FI_ID = @FaqId ORDER BY FI_ORDER, FI_LINK_TITLE"; parms.Add(new SqlParameter("@FaqId", SqlDbType.Int) { Value = id }); //Execute a query to read the products using (SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnString, CommandType.Text, strSql, parms.ToArray())) { while (rdr.Read()) { faq = BoHelper.CopyFaqQuestionsToBO(rdr); } } return(faq); }
public int Add(FaqInfo faq) { string insertSql = "INSERT INTO " + Config.ForumTablePrefix + "FAQ_INFO (FI_ORDER,FI_CAT,FI_LANG_ID,FI_LINK,FI_LINK_TITLE,FI_LINK_BODY) VALUES "; insertSql = insertSql + "(@Order,@CatId,@Lang,@Link,@LinkTitle,@LinkBody) "; List <OleDbParameter> parms = new List <OleDbParameter> { new OleDbParameter("@Order", OleDbType.Integer) { Value = faq.Order }, new OleDbParameter("@CatId", OleDbType.Integer) { Value = faq.CatId }, new OleDbParameter("@Lang", OleDbType.VarChar) { Value = faq.Language }, new OleDbParameter("@Link", OleDbType.VarChar) { Value = (object)faq.Link ?? DBNull.Value, IsNullable = true }, new OleDbParameter("@LinkTitle", OleDbType.VarChar) { Value = faq.LinkTitle }, new OleDbParameter("@LinkBody", OleDbType.VarChar) { Value = faq.LinkBody } }; int faqid = Convert.ToInt32(SqlHelper.ExecuteInsertQuery(SqlHelper.ConnString, CommandType.Text, insertSql, parms.ToArray())); return(faqid); }
public object GetItem(IDataReader dr, ref int index) { FaqInfo item = new FaqInfo(); if (!dr.IsDBNull(++index)) { item.Id = (uint?)dr.GetInt32(index); } if (!dr.IsDBNull(++index)) { item.Faqtype_id = (uint?)dr.GetInt32(index); } if (!dr.IsDBNull(++index)) { item.Create_time = (DateTime?)dr.GetDateTime(index); } if (!dr.IsDBNull(++index)) { item.Title = dr.GetString(index); } return(item); }
public static FaqInfo GetItem(uint Id) { if (itemCacheTimeout <= 0) { return(Select.WhereId(Id).ToOne()); } string key = string.Concat("pifa_BLL_Faq_", Id); string value = RedisHelper.Get(key); if (!string.IsNullOrEmpty(value)) { try { return(FaqInfo.Parse(value)); } catch { } } FaqInfo item = Select.WhereId(Id).ToOne(); if (item == null) { return(null); } RedisHelper.Set(key, item.Stringify(), itemCacheTimeout); return(item); }
protected void Add(object sender, ImageClickEventArgs e) { if (fnTitle.Text == "" || fnBody.Text == "") { return; } string category = fnCategory.SelectedValue; string question = fnTitle.Text; string answer = fnBody.Text; FaqInfo faq = new FaqInfo { CatId = Convert.ToInt32(category), Language = CultureInfo.CurrentCulture.TwoLetterISOLanguageName, Link = String.Format("/{0}/{1}", fnCategory.SelectedItem.Text, question), LinkTitle = question, LinkBody = answer, Order = fnOrder.Text == "" ? 0 : Convert.ToInt32(fnOrder.Text) }; SnitzFaq.AddFaqQuestion(faq); Response.Redirect(this.Request.RawUrl); }
public SqlUpdateBuild(FaqInfo item, uint Id) { _item = item; _where = SqlHelper.Addslashes("`id` = {0}", Id); }
public static void DeleteFaqQuestion(FaqInfo question) { IFaqQuestion dal = Factory <IFaqQuestion> .Create("Faq"); dal.Delete(question); }
public static int AddFaqQuestion(FaqInfo question) { IFaqQuestion dal = Factory <IFaqQuestion> .Create("Faq"); return(dal.Add(question)); }