📄 topiclistadmin.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using SampleForum.SetData;
using BusObjectForum;
namespace SampleForum.SysManage
{
/// <summary>
/// TopicListAdmin 的摘要说明。
/// </summary>
public class TopicListAdmin : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DropDownList selFunction;
protected System.Web.UI.WebControls.Label labCurrentPage;
protected System.Web.UI.WebControls.DataGrid dgrTopic;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!Page.IsPostBack)
{
ForumC oForum = new ForumC();
string ErrDesc = "";
DataSet oDataSet = oForum.getForumList(CONNSTRING,out ErrDesc);
this.selFunction.DataSource = oDataSet;
selFunction.DataMember = "T_Function";
selFunction.DataValueField = "fchrFunctionID";
selFunction.DataTextField = "fchrFunctionName";
Page.DataBind();
InitList("");
}
}
//初始化选择功能模块的下拉框
public void Init_ObjChangeFunction(object oSource, System.EventArgs e)
{
DropDownList oSelFunction = (DropDownList)oSource;
ForumC oForum = new ForumC();
string ErrDesc = "";
DataSet oDataSet = oForum.getForumList(CONNSTRING,out ErrDesc);
oSelFunction.DataSource = oDataSet;
oSelFunction.DataMember = "T_Function";
oSelFunction.DataValueField = "fchrFunctionID";
oSelFunction.DataTextField = "fchrFunctionName";
oSelFunction.DataBind();
}
public static string CONNSTRING
{
get
{
connect_strings oConn = new connect_strings();
return oConn.OLEDBConnectionString;
}
}
public static string SQLCONNSTRING
{
get
{
connect_strings oConn = new connect_strings();
return oConn.SqlConnectionString;
}
}
public void InitList(string strFunctionID)
{
if (strFunctionID=="")
{
strFunctionID = this.selFunction.SelectedValue;
}
string ErrDesc="";
InnerFunction oFunction = new InnerFunction();
dgrTopic.PageSize =int.Parse(oFunction.getUserParaByName(CONNSTRING,"Forum_ListPageNO",out ErrDesc));
dgrTopic.PagerStyle.Mode=PagerMode.NumericPages;
ErrDesc= "";
ForumC oForum = new ForumC();
DataSet oDataSet = oForum.getTopicByFunction(CONNSTRING,strFunctionID,true,out ErrDesc);
if(ErrDesc=="")
{
dgrTopic.DataSource = oDataSet.Tables[0].DefaultView;
dgrTopic.DataBind();
dgrTopic.Columns[0].Visible = false;
}
else
{
Response.Write("错误:"+ErrDesc);
}
}
public void OnChangeFunction(object oSource, System.EventArgs e)
{
InitList(selFunction.SelectedItem.Value);
}
public void DoItemEdit(object oSource,DataGridCommandEventArgs oArgs)
{
this.dgrTopic.EditItemIndex = oArgs.Item.ItemIndex;
InitList("");
}
public void TopicUpdate(object oSource,DataGridCommandEventArgs oArgs)
{
string ErrDesc="";
string strTopicId = oArgs.Item.Cells[0].Text;
DropDownList oIsGood = (DropDownList)oArgs.Item.FindControl("selIsGood");
DropDownList oIsTop = (DropDownList)oArgs.Item.FindControl("selIsTop");
DropDownList oIsNoUsed = (DropDownList)oArgs.Item.FindControl("selIsNoUsed");
DropDownList oSelFunction = (DropDownList)oArgs.Item.FindControl("selChangeFunction");
AdminC oAdmin = new AdminC();
if(oAdmin.UpdateTopicState(SQLCONNSTRING,oIsGood.SelectedValue,oIsTop.SelectedValue,oSelFunction.SelectedValue,oIsNoUsed.SelectedValue,strTopicId,out ErrDesc))
{
Response.Write ("更新话题状态成功!");
}
else
{
Response.Write ("发生错误:"+ErrDesc);
}
}
public void TopicCancel(object oSource,DataGridCommandEventArgs oArgs)
{
this.dgrTopic.EditItemIndex = -1;
this.InitList("");
}
public void ChangePage(object oSender,DataGridPageChangedEventArgs objArgs)
{
dgrTopic.CurrentPageIndex = objArgs.NewPageIndex;
InitList("");
labCurrentPage.Text = (dgrTopic.CurrentPageIndex+1).ToString();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -