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

.net编程

开发平台:

C#

  1. using System;
  2. using System.Collections;
  3. using System.Data;
  4. using System.Configuration;
  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 _Default : 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.             bool bl = true;
  25.             //Array ThreeIndex;
  26.             
  27.                         
  28.             dv = EFly.ReadOrgData();
  29.             rows = dv.Count;
  30.             int[] ThreeIndex = new int[rows];
  31.             for (i = 0; i < rows; i++)
  32.             {
  33.                 OrgArr = dv.Table.Rows[i].ItemArray;
  34.                 PrentID = Convert.ToString(OrgArr.GetValue(1));
  35.                 OrgName = Convert.ToString(OrgArr.GetValue(2));
  36.                 OrgLevel = Convert.ToInt32(OrgArr.GetValue(5));
  37.                 StrOrgID = Convert.ToString(OrgArr.GetValue(0));
  38.                 OrgID = Convert.ToInt32(OrgArr.GetValue(0));
  39.                 StrPath = Convert.ToString(OrgArr.GetValue(8));
  40.                 if (PrentID != "" && PrentID != null)
  41.                 {
  42.                     prentID = Convert.ToInt32(PrentID);
  43.                     TreeNode trnode = new TreeNode();
  44.                     if (prentID == -1)
  45.                     {
  46.                         trnode.Text = OrgName;
  47.                         trnode.Value = StrOrgID;
  48.                         trnode.ToolTip = OrgName;
  49.                         TreeOrg.Nodes.Add(trnode);
  50.                     }
  51.                     else
  52.                     {
  53.                         trnode.Text = OrgName;
  54.                         trnode.Value = StrOrgID;
  55.                         trnode.ToolTip = OrgName;
  56.                         if (OrgLevel == 2)
  57.                         {
  58.                             trnode.ImageToolTip = Convert.ToString(TwoIndex);
  59.                             TreeOrg.Nodes[0].ChildNodes.Add(trnode);
  60.                             TwoIndex++;
  61.                         }
  62.                         if (OrgLevel == 3)
  63.                         {
  64.                             //if (bl)
  65.                             //{
  66.                                 
  67.                             //    bl = false;
  68.                             //}
  69.                             
  70.                             //TreeNode ParentNode = new TreeNode();
  71.                             PrentIndex = Convert.ToInt32( TreeOrg.FindNode(EFly.GetParentNode(PrentID)).ImageToolTip);
  72.                             ThreeIndex[PrentIndex]++;
  73.                             trnode.ImageToolTip = Convert.ToString(ThreeIndex[PrentIndex]-1);
  74.                             //ThreeIndex.SetValue( Convert.ToInt32( ThreeIndex.GetValue(PrentIndex))+1,PrentIndex);
  75.                             //PrentIndex = TreeOrg.Nodes[0].ChildNodes.IndexOf(ParentNode);
  76.                             TreeOrg.Nodes[0].ChildNodes[PrentIndex].ChildNodes.Add(trnode);
  77.                             //ThreeIndex++;
  78.                         }
  79.                         //TreeOrg.Nodes.Add(trnode);
  80.                     }
  81.                 }
  82.             }
  83.             ///value 值用"职工"区别
  84.             TreeCount.Value = rows.ToString(); 
  85.             string EmpName,StrEmpID;
  86.             int PrOrgID, PID;
  87.             rows = OrgLevel = 0;
  88.             dv = EFly.ReadEmpData();
  89.             rows = dv.Count;
  90.             for (i = 0; i < rows; i++)
  91.             {
  92.                 OrgArr = dv.Table.Rows[i].ItemArray;
  93.                 StrEmpID = Convert.ToString(OrgArr.GetValue(0));
  94.                 EmpName = Convert.ToString(OrgArr.GetValue(1));
  95.                 OrgLevel = Convert.ToInt32(OrgArr.GetValue(3));
  96.                 PrOrgID = Convert.ToInt32(OrgArr.GetValue(2));
  97.                 TreeNode trnode = new TreeNode();
  98.                 trnode.Text = EmpName;
  99.                 trnode.ToolTip = EmpName;
  100.                 trnode.Value = "职工" + StrEmpID;
  101.                 trnode.ImageUrl = "image/user.gif";
  102.                 //trnode.ImageToolTip = StrEmpID;
  103.                 if (OrgLevel == 1)
  104.                 {
  105.                     TreeOrg.Nodes[0].ChildNodes.Add(trnode);
  106.                 }
  107.                 else if (OrgLevel == 2)
  108.                 {
  109.                     PrOrgID = Convert.ToInt32(TreeOrg.FindNode(EFly.GetParentNode( Convert.ToString(PrOrgID))).ImageToolTip);
  110.                     TreeOrg.Nodes[0].ChildNodes[PrOrgID].ChildNodes.Add(trnode);
  111.                 }
  112.                 else if (OrgLevel == 3)
  113.                 {
  114.                     PID = Convert.ToInt32(EFly.GetParentID(Convert.ToString(PrOrgID)));
  115.                     PrOrgID = Convert.ToInt32(TreeOrg.FindNode(EFly.GetParentNode(Convert.ToString(PrOrgID))).ImageToolTip);
  116.                     PID = Convert.ToInt32(TreeOrg.FindNode(EFly.GetParentNode(Convert.ToString(PID))).ImageToolTip);
  117.                     TreeOrg.Nodes[0].ChildNodes[PID].ChildNodes[PrOrgID].ChildNodes.Add(trnode);
  118.                 }
  119.             }
  120.                 //string EmpName;
  121.                 //int PrOrgID,PID;
  122.                 //rows = OrgLevel = 0;
  123.                 //dv = EFly.ReadEmpData();
  124.                 //rows = dv.Count;
  125.                 //for (i = 0; i < rows; i++)
  126.                 //{
  127.                 //    OrgArr = dv.Table.Rows[i].ItemArray;
  128.                 //    EmpName = Convert.ToString(OrgArr.GetValue(1));
  129.                 //    PrOrgID = Convert.ToInt32(OrgArr.GetValue(2));
  130.                 //    OrgLevel = Convert.ToInt32(OrgArr.GetValue(3));
  131.                 //    TreeNode trnode = new TreeNode();
  132.                 //    trnode.Text = EmpName;
  133.                 //    trnode.Value = Convert.ToString(PrOrgID);
  134.                 //    trnode.ToolTip = EmpName;
  135.                 //    //trnode.ShowCheckBox = true;
  136.                 //    trnode.ImageUrl = "~/image/user.gif";
  137.                 //    if (OrgLevel == 1)
  138.                 //    {
  139.                 //        TreeOrg.Nodes[0].ChildNodes.Add(trnode);
  140.                 //    }
  141.                 //    else if (OrgLevel == 2)
  142.                 //    {
  143.                 //        PrOrgID = PrOrgID - 2001;
  144.                 //        TreeOrg.Nodes[0].ChildNodes[PrOrgID].ChildNodes.Add(trnode);
  145.                 //    }
  146.                 //    else if (OrgLevel == 3)
  147.                 //    {
  148.                 //        PID = (PrOrgID - 3000001) / 1000;
  149.                 //        PrOrgID = PrOrgID - 3003001;
  150.                 //        TreeOrg.Nodes[0].ChildNodes[PID-1].ChildNodes[PrOrgID].ChildNodes.Add(trnode);
  151.                 //    }
  152.                 //}
  153.                 TreeOrg.CollapseAll();
  154.                 TreeOrg.Nodes[0].Expand();
  155.                 TreeCount.Value = Convert.ToString( (Convert.ToInt32( TreeCount.Value) + rows)); 
  156.                 TreeOrg.Attributes.Add("onclick", "javascript:return TreeOnClientClick();");
  157.         }
  158.        
  159.         //OrgArr = dv.Table.Rows[0].ItemArray;
  160.         //PrentID = Convert.ToString( OrgArr.GetValue(1));
  161.         //TextBox1.Text = PrentID; 
  162.         //ClientScript.RegisterStartupScript(Me.GetType(), "", "alert('删除成功');", True)
  163.         //        Msg.Text = "Role '" & Server.HtmlEncode(RolesName) & "' deleted."
  164.         //rows = 0
  165.         //rows = GrdVwMenu.Rows.Count()
  166.         //Menu1.Items.Clear()
  167.         //GrdVwMenu.Visible = False
  168.         //For i = -1 To rows - 1
  169.         //    Dim PMenu As New MenuItem
  170.         //    If i = -1 Then
  171.         //        PMenu.Text = "主页"
  172.         //        PMenu.Value = "-1"
  173.         //        PMenu.ToolTip = "主页"
  174.         //        Menu1.Items.Add(PMenu)
  175.         //    Else
  176.         //        If Convert.ToInt32(GrdVwMenu.Rows(i).Cells(2).Text) = -1 Then
  177.         //            PMenu.Text = GrdVwMenu.Rows(i).Cells(1).Text
  178.         //            PMenu.Value = GrdVwMenu.Rows(i).Cells(0).Text
  179.         //            PMenu.ToolTip = GrdVwMenu.Rows(i).Cells(1).Text
  180.         //            Menu1.Items.Add(PMenu)
  181.         //        Else
  182.         //        End If
  183.         //    End If
  184.         //Next
  185.     } 
  186.     protected void Del_Click(object sender, EventArgs e)
  187.     {
  188.         this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:shanc!');", true);
  189.     }
  190.     protected void Button1_Click(object sender, EventArgs e)
  191.     {
  192.         string sMenu = Request.Form["SMenuID"];
  193.         if (sMenu == "1")
  194.         {
  195.              //TreeOrg.ExpandAll();
  196.         }
  197.         else
  198.         {
  199.             string StrValue = Request.Form["dellValue"];
  200.             EtongFlyChou EFly = new EtongFlyChou();
  201.             if (StrValue.Length > 2)
  202.             {
  203.                 if (StrValue.Substring(0, 2) == "职工")
  204.                 {
  205.                     int iEmpID = Convert.ToInt32(StrValue.Substring(2, StrValue.Length - 2));
  206.                     if (EFly.BlEmpUser(iEmpID) == false)
  207.                     {
  208.                         this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:本职工正在使用不能删除!');", true);
  209.                         return;
  210.                     }
  211.                     else
  212.                     {
  213.                         if (EFly.DelEmp(iEmpID) == true)
  214.                         {
  215.                             this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:职工信息删除成功!');document.form1.dellValue.value = '';window.location.replace(window.location.href);", true);//window.location.reload();
  216.                             return;
  217.                         }
  218.                         else
  219.                         {
  220.                             this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:职工信息删除失败!');", true);
  221.                             return;
  222.                         }
  223.                     }
  224.                 }
  225.             }
  226.             int iOrgID = Convert.ToInt32(StrValue);
  227.             if (EFly.BlOrgParent(iOrgID) == false)
  228.             {
  229.                 this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:此组织机构拥有下级机构,不允许删除!');", true);
  230.                 return;
  231.             }
  232.             else
  233.             {
  234.                 if (EFly.BlEmpParent(iOrgID) == false)
  235.                 {
  236.                     this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:此组织机构拥有下级职工,不允许删除!');", true);
  237.                     return;
  238.                 }
  239.                 else
  240.                 {
  241.                     if (EFly.DelOrg(iOrgID) == true)
  242.                     {
  243.                         this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:组织机构信息删除成功!');document.form1.dellValue.value = '';window.location.replace(window.location.href);", true);
  244.                         return;
  245.                     }
  246.                     else
  247.                     {
  248.                         this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:组织机构信息删除失败!');", true);
  249.                         return;
  250.                     }
  251.                 }
  252.             }
  253.             //string temp = "alert('系统提示:" + Request.Form["dellValue"] + "!');";
  254.             //this.ClientScript.RegisterStartupScript(this.GetType(), "", temp, true);
  255.         }
  256.     }
  257. }