首页 新闻 搜索 专区 学院

根据用户访问权限,本地区及下级地区显示可编辑按钮,别的显示不可编辑按钮

0
[已关闭问题] 关闭于 2012-09-01 09:27

main.aspx

 <%if(Session["rights"].ToString().IndexOf("qx_xxcbj")!=-1){%>
                <img id="imgbutton" src="../images/editword.png" alt="" title="编辑词条" style="cursor: pointer;" 
                onmouseover="this.src='../images/editword1.png'" onmouseout="this.src='../images/editword.png'" onclick="editAll();"/>
                <%}else{ %>
                <img src="../images/editword_disabled.png" alt="" title="编辑词条"/>
                <%} %>  

main.aspx.cs

public string idinfo = "";
        public string name = "";
        public string namepronode = "";
        string nodeid = "";
        string Aid = "";
        string PreNode = "";
        public bool check = false;


        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserID"] == null)
            {
                Response.Redirect("/index/Default.aspx", true);
            }
            else
            {
                DataTable dt = DAL.BMarea_DAL.GetUserArea(Session["UserID"].ToString());// 用户所在的部门
                idinfo = dt.Rows[0][0].ToString();
                Aid = dt.Rows[0][2].ToString(); //登录用户的所在部门编号
                PreNode = dt.Rows[0][1].ToString();
            }

            if (Request.QueryString["name"] != null)
            {
                name = Request.QueryString["name"].ToString().Trim();
                DataTable dt1 = DAL.BMarea_DAL.GetNameId(name);

                namepronode = dt1.Rows[0][0].ToString(); //得到传递值(所在部门)的上一级编号

                if (name != "XX区")
                {
                    nodeid = DAL.BMarea_DAL.GetParentID(namepronode).ToString();
                }
                wordtitle.Value = name;
            }

            if (!string.IsNullOrEmpty(idinfo))
            {
                if (idinfo == name || (namepronode == Aid) || (nodeid == Aid))
                {
                    check = true;
                }

            }



        }


BMarea_DAL.cs

public static DataTable GetUserArea(string userid)
        {
            DbHelperSQLP db = new DbHelperSQLP();
            db.connectionString = PubConstant.GetConnectionString("Users");
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select top 1 Aid from BMuserlist where userid = '" + userid + "'");
            DataTable ds = db.Query(strSql.ToString()).Tables[0];
            if (ds.Rows.Count > 0)
            {
                string aid = ds.Rows[0][0].ToString();
                StringBuilder strSql2 = new StringBuilder();
                strSql2.Append("select top 1 areaname,pre,Aid from BMarea where Aid = '" + aid + "'");
                DataTable da = db.Query(strSql2.ToString()).Tables[0];
                if (da.Rows.Count > 0)
                {
                    return da;

                }
                else
                {
                    return null;
                }

            }
            else
            {
                return null;
            }
            
        }

//通过区域名称获取信息表(id)
        public static DataTable GetNameId(string name)
        {
            DbHelperSQLP db = new DbHelperSQLP();
            db.connectionString = PubConstant.GetConnectionString("Users");
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select top 1 pre,Aid from  BMarea where areaname = '" + name + "'");
            DataTable dt = db.Query(strSql.ToString()).Tables[0];
            if (dt.Rows.Count > 0)
            {

                return dt;
            }
            else
            {

                return null;
            }

        }

        //通过id得到上级部门的id

        public static string GetParentID(string aid)
        {
            string parentID = "";

            DbHelperSQLP db = new DbHelperSQLP();
            db.connectionString = PubConstant.GetConnectionString("Users");
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select top 1 pre from  BMarea where Aid = '" + aid + "'");
            DataTable ds = db.Query(strSql.ToString()).Tables[0];
            if (ds.Rows.Count > 0)
            {
                parentID = ds.Rows[0][0].ToString();
                return parentID;
            }
            else
            {
                return "";
            }

        }

  查询的数据表:

select u.Aid,u.username,a.Aid,a.pre from BMuserlist as u,BMarea as a where u.Aid=a.Aid

部分结果如下:

 在mian.aspx代码里加个什么条件可以实现其功能

请大侠帮我解决解决。。。。。

doubledu的主页 doubledu | 初学一级 | 园豆:199
提问于:2012-07-28 15:00
< >
分享
所有回答(2)
0

我能看完都是勇气。。。。,为啥不能把你问题再提仔细一点。。。我真心没看懂。。

羽商宫 | 园豆:2490 (老鸟四级) | 2012-07-29 08:31
0

呵呵,此问题已解决、

doubledu | 园豆:199 (初学一级) | 2012-09-01 09:26
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册