⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tree.aspx

📁 一个用ajax作的树插件
💻 ASPX
📖 第 1 页 / 共 2 页
字号:
        {
            return "禁止提交非法的数据!";
        }
        string StrSql = "Select * From tree Where id=" + id;
        OleDbConnection MyConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath(g_StrConn));
        try
        {
            MyConn.Open();
            OleDbDataAdapter odAdapt = new OleDbDataAdapter(StrSql, MyConn);
            DataSet DS = new DataSet();
            odAdapt.Fill(DS);
            DataTable DT = DS.Tables[0];
            startValue = DT.Rows[0]["name"].ToString().Trim();
            fatherID = DT.Rows[0]["fatherID"].ToString().Trim();
            MyConn.Close();
            return moveHtml(startValue);
        }
        catch
        {
            return "数据库连接失败!";
        }
    }

    //************************
    //**  保存移动后的节点  **
    //************************
    public string move()
    {
        string ffatherID = "";
        string fID = "";
        string id = Request["id"];
        if (!IsNumber(id))
        {
            return "禁止提交非法的数据!";
        }
        string fatherID = Request["fatherID"];
        if (!IsNumber(fatherID))
        {
            return "禁止提交非法的数据!";
        }
        string StrSql = "Select * From tree Where id=" + fatherID;
        OleDbConnection MyConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath(g_StrConn));
        try
        {
            MyConn.Open();
            OleDbDataAdapter odAdapt = new OleDbDataAdapter(StrSql, MyConn);
            DataSet DS = new DataSet();
            odAdapt.Fill(DS);
            DataTable DT = DS.Tables[0];
            ffatherID = DT.Rows[0]["fatherID"].ToString().Trim();
            MyConn.Close();
        }
        catch
        {
            return "数据库连接失败!";
        }
        string StrSql2 = "Select * From tree Where id=" + id;
        OleDbConnection MyConn2 = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath(g_StrConn));
        try
        {
            MyConn2.Open();
            OleDbDataAdapter odAdapt2 = new OleDbDataAdapter(StrSql2, MyConn2);
            OleDbCommandBuilder oCB = new OleDbCommandBuilder(odAdapt2);
            DataSet DS2 = new DataSet();
            odAdapt2.Fill(DS2);
            DataTable DT2 = DS2.Tables[0];
            fID = DT2.Rows[0]["fatherID"].ToString();
            DT2.Rows[0]["fatherID"] = fatherID;
            odAdapt2.Update(DS2);
            MyConn2.Close();
            return "moved" + ffatherID + "i" + fID + "f" + fatherID;
        }
        catch
        {
            return "数据库连接失败!";
        }
    }
    
    //****************
    //**  删除节点  **
    //****************
    public string del()
    {
        string ffatherID;
        string id = Request.QueryString["id"];
        if (!IsNumber(id))
        {
            return "禁止提交非法的数据!";
        }
        string fatherID = Request.QueryString["fatherID"];
        if (!IsNumber(fatherID))
        {
            return "禁止提交非法的数据!";
        }
        string StrSql = "select * From Tree where fatherID=" + id;
        OleDbConnection MyConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath(g_StrConn));
        OleDbCommand MyCmd = new OleDbCommand(StrSql, MyConn);
        try
        {
            MyCmd.Connection.Open();
            OleDbDataReader Dr = MyCmd.ExecuteReader();
            if (Dr.Read())
            {
                return "deletError" + fatherID;
            }
            MyCmd.Connection.Close();
        }
        catch
        {
            return "数据库连接失败!";
        } 
        string StrSql2 = "Delete * From Tree where id=" + id;
        OleDbConnection MyConn2 = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath(g_StrConn));
        OleDbCommand myCmd2 = new OleDbCommand(StrSql2, MyConn2);
        try
        {
            MyConn2.Open();
            myCmd2.ExecuteReader();
            MyConn2.Close();
            string StrSql3 = "select * From Tree where fatherID=" + fatherID;
            OleDbConnection MyConn3 = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath(g_StrConn));
            OleDbCommand MyCmd3 = new OleDbCommand(StrSql3, MyConn3);
            try
            {
                MyCmd3.Connection.Open();
                OleDbDataReader Dr3 = MyCmd3.ExecuteReader();
                if (Dr3.Read())
                {
                    return "deleted" + fatherID;
                }
                else
                {
                    string StrSql4 = "Select * From tree Where id=" + fatherID;
                    OleDbConnection MyConn4 = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath(g_StrConn));
                    try
                    {
                        MyConn4.Open();
                        OleDbDataAdapter odAdapt4 = new OleDbDataAdapter(StrSql4, MyConn4);
                        DataSet DS4 = new DataSet();
                        odAdapt4.Fill(DS4);
                        DataTable DT4 = DS4.Tables[0];
                        ffatherID = DT4.Rows[0]["fatherID"].ToString().Trim();
                        MyConn4.Close();
                        return "deleted" + ffatherID;
                    }
                    catch
                    {
                        return "数据库连接失败!";
                    }
                }
                MyCmd3.Connection.Close();
            }
            catch
            {
                return "数据库连接失败!";
            }
        }
        catch
        {
            return "数据库连接失败!";
        }
    }
    
    //************************
    //**  判断名字是否存在  **
    //************************
    public bool checkName(string name,string id)
    {
        name = MoveBidStr(name);
        string StrSql = "";
        if (id.CompareTo("") == 0)
        {
            StrSql = "select * from Tree where name='" + name + "'";
        }
        else
        {
            StrSql = "select * from Tree where name='" + name + "' and id<>" + id;
        }
        OleDbConnection MyConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath(g_StrConn));
        OleDbCommand MyCmd = new OleDbCommand(StrSql, MyConn);
        try
        {
            MyCmd.Connection.Open();
            OleDbDataReader Dr = MyCmd.ExecuteReader();
            if (Dr.Read())
            {
                return false;
            }
            else
            {
                return true;
            }
            MyCmd.Connection.Close();
        }
        catch
        {
            return false;
        }
    }
    //**************************
    //**  判断是否是数字组合  **
    //**************************
    public bool IsNumber(string strDate)
    {
        if (strDate == null)
        {
            return false;
        }
        if (strDate.Equals(string.Empty))
        {
            return false;
        }

        Regex numRegex = new Regex(@"0*[0-9][0-9]*$");
        return numRegex.IsMatch(strDate);
    }
    
    //******************
    //**  过滤JS代码  **
    //******************
    public string moveJS(string strString)
    {
        string str;
        str = strString;
        if (str != null)
        {
            str = str.Replace("\\", "\\\\");
            str = str.Replace(((char)34).ToString(), "\\\"");
            str = str.Replace(((char)39).ToString(), "\\'");
            str = str.Replace(((char)13).ToString(), "\\n");
            str = str.Replace(((char)10).ToString(), "\\r");
            str = str.Replace("'", "&#39;");
            str = str.Replace(" ", "&nbsp;");
            str = str.Replace(((char)9).ToString(), "&nbsp;");
            str = str.Replace("<", "&lt");
            str = str.Replace(">", "&gt");
        }
        return str;
    }
    
    //********************
    //**  过滤HTML代码  **
    //********************
    public string moveHtml(string strString)
    {
        string str;
        str = strString;
        if (str != null)
        {
            str = str.Replace(" ", "&nbsp;");
            str = str.Replace("<", "&lt");
            str = str.Replace(">", "&gt");
            str = str.Replace("|", "");
            str = str.Replace(((char)9).ToString(), "&nbsp;");
            str = str.Replace(((char)34).ToString(), "&quot;");
            str = str.Replace(((char)39).ToString(), "&#39;");
            str = str.Replace(((char)13).ToString() + ((char)10).ToString(), "<br>");
        }
        return str;
    }
    
    //******************
    //**  过滤'"符号  **
    //******************
    public string MoveBidStr(string strString)
    {
        string str;
        str = strString;
        if (str != null)
        {
            str = str.Replace("'", "''");
            str = str.Replace(((char)39).ToString(), ((char)39 + (char)39).ToString());
        }
        return str;
    }
</script>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -