- 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;
- using qminoa.DA;
- namespace qminoa.Webs.MR
- {
- public class DepInf : qminoa.Webs.PageBase
- {
- protected System.Web.UI.WebControls.DataGrid dgdDep;
- protected System.Web.UI.WebControls.HyperLink AddDepLink;
- private void Page_Load(object sender, System.EventArgs e)
- {
- this.PageBegin("部门管理",true);
- if(this.EmpRightCode >= 2)
- AddDepLink.NavigateUrl="./DepNew.aspx";
- DataBind();
- }
- public DataTable DepTB
- {
- get
- {
- return (new DepSystem()).GetDepTB();
- }
- }
- #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.dgdDep.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.dgdDep_PageIndexChanged);
- this.dgdDep.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgdDep_DeleteCommand);
- this.dgdDep.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.dgdDep_ItemDataBound);
- this.Load += new System.EventHandler(this.Page_Load);
- }
- #endregion
- private void dgdDep_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
- {
- if(this.EmpRightCode == 4)
- {
- int index = e.Item.ItemIndex;
- int depID = (int)dgdDep.DataKeys[index];
- try
- {
- if((new DepSystem()).DeleteDep(depID))
- {
- this.WriteOptLog("删除部门"+depID.ToString()+"信息");
- JScript.Alert("删除部门操作成功!");
- }
- else
- {
- JScript.Alert("删除部门操作失败!");
- return;
- }
- }
- catch
- {
- JScript.Alert("存在于此部门相关联的信息,不能删除!");
- return;
- }
- dgdDep.DataBind();
- }
- else
- JScript.Alert("您没有权限进行此操作!");
- }
- private void dgdDep_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
- {
- dgdDep.CurrentPageIndex = e.NewPageIndex;
- dgdDep.DataBind();
- }
- private void dgdDep_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 ("确定要删除此项记录吗?");");
- }
- }
- }
- }