Ejemplo n.º 1
0
        public StringBuilder GetDeptTreeStr(int flag, string type, string clickFunction)
        {
            string prefix = "";

            if (type == "checkbox")
            {
                prefix = "<input type='checkbox' class='fll' id='{0}' value='{4}' />";
            }
            else if (type == "radio")
            {
                prefix = "<input type='radio' class='fll' id='{0}' value='{4}' name='prd'/>";
            }
            var treeStr = new StringBuilder();

            if (flag == 0)
            {
                treeStr.AppendFormat(
                    "<ul id=\"navigation\" class=\"treeview w700\"><li id=\"0\"><span title='{2}' id='{1}' class=\"rootNote\">{2}</span><ul>",
                    0, "0_-1", CommonLanguage.ParentDept, "", "0_-1_" + CommonLanguage.ParentDept);
            }
            else
            {
                treeStr.AppendLine("<ul id=\"navigation\" class=\"treeview w700\">");
            }
            GetDeptTreeChild(AllDepartments.FindAll(p => p.ParentDeptId == 0), treeStr, clickFunction, prefix);
            if (flag == 0)
            {
                treeStr.AppendLine("</ul></li></ul>");
            }
            else
            {
                treeStr.AppendLine("</ul>");
            }
            return(treeStr);
        }
Ejemplo n.º 2
0
 private void GetDeptTreeChild(List <Sys_Department> deptList, StringBuilder html,
                               string clickFunction = "deptNodeClick(this)", string prefix = "")
 {
     if (deptList.Count > 0)
     {
         foreach (Sys_Department v in deptList)
         {
             //string dept = v.DeptCode + "[" + v.DeptName + "]";
             string dept = v.DeptName;
             html.AppendFormat(
                 "<li class='pNote'>" + prefix +
                 "<a title='{2}' style='cursor:pointer;' id='{1}' {3} >{2}</a>", v.DepartmentId,
                 v.DepartmentId + "_" + v.ParentDeptId, dept,
                 (string.IsNullOrWhiteSpace(clickFunction) ? "" : "onclick=\"" + clickFunction + "\""),
                 v.DepartmentId + "_" + v.ParentDeptId + "_" + dept);
             if (AllDepartments.Exists(p => p.ParentDeptId == v.DepartmentId))
             {
                 html.AppendLine("<ul>");
                 GetDeptTreeChild(AllDepartments.FindAll(p => p.ParentDeptId == v.DepartmentId), html,
                                  clickFunction, prefix);
                 html.AppendLine("</ul>");
             }
             html.AppendLine("</li>");
         }
     }
 }
Ejemplo n.º 3
0
        private void AddDepartmentExecute(object parameter)
        {
            var editDepartmentViewModel = new EditDepartmentViewModel(m_unitOfWorkFactory);
            var editView = new View.EditDepartmentView
            {
                DataContext = editDepartmentViewModel
            };

            // This seems nuts - we are inspecting the view model
            bool?result = editView.ShowDialog();

            if (result.HasValue && result.Value)
            {
                // Update model
                Department newDepartment = new Department
                {
                    Name = editDepartmentViewModel.Name
                };
                using (IUnitOfWork unitOfWork = m_unitOfWorkFactory.Create())
                {
                    unitOfWork.Departments.Add(newDepartment);
                    unitOfWork.Complete();
                }

                // Update view model
                var newViewModel = new DepartmentViewModel(m_unitOfWorkFactory, newDepartment.DepartmentId, newDepartment.Name);
                AllDepartments.Add(newViewModel);
                SelectedDepartment = newViewModel;
            }
        }
Ejemplo n.º 4
0
        public ActionResult DeptEdit(int id = 0, int parentId = 0)
        {
            string         childs = "";
            Sys_Department model  = AllDepartments.Find(p => p.DepartmentId == id);

            if (model == null)
            {
                model = new Sys_Department
                {
                    DepartmentId = id,
                    ParentDeptId = parentId,
                    DeptCode     = "",
                    DeptName     = "",
                    Remark       = ""
                }
            }
            ;
            else
            {
                var list = new List <int>();
                GetChildDeptIds(model.DepartmentId, list);
                childs = list.Aggregate("", (current, deptId) => current + (deptId + ","));
            }
            if (model.ParentDeptId == 0)
            {
                model.parentDeptName = CommonLanguage.ParentDept;
            }
            else
            {
                model.parentDeptName = AllDepartments.Find(p => p.DepartmentId == model.ParentDeptId).DeptNameShow;
            }
            ViewBag.model  = model;
            ViewBag.childs = childs;
            return(View());
        }
Ejemplo n.º 5
0
 private void GetChildDeptIds(int parentId, List <int> list)
 {
     foreach (Sys_Department dept in AllDepartments.Where(p => p.ParentDeptId == parentId))
     {
         list.Add(dept.DepartmentId);
         GetChildDeptIds(dept.DepartmentId, list);
     }
 }
Ejemplo n.º 6
0
        private void AddEmployeeExecute(object parameter)
        {
            var newEmployee = new EmployeeViewModel(m_unitOfWorkFactory, AllDepartments.First());

            AllEmployees.Add(newEmployee);

            SelectedEmployee = newEmployee;
        }
Ejemplo n.º 7
0
 private void GetParentDeptId(int deptId, List <int> list)
 {
     if (deptId > 0)
     {
         list.Add(deptId);
         var dept = AllDepartments.Find(p => p.DepartmentId == deptId);
         GetParentDeptId(dept.ParentDeptId, list);
     }
 }
Ejemplo n.º 8
0
        public StringBuilder GetDeptTreeSearchStr(int flag, string type, string clickFunction, string name)
        {
            var treeStr = new StringBuilder();

            if (string.IsNullOrWhiteSpace(name))
            {
                searchDeptIds     = AllDepartments.Select(p => p.DepartmentId).ToList();
                SearchDepartments = AllDepartments;
            }
            else
            {
                searchDeptIds = AllDepartments.Where(p => p.DeptName.Contains(name)).Select(p => p.DepartmentId).ToList();
                List <int> listIds = new List <int>();
                for (int i = 0; i < searchDeptIds.Count; i++)
                {
                    GetParentDeptId(searchDeptIds[i], listIds);
                }
                if (listIds.Count == 0)
                {
                    return(treeStr);
                }
                SearchDepartments = AllDepartments.Where(p => listIds.Contains(p.DepartmentId)).ToList();
            }

            string prefix = "";

            if (type == "checkbox")
            {
                prefix = "<input type='checkbox' class='fll'  id='{0}' value='{4}' />";
            }
            else if (type == "radio")
            {
                prefix = "<input type='radio' class='fll' id='{0}' value='{4}' name='prd'/>";
            }

            if (flag == 0)
            {
                treeStr.AppendFormat(
                    "<ul id=\"navigation\" class=\"treeview w700\"><li id=\"0\"><span title='{2}' id='{1}' class=\"rootNote\">{2}</span><ul>",
                    0, "0_-1", CommonLanguage.ParentDept, "", "0_-1_" + CommonLanguage.ParentDept);
            }
            else
            {
                treeStr.AppendLine("<ul id=\"navigation\" class=\"treeview w700\">");
            }
            GetDeptTreeSearchChild(SearchDepartments.FindAll(p => p.ParentDeptId == 0), treeStr, clickFunction, prefix);
            if (flag == 0)
            {
                treeStr.AppendLine("</ul></li></ul>");
            }
            else
            {
                treeStr.AppendLine("</ul>");
            }
            return(treeStr);
        }
Ejemplo n.º 9
0
 private void ExcecuteDeleteDepartments()
 {
     AllDepartments = _depoRepo.GetAllDepartments();
     foreach (var goal in Goals)
     {
         goal.RelatedDepartments.RemoveAll(x => x == SelectedGoal.Id);
     }
     AllDepartments.Single(x => x.Id == SelectedDepartment.Id).Deleted = true;
     _depoRepo.SaveDepartments(AllDepartments);
     AllDepartments = _depoRepo.GetAllDepartments();
     UpdateCanvas();
 }
Ejemplo n.º 10
0
 private void DeleteDeptChild(int deptId)
 {
     deptBL.Delete(deptId);
     AllDepartments.Remove(AllDepartments.Find(p => p.DepartmentId == deptId));
     if (AllDepartments.FindAll(p => p.ParentDeptId == deptId).Count > 0)
     {
         foreach (Sys_Department item in AllDepartments.FindAll(p => p.ParentDeptId == deptId))
         {
             DeleteDeptChild(item.DepartmentId);
         }
     }
 }
Ejemplo n.º 11
0
        private void DeleteDepartmentExecute(object parameter)
        {
            // update model
            using (IUnitOfWork unitOfWork = m_unitOfWorkFactory.Create()) {
                Department storedDepartment = unitOfWork.Departments.Get(SelectedDepartment.DepartmentId);
                unitOfWork.Departments.Remove(storedDepartment);
                unitOfWork.Complete();
            }

            // update viewmodel
            AllDepartments.Remove(SelectedDepartment);
            SelectedDepartment = null;
        }
Ejemplo n.º 12
0
        private void ExcecuteAddNewDepartment()
        {
            var department = new Department();

            department.Id      = _idService.GetFreeId(AllDepartments);
            department.Deleted = false;
            department.Name    = NewDepartmentName;
            NewDepartmentName  = "";
            AllDepartments.Add(department);
            _depoRepo.SaveDepartments(AllDepartments);
            UpdateDepartments();
            UpdateCanvas();
        }
Ejemplo n.º 13
0
        public static IList <T> Find <T>(Func <T, bool> filter) where T : class
        {
            if (typeof(T) == typeof(Department))
            {
                return(AllDepartments.Where(department => filter(department as T)).ToList() as IList <T>);
            }
            if (typeof(T) == typeof(Employee))
            {
                return(AllEmployees.Where(empl => filter(empl as T)).ToList() as IList <T>);
            }

            throw new NotSupportedException("Type not supported");
        }
Ejemplo n.º 14
0
        public JsonResult SaveDept(int deptId, string deptCode, string deptName, string deptDesc, int parentId)
        {
            try
            {
                if (deptBL.Exists(deptCode, deptName, deptId))
                {
                    return(Json(new { result = 0, content = "部门代码或部门名称重复!" }, JsonRequestBehavior.AllowGet));
                }

                Sys_Department model = AllDepartments.Find(p => p.DepartmentId == deptId);
                if (model == null)
                {
                    model = new Sys_Department();
                }
                model.DepartmentId = deptId;
                model.DeptCode     = deptCode;
                model.DeptName     = deptName;
                model.Remark       = deptDesc;
                model.ParentDeptId = parentId;

                if (model.DepartmentId == 0)
                {
                    deptBL.Add(model);
                    AllDepartments.Add(model);
                }
                else
                {
                    deptBL.Update(model);
                }
                lock (lockobj)
                {
                    RefreshDepartmentCache();
                }
                return(Json(new { result = 1, content = "保存成功" }, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(Json(new { result = 0, content = "保存失败" }, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 15
0
        private void UpdateAllRelatedDepartment()
        {
            RelatedDepartment = new List <Department>();
            Departments       = new List <Department>();

            if (SelectedGoal != null)
            {
                //if (SelectedGoal.GoalType == GoalType.ShortTerm)
                //{
                Departments = _depoRepo.GetAllDepartments();
                var tempDeps = new List <Department>();
                SelectedGoal.RelatedDepartments.ForEach(x => tempDeps.Add(AllDepartments.First(y => y.Id == x)));
                RelatedDepartment = tempDeps;
                SelectedGoal.RelatedDepartments.ForEach(x => Departments.RemoveAll(y => y.Id == x));
                //foreach (var departmentId in SelectedGoal.RelatedDepartments)
                //{
                //    RelatedDepartment.Add(AllDepartments.Single(x => x.Id == departmentId));
                //    Departments.RemoveAll(x => x.Id == departmentId);
                //}
                //}
            }
            UpdateCanvas();
        }
Ejemplo n.º 16
0
    private void SetAvailableDataForDepartments()
    {
        GetDepartments();
        if (IncludedDepartments == null)
        {
            IncludedDepartments = new List <PHNode>();
        }
        AvailableFilteredDepartments = AllDepartments.Where(d => !IncludedDepartments.Any(inc => inc.NodeID == d.NodeID)).ToList();
        lstDeptSelected.DataSource   = IncludedDepartments;
        lstDeptSelected.DataBind();

        foreach (ListItem item in lstDeptSelected.Items)
        {
            item.Attributes["title"] = item.Text;
        }

        lstDeptAvailable.DataSource = AvailableFilteredDepartments;
        lstDeptAvailable.DataBind();
        foreach (ListItem item in lstDeptAvailable.Items)
        {
            item.Attributes["title"] = item.Text;
        }
        //SetHeightForListbox();
    }
Ejemplo n.º 17
0
        private void InsertUserList(List <Sys_User> listUser, ref string userTempID, ref string chongfu)
        {
            List <Sys_User> listUserSql = userBL.GetList(" Sys_User.IsDelete = 0 ");

            foreach (Sys_User item in listUser)
            {
                try
                {
                    Sys_User model = listUserSql.Find(p => p.JobNum == item.JobNum);
                    if (model != null)
                    {
                        #region 系统已存在用户,做修改操作    但是被无知的人说,这个不需要;那这个就被邪恶的我干掉了。。。不要怪我哦

                        //model.Realname = item.Realname;
                        //model.Sex = item.Sex;
                        //model.Birthday = item.Birthday;
                        //model.Email = item.Email;
                        //model.Telephone = item.Telephone;
                        //model.Fax = item.Fax;
                        //model.JobTitle = item.JobTitle;
                        //model.Ename = item.Ename;

                        //Sys_Department dep = AllDepartments.Find(p => p.DeptCode == item.DeptCode);
                        //if (dep != null)
                        //{
                        //    item.DeptCode = dep.DeptCode;
                        //    item.DeptName = dep.DeptName;
                        //    item.DeptId = dep.DepartmentId;
                        //}
                        //else
                        //{
                        //    item.DeptCode = "";
                        //    item.DeptName = "";
                        //    item.DeptId = -1;
                        //}

                        //Sys_Post post = AllPosts.Find(p => p.PostCode == item.PostCode);
                        //if (post != null)
                        //{
                        //    item.PostCode = post.PostCode;
                        //    item.PostName = post.PostName;
                        //    item.PostLevel = post.PostLevel;
                        //    item.PostId = post.PostId;
                        //}
                        //else
                        //{
                        //    item.PostLevel = null;
                        //    item.PostName = "";
                        //    item.PostCode = "";
                        //    item.PostId = -1;
                        //}

                        //model.Status = item.Status;
                        //model.FreezeTime = null;

                        //userBL.Update(model);

                        #endregion

                        if (chongfu != "")
                        {
                            chongfu = chongfu + "," + item.Username;
                        }
                        else
                        {
                            chongfu = item.Username;
                        }
                    }
                    else
                    {
                        if (item.Status < 2)
                        {
                            Sys_Department dep = AllDepartments.Find(p => p.DeptCode == item.DeptCode);
                            if (dep != null)
                            {
                                item.DeptCode = dep.DeptCode;
                                item.DeptName = dep.DeptName;
                                item.DeptId   = dep.DepartmentId;
                            }
                            else
                            {
                                item.DeptCode = "";
                                item.DeptName = "";
                                item.DeptId   = -1;
                            }

                            Sys_Post post = AllPosts.Find(p => p.PostCode == item.PostCode);
                            if (post != null)
                            {
                                item.PostCode = post.PostCode;
                                item.PostName = post.PostName;
                                //item.PostLevel = post.PostLevel;
                                item.PostId = post.PostId;
                            }
                            else
                            {
                                item.PostLevel = null;
                                item.PostName  = "";
                                item.PostCode  = "";
                                item.PostId    = -1;
                            }

                            userBL.Add(item);
                        }
                    }
                }
                catch
                {
                    if (userTempID != "")
                    {
                        userTempID = userTempID + "," + item.Username;
                    }
                    else
                    {
                        userTempID = item.Username;
                    }
                }
            }
        }
Ejemplo n.º 18
0
        public JsonResult SaveUser(int userId, string jobNum, string realName, string email, int sex, int deptId,
                                   string deptName, int postId, string postName)
        {
            try
            {
                if (userBL.Exists(jobNum.ReplaceSingleSql(), jobNum.ReplaceSingleSql(), userId))
                {
                    return(Json(new
                    {
                        result = 0,
                        content = "工号重复!"
                    }, JsonRequestBehavior.AllowGet));
                }
                var model = new Sys_User();
                if (userId != 0)
                {
                    model = userBL.Get(userId);
                }
                model.JobNum   = jobNum;
                model.Username = jobNum;
                model.Password = BaseEncode.GetMd5Str("123456");
                model.Realname = realName;
                model.Ename    = realName;
                model.Email    = email;
                model.Sex      = sex;
                model.PostId   = -1;
                model.DeptId   = -1;
                var postTemp = AllPosts.Find(p => p.PostId == postId);
                if (postTemp != null)
                {
                    model.PostId   = postId;
                    model.PostCode = postTemp.PostCode;
                    model.PostName = postTemp.PostName;
                    //model.PostLevel = postTemp.PostLevel;
                }
                var deptTemp = AllDepartments.Find(p => p.DepartmentId == deptId);
                if (deptTemp != null)
                {
                    model.DeptId   = deptId;
                    model.DeptCode = deptTemp.DeptCode;
                    model.DeptName = deptTemp.DeptName;
                }
                if (userId == 0)
                {
                    userBL.Add(model);
                }
                else
                {
                    userBL.Update(model);
                }

                return(Json(new
                {
                    result = 1,
                    content = "保存成功!"
                }, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(Json(new
                {
                    result = 0,
                    content = "保存失败!"
                }, JsonRequestBehavior.AllowGet));
            }
        }