dir_list.aspx.cs
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:3k
源码类别:

OA系统

开发平台:

ASP/ASPX

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. using System.Data.SqlClient;
  12. public partial class web_regulation_dir_list : System.Web.UI.Page
  13. {
  14.     protected void Page_Load(object sender, EventArgs e)
  15.     {
  16.         if (!IsPostBack)
  17.         {
  18.             DirList.DataKeyNames = new string[] { "id" };
  19.         }
  20.     }
  21.     protected void DirList_RowUpdated(object sender, GridViewUpdatedEventArgs e)
  22.     {
  23.         //刷新樹
  24.         Response.Write("<script language='javascript'>window.parent.window.parent.frames.leftFrame.location.reload()</script>");
  25.     }
  26.     protected void DirList_RowCommand(object sender, GridViewCommandEventArgs e)
  27.     {
  28.         if (e.CommandName.Equals("DeleteData"))
  29.         {
  30.             string id = e.CommandArgument.ToString();
  31.             //點擊刪除按鈕
  32.             SqlConnection conn = dbConnection.getConnection();
  33.             conn.Open();
  34.             SqlCommand cmd = new SqlCommand("delete from OA_SYS_CHILD_MENU where id="+id, conn);
  35.             cmd.ExecuteNonQuery();
  36.             conn.Close();
  37.             //刷新樹
  38.             Response.Write("<script language='javascript'>window.parent.window.parent.frames.leftFrame.location.reload()</script>");
  39.             DirList.DataBind();
  40.         }
  41.     }
  42.     protected void DirList_RowCreated(object sender, GridViewRowEventArgs e)
  43.     {
  44.         if (e.Row.RowType == DataControlRowType.DataRow && Session["dir_id"] != null)
  45.         {
  46.             LinkButton btn = (LinkButton)e.Row.FindControl("BtnDelete");
  47.             SqlConnection conn = dbConnection.getConnection();
  48.             conn.Open();
  49.             SqlCommand cmd = new SqlCommand("select count(id) from OA_REGULATION_FILE where dir_id=" + DirList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
  50.             int count = Convert.ToInt32(cmd.ExecuteScalar().ToString());
  51.             if (count > 0)
  52.             {
  53.                 btn.OnClientClick = "";
  54.                 btn.Enabled = false;
  55.             }
  56.             else
  57.             {
  58.                 cmd = new SqlCommand("select id from OA_SYS_CHILD_MENU where parent_id=" + DirList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
  59.                 try
  60.                 {
  61.                     int id = Convert.ToInt32(cmd.ExecuteScalar().ToString());
  62.                     btn.OnClientClick = "";
  63.                     btn.Enabled = false;
  64.                 }
  65.                 catch 
  66.                 { 
  67.                     btn.CommandArgument = DirList.DataKeys[e.Row.RowIndex].Value.ToString();
  68.                 }
  69.             }
  70.             conn.Close();
  71.         }
  72.     }
  73. }