OrganzationTree.aspx.cs
上传用户:tiancihang
上传日期:2014-03-12
资源大小:21387k
文件大小:4k
源码类别:

.net编程

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. using com.etong.DAL.FC;
  12. public partial class OrganzationTree : System.Web.UI.Page
  13. {
  14.     protected void Page_Load(object sender, EventArgs e)
  15.     {
  16.         if (!IsPostBack)
  17.         {
  18.             int rows = 0, i = 0, prentID = 0, OrgLevel = 0, OrgID = 0;
  19.             DataView dv = new DataView();
  20.             EtongFlyChou EFly = new EtongFlyChou();
  21.             string PrentID, OrgName, StrOrgID, StrPath;
  22.             Array OrgArr;
  23.             int PrentIndex, TwoIndex = 0;
  24.             //Array ThreeIndex;
  25.             dv = EFly.ReadOrgData();
  26.             rows = dv.Count;
  27.             int[] ThreeIndex = new int[rows];
  28.             for (i = 0; i < rows; i++)
  29.             {
  30.                 OrgArr = dv.Table.Rows[i].ItemArray;
  31.                 PrentID = Convert.ToString(OrgArr.GetValue(1));
  32.                 OrgName = Convert.ToString(OrgArr.GetValue(2));
  33.                 OrgLevel = Convert.ToInt32(OrgArr.GetValue(5));
  34.                 StrOrgID = Convert.ToString(OrgArr.GetValue(0));
  35.                 OrgID = Convert.ToInt32(OrgArr.GetValue(0));
  36.                 StrPath = Convert.ToString(OrgArr.GetValue(8));
  37.                 if (PrentID != "" && PrentID != null)
  38.                 {
  39.                     prentID = Convert.ToInt32(PrentID);
  40.                     TreeNode trnode = new TreeNode();
  41.                     if (prentID == -1)
  42.                     {
  43.                         trnode.Text = OrgName;
  44.                         trnode.Value = StrOrgID;
  45.                         trnode.ToolTip = OrgName;
  46.                         TOrganzation.Nodes.Add(trnode);
  47.                     }
  48.                     else
  49.                     {
  50.                         trnode.Text = OrgName;
  51.                         trnode.Value = StrOrgID;
  52.                         trnode.ToolTip = OrgName;
  53.                         if (OrgLevel == 2)
  54.                         {
  55.                             trnode.ImageToolTip = Convert.ToString(TwoIndex);
  56.                             TOrganzation.Nodes[0].ChildNodes.Add(trnode);
  57.                             TwoIndex++;
  58.                         }
  59.                         if (OrgLevel == 3)
  60.                         {
  61.                             PrentIndex = Convert.ToInt32(TOrganzation.FindNode(EFly.GetParentNode(PrentID)).ImageToolTip);
  62.                             ThreeIndex[PrentIndex]++;
  63.                             trnode.ImageToolTip = Convert.ToString(ThreeIndex[PrentIndex] - 1);
  64.                             //ThreeIndex.SetValue( Convert.ToInt32( ThreeIndex.GetValue(PrentIndex))+1,PrentIndex);
  65.                             //PrentIndex = TOrganzation.Nodes[0].ChildNodes.IndexOf(ParentNode);
  66.                             TOrganzation.Nodes[0].ChildNodes[PrentIndex].ChildNodes.Add(trnode);
  67.                         }
  68.                     }
  69.                 }
  70.                 TOrganzation.CollapseAll();
  71.                 TOrganzation.Nodes[0].Expand();
  72.             }
  73.         }
  74.     }
  75.     protected void TOrganzation_SelectedNodeChanged(object sender, EventArgs e)
  76.     {
  77.         int iEmpID,iOrgID;
  78.         iEmpID = Convert.ToInt32(Request.QueryString["StrValue"]);
  79.         iOrgID = Convert.ToInt32(TOrganzation.SelectedNode.Value); 
  80.         EtongFlyChou EFly = new EtongFlyChou();
  81.         if (EFly.UpEmpParent(iEmpID, iOrgID) == true)
  82.         {
  83.             Response.Write("<script>alert('系统提示:职工信息转移成功!');window.close();</script>");
  84.         }
  85.         else
  86.         {
  87.             Response.Write("<script>alert('系统提示:职工信息转移失败!');window.close();</script>");
  88.         }
  89.         
  90.         return;
  91.     }
  92. }