dir_list.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:3k
源码类别:
OA系统
开发平台:
ASP/ASPX
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using System.Data.SqlClient;
- public partial class web_regulation_dir_list : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- DirList.DataKeyNames = new string[] { "id" };
- }
- }
- protected void DirList_RowUpdated(object sender, GridViewUpdatedEventArgs e)
- {
- //刷新樹
- Response.Write("<script language='javascript'>window.parent.window.parent.frames.leftFrame.location.reload()</script>");
- }
- protected void DirList_RowCommand(object sender, GridViewCommandEventArgs e)
- {
- if (e.CommandName.Equals("DeleteData"))
- {
- string id = e.CommandArgument.ToString();
- //點擊刪除按鈕
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("delete from OA_SYS_CHILD_MENU where id="+id, conn);
- cmd.ExecuteNonQuery();
- conn.Close();
- //刷新樹
- Response.Write("<script language='javascript'>window.parent.window.parent.frames.leftFrame.location.reload()</script>");
- DirList.DataBind();
- }
- }
- protected void DirList_RowCreated(object sender, GridViewRowEventArgs e)
- {
- if (e.Row.RowType == DataControlRowType.DataRow && Session["dir_id"] != null)
- {
- LinkButton btn = (LinkButton)e.Row.FindControl("BtnDelete");
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select count(id) from OA_REGULATION_FILE where dir_id=" + DirList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
- int count = Convert.ToInt32(cmd.ExecuteScalar().ToString());
- if (count > 0)
- {
- btn.OnClientClick = "";
- btn.Enabled = false;
- }
- else
- {
- cmd = new SqlCommand("select id from OA_SYS_CHILD_MENU where parent_id=" + DirList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
- try
- {
- int id = Convert.ToInt32(cmd.ExecuteScalar().ToString());
- btn.OnClientClick = "";
- btn.Enabled = false;
- }
- catch
- {
- btn.CommandArgument = DirList.DataKeys[e.Row.RowIndex].Value.ToString();
- }
- }
- conn.Close();
- }
- }
- }