RegCatalog.aspx.cs
上传用户:autodoor
上传日期:2022-08-04
资源大小:9973k
文件大小:5k
- 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;
- using qminoa.Common.Data;
- namespace qminoa.Webs.sysSecurity
- {
- public class RegCatalog : qminoa.Webs.PageBase
- {
- protected System.Web.UI.WebControls.HyperLink HyperLink2;
- protected System.Web.UI.WebControls.DataGrid dgCatalog;
- protected System.Web.UI.WebControls.Label lblError;
-
- private void Page_Load(object sender, System.EventArgs e)
- {
- this.PageBegin("目录管理",true);
- if(!Page.IsPostBack)
- {
- DataBind();
- }
- }
- private DataTable GetCatalogsTB()
- {
- DataTable table ;
- CatalogSystem CatalogsBLL = new CatalogSystem();
- table = CatalogsBLL.GetCatalogsData().Tables[0];
- return table;
- }
- public DataTable CatalogsTB
- {
- get
- {
- return GetCatalogsTB();
- }
- }
- private void dgCatalog_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
- {
- if(this.EmpRightCode>=3)
- {
- int index = e.Item.ItemIndex;
- dgCatalog.EditItemIndex = index;
- dgCatalog.DataBind();
- }
- else
- {
- JScript.Alert("您没有权限进行此操作!");
- }
- }
- private void dgCatalog_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
- {
- if(this.EmpRightCode==4)
- {
- lblError.Visible = false;
- int index = e.Item.ItemIndex;
- int PKID = Convert.ToInt16(dgCatalog.DataKeys[index].ToString(),10);
- try
- {
- bool result = (new CatalogSystem()).DeleteCatalog(PKID);
- this.WriteOptLog("删除目录"+PKID.ToString()+"信息");
- }
- catch
- {
- lblError.Visible = true;
- lblError.Text = "删除失败!";
- }
- dgCatalog.DataBind();
- }
- else
- {
- JScript.Alert("您没有权限进行此操作!");
- }
- }
- private void dgCatalog_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
- {
- int index = e.Item.ItemIndex;
- dgCatalog.EditItemIndex = -1;
- dgCatalog.DataBind();
- }
- private void dgCatalog_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
- {
- int index = e.Item.ItemIndex;
- int PKID = Convert.ToInt16(dgCatalog.DataKeys[index].ToString(),10);
- CatalogData _Catalogdata = new CatalogData();
- DataTable _CatalogTB = _Catalogdata.Tables[CatalogData.CATALOG_TABLE_NAME];
- DataRow row = _CatalogTB.NewRow();
- _CatalogTB.Rows.Add(row);
- _CatalogTB.AcceptChanges();
- row[CatalogData.PK_FIELD] = PKID;
- row[CatalogData.TABID_FIELD] = ((TextBox)e.Item.Cells[0].Controls[0]).Text.ToString();
- row[CatalogData.INDEXID_FIELD] = ((TextBox)e.Item.Cells[1].Controls[0]).Text.ToString();
- row[CatalogData.NAME_FIELD] = ((TextBox)e.Item.Cells[2].Controls[0]).Text.ToString();
- row[CatalogData.DESCRIPTION_FIELD] = ((TextBox)e.Item.Cells[3].Controls[0]).Text.ToString();
- row[CatalogData.URL_FIELD] = ((TextBox)e.Item.Cells[4].Controls[0]).Text.ToString();
- bool result = (new CatalogSystem()).UpdateCatalog(_Catalogdata);
- dgCatalog.EditItemIndex = -1;
- dgCatalog.DataBind();
- }
- private void dgCatalog_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';";
- }
- if (e.Item.ItemType == ListItemType.Item ||
- e.Item.ItemType == ListItemType.AlternatingItem)
- {
- ImageButton button = (ImageButton) e.Item.FindControl("Imagebutton2");
- button.Attributes.Add ("onclick",
- "return confirm ("确定要删除此项记录吗?");");
- }
- }
- #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.dgCatalog.CancelCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgCatalog_CancelCommand);
- this.dgCatalog.EditCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgCatalog_EditCommand);
- this.dgCatalog.UpdateCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgCatalog_UpdateCommand);
- this.dgCatalog.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgCatalog_DeleteCommand);
- this.dgCatalog.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.dgCatalog_ItemDataBound);
- this.Load += new System.EventHandler(this.Page_Load);
- }
- #endregion
- }
- }