using BizCom; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Utils; using SiteCore; using NHibernate.Mapping; public partial class Ehr_EmployeeManage : TreeBasePage, ITreePage { protected override void OnPreInit(EventArgs e) { PmTag = "employee"; TreeTitle = "选择组织机构"; ContentTitle = "员工信息"; TreeSelValue = "0"; } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (_permissions.Contains("account")) { //accountPlace.Visible = true; } } } #region 左边数据 System.Data.DataView dv = null; public object GetTreeData() { StringBuilder str = new StringBuilder(); DataTable resources = null; resources = CeErpOrganization.Get(); //if (_permissions.Contains("all")) resources = CeErpOrganization.Get(); //else resources = CeErpOrganization.Get(CurrentUser.UserPost.OrgID); int i = 0; if (resources != null && resources.Rows.Count > 0) { //if (i == 0) //{ // TreeSelValue = "-1"; // str.Append("{"); //} //else string orgids = CurrentUser.User.ManageOrgIds; string[] list = orgids != null ? orgids.Split(',') : new string[0]; if (CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "HumanResMr") { TreeSelValue = "0"; str.Append("{"); str.AppendFormat("\"id\":\"0\",\"name\":\"{0}\",\"path\":\"\",\"expanded\": true", "公司"); str.Append("}"); dv = new System.Data.DataView(resources); dv.RowFilter = "ParentID=0"; } else { TreeSelValue = CurrentUser.UserPost.OrgID; dv = new System.Data.DataView(resources); dv.RowFilter = "ParentID=0"; } foreach (DataRowView drv in dv) { if (list.Contains(drv["id"].ToString()) || CurrentUser.UserPost.Post.Code == "SysAdmin") { str.Append(",{"); str.AppendFormat("\"id\":\"{0}\",\"name\":\"{1}\",\"path\":\"\",\"pid\":\"{2}\",\"expanded\": true", drv["id"], drv["Name"], 0); str.Append("}"); GetOtherTree(drv["ID"], ref str); i++; } } // } // else //{ // TreeSelValue = CurrentUser.UserPost.OrgID; // dv = new System.Data.DataView(resources); // dv.RowFilter = "ID=" + CurrentUser.UserPost.OrgID; //foreach (DataRowView drv in dv) //{ // if (list.Contains(drv["id"].ToString()) || CurrentUser.UserPost.Post.Code == "SysAdmin") // { // str.Append("{"); // str.AppendFormat("\"id\":\"{0}\",\"name\":\"{1}\",\"path\":\"\",\"expanded\": true", drv["id"], drv["Name"], 0); //str.Append("}"); //GetOtherTree(drv["ID"], ref str); //i++; //} //} // } } string vstr = str.ToString().Trim(','); str = new StringBuilder(); str.Append("["); str.Append(vstr); str.Append("]"); return str.ToString(); } private void GetOtherTree(object id, ref StringBuilder str) { dv.RowFilter = "ParentID=" + id; dv.Sort = "Sort asc"; if (dv.Count < 1) { return; } string orgids = CurrentUser.User.ManageOrgIds; string[] list = orgids != null ? orgids.Split(',') : new string[0]; foreach (DataRowView drv in dv) { if (list.Contains(drv["id"].ToString()) || CurrentUser.UserPost.Post.Code == "SysAdmin") { //if (TreeSelValue.ToString() == "0") TreeSelValue = drv["id"].ToString(); str.Append(",{"); str.AppendFormat("\"id\":\"{0}\",\"name\":\"{1}\",\"pid\":\"{3}\",\"path\":\"{2}\",\"expanded\": true", drv["ID"], drv["Name"], drv["Path"], drv["ParentID"]); str.Append("}"); GetOtherTree(drv["ID"], ref str); } } } #endregion }