authority_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_system_authority_list : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- LoginDAO.CheckLogin(Session, Response, "../", 2);
- if (!IsPostBack)
- {
- GroupList.DataKeyNames = new string[] { "id" };
- }
- }
- protected void GroupList_RowCreated(object sender, GridViewRowEventArgs e)
- {
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- LinkButton btnDelete = (LinkButton)e.Row.FindControl("BtnDelete");
- btnDelete.CommandArgument = GroupList.DataKeys[e.Row.RowIndex].Value.ToString();
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- LinkButton BtnCount = (LinkButton)e.Row.FindControl("BtnEmpCount");
- SqlCommand cmd = new SqlCommand("select count(id) from OA_EMPLOYEE where user_group="+GroupList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
- BtnCount.Text = cmd.ExecuteScalar().ToString();
- BtnCount.PostBackUrl = "authority_employee_list.aspx?g_id=" + GroupList.DataKeys[e.Row.RowIndex].Value.ToString();
- LinkButton btn = (LinkButton)e.Row.FindControl("BtnDelete");
- if (!BtnCount.Text.Equals("0"))
- {
- btn.OnClientClick = "";
- btn.Enabled = false;
- }
- btn = (LinkButton)e.Row.FindControl("BtnName");
- cmd = new SqlCommand("select name from OA_USER_GROUP_MAIN where id=" + GroupList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
- btn.Text = cmd.ExecuteScalar().ToString();
- btn.PostBackUrl = "authority_edit.aspx?g_id=" + GroupList.DataKeys[e.Row.RowIndex].Value.ToString();
- conn.Close();
- }
- }
- protected void GroupList_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- //行高亮
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;");
- e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
- //e.Row.Attributes.Add("onclick", "location.href='authority_edit.aspx?g_id=" + GroupList.DataKeys[e.Row.RowIndex].Value.ToString() + "'");
- }
- }
- protected void GroupList_RowCommand(object sender, GridViewCommandEventArgs e)
- {
- if (e.CommandName.Equals("DeleteData"))
- {
- string id = e.CommandArgument.ToString();
- //點擊刪除按鈕
- try
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("delete from OA_USER_GROUP_MAIN where id="+id, conn);
- cmd.ExecuteNonQuery();
- conn.Close();
- GroupList.DataBind();
- }
- catch (Exception ex)
- {
- Response.Write("delete from OA_USER_GROUP_MAIN where id=" + id);
- Response.Write(ex.Message);
- }
- }
- }
- }