您目前尚未登陆,请选择【登陆】或【注册
首页->行政办公->人事管理系统(课程设计)源码>>App-Code/tree.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:人事管理系统(课程设计)源码
当前文件:文件类型 Mispersonal/App_Code/tree.cs打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Web; 4using System.Web.Security; 5using System.Web.UI; 6using System.Web.UI.WebControls; 7using System.Web.UI.WebControls.WebParts; 8using System.Web.UI.HtmlControls; 9using System.Data.SqlClient; 10 11namespace Tree 12{ 13 /// <summary> 14 /// tree 的摘要说明。 15 /// </summary> 16 17 public class tree : System.Web.UI.Page 18 { 19 private string tablename = "Tb_Tree"; 20 int current = 0; 21 int len = 0; 22 string[] arrPowerName; 23 string ConnectionString; 24 public tree() 25 { 26 ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["Mispersonalconn"]; 27 len = GetRecordCount(); 28 arrPowerName = new string[len]; 29 } 30 private void Page_Load(object sender, System.EventArgs e) 31 { 32 33 GetPowerName(0); 34 //CloseDbConnection(); 35 //ResponseArray(); 36 // 在此处放置用户代码以初始化页面 37 } 38 private void GetPowerName(int _ParentId) 39 { 40 int Id; 41 string PowerName; 42 string sql = "select Id,PowerName,Layer from " + tablename + " where ParentId=" + _ParentId; 43 try 44 { 45 SqlConnection conn = new SqlConnection(ConnectionString); 46 conn.Open(); 47 SqlCommand cmd = new SqlCommand(sql, conn); 48 SqlDataReader dr = cmd.ExecuteReader(); 49 while (dr.Read()) 50 { 51 for (int j = 0; j < int.Parse(dr["Layer"].ToString()); j++) 52 { 53 Response.Write("&nbsp;&nbsp;&nbsp;&nbsp;"); 54 } 55 PowerName = dr["PowerName"].ToString(); 56 Response.Write(PowerName + "<br>"); 57 arrPowerName[current++] = PowerName; 58 Id = int.Parse(dr["Id"].ToString()); 59 GetPowerName(Id); 60 } 61 dr.Close(); 62 conn.Close(); 63 } 64 catch (Exception ex) 65 { 66 Response.Write(ex.ToString()); 67 } 68 } 69 private void ResponseArray() 70 { 71 int i; 72 for (i = 0; i < len; i++) 73 { 74 Response.Write(arrPowerName[i] + "<br>"); 75 } 76 } 77 private void CloseDbConnection() 78 { 79 //conn.Close(); 80 } 81 private int GetRecordCount() 82 { 83 SqlConnection conn = new SqlConnection(ConnectionString); 84 string sql = "select count(id) from " + tablename; 85 conn.Open(); 86 SqlCommand cmd = new SqlCommand(sql, conn); 87 int count = int.Parse(cmd.ExecuteScalar().ToString()); 88 conn.Close(); 89 return count; 90 } 91 92 93 } 94} 95
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:人事管理系统(课程设计)源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号