menu.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_menu : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- //設置主鍵
- MenuList.DataKeyNames = new string[] { "id" };
- if (Request.QueryString["m_id"] != null)
- {
- PnlMenu.Visible = true;
- this.setMenu(Request.QueryString["m_id"]);
- }
- }
- }
- protected void setMenu(string id)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("SELECT m.name, m.is_open, m.parent_id, p.name parent FROM "+
- "dbo.OA_SYS_CHILD_MENU AS m INNER JOIN dbo.OA_SYS_CHILD_MENU AS p ON m.parent_id = p.id where m.id="+
- Request.QueryString["m_id"], conn);
- SqlDataReader dr = cmd.ExecuteReader();
- if (dr.Read())
- {
- TxtName.Text = dr["name"].ToString();
- DdlOpen.SelectedValue = dr["is_open"].ToString();
- ParentId.Value = dr["parent_id"].ToString();
- TxtParent.Value = dr["parent"].ToString();
- }
- dr.Close();
- conn.Close();
- }
- protected void MenuList_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- //行高亮
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor; this.style.backgroundColor='#c8dafa';this.style.cursor='pointer';");
- e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
- e.Row.Attributes.Add("onclick", "location.href='menu.aspx?m_id=" + MenuList.DataKeys[e.Row.RowIndex].Value.ToString() + "'");
- }
- }
- protected void BtnOk_Click(object sender, EventArgs e)
- {
- int flag = 0;
- if (TxtName.Text.Trim().Equals(""))
- {
- flag = 1;
- LblErrName.Text = "選單名稱不能為空";
- }
- if (ParentId.Value.Equals(""))
- {
- flag = 1;
- LblErrParent.Text = "上級部門不能為空";
- }
- if (flag == 0 && Request.QueryString["m_id"]!=null)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("update OA_SYS_CHILD_MENU set name='"+TxtName.Text+"', parent_id='"+ParentId.Value+"', is_open='"+DdlOpen.SelectedValue+"' where id="+Request.QueryString["m_id"], conn);
- cmd.ExecuteNonQuery();
- conn.Close();
- MenuList.DataBind();
- //刷新樹
- Response.Write("<script language='javascript'>window.parent.frames.leftFrame.location.reload()</script>");
- PnlMenu.Visible = false;
- }
- }
- }