?? funcrights.ascx.cs
字號:
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Windows.Forms;
//引用數(shù)據(jù)庫訪問層。
using qminoa.DA;
using qminoa.Common;
namespace qminoa.Webs.module
{
/// <summary>
/// FuncRights 的摘要說明。
/// 本頁面為一個用戶控件,作為SecurityRoles.aspx頁面的一部分來顯示。
/// 本模塊主要用來顯示系統(tǒng)管理中的所有模塊信息,可以查看模塊的詳細信息,添加和刪除模塊信息。
/// 模塊主要由一個DataList控件和一個LinkButton組成。
/// </summary>
public abstract class FuncRights : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.LinkButton AddFuncBtn;
protected System.Web.UI.WebControls.TextBox FuncName;
protected System.Web.UI.WebControls.TextBox FuncDescription;
protected System.Web.UI.WebControls.DataList FuncList;
private void Page_Load(object sender, System.EventArgs e)
{
if (Page.IsPostBack == false)
{ //當?shù)谝淮握{(diào)用頁面時綁定數(shù)據(jù)庫數(shù)據(jù)。
BindData();
}
}
//從數(shù)據(jù)庫中取得所有的模塊信息數(shù)據(jù),并顯示在頁面上。
private void BindData()
{ //引用數(shù)據(jù)庫訪問層中的系統(tǒng)管理類。
AdminDB admin = new AdminDB();
//用數(shù)據(jù)庫信息填充FuncList模塊信息。
FuncList.DataSource = admin.GetAllFuncs();
FuncList.DataBind();
}
//FuncList中的ItemCommand事件函數(shù),用來完成各元素中的按鈕事件。
private void FuncList_ItemCommand(object sender, DataListCommandEventArgs e)
{
//引用數(shù)據(jù)庫訪問層中的系統(tǒng)管理類。
AdminDB admin = new AdminDB();
//取得單擊按鈕在FuncList控件中的主鍵值,取得模塊號。
int FuncID = (int) FuncList.DataKeys[e.Item.ItemIndex];
//判斷事件的命令類型。
if (e.CommandName == "edit")
{ //轉(zhuǎn)到查看模塊詳細信息頁面。
Response.Redirect("FuncRightSet.aspx?funcid=" + FuncID,false);
}
else if (e.CommandName == "delete")
{
if(admin.DeleteFuncRoleUser(FuncID,"func"))
{
JScript.Alert("刪除成功!");
BindData();
}
else
JScript.Alert("刪除失敗!");
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:該調(diào)用是 ASP.NET Web 窗體設(shè)計器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// 設(shè)計器支持所需的方法 - 不要使用
/// 代碼編輯器修改此方法的內(nèi)容。
/// </summary>
private void InitializeComponent()
{
this.FuncList.ItemCommand += new System.Web.UI.WebControls.DataListCommandEventHandler(this.FuncList_ItemCommand);
this.AddFuncBtn.Click += new System.EventHandler(this.AddFuncBtn_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
//添加模塊信息按鈕事件函數(shù)。
private void AddFuncBtn_Click(object sender, System.EventArgs e)
{
if(FuncName.Text.ToString()!="")
{
bool result = (new AdminDB()).InsertFuncInfo(FuncName.Text.ToString(),FuncDescription.Text.ToString());
BindData();
FuncName.Text = "";
FuncDescription.Text = "";
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -