📄 faqsedit.aspx.cs
字号:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.UI;
using Rainbow.Admin;
namespace Rainbow.DesktopModules
{
/// <summary>
/// IBS Portal FAQ module - Edit page part
/// (c)2002 by Christopher S Judd, CDP & Horizons, LLC
/// Moved into Rainbow by Jakob Hansen, hansen3000@hotmail.com
/// </summary>
public class FAQsEdit : Rainbow.UI.EditItemPage
{
protected System.Web.UI.WebControls.TextBox Question;
protected System.Web.UI.WebControls.TextBox Answer;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidatorQuestion;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidatorAnswer;
int itemId = -1;
private void Page_Load(object sender, System.EventArgs e)
{
// Determine ItemId of FAQ to Update
if (Request.Params["ItemId"] != null )
{
itemId = Int32.Parse(Request.Params["ItemId"]);
}
// populate with FAQ Details
if (Page.IsPostBack == false )
{
if (itemId != -1 )
{
// get a single row of FAQ info
FAQsDB questions = new FAQsDB();
SqlDataReader dr = questions.GetSingleFAQ(itemId);
// Read database
dr.Read();
Question.Text = (String) dr["Question"];
Answer.Text = (String) dr["Answer"];
dr.Close();
}
}
}
override protected void OnUpdate()
{
// Don't Allow empty data
if (Question.Text == "" || Answer.Text == "")
return;
// Update only if entered data is valid
if (Page.IsValid == true)
{
FAQsDB questions = new FAQsDB();
if (itemId == -1)
{
// Add the question within the questions table
questions.AddFAQ(ModuleId, itemId, Question.Text, Answer.Text);
}
else
{
// Update the question within the questions table
questions.UpdateFAQ(ModuleId, itemId, Question.Text, Answer.Text);
}
this.RedirectBackToReferringPage();
}
}
override protected void OnDelete()
{
// Only attempt to delete the item if it is an existing item
// (new items will have "ItemId" of -1)
if (itemId != -1 )
{
FAQsDB questions = new FAQsDB();
questions.DeleteFAQ(itemId);
}
this.RedirectBackToReferringPage();
}
#region Web Form Designer generated code
/// <summary>
/// Raises OnInitEvent
/// </summary>
/// <param name="e"></param>
protected override void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -