• asp.net,简单权限。存取读XML


    public string strToExcel = "none";
    public string strConter = "none";
    public string updateuid = "";
    public string fileContents;
    
    public void XunHuan()
            {
    
                string Modify_Employ = Session["Login_Employ_No"];
                string filename = null;
                string curDir = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;
                //运行文件的当前相对目录     '""
    
                curDir = curDir.Substring(curDir.IndexOf("E:"), curDir.LastIndexOf(".") - 8);
                filename = curDir + "/aul.xml";
                filename = filename.Replace(".", "/").Replace("aul/xml", "aul.xml").Replace("/WebRoot/bin/Status", "");
                //Response.Write(filename)
                XmlDocument doc = new XmlDocument();
                doc.Load(filename);
    
                XmlNode root = doc.DocumentElement;
                XmlNode shopId = root.SelectSingleNode("//base/shopId");
                fileContents = shopId.InnerText;
                //读取节点值
    
                //控制导出功能的显示隐藏
                if (fileContents.IndexOf(Modify_Employ) >= 0)
                {
                    strToExcel = "block";
                }
                string fileConter = "0002439,0004698,0000403,";
                //控制权限功能的显示隐藏
                if (fileConter.IndexOf(Modify_Employ) >= 0)
                {
                    strConter = "block";
                }
    
                string strtypeuid = Request.QueryString["hdtuid"];
                //获取隐藏域的操作类型 a添加  d是移除
                updateuid = Request.QueryString["txtuserid"];
                //要添加或删除的员工ID
                //如果参数是添加员工
                if (strtypeuid == "a")
                {
                    if (fileContents.IndexOf(updateuid) >= 0)
                    {
                        //Page.ClientScript.RegisterStartupScript(Page.GetType(), "message0", "<script language='javascript'>alert('该员工已有权限');</script>")
                    }
                    else
                    {
                        shopId.InnerText = fileContents + updateuid + ",";
                        //设置节点值
                        doc.Save(filename);
                        //保存XML
                        //My.Computer.FileSystem.WriteAllText("E:/Project/eip/WebRoot/eiptohtuserlist.txt", fileContents & updateuid & ",", False, System.Text.Encoding.Unicode) '把员工ID保存进文件
                        Page.ClientScript.RegisterStartupScript(Page.GetType(), "message1", "<script language='javascript'>alert('添加成功');document.forms[0].submit();</script>");
                    }
                }
                //如果参数是移除员工
                if (strtypeuid == "d")
                {
                    fileContents = fileContents.Replace(updateuid + ",", "");
                    shopId.InnerText = fileContents;
                    //设置节点值
                    doc.Save(filename);
                    //保存XML
                    //My.Computer.FileSystem.WriteAllText("E:/Project/eip/WebRoot/eiptohtuserlist.txt", fileContents, False, System.Text.Encoding.Unicode) '把员工ID保存进文件
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "message2", "<script language='javascript'>alert('移除成功');  self.opener.location.reload(); </script>");
                }
    
                
    
            }

  • 相关阅读:
    Android之基于XMPP即时通讯(转)
    开机启动service小DEMO
    Android 歌词同步滚动效果(转)
    OC中的消息传递和初始化
    oc中对象的初始化
    c语言的结构体字节数统计
    css的页面布局
    说一说我理解的css
    什么是js闭包
    我对js作用域的理解
  • 原文地址:https://www.cnblogs.com/wybshyy/p/13783725.html
Copyright © 2020-2023  润新知