📄 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;
//引用数据库访问层。
using qminoa.DA;
using qminoa.Common;
namespace qminoa.Webs.module
{
/// <summary>
/// FuncRights 的摘要说明。
/// 本页面为一个用户控件,作为SecurityRoles.aspx页面的一部分来显示。
/// 本模块主要用来显示系统管理中的所有模块信息,可以查看模块的详细信息,添加和删除模块信息。
/// 模块主要由一个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)
{ //当第一次调用页面时绑定数据库数据。
BindData();
}
}
//从数据库中取得所有的模块信息数据,并显示在页面上。
private void BindData()
{ //引用数据库访问层中的系统管理类。
AdminDB admin = new AdminDB();
//用数据库信息填充FuncList模块信息。
FuncList.DataSource = admin.GetAllFuncs();
FuncList.DataBind();
}
//FuncList中的ItemCommand事件函数,用来完成各元素中的按钮事件。
private void FuncList_ItemCommand(object sender, DataListCommandEventArgs e)
{
//引用数据库访问层中的系统管理类。
AdminDB admin = new AdminDB();
//取得单击按钮在FuncList控件中的主键值,取得模块号。
int FuncID = (int) FuncList.DataKeys[e.Item.ItemIndex];
//判断事件的命令类型。
if (e.CommandName == "edit")
{ //转到查看模块详细信息页面。
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:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// 设计器支持所需的方法 - 不要使用
/// 代码编辑器修改此方法的内容。
/// </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
//添加模块信息按钮事件函数。
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 + -