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

📄 tree.cs

📁 vs2005开发的人事管理系统,b/s的,做毕业设计的同学可以下载参考一下.
💻 CS
字号:
using System;
using System.Data;
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;

namespace Tree
{
    /// <summary>
    /// tree 的摘要说明。
    /// </summary>

    public class tree : System.Web.UI.Page
    {
        private string tablename = "Tb_Tree";
        int current = 0;
        int len = 0;
        string[] arrPowerName;
        string ConnectionString;
        public tree()
        {
            ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["Mispersonalconn"];
            len = GetRecordCount();
            arrPowerName = new string[len];
        }
        private void Page_Load(object sender, System.EventArgs e)
        {

            GetPowerName(0);
            //CloseDbConnection();
            //ResponseArray();
            // 在此处放置用户代码以初始化页面
        }
        private void GetPowerName(int _ParentId)
        {
            int Id;
            string PowerName;
            string sql = "select Id,PowerName,Layer from " + tablename + " where ParentId=" + _ParentId;
            try
            {
                SqlConnection conn = new SqlConnection(ConnectionString);
                conn.Open();
                SqlCommand cmd = new SqlCommand(sql, conn);
                SqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    for (int j = 0; j < int.Parse(dr["Layer"].ToString()); j++)
                    {
                        Response.Write("&nbsp;&nbsp;&nbsp;&nbsp;");
                    }
                    PowerName = dr["PowerName"].ToString();
                    Response.Write(PowerName + "<br>");
                    arrPowerName[current++] = PowerName;
                    Id = int.Parse(dr["Id"].ToString());
                    GetPowerName(Id);
                }
                dr.Close();
                conn.Close();
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
        }
        private void ResponseArray()
        {
            int i;
            for (i = 0; i < len; i++)
            {
                Response.Write(arrPowerName[i] + "<br>");
            }
        }
        private void CloseDbConnection()
        {
            //conn.Close();
        }
        private int GetRecordCount()
        {
            SqlConnection conn = new SqlConnection(ConnectionString);
            string sql = "select count(id) from " + tablename;
            conn.Open();
            SqlCommand cmd = new SqlCommand(sql, conn);
            int count = int.Parse(cmd.ExecuteScalar().ToString());
            conn.Close();
            return count;
        }

  
    }
}

⌨️ 快捷键说明

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