EmpTree.aspx.cs
上传用户:tiancihang
上传日期:2014-03-12
资源大小:21387k
文件大小:6k
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- 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 com.etong.DAL.FC;
- public partial class EmpTree : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- Response.Buffer = true;
- Response.ExpiresAbsolute = System.DateTime.Now;
- Response.Expires = 0;
- Response.CacheControl = "no-cache";
- if (!IsPostBack)
- {
- int rows = 0, i = 0, prentID = 0, OrgLevel = 0, OrgID = 0;
- DataView dv = new DataView();
- EtongFlyChou EFly = new EtongFlyChou();
- string PrentID, OrgName, StrOrgID, StrPath;
- Array OrgArr;
- int PrentIndex, TwoIndex = 0;
- bool bl = true;
- //Array ThreeIndex;
- dv = EFly.ReadOrgData();
- rows = dv.Count;
- int[] ThreeIndex = new int[rows];
- for (i = 0; i < rows; i++)
- {
- OrgArr = dv.Table.Rows[i].ItemArray;
- PrentID = Convert.ToString(OrgArr.GetValue(1));
- OrgName = Convert.ToString(OrgArr.GetValue(2));
- OrgLevel = Convert.ToInt32(OrgArr.GetValue(5));
- StrOrgID = Convert.ToString(OrgArr.GetValue(0));
- OrgID = Convert.ToInt32(OrgArr.GetValue(0));
- StrPath = Convert.ToString(OrgArr.GetValue(8));
- if (PrentID != "" && PrentID != null)
- {
- prentID = Convert.ToInt32(PrentID);
- TreeNode trnode = new TreeNode();
- if (prentID == -1)
- {
- trnode.Text = OrgName;
- trnode.Value = StrOrgID;
- trnode.ToolTip = OrgName;
- OrgTree.Nodes.Add(trnode);
- }
- else
- {
- trnode.Text = OrgName;
- trnode.Value = StrOrgID;
- trnode.ToolTip = OrgName;
- if (OrgLevel == 2)
- {
- trnode.ImageToolTip = Convert.ToString(TwoIndex);
- OrgTree.Nodes[0].ChildNodes.Add(trnode);
- TwoIndex++;
- }
- if (OrgLevel == 3)
- {
- PrentIndex = Convert.ToInt32(OrgTree.FindNode(EFly.GetParentNode(PrentID)).ImageToolTip);
- ThreeIndex[PrentIndex]++;
- trnode.ImageToolTip = Convert.ToString(ThreeIndex[PrentIndex] - 1);
- OrgTree.Nodes[0].ChildNodes[PrentIndex].ChildNodes.Add(trnode);
- }
- //OrgTree.Nodes.Add(trnode);
- }
- }
- }
- ///value 值用"职工"区别
- string EmpName, StrEmpID;
- int PrOrgID, PID;
- rows = OrgLevel = 0;
- dv = EFly.ReadEmpData();
- rows = dv.Count;
- for (i = 0; i < rows; i++)
- {
- OrgArr = dv.Table.Rows[i].ItemArray;
- StrEmpID = Convert.ToString(OrgArr.GetValue(0));
- EmpName = Convert.ToString(OrgArr.GetValue(1));
- OrgLevel = Convert.ToInt32(OrgArr.GetValue(3));
- PrOrgID = Convert.ToInt32(OrgArr.GetValue(2));
- TreeNode trnode = new TreeNode();
- trnode.Text = EmpName;
- trnode.ToolTip = EmpName;
- trnode.Value = "职工" + StrEmpID;
- trnode.ImageUrl = "image/user.gif";
- //trnode.ImageToolTip = StrEmpID;
- if (OrgLevel == 1)
- {
- OrgTree.Nodes[0].ChildNodes.Add(trnode);
- }
- else if (OrgLevel == 2)
- {
- PrOrgID = Convert.ToInt32(OrgTree.FindNode(EFly.GetParentNode(Convert.ToString(PrOrgID))).ImageToolTip);
- OrgTree.Nodes[0].ChildNodes[PrOrgID].ChildNodes.Add(trnode);
- }
- else if (OrgLevel == 3)
- {
- PID = Convert.ToInt32(EFly.GetParentID(Convert.ToString(PrOrgID)));
- PrOrgID = Convert.ToInt32(OrgTree.FindNode(EFly.GetParentNode(Convert.ToString(PrOrgID))).ImageToolTip);
- PID = Convert.ToInt32(OrgTree.FindNode(EFly.GetParentNode(Convert.ToString(PID))).ImageToolTip);
- OrgTree.Nodes[0].ChildNodes[PID].ChildNodes[PrOrgID].ChildNodes.Add(trnode);
- }
- }
- OrgTree.CollapseAll();
- OrgTree.Nodes[0].Expand();
- }
- }
- protected void OrgTree_SelectedNodeChanged(object sender, EventArgs e)
- {
- string EmId = "", EMName = "";
- EmId = OrgTree.SelectedValue;
- EMName = OrgTree.SelectedNode.Text;
- int EmidLen = EmId.Length;
- if (EmidLen > 2)
- {
- string firstword = EmId.Substring(0, 2).ToString();
- if (firstword == "职工")
- {
- string secondword = "";
- secondword=EmId.Substring(2).ToString()+ "" + "," + EMName.ToString();
-
- ClientScript.RegisterStartupScript(this.GetType(), "", "<script>window.returnValue='" + secondword + "';window.close();</script>");
- // Response.Write("<script>window.returnValue=" + secondword + " ;window.close();</script>");
- // return;
- }
- else
- ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:请选择职工');</script>");
- }
- else
- ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:请选择职工');</script>");
-
- }
- }