- 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 qminoa.BLL;
- using qminoa.Common.Data;
- namespace qminoa.Webs.sysSecurity
- {
- /// <summary>
- /// regModule 的摘要说明。
- /// </summary>
- public class regModule : System.Web.UI.Page
- {
- protected System.Web.UI.WebControls.HyperLink HyperLink2;
- protected System.Web.UI.WebControls.DataGrid dgModule;
- protected System.Web.UI.WebControls.Label lblError;
- private void Page_Load(object sender, System.EventArgs e)
- {
- if(Page.IsPostBack)
- {
- return;
- }
- DataBind();
- }
- private DataTable GetModulesTB()
- {
- DataTable table ;
- ModuleSystem ModulesBLL = new ModuleSystem();
- table = ModulesBLL.GetModulesData().Tables[0];
- return table;
- }
- public DataTable ModulesTB
- {
- get
- {
- return GetModulesTB();
- }
- }
- private void dgModule_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
- {
- int index = e.Item.ItemIndex;
- dgModule.EditItemIndex = index;
- dgModule.DataBind();
- }
- private void dgModule_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
- {
- lblError.Visible = false;
- int index = e.Item.ItemIndex;
- int PKID = Convert.ToInt16(dgModule.DataKeys[index].ToString(),10);
- try
- {
- bool result = (new ModuleSystem()).DeleteModule(PKID);
- }
- catch(Exception ex)
- {
- lblError.Visible = true;
- lblError.Text = "删除失败!";
- }
- dgModule.DataBind();
- }
- private void dgModule_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
- {
- int index = e.Item.ItemIndex;
- dgModule.EditItemIndex = -1;
- dgModule.DataBind();
- }
- private void dgModule_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
- {
- int index = e.Item.ItemIndex;
- int PKID = Convert.ToInt16(dgModule.DataKeys[index].ToString(),10);
- ModuleData _moduledata = new ModuleData();
- DataTable _moduleTB = _moduledata.Tables[ModuleData.MODULE_TABLE_NAME];
- DataRow row = _moduleTB.NewRow();
- _moduleTB.Rows.Add(row);
- _moduleTB.AcceptChanges();
- row[ModuleData.PK_FIELD] = PKID;
- row[ModuleData.TABID_FIELD] = ((TextBox)e.Item.Cells[0].Controls[0]).Text.ToString();
- row[ModuleData.INDEXID_FIELD] = ((TextBox)e.Item.Cells[1].Controls[0]).Text.ToString();
- row[ModuleData.NAME_FIELD] = ((TextBox)e.Item.Cells[2].Controls[0]).Text.ToString();
- row[ModuleData.DESCRIPTION_FIELD] = ((TextBox)e.Item.Cells[3].Controls[0]).Text.ToString();
- row[ModuleData.URL_FIELD] = ((TextBox)e.Item.Cells[4].Controls[0]).Text.ToString();
- bool result = (new ModuleSystem()).UpdateModule(_moduledata);
- dgModule.EditItemIndex = -1;
- dgModule.DataBind();
- }
- private void dgModule_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
- {
- ListItemType itemType = e.Item.ItemType;
- e.Item.Attributes["onmouseover"] = "javascript:this.style.backgroundColor='#fff7ce';cursor='hand';" ;
- if (itemType == ListItemType.Item )
- {
- e.Item.Attributes["onmouseout"] = "javascript:this.style.backgroundColor='#dedfde';";
- }
- else if( itemType == ListItemType.AlternatingItem)
- {
- e.Item.Attributes["onmouseout"] = "javascript:this.style.backgroundColor='#ffffff';";
- }
- }
- #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.dgModule.CancelCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgModule_CancelCommand);
- this.dgModule.EditCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgModule_EditCommand);
- this.dgModule.UpdateCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgModule_UpdateCommand);
- this.dgModule.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgModule_DeleteCommand);
- this.dgModule.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.dgModule_ItemDataBound);
- this.Load += new System.EventHandler(this.Page_Load);
- }
- #endregion
- }
- }