📄 faqsedit.aspx.cs
字号:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.UI;
//Namespaces added for editor and config settings
//Chris Farrell, 10/27/03, chris@cftechconsulting.com
using Rainbow.Admin;
using Rainbow.Configuration;
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 Esperantus.WebControls.RequiredFieldValidator RequiredFieldValidatorQuestion;
protected Esperantus.WebControls.Literal CreatedLabel;
protected Esperantus.WebControls.Literal OnLabel;
protected System.Web.UI.WebControls.Label CreatedBy;
protected System.Web.UI.WebControls.Label CreatedDate;
protected Esperantus.WebControls.Literal Literal1;
protected Esperantus.WebControls.Literal Literal2;
protected Esperantus.WebControls.Literal Literal3;
int itemId = -1;
/*Editor added 10/27/03 by Chris Farrell, chris@cftechconsulting.com*/
//protected System.Web.UI.WebControls.TextBox Answer;
//protected Esperantus.WebControls.RequiredFieldValidator RequiredFieldValidatorAnswer;
protected System.Web.UI.WebControls.PlaceHolder PlaceHolderHTMLEditor;
protected Rainbow.UI.WebControls.IHtmlEditor DesktopText;
private void Page_Load(object sender, System.EventArgs e)
{
//Editor placeholder setup
Rainbow.UI.DataTypes.HtmlEditorDataType h = new Rainbow.UI.DataTypes.HtmlEditorDataType();
h.Value = moduleSettings["Editor"].ToString();
DesktopText = h.GetEditor(PlaceHolderHTMLEditor, ModuleId, bool.Parse(moduleSettings["ShowUpload"].ToString()), portalSettings);
DesktopText.Width = new System.Web.UI.WebControls.Unit(moduleSettings["Width"].ToString());
DesktopText.Height = new System.Web.UI.WebControls.Unit(moduleSettings["Height"].ToString());
// 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"];
DesktopText.Text = (String) dr["Answer"];
CreatedBy.Text = (String) dr["CreatedByUser"];
CreatedDate.Text = ((DateTime) dr["CreatedDate"]).ToShortDateString();
dr.Close();
}
}
}
override protected void OnUpdate(EventArgs e)
{
base.OnUpdate(e);
// Don't Allow empty data
if (Question.Text == "" || DesktopText.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, PortalSettings.CurrentUser.Identity.Email, Question.Text, DesktopText.Text);
}
else
{
// Update the question within the questions table
questions.UpdateFAQ(ModuleId, itemId, PortalSettings.CurrentUser.Identity.Email, Question.Text, DesktopText.Text);
}
this.RedirectBackToReferringPage();
}
}
override protected void OnDelete(EventArgs e)
{
base.OnDelete(e);
// 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 + -