Esempio n. 1
0
        private void BindPosition(string departmentID, TreeViewItem treeItem)
        {
            loadbar.Start();
            //if (treeItem.Items.Count > 0)
            //{
            //    loadbar.Stop();
            //    return;
            //}
            List <T_HR_POST> Positions = Application.Current.Resources["ORGTREESYSPostInfo" + Perm + Entity] as List <T_HR_POST>;

            Positions = Positions.Where(p => p.T_HR_DEPARTMENT != null).Where(s => s.T_HR_DEPARTMENT.DEPARTMENTID == departmentID && s.EDITSTATE == "1").ToList();
            if (Positions == null)
            {
                loadbar.Stop();
                return;
            }

            if (Positions.Count() == 0)
            {
                loadbar.Stop();
                return;
            }


            foreach (T_HR_POST tmpPosition in Positions)
            {
                if (tmpPosition.T_HR_DEPARTMENT == null || string.IsNullOrEmpty(tmpPosition.T_HR_DEPARTMENT.DEPARTMENTID))
                {
                    continue;
                }
                TreeViewItem parentItem = GetParentItem(OrgTreeItemTypes.Department, tmpPosition.T_HR_DEPARTMENT.DEPARTMENTID);
                if (parentItem != null)
                {
                    TreeViewItem item = new TreeViewItem();
                    item.Header = tmpPosition.T_HR_POSTDICTIONARY.POSTNAME;
                    item.Style  = Application.Current.Resources["TreeViewItemStyle"] as Style;
                    ExtOrgObj obj = new ExtOrgObj();
                    obj.ObjectInstance = tmpPosition;
                    item.DataContext   = obj;

                    //设置父级对像
                    obj.ParentObject = parentItem.DataContext;

                    // item.Style = this.Resources["CheckBoxTreeItemStyle"] as Style;
                    item.HeaderTemplate = treeViewItemTemplate;
                    //标记为岗位
                    item.Tag = OrgTreeItemTypes.Post;
                    parentItem.Items.Add(item);
                }
            }
            depIDsCach.Add(departmentID, "1");
            //树全部展开
            //  treeOrganization.ExpandAll();
            //if (treeOrganization.Items.Count > 0)
            //{
            //    TreeViewItem selectedItem = treeOrganization.Items[0] as TreeViewItem;
            //    selectedItem.IsSelected = true;
            //}
            loadbar.Stop();
        }
Esempio n. 2
0
        private void GetChildSelectedCompany(TreeViewItem item, List <ExtOrgObj> selObj)
        {
            foreach (TreeViewItem childItem in item.Items)
            {
                TreeViewItem myItem =
                    (TreeViewItem)(item.ItemContainerGenerator.ContainerFromItem(childItem));

                CheckBox cbx = Helper.UIHelper.FindChildControl <CheckBox>(myItem);

                if (cbx != null && cbx.IsChecked.GetValueOrDefault(false))
                {
                    OrgTreeItemTypes type = (OrgTreeItemTypes)(childItem.Tag);

                    if (SelectedObjType == OrgTreeItemTypes.All || type == SelectedObjType)
                    {
                        if (type == OrgTreeItemTypes.Post)
                        {
                            ExtOrgObj obj  = childItem.DataContext as ExtOrgObj;
                            ExtOrgObj pobj = item.DataContext as ExtOrgObj;
                            if (obj != null && pobj != null)
                            {
                                //附父节点的值
                                ((T_HR_POST)obj.ObjectInstance).T_HR_DEPARTMENT = pobj.ObjectInstance as T_HR_DEPARTMENT;
                            }
                        }

                        selObj.Add(childItem.DataContext as ExtOrgObj);
                    }
                }

                GetChildSelectedCompany(childItem, selObj);
            }
        }
Esempio n. 3
0
        private void AddChildOrgItems(TreeViewItem item, string companyID)
        {
            List <T_HR_COMPANY> childs = GetChildORG(companyID);

            if (childs == null || childs.Count <= 0)
            {
                return;
            }

            foreach (T_HR_COMPANY childOrg in childs)
            {
                TreeViewItem childItem = new TreeViewItem();

                childItem.Header = childOrg.CNAME;
                //childItem.Header = childOrg.BRIEFNAME;
                childItem.Style = Application.Current.Resources["TreeViewItemStyle"] as Style;
                ExtOrgObj obj = new ExtOrgObj();
                obj.ObjectInstance = childOrg;

                childItem.DataContext = obj;
                //设置父级对像
                obj.ParentObject = item.DataContext;

                // childItem.Style = this.Resources["CheckBoxTreeItemStyle"] as Style;
                childItem.HeaderTemplate = treeViewItemTemplate;
                //标记为公司
                childItem.Tag = OrgTreeItemTypes.Company;
                item.Items.Add(childItem);

                AddChildOrgItems(childItem, childOrg.COMPANYID);
            }
        }
Esempio n. 4
0
        void perclient_GetEmployeePostByPostIDCompleted(object sender, PersonnelWS.GetEmployeePostByPostIDCompletedEventArgs e)
        {
            try
            {
                List <PersonnelWS.T_HR_EMPLOYEEPOST> eplist = new List <PersonnelWS.T_HR_EMPLOYEEPOST>();
                if (e.Result != null)
                {
                    eplist = e.Result.ToList();
                }

                TreeViewItem parentItem = e.UserState as TreeViewItem;

                if (eplist == null || eplist.Count == 0 || parentItem == null)
                {
                    loadbar.Stop();
                    return;
                }
                parentItem.Items.Clear();

                string postID = string.Empty;
                foreach (PersonnelWS.T_HR_EMPLOYEEPOST ep in eplist)
                {
                    TreeViewItem subItem = new TreeViewItem();
                    subItem.Style  = Application.Current.Resources["TreeViewItemStyle"] as Style;
                    subItem.Header = ep.T_HR_EMPLOYEE.EMPLOYEECNAME;

                    ExtOrgObj obj = new ExtOrgObj();
                    obj.ObjectInstance  = ep.T_HR_EMPLOYEE;
                    subItem.DataContext = obj;

                    //设置父级对像
                    obj.ParentObject = parentItem.DataContext;
                    #region
                    ExtOrgObj post     = (ExtOrgObj)obj.ParentObject;
                    string    postName = post.ObjectName;
                    //  fromPostLevel=(post as SMT.Saas.Tools.OrganizationWS.T_HR_POST).POSTLEVEL.ToString();
                    if (string.IsNullOrEmpty(postID))
                    {
                        postID = post.ObjectID;
                    }
                    ExtOrgObj dept     = (ExtOrgObj)post.ParentObject;
                    string    deptName = dept.ObjectName;

                    // ExtOrgObj corp = (ExtOrgObj)dept.ParentObject;
                    SMT.Saas.Tools.OrganizationWS.T_HR_COMPANY corp = (dept.ObjectInstance as SMT.Saas.Tools.OrganizationWS.T_HR_DEPARTMENT).T_HR_COMPANY;
                    string corpName = corp.CNAME;
                    obj.ObjectName = ep.T_HR_EMPLOYEE.EMPLOYEECNAME + "-" + postName + "-" + deptName + "-" + corpName;
                    #endregion
                    //标记为岗位
                    subItem.Tag            = OrgTreeItemTypes.Personnel;
                    subItem.HeaderTemplate = treeViewItemTemplate;
                    parentItem.Items.Add(subItem);
                }
                postIDsCach.Add(postID, "1");
            }
            catch (Exception ex)
            {
            }
            loadbar.Stop();
        }
Esempio n. 5
0
        protected void lookUpTree_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            //return;
            if (treeOrganization.SelectedItem == null)
            {
                return;
            }
            if (treeOrganization.SelectedItem.GetType() != typeof(TreeViewItem))
            {
                return;
            }

            TreeViewItem item = (TreeViewItem)treeOrganization.SelectedItem;

            //TODO: 这个方法在单选时选择有bug,可能是Selected事件与Checked事件有冲突
            //CheckBox cbx = Helper.UIHelper.FindChildControl<CheckBox>(item);
            //if (cbx != null)
            //    cbx.IsChecked = true;

            if (item == null || item.DataContext == null)
            {
                return;
            }

            OrgTreeItemTypes type = (OrgTreeItemTypes)(item.Tag);

            if ((SelectedObjType == OrgTreeItemTypes.All || SelectedObjType == OrgTreeItemTypes.Personnel) &&
                type == OrgTreeItemTypes.Post)
            {
                //TODO:多选
                ExtOrgObj obj = new ExtOrgObj();

                obj = item.DataContext as ExtOrgObj;

                if (type == OrgTreeItemTypes.Post && obj != null)
                {
                    //加载员工
                    BindEmployee(item, obj.ObjectID);
                }
            }
            else if (type == OrgTreeItemTypes.Department)
            {
                ExtOrgObj obj = new ExtOrgObj();

                obj = item.DataContext as ExtOrgObj;
                if (depIDsCach.ContainsKey(obj.ObjectID))
                {
                    return;
                }
                BindPosition(obj.ObjectID, item);
            }
        }
Esempio n. 6
0
        //private string parentName = "";
        //private void UnCheckChildCheckbox(TreeViewItem item, CheckBox selfCheckbox)
        //{

        //    foreach (TreeViewItem childItem in item.Items)
        //    {
        //        TreeViewItem myItem =
        //        (TreeViewItem)(item.ItemContainerGenerator.ContainerFromItem(childItem));
        //        CheckBox cbx = Helper.UIHelper.FindChildControl<CheckBox>(myItem);
        //        if (cbx == selfCheckbox)
        //        {
        //            UnCheckChildCheckbox(myItem, selfCheckbox);
        //        }
        //        else
        //        {

        //            //if (MultiSelected && parentName == GetParentName(myItem) && cbx.IsChecked==true)
        //            if (MultiSelected && !HaveChildItemChecked(myItem, selfCheckbox))
        //            {
        //                return;
        //            }
        //            if (cbx != null && cbx.IsChecked.GetValueOrDefault(false))
        //            {
        //                cbx.IsChecked = false;
        //            }
        //            UnCheckChildCheckbox(childItem, selfCheckbox);
        //        }
        //    }
        //}


        private bool IsSameParent(TreeViewItem item, CheckBox selfCheckbox)
        {
            if (item == null || item.Parent == null)
            {
                return(false);
            }
            ExtOrgObj    obj        = new ExtOrgObj();
            TreeViewItem parentItem = new TreeViewItem();

            parentItem = item.Parent as TreeViewItem;
            obj        = parentItem.DataContext as ExtOrgObj;
            //ExtOrgObj obj1 = new ExtOrgObj();
            //obj1= selfCheckbox.DataContext as ExtOrgObj;
            return(obj.ObjectName == selfCheckbox.DataContext.ToString());
        }
Esempio n. 7
0
        private TreeViewItem GetParentItemFromChild(TreeViewItem item, OrgTreeItemTypes parentType, string parentID)
        {
            TreeViewItem tmpItem = null;

            ExtOrgObj obj = item.DataContext as ExtOrgObj;

            if (obj != null && item.Tag != null && item.Tag.ToString() == parentType.ToString())
            {
                switch (parentType)
                {
                case OrgTreeItemTypes.Company:
                    T_HR_COMPANY tmpOrg = obj.ObjectInstance as T_HR_COMPANY;
                    if (tmpOrg != null)
                    {
                        if (tmpOrg.COMPANYID == parentID)
                        {
                            return(item);
                        }
                    }
                    break;

                case OrgTreeItemTypes.Department:
                    T_HR_DEPARTMENT tmpDep = obj.ObjectInstance as T_HR_DEPARTMENT;
                    if (tmpDep != null)
                    {
                        if (tmpDep.DEPARTMENTID == parentID)
                        {
                            return(item);
                        }
                    }
                    break;
                }
            }
            if (item.Items != null && item.Items.Count > 0)
            {
                foreach (TreeViewItem childitem in item.Items)
                {
                    tmpItem = GetParentItemFromChild(childitem, parentType, parentID);
                    if (tmpItem != null)
                    {
                        break;
                    }
                }
            }
            return(tmpItem);
        }
Esempio n. 8
0
        private void BindEmployeeByTreeViewItem(TreeViewItem item)
        {
            if (item == null)
            {
                return;
            }
            ExtOrgObj tmp = new ExtOrgObj();

            tmp = item.DataContext as ExtOrgObj;
            if (tmp.ObjectType == OrgTreeItemTypes.Personnel)
            {
                foreach (var h in ((PersonnelWS.T_HR_EMPLOYEE)tmp.ObjectInstance).T_HR_EMPLOYEEPOST)
                {
                    PersonnelWS.T_HR_POST    tmpPost_P = new PersonnelWS.T_HR_POST();
                    OrganizationWS.T_HR_POST tmpPost_O = new OrganizationWS.T_HR_POST();
                    tmpPost_O = BindEmployeePost(item);
                }
            }
        }
Esempio n. 9
0
        protected void lookUpTree_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
        {

            //return;
            if (treeOrganization.SelectedItem == null)
            {
                return;
            }
            if (treeOrganization.SelectedItem.GetType() != typeof(TreeViewItem))
                return;

            TreeViewItem item = (TreeViewItem)treeOrganization.SelectedItem;

            //TODO: 这个方法在单选时选择有bug,可能是Selected事件与Checked事件有冲突
            //CheckBox cbx = Helper.UIHelper.FindChildControl<CheckBox>(item);
            //if (cbx != null)
            //    cbx.IsChecked = true;

            if (item == null || item.DataContext == null)
                return;

            OrgTreeItemTypes type = (OrgTreeItemTypes)(item.Tag);

            if ((SelectedObjType == OrgTreeItemTypes.All || SelectedObjType == OrgTreeItemTypes.Personnel)
                && type == OrgTreeItemTypes.Post)
            {
                //TODO:多选 
                ExtOrgObj obj = new ExtOrgObj();

                obj = item.DataContext as ExtOrgObj;

                if (type == OrgTreeItemTypes.Post && obj != null)
                {
                    //加载员工
                    BindEmployee(item, obj.ObjectID);
                }

            }
            else if (type == OrgTreeItemTypes.Department)
            {
                ExtOrgObj obj = new ExtOrgObj();

                obj = item.DataContext as ExtOrgObj;
                if (depIDsCach.ContainsKey(obj.ObjectID)) return;
                BindPosition(obj.ObjectID, item);
            }

        }
Esempio n. 10
0
        private void AddChildOrgItems(TreeViewItem item, string companyID)
        {
            List<T_HR_COMPANY> childs = GetChildORG(companyID);
            if (childs == null || childs.Count <= 0)
                return;

            foreach (T_HR_COMPANY childOrg in childs)
            {
                TreeViewItem childItem = new TreeViewItem();

                childItem.Header = childOrg.CNAME;
                //childItem.Header = childOrg.BRIEFNAME;
                childItem.Style = Application.Current.Resources["TreeViewItemStyle"] as Style;
                ExtOrgObj obj = new ExtOrgObj();
                obj.ObjectInstance = childOrg;

                childItem.DataContext = obj;
                //设置父级对像
                obj.ParentObject = item.DataContext;

                // childItem.Style = this.Resources["CheckBoxTreeItemStyle"] as Style;
                childItem.HeaderTemplate = treeViewItemTemplate;
                //标记为公司
                childItem.Tag = OrgTreeItemTypes.Company;
                item.Items.Add(childItem);

                AddChildOrgItems(childItem, childOrg.COMPANYID);
            }
        }
Esempio n. 11
0
        private void BindPosition(string departmentID, TreeViewItem treeItem)
        {
            loadbar.Start();
            //if (treeItem.Items.Count > 0)
            //{
            //    loadbar.Stop();
            //    return;
            //}
            List<T_HR_POST> Positions = Application.Current.Resources["ORGTREESYSPostInfo" + Perm + Entity] as List<T_HR_POST>;
            Positions = Positions.Where(p => p.T_HR_DEPARTMENT != null).Where(s => s.T_HR_DEPARTMENT.DEPARTMENTID == departmentID && s.EDITSTATE == "1").ToList();
            if (Positions == null)
            {
                loadbar.Stop();
                return;
            }

            if (Positions.Count() == 0)
            {
                loadbar.Stop();
                return;
            }


            foreach (T_HR_POST tmpPosition in Positions)
            {
                if (tmpPosition.T_HR_DEPARTMENT == null || string.IsNullOrEmpty(tmpPosition.T_HR_DEPARTMENT.DEPARTMENTID))
                    continue;
                TreeViewItem parentItem = GetParentItem(OrgTreeItemTypes.Department, tmpPosition.T_HR_DEPARTMENT.DEPARTMENTID);
                if (parentItem != null)
                {
                    TreeViewItem item = new TreeViewItem();
                    item.Header = tmpPosition.T_HR_POSTDICTIONARY.POSTNAME;
                    item.Style = Application.Current.Resources["TreeViewItemStyle"] as Style;
                    ExtOrgObj obj = new ExtOrgObj();
                    obj.ObjectInstance = tmpPosition;
                    item.DataContext = obj;

                    //设置父级对像
                    obj.ParentObject = parentItem.DataContext;

                    // item.Style = this.Resources["CheckBoxTreeItemStyle"] as Style;
                    item.HeaderTemplate = treeViewItemTemplate;
                    //标记为岗位
                    item.Tag = OrgTreeItemTypes.Post;
                    parentItem.Items.Add(item);
                }
            }
            depIDsCach.Add(departmentID, "1");
            //树全部展开
            //  treeOrganization.ExpandAll();
            //if (treeOrganization.Items.Count > 0)
            //{
            //    TreeViewItem selectedItem = treeOrganization.Items[0] as TreeViewItem;
            //    selectedItem.IsSelected = true;
            //}
            loadbar.Stop();
        }
Esempio n. 12
0
        /// <summary>
        /// 绑定组织架构节点
        /// </summary>
        private void BindCompany()
        {
            treeOrganization.Items.Clear();
            allCompanys = Application.Current.Resources["ORGTREESYSCompanyInfo" + Perm + Entity] as List<T_HR_COMPANY>;

            allDepartments = Application.Current.Resources["ORGTREESYSDepartmentInfo" + Perm + Entity] as List<T_HR_DEPARTMENT>;


            if (allCompanys == null)
            {
                loadbar.Stop();
                return;
            }
            else
            {
                allCompanys = allCompanys.Where(s => s.EDITSTATE == "1").ToList();
                allCompanys = allCompanys.OrderBy(s => s.SORTINDEX).ToList();
            }
            if (allDepartments != null)
            {
                allDepartments = allDepartments.Where(s => s.EDITSTATE == "1").ToList();
                allDepartments = allDepartments.OrderBy(s => s.SORTINDEX).ToList();
            }

            List<T_HR_COMPANY> TopCompany = new List<T_HR_COMPANY>();

            foreach (T_HR_COMPANY tmpOrg in allCompanys)
            {
                //如果当前公司没有父机构的ID,则为顶级公司
                if (string.IsNullOrWhiteSpace(tmpOrg.FATHERID))
                {
                    TreeViewItem item = new TreeViewItem();
                    item.Header = tmpOrg.CNAME;
                    // item.Header = tmpOrg.BRIEFNAME;
                    item.HeaderTemplate = treeViewItemTemplate;
                    item.Style = Application.Current.Resources["TreeViewItemStyle"] as Style;

                    ExtOrgObj obj = new ExtOrgObj();
                    obj.ObjectInstance = tmpOrg;

                    item.DataContext = obj;

                    //标记为公司
                    item.Tag = OrgTreeItemTypes.Company;
                    treeOrganization.Items.Add(item);
                    TopCompany.Add(tmpOrg);
                }
                else
                {
                    //查询当前公司是否在公司集合内有父公司存在
                    var ent = from c in allCompanys
                              where c.COMPANYID == tmpOrg.FATHERID && tmpOrg.FATHERTYPE == "0"
                              select c;

                    var ent2 = from c in allDepartments
                               where tmpOrg.FATHERTYPE == "1" && tmpOrg.FATHERID == c.DEPARTMENTID
                               select c;

                    //如果不存在,则为顶级公司
                    if (ent.Count() == 0 && ent2.Count() == 0)
                    {
                        TreeViewItem item = new TreeViewItem();
                        item.Header = tmpOrg.CNAME;
                        //item.Header = tmpOrg.BRIEFNAME;
                        item.HeaderTemplate = treeViewItemTemplate; ;
                        item.Style = Application.Current.Resources["TreeViewItemStyle"] as Style;

                        ExtOrgObj obj = new ExtOrgObj();
                        obj.ObjectInstance = tmpOrg;

                        item.DataContext = obj;

                        //标记为公司
                        item.Tag = OrgTreeItemTypes.Company;
                        treeOrganization.Items.Add(item);

                        TopCompany.Add(tmpOrg);
                    }
                }
            }
            //开始递归
            foreach (var topComp in TopCompany)
            {
                TreeViewItem parentItem = GetParentItem(OrgTreeItemTypes.Company, topComp.COMPANYID);
                List<T_HR_COMPANY> lsCompany = (from ent in allCompanys
                                                where ent.FATHERTYPE == "0"
                                                && ent.FATHERID == topComp.COMPANYID
                                                select ent).ToList();
                List<T_HR_DEPARTMENT> lsDepartment = (from ent in allDepartments
                                                      where ent.FATHERID == topComp.COMPANYID && ent.FATHERTYPE == "0"
                                                      select ent).ToList();

                AddOrgNode(lsCompany, lsDepartment, parentItem);
            }
        }
Esempio n. 13
0
        /// <summary>
        /// 添加子节点
        /// </summary>
        /// <param name="lsCompany"></param>
        /// <param name="lsDepartment"></param>
        /// <param name="FatherNode"></param>
        private void AddOrgNode(List<T_HR_COMPANY> lsCompany, List<T_HR_DEPARTMENT> lsDepartment, TreeViewItem FatherNode)
        {
            //绑定公司的子公司
            foreach (var childCompany in lsCompany)
            {
                TreeViewItem item = new TreeViewItem();
                item.Header = childCompany.CNAME;
                //item.Header = childCompany.BRIEFNAME;
                item.HeaderTemplate = treeViewItemTemplate;
                item.Style = Application.Current.Resources["TreeViewItemStyle"] as Style;

                ExtOrgObj obj = new ExtOrgObj();
                obj.ObjectInstance = childCompany;

                item.DataContext = obj;

                //标记为公司
                item.Tag = OrgTreeItemTypes.Company;
                FatherNode.Items.Add(item);

                if (lsCompany.Count() > 0)
                {
                    List<T_HR_COMPANY> lsTempCom = (from ent in allCompanys
                                                    where ent.FATHERID == childCompany.COMPANYID && ent.FATHERTYPE == "0"
                                                    select ent).ToList();
                    List<T_HR_DEPARTMENT> lsTempDep = (from ent in allDepartments
                                                       where ent.FATHERID == childCompany.COMPANYID && ent.FATHERTYPE == "0"
                                                       select ent).ToList();

                    AddOrgNode(lsTempCom, lsTempDep, item);
                }
            }
            //绑定公司下的部门
            foreach (var childDepartment in lsDepartment)
            {
                TreeViewItem item = new TreeViewItem();
                item.Header = childDepartment.T_HR_DEPARTMENTDICTIONARY.DEPARTMENTNAME;
                item.HeaderTemplate = treeViewItemTemplate;
                item.Style = Application.Current.Resources["TreeViewItemStyle"] as Style;

                ExtOrgObj obj = new ExtOrgObj();
                obj.ObjectInstance = childDepartment;

                item.DataContext = obj;

                //标记为部门
                item.Tag = OrgTreeItemTypes.Department;
                FatherNode.Items.Add(item);

                if (lsDepartment.Count() > 0)
                {
                    List<T_HR_COMPANY> lsTempCom = (from ent in allCompanys
                                                    where ent.FATHERID == childDepartment.DEPARTMENTID && ent.FATHERTYPE == "1"
                                                    select ent).ToList();
                    List<T_HR_DEPARTMENT> lsTempDep = (from ent in allDepartments
                                                       where ent.FATHERID == childDepartment.DEPARTMENTID && ent.FATHERTYPE == "1"
                                                       select ent).ToList();

                    AddOrgNode(lsTempCom, lsTempDep, item);
                }
            }
        }
Esempio n. 14
0
        //private string parentName = "";
        //private void UnCheckChildCheckbox(TreeViewItem item, CheckBox selfCheckbox)
        //{

        //    foreach (TreeViewItem childItem in item.Items)
        //    {
        //        TreeViewItem myItem =
        //        (TreeViewItem)(item.ItemContainerGenerator.ContainerFromItem(childItem));
        //        CheckBox cbx = Helper.UIHelper.FindChildControl<CheckBox>(myItem);
        //        if (cbx == selfCheckbox)
        //        {
        //            UnCheckChildCheckbox(myItem, selfCheckbox);
        //        }
        //        else
        //        {

        //            //if (MultiSelected && parentName == GetParentName(myItem) && cbx.IsChecked==true)
        //            if (MultiSelected && !HaveChildItemChecked(myItem, selfCheckbox))
        //            {
        //                return;
        //            }
        //            if (cbx != null && cbx.IsChecked.GetValueOrDefault(false))
        //            {
        //                cbx.IsChecked = false;
        //            }
        //            UnCheckChildCheckbox(childItem, selfCheckbox);
        //        }
        //    }
        //}


        private bool IsSameParent(TreeViewItem item, CheckBox selfCheckbox)
        {
            if (item == null || item.Parent == null)
                return false;
            ExtOrgObj obj = new ExtOrgObj();
            TreeViewItem parentItem = new TreeViewItem();
            parentItem = item.Parent as TreeViewItem;
            obj = parentItem.DataContext as ExtOrgObj;
            //ExtOrgObj obj1 = new ExtOrgObj();
            //obj1= selfCheckbox.DataContext as ExtOrgObj;
            return obj.ObjectName == selfCheckbox.DataContext.ToString();
        }
Esempio n. 15
0
        //private void BindDepartment()
        //{
        //    allDepartments = Application.Current.Resources["SYS_DepartmentInfo"] as List<T_HR_DEPARTMENT>;
        //    if (allDepartments == null)
        //    {
        //        return;
        //    }

        //    if (allDepartments.Count() == 0)
        //    {
        //        return;
        //    }

        //    foreach (T_HR_DEPARTMENT tmpDep in allDepartments)
        //    {
        //        if (tmpDep.T_HR_COMPANY == null)
        //            continue;

        //        TreeViewItem parentItem = GetParentItem(OrgTreeItemTypes.Company, tmpDep.T_HR_COMPANY.COMPANYID);
        //        if (parentItem != null)
        //        {
        //            TreeViewItem item = new TreeViewItem();
        //            item.Style = Application.Current.Resources["TreeViewItemStyle"] as Style;
        //            item.Header = tmpDep.T_HR_DEPARTMENTDICTIONARY.DEPARTMENTNAME;

        //            ExtOrgObj obj = new ExtOrgObj();
        //            obj.ObjectInstance = tmpDep;
        //            item.DataContext = obj;

        //            //设置父级对像
        //            obj.ParentObject = parentItem.DataContext;
        //            item.HeaderTemplate = treeViewItemTemplate;
        //            //标记为部门
        //            item.Tag = OrgTreeItemTypes.Department;
        //            parentItem.Items.Add(item);
        //        }
        //    }
        //}

        private void BindPosition()
        {
            allPositions = Application.Current.Resources["SYS_PostInfo"] as List<T_HR_POST>;
            if (allPositions == null)
            {
                loadbar.Stop();
                return;
            }

            if (allPositions.Count() == 0)
            {
                loadbar.Stop();
                return;
            }


            foreach (T_HR_POST tmpPosition in allPositions)
            {
                if (tmpPosition.T_HR_DEPARTMENT == null || string.IsNullOrEmpty(tmpPosition.T_HR_DEPARTMENT.DEPARTMENTID))
                    continue;
                TreeViewItem parentItem = GetParentItem(OrgTreeItemTypes.Department, tmpPosition.T_HR_DEPARTMENT.DEPARTMENTID);
                if (parentItem != null)
                {
                    TreeViewItem item = new TreeViewItem();
                    item.Header = tmpPosition.T_HR_POSTDICTIONARY.POSTNAME;
                    item.Style = Application.Current.Resources["TreeViewItemStyle"] as Style;
                    ExtOrgObj obj = new ExtOrgObj();
                    obj.ObjectInstance = tmpPosition;
                    item.DataContext = obj;

                    //设置父级对像
                    obj.ParentObject = parentItem.DataContext;

                    // item.Style = this.Resources["CheckBoxTreeItemStyle"] as Style;
                    item.HeaderTemplate = treeViewItemTemplate;
                    //标记为岗位
                    item.Tag = OrgTreeItemTypes.Post;
                    parentItem.Items.Add(item);
                }
            }

            //树全部展开
            //  treeOrganization.ExpandAll();
            //if (treeOrganization.Items.Count > 0)
            //{
            //    TreeViewItem selectedItem = treeOrganization.Items[0] as TreeViewItem;
            //    selectedItem.IsSelected = true;
            //}
        }
Esempio n. 16
0
        /// <summary>
        /// 绑定组织架构节点
        /// </summary>
        private void BindCompany()
        {
            treeOrganization.Items.Clear();
            allCompanys = Application.Current.Resources["ORGTREESYSCompanyInfo" + Perm + Entity] as List <T_HR_COMPANY>;

            allDepartments = Application.Current.Resources["ORGTREESYSDepartmentInfo" + Perm + Entity] as List <T_HR_DEPARTMENT>;


            if (allCompanys == null)
            {
                loadbar.Stop();
                return;
            }
            else
            {
                allCompanys = allCompanys.Where(s => s.EDITSTATE == "1").ToList();
                allCompanys = allCompanys.OrderBy(s => s.SORTINDEX).ToList();
            }
            if (allDepartments != null)
            {
                allDepartments = allDepartments.Where(s => s.EDITSTATE == "1").ToList();
                allDepartments = allDepartments.OrderBy(s => s.SORTINDEX).ToList();
            }

            List <T_HR_COMPANY> TopCompany = new List <T_HR_COMPANY>();

            foreach (T_HR_COMPANY tmpOrg in allCompanys)
            {
                //如果当前公司没有父机构的ID,则为顶级公司
                if (string.IsNullOrWhiteSpace(tmpOrg.FATHERID))
                {
                    TreeViewItem item = new TreeViewItem();
                    item.Header = tmpOrg.CNAME;
                    // item.Header = tmpOrg.BRIEFNAME;
                    item.HeaderTemplate = treeViewItemTemplate;
                    item.Style          = Application.Current.Resources["TreeViewItemStyle"] as Style;

                    ExtOrgObj obj = new ExtOrgObj();
                    obj.ObjectInstance = tmpOrg;

                    item.DataContext = obj;

                    //标记为公司
                    item.Tag = OrgTreeItemTypes.Company;
                    treeOrganization.Items.Add(item);
                    TopCompany.Add(tmpOrg);
                }
                else
                {
                    //查询当前公司是否在公司集合内有父公司存在
                    var ent = from c in allCompanys
                              where c.COMPANYID == tmpOrg.FATHERID && tmpOrg.FATHERTYPE == "0"
                              select c;

                    var ent2 = from c in allDepartments
                               where tmpOrg.FATHERTYPE == "1" && tmpOrg.FATHERID == c.DEPARTMENTID
                               select c;

                    //如果不存在,则为顶级公司
                    if (ent.Count() == 0 && ent2.Count() == 0)
                    {
                        TreeViewItem item = new TreeViewItem();
                        item.Header = tmpOrg.CNAME;
                        //item.Header = tmpOrg.BRIEFNAME;
                        item.HeaderTemplate = treeViewItemTemplate;;
                        item.Style          = Application.Current.Resources["TreeViewItemStyle"] as Style;

                        ExtOrgObj obj = new ExtOrgObj();
                        obj.ObjectInstance = tmpOrg;

                        item.DataContext = obj;

                        //标记为公司
                        item.Tag = OrgTreeItemTypes.Company;
                        treeOrganization.Items.Add(item);

                        TopCompany.Add(tmpOrg);
                    }
                }
            }
            //开始递归
            foreach (var topComp in TopCompany)
            {
                TreeViewItem        parentItem = GetParentItem(OrgTreeItemTypes.Company, topComp.COMPANYID);
                List <T_HR_COMPANY> lsCompany  = (from ent in allCompanys
                                                  where ent.FATHERTYPE == "0" &&
                                                  ent.FATHERID == topComp.COMPANYID
                                                  select ent).ToList();
                List <T_HR_DEPARTMENT> lsDepartment = (from ent in allDepartments
                                                       where ent.FATHERID == topComp.COMPANYID && ent.FATHERTYPE == "0"
                                                       select ent).ToList();

                AddOrgNode(lsCompany, lsDepartment, parentItem);
            }
        }
Esempio n. 17
0
        void perclient_GetEmployeePostByPostIDCompleted(object sender, PersonnelWS.GetEmployeePostByPostIDCompletedEventArgs e)
        {
            try
            {
                List<PersonnelWS.T_HR_EMPLOYEEPOST> eplist = new List<PersonnelWS.T_HR_EMPLOYEEPOST>();
                if (e.Result != null)
                {
                    eplist = e.Result.ToList();
                }

                TreeViewItem parentItem = e.UserState as TreeViewItem;

                if (eplist == null || eplist.Count == 0 || parentItem == null)
                {
                    loadbar.Stop();
                    return;
                }
                parentItem.Items.Clear();

                string postID = string.Empty;
                foreach (PersonnelWS.T_HR_EMPLOYEEPOST ep in eplist)
                {
                    TreeViewItem subItem = new TreeViewItem();
                    subItem.Style = Application.Current.Resources["TreeViewItemStyle"] as Style;
                    subItem.Header = ep.T_HR_EMPLOYEE.EMPLOYEECNAME;

                    ExtOrgObj obj = new ExtOrgObj();
                    obj.ObjectInstance = ep.T_HR_EMPLOYEE;
                    subItem.DataContext = obj;

                    //设置父级对像
                    obj.ParentObject = parentItem.DataContext;
                    #region
                    ExtOrgObj post = (ExtOrgObj)obj.ParentObject;
                    string postName = post.ObjectName;
                    //  fromPostLevel=(post as SMT.Saas.Tools.OrganizationWS.T_HR_POST).POSTLEVEL.ToString();
                    if (string.IsNullOrEmpty(postID))
                    {
                        postID = post.ObjectID;
                    }
                    ExtOrgObj dept = (ExtOrgObj)post.ParentObject;
                    string deptName = dept.ObjectName;

                    // ExtOrgObj corp = (ExtOrgObj)dept.ParentObject;
                    SMT.Saas.Tools.OrganizationWS.T_HR_COMPANY corp = (dept.ObjectInstance as SMT.Saas.Tools.OrganizationWS.T_HR_DEPARTMENT).T_HR_COMPANY;
                    string corpName = corp.CNAME;
                    obj.ObjectName = ep.T_HR_EMPLOYEE.EMPLOYEECNAME + "-" + postName + "-" + deptName + "-" + corpName;
                    #endregion
                    //标记为岗位
                    subItem.Tag = OrgTreeItemTypes.Personnel;
                    subItem.HeaderTemplate = treeViewItemTemplate;
                    parentItem.Items.Add(subItem);
                }
                postIDsCach.Add(postID, "1");
            }
            catch (Exception ex)
            {

            }
            loadbar.Stop();
        }
Esempio n. 18
0
        /// <summary>
        /// 添加子节点
        /// </summary>
        /// <param name="lsCompany"></param>
        /// <param name="lsDepartment"></param>
        /// <param name="FatherNode"></param>
        private void AddOrgNode(List <T_HR_COMPANY> lsCompany, List <T_HR_DEPARTMENT> lsDepartment, TreeViewItem FatherNode)
        {
            //绑定公司的子公司
            foreach (var childCompany in lsCompany)
            {
                TreeViewItem item = new TreeViewItem();
                item.Header = childCompany.CNAME;
                //item.Header = childCompany.BRIEFNAME;
                item.HeaderTemplate = treeViewItemTemplate;
                item.Style          = Application.Current.Resources["TreeViewItemStyle"] as Style;

                ExtOrgObj obj = new ExtOrgObj();
                obj.ObjectInstance = childCompany;

                item.DataContext = obj;

                //标记为公司
                item.Tag = OrgTreeItemTypes.Company;
                FatherNode.Items.Add(item);

                if (lsCompany.Count() > 0)
                {
                    List <T_HR_COMPANY> lsTempCom = (from ent in allCompanys
                                                     where ent.FATHERID == childCompany.COMPANYID && ent.FATHERTYPE == "0"
                                                     select ent).ToList();
                    List <T_HR_DEPARTMENT> lsTempDep = (from ent in allDepartments
                                                        where ent.FATHERID == childCompany.COMPANYID && ent.FATHERTYPE == "0"
                                                        select ent).ToList();

                    AddOrgNode(lsTempCom, lsTempDep, item);
                }
            }
            //绑定公司下的部门
            foreach (var childDepartment in lsDepartment)
            {
                TreeViewItem item = new TreeViewItem();
                item.Header         = childDepartment.T_HR_DEPARTMENTDICTIONARY.DEPARTMENTNAME;
                item.HeaderTemplate = treeViewItemTemplate;
                item.Style          = Application.Current.Resources["TreeViewItemStyle"] as Style;

                ExtOrgObj obj = new ExtOrgObj();
                obj.ObjectInstance = childDepartment;

                item.DataContext = obj;

                //标记为部门
                item.Tag = OrgTreeItemTypes.Department;
                FatherNode.Items.Add(item);

                if (lsDepartment.Count() > 0)
                {
                    List <T_HR_COMPANY> lsTempCom = (from ent in allCompanys
                                                     where ent.FATHERID == childDepartment.DEPARTMENTID && ent.FATHERTYPE == "1"
                                                     select ent).ToList();
                    List <T_HR_DEPARTMENT> lsTempDep = (from ent in allDepartments
                                                        where ent.FATHERID == childDepartment.DEPARTMENTID && ent.FATHERTYPE == "1"
                                                        select ent).ToList();

                    AddOrgNode(lsTempCom, lsTempDep, item);
                }
            }
        }
Esempio n. 19
0
 private void BindEmployeeByTreeViewItem(TreeViewItem item)
 {
     if (item == null)
         return;
     ExtOrgObj tmp = new ExtOrgObj();
     tmp = item.DataContext as ExtOrgObj;
     if (tmp.ObjectType == OrgTreeItemTypes.Personnel)
     {
         foreach (var h in ((PersonnelWS.T_HR_EMPLOYEE)tmp.ObjectInstance).T_HR_EMPLOYEEPOST)
         {
             PersonnelWS.T_HR_POST tmpPost_P = new PersonnelWS.T_HR_POST();
             OrganizationWS.T_HR_POST tmpPost_O = new OrganizationWS.T_HR_POST();
             tmpPost_O = BindEmployeePost(item);
         }
     }
 }
Esempio n. 20
0
        /// <summary>
        /// 绑定组织架构节点
        /// </summary>
        private void BindCompany()
        {
            treeOrganization.Items.Clear();
            allCompanys = Application.Current.Resources["SYS_CompanyInfo"] as List<T_HR_COMPANY>;

            allDepartments = Application.Current.Resources["SYS_DepartmentInfo"] as List<T_HR_DEPARTMENT>;


            if (allCompanys == null)
            {
                loadbar.Stop();
                return;
            }
            else
            {
                allCompanys = allCompanys.Where(s => s.EDITSTATE == "1").ToList();
                allCompanys = allCompanys.OrderBy(s => s.SORTINDEX).ToList();
            }
            if (allDepartments != null)
            {
                allDepartments = allDepartments.Where(s => s.EDITSTATE == "1").ToList();
                allDepartments = allDepartments.OrderBy(s => s.SORTINDEX).ToList();
            }
            T_HR_COMPANY MOstTopCompany = GetFatherByDepartmentID(SMT.SAAS.Main.CurrentContext.Common.LoginUserInfo.UserPosts[0].DepartmentID);

            List<T_HR_COMPANY> TopCompany = new List<T_HR_COMPANY>();

            //foreach (T_HR_COMPANY tmpOrg in allCompanys)
            //{
            //    //如果当前公司没有父机构的ID,则为顶级公司
            //    if (string.IsNullOrWhiteSpace(tmpOrg.FATHERID))
            //    {
            TreeViewItem item = new TreeViewItem();
            //item.Header = tmpOrg.CNAME;
            item.Header = MOstTopCompany.BRIEFNAME;
            item.HeaderTemplate = treeViewItemTemplate;
            item.Style = Application.Current.Resources["TreeViewItemStyle"] as Style;

            ExtOrgObj obj = new ExtOrgObj();
            obj.ObjectInstance = MOstTopCompany;

            item.DataContext = obj;

            //标记为公司
            item.Tag = OrgTreeItemTypes.Company;
            treeOrganization.Items.Add(item);
            TopCompany.Add(MOstTopCompany);
            //    }
            //    else
            //    {
            //        //查询当前公司是否在公司集合内有父公司存在
            //        var ent = from c in allCompanys
            //                  where c.COMPANYID == tmpOrg.FATHERID && tmpOrg.FATHERTYPE == "0"
            //                  select c;

            //        var ent2 = from c in allDepartments
            //                   where tmpOrg.FATHERTYPE == "1" && tmpOrg.FATHERID == c.DEPARTMENTID
            //                   select c;

            //        //如果不存在,则为顶级公司
            //        if (ent.Count() == 0 && ent2.Count() == 0)
            //        {
            //            TreeViewItem item = new TreeViewItem();
            //            //item.Header = tmpOrg.CNAME;
            //            item.Header = tmpOrg.BRIEFNAME;
            //            item.HeaderTemplate = treeViewItemTemplate; ;
            //            item.Style = Application.Current.Resources["TreeViewItemStyle"] as Style;

            //            ExtOrgObj obj = new ExtOrgObj();
            //            obj.ObjectInstance = tmpOrg;

            //            item.DataContext = obj;

            //            //标记为公司
            //            item.Tag = OrgTreeItemTypes.Company;
            //            treeOrganization.Items.Add(item);

            //            TopCompany.Add(tmpOrg);
            //        }
            //    }
            //}
            //开始递归
            foreach (var topComp in TopCompany)
            {
                TreeViewItem parentItem = GetParentItem(OrgTreeItemTypes.Company, topComp.COMPANYID);
                List<T_HR_COMPANY> lsCompany = (from ent in allCompanys
                                                where ent.FATHERTYPE == "0"
                                                && ent.FATHERID == topComp.COMPANYID
                                                select ent).ToList();
                List<T_HR_DEPARTMENT> lsDepartment = (from ent in allDepartments
                                                      where ent.FATHERID == topComp.COMPANYID && ent.FATHERTYPE == "0"
                                                      select ent).ToList();

                AddOrgNode(lsCompany, lsDepartment, parentItem);
            }
        }