Org.aspx.cs
上传用户:tiancihang
上传日期:2014-03-12
资源大小:21387k
文件大小:12k
- using System;
- using System.Collections;
- using System.Data;
- using System.Configuration;
- 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 _Default : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- 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;
- TreeOrg.Nodes.Add(trnode);
- }
- else
- {
- trnode.Text = OrgName;
- trnode.Value = StrOrgID;
- trnode.ToolTip = OrgName;
- if (OrgLevel == 2)
- {
- trnode.ImageToolTip = Convert.ToString(TwoIndex);
- TreeOrg.Nodes[0].ChildNodes.Add(trnode);
- TwoIndex++;
- }
- if (OrgLevel == 3)
- {
- //if (bl)
- //{
-
- // bl = false;
- //}
-
- //TreeNode ParentNode = new TreeNode();
- PrentIndex = Convert.ToInt32( TreeOrg.FindNode(EFly.GetParentNode(PrentID)).ImageToolTip);
- ThreeIndex[PrentIndex]++;
- trnode.ImageToolTip = Convert.ToString(ThreeIndex[PrentIndex]-1);
- //ThreeIndex.SetValue( Convert.ToInt32( ThreeIndex.GetValue(PrentIndex))+1,PrentIndex);
- //PrentIndex = TreeOrg.Nodes[0].ChildNodes.IndexOf(ParentNode);
- TreeOrg.Nodes[0].ChildNodes[PrentIndex].ChildNodes.Add(trnode);
- //ThreeIndex++;
- }
- //TreeOrg.Nodes.Add(trnode);
- }
- }
- }
- ///value 值用"职工"区别
- TreeCount.Value = rows.ToString();
- 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)
- {
- TreeOrg.Nodes[0].ChildNodes.Add(trnode);
- }
- else if (OrgLevel == 2)
- {
- PrOrgID = Convert.ToInt32(TreeOrg.FindNode(EFly.GetParentNode( Convert.ToString(PrOrgID))).ImageToolTip);
- TreeOrg.Nodes[0].ChildNodes[PrOrgID].ChildNodes.Add(trnode);
- }
- else if (OrgLevel == 3)
- {
- PID = Convert.ToInt32(EFly.GetParentID(Convert.ToString(PrOrgID)));
- PrOrgID = Convert.ToInt32(TreeOrg.FindNode(EFly.GetParentNode(Convert.ToString(PrOrgID))).ImageToolTip);
- PID = Convert.ToInt32(TreeOrg.FindNode(EFly.GetParentNode(Convert.ToString(PID))).ImageToolTip);
- TreeOrg.Nodes[0].ChildNodes[PID].ChildNodes[PrOrgID].ChildNodes.Add(trnode);
- }
- }
- //string EmpName;
- //int PrOrgID,PID;
- //rows = OrgLevel = 0;
- //dv = EFly.ReadEmpData();
- //rows = dv.Count;
- //for (i = 0; i < rows; i++)
- //{
- // OrgArr = dv.Table.Rows[i].ItemArray;
- // EmpName = Convert.ToString(OrgArr.GetValue(1));
- // PrOrgID = Convert.ToInt32(OrgArr.GetValue(2));
- // OrgLevel = Convert.ToInt32(OrgArr.GetValue(3));
- // TreeNode trnode = new TreeNode();
- // trnode.Text = EmpName;
- // trnode.Value = Convert.ToString(PrOrgID);
- // trnode.ToolTip = EmpName;
- // //trnode.ShowCheckBox = true;
- // trnode.ImageUrl = "~/image/user.gif";
- // if (OrgLevel == 1)
- // {
- // TreeOrg.Nodes[0].ChildNodes.Add(trnode);
- // }
- // else if (OrgLevel == 2)
- // {
- // PrOrgID = PrOrgID - 2001;
- // TreeOrg.Nodes[0].ChildNodes[PrOrgID].ChildNodes.Add(trnode);
- // }
- // else if (OrgLevel == 3)
- // {
- // PID = (PrOrgID - 3000001) / 1000;
- // PrOrgID = PrOrgID - 3003001;
- // TreeOrg.Nodes[0].ChildNodes[PID-1].ChildNodes[PrOrgID].ChildNodes.Add(trnode);
- // }
- //}
- TreeOrg.CollapseAll();
- TreeOrg.Nodes[0].Expand();
- TreeCount.Value = Convert.ToString( (Convert.ToInt32( TreeCount.Value) + rows));
- TreeOrg.Attributes.Add("onclick", "javascript:return TreeOnClientClick();");
- }
-
- //OrgArr = dv.Table.Rows[0].ItemArray;
- //PrentID = Convert.ToString( OrgArr.GetValue(1));
- //TextBox1.Text = PrentID;
- //ClientScript.RegisterStartupScript(Me.GetType(), "", "alert('删除成功');", True)
- // Msg.Text = "Role '" & Server.HtmlEncode(RolesName) & "' deleted."
- //rows = 0
- //rows = GrdVwMenu.Rows.Count()
- //Menu1.Items.Clear()
- //GrdVwMenu.Visible = False
- //For i = -1 To rows - 1
- // Dim PMenu As New MenuItem
- // If i = -1 Then
- // PMenu.Text = "主页"
- // PMenu.Value = "-1"
- // PMenu.ToolTip = "主页"
- // Menu1.Items.Add(PMenu)
- // Else
- // If Convert.ToInt32(GrdVwMenu.Rows(i).Cells(2).Text) = -1 Then
- // PMenu.Text = GrdVwMenu.Rows(i).Cells(1).Text
- // PMenu.Value = GrdVwMenu.Rows(i).Cells(0).Text
- // PMenu.ToolTip = GrdVwMenu.Rows(i).Cells(1).Text
- // Menu1.Items.Add(PMenu)
- // Else
- // End If
- // End If
- //Next
- }
- protected void Del_Click(object sender, EventArgs e)
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:shanc!');", true);
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- string sMenu = Request.Form["SMenuID"];
- if (sMenu == "1")
- {
- //TreeOrg.ExpandAll();
- }
- else
- {
- string StrValue = Request.Form["dellValue"];
- EtongFlyChou EFly = new EtongFlyChou();
- if (StrValue.Length > 2)
- {
- if (StrValue.Substring(0, 2) == "职工")
- {
- int iEmpID = Convert.ToInt32(StrValue.Substring(2, StrValue.Length - 2));
- if (EFly.BlEmpUser(iEmpID) == false)
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:本职工正在使用不能删除!');", true);
- return;
- }
- else
- {
- if (EFly.DelEmp(iEmpID) == true)
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:职工信息删除成功!');document.form1.dellValue.value = '';window.location.replace(window.location.href);", true);//window.location.reload();
- return;
- }
- else
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:职工信息删除失败!');", true);
- return;
- }
- }
- }
- }
- int iOrgID = Convert.ToInt32(StrValue);
- if (EFly.BlOrgParent(iOrgID) == false)
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:此组织机构拥有下级机构,不允许删除!');", true);
- return;
- }
- else
- {
- if (EFly.BlEmpParent(iOrgID) == false)
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:此组织机构拥有下级职工,不允许删除!');", true);
- return;
- }
- else
- {
- if (EFly.DelOrg(iOrgID) == true)
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:组织机构信息删除成功!');document.form1.dellValue.value = '';window.location.replace(window.location.href);", true);
- return;
- }
- else
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:组织机构信息删除失败!');", true);
- return;
- }
- }
- }
- //string temp = "alert('系统提示:" + Request.Form["dellValue"] + "!');";
- //this.ClientScript.RegisterStartupScript(this.GetType(), "", temp, true);
- }
- }
- }