- 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 System.Security;
- using System.Security.Principal;
- using System.Web.Security;
- using System.Data.SqlClient;
- using qminoa.DA;
- using qminoa.Common;
- namespace qminoa.Webs.sysSecurity
- {
- public class Moduleadmin : qminoa.Webs.PageBase
- {
- protected System.Web.UI.WebControls.DataList FuncList;
- protected System.Web.UI.WebControls.TextBox FuncName;
- protected System.Web.UI.WebControls.TextBox FuncDescription;
- protected System.Web.UI.WebControls.LinkButton AddFuncBtn;
- private void Page_Load(object sender, System.EventArgs e)
- {
- this.PageBegin("模块管理",true);
- if (Page.IsPostBack == false)
- {
- BindData();
- }
- }
- #region Web Form Designer generated code
- 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);
- this.FuncList.ItemCommand += new System.Web.UI.WebControls.DataListCommandEventHandler(this.FuncList_ItemCommand);
- this.FuncList.ItemDataBound += new System.Web.UI.WebControls.DataListItemEventHandler(this.OnAttachScript);
- this.AddFuncBtn.Click += new System.EventHandler(this.AddFuncBtn_Click);
- }
- #endregion
- private void BindData()
- {
- AdminDB admin = new AdminDB();
- FuncList.DataSource = admin.GetAllFuncs();
- FuncList.DataBind();
- }
- private void FuncList_ItemCommand(object sender, DataListCommandEventArgs e)
- {
- AdminDB admin = new AdminDB();
- int FuncID = (int) FuncList.DataKeys[e.Item.ItemIndex];
- if (e.CommandName == "edit")
- {
- if(this.EmpRightCode >= 3)
- {
- Response.Redirect("FuncRightSet.aspx?funcid=" + FuncID,false);
- }
- else
- {
- JScript.Alert("您没有权限进行此操作!");
- }
- }
- else if (e.CommandName == "delete")
- {
- if(this.EmpRightCode == 4)
- {
- if(admin.DeleteFuncRoleUser(FuncID,"func"))
- {
- this.WriteOptLog("删除模块信息");
- JScript.Alert("删除成功!");
- BindData();
- }
- else
- JScript.Alert("删除失败!");
- }
- else
- {
- JScript.Alert("您没有权限进行此操作!");
- }
- }
- }
- private void AddFuncBtn_Click(object sender, System.EventArgs e)
- {
- if(this.EmpRightCode >=2 )
- {
- if(FuncName.Text.ToString()!="")
- {
- bool result = (new AdminDB()).InsertFuncInfo(FuncName.Text.ToString(),FuncDescription.Text.ToString());
- if(result == false)
- JScript.Alert("添加失败!");
- else
- {
- this.WriteOptLog("添加模块角色关系信息");
- JScript.Alert("添加成功!");
- }
- BindData();
- FuncName.Text = "";
- FuncDescription.Text = "";
- }
- else
- {
- JScript.Alert("您没有权限进行此操作!");
- }
- }
- }
- private void OnAttachScript (object sender, System.Web.UI.WebControls.DataListItemEventArgs e)
- {
- if (e.Item.ItemType == ListItemType.Item ||
- e.Item.ItemType == ListItemType.AlternatingItem)
- {
- ImageButton button = (ImageButton) e.Item.FindControl("Imagebutton2");
- button.Attributes.Add ("onclick",
- "return confirm ("确定要删除此项记录吗?");");
- }
- }
- }
- }