Exemple #1
0
 public bool UpdateDepartment(ViewDepartment department)
 {
     return(Function(context =>
     {
         return Update(Mapper.Map <Department>(department));
     }));
 }
Exemple #2
0
 public IEnumerable <ViewDepartment> GetDepartmentOrganization()
 {
     return(Function(context =>
     {
         var organizationData = Mapper.Map <IEnumerable <ViewDepartment> >(context.Departments.ToList());
         List <ViewDepartment> departmentOrganizations = new List <ViewDepartment>();
         foreach (var item in organizationData)
         {
             if (item.SuperiorDepartmentId == null)
             {
                 ViewDepartment departmentOrganization = new ViewDepartment()
                 {
                     Id = item.Id,
                     DepartmentName = item.DepartmentName,
                     DepartmentCode = item.DepartmentCode,
                     Number = item.Number,
                     IsDisable = item.IsDisable,
                     Remarks = item.Remarks,
                     PrincipalId = item.PrincipalId,
                     SuperiorDepartmentId = item.SuperiorDepartmentId,
                     Children = GetChildDepartmentOrganization(organizationData, item.Id)
                 };
                 departmentOrganizations.Add(departmentOrganization);
             }
         }
         return departmentOrganizations;
     }));
 }
        /// <summary>
        /// 根据部门ID获得部门对象
        /// </summary>
        /// <param name="iID"></param>
        /// <returns></returns>
        public static Department GetDepartment(int iID)
        {
            ViewBase vb = new ViewDepartment(true);

            vb.BaseCondition = "a.ID = " + iID.ToString();
            return(vb.Count > 0 ? vb.GetItem(0) as Department : null);
        }
Exemple #4
0
        /// <summary>
        /// 绑定子部门
        /// </summary>
        /// <param name="pid"></param>
        /// <param name="strCount"></param>
        /// <param name="seleceid"></param>
        private void BindChildDept1(string pid, string strCount, int seleceid)
        {
            strCount = "";
            ViewDepartment vbDepts = new ViewDepartment(true);

            vbDepts.BaseCondition = "a.ParentID=" + pid;
            foreach (Department dept in vbDepts.Ens)
            {
                int level = int.Parse(dept.FloorCode.ToString());
                while (level != 0)
                {
                    strCount += " ";
                    level--;
                }
                if (dept.ID == seleceid)
                {
                    this.m_strDeptHtml += "<option selected value='" + dept.ID.ToString() + "'>" + strCount + "├" + dept.Name + "</option>";
                }
                else
                {
                    this.m_strDeptHtml += "<option value='" + dept.ID.ToString() + "'>" + strCount + "├" + dept.Name + "</option>";
                }
                this.BindChildDept1(dept.ID.ToString(), strCount, seleceid);
                if (level == 0)
                {
                    strCount = "";
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// 用户所在部门的处室或科室
        /// </summary>
        /// <param name="iFloorCode"> >0:自己  >0:子部门层数, -1:所有</param>
        /// <returns></returns>
        public ViewBase GetChildOrParentDepts(int iFloorCode)
        {
            Department dpt      = new Department();
            string     strDepts = string.Empty;

            foreach (Department dept in this.Depts.Ens)
            {
                if (strDepts.Length > 0 && !strDepts.EndsWith(","))
                {
                    strDepts += ",";
                }
                strDepts += dpt.GetParentDeptID(dept);
            }
            strDepts = strDepts.Length > 0 && strDepts.EndsWith(",") ? strDepts.Substring(0, strDepts.Length - 1) : strDepts;
            ViewBase vwDept       = new ViewDepartment();
            string   strCondition = strDepts.Length > 0 ? "(a.ID IN (" + strDepts + ") OR a.ID IN(" + this.Depts.IDs + "))" : " a.ID IN(" + this.Depts.IDs + ")";

            if (iFloorCode == 0)
            {
                strCondition = " a.ID IN(" + this.Depts.IDs + ")";
            }
            else if (iFloorCode > 0)
            {
                strCondition += " AND a.FloorCode =" + iFloorCode.ToString();
            }
            vwDept.BaseCondition = strCondition;
            return(vwDept);
        }
        /// <summary>
        /// 根据部门名称获得部门对象
        /// </summary>
        /// <param name="strName"></param>
        /// <returns></returns>
        public static Department GetDepartment(string strName)
        {
            ViewDepartment vwDept = new ViewDepartment(true);

            vwDept.BaseCondition = " a.Name = '" + strName + "'";
            return(vwDept.Count > 0 ? vwDept.GetItem(0) as Department : null);
        }
        /// <summary>
        /// 根据部门的FloorCode获得子部门,包含自己
        /// </summary>
        /// <param name="strIDs">部门IDs,用,连接</param>
        /// <param name="iFloorCode"> >0 子部门层数, -1所有</param>
        /// <returns></returns>
        public static ViewBase GetChildDeptsConSelf(string strIDs, int iFloorCode)
        {
            ViewBase vbDepts = new ViewDepartment();

            string[]   strArray   = strIDs.Split(',');
            string     strDeptIDs = string.Empty;
            Department dept       = new Department();

            foreach (string str in strArray)
            {
                if (strDeptIDs.Length > 0 && !strDeptIDs.EndsWith(","))
                {
                    strDeptIDs += ",";
                }
                strDeptIDs += dept.GetChildDeptID(Convert.ToInt32(str), iFloorCode);
            }
            if (strDeptIDs.EndsWith(","))
            {
                strDeptIDs = strDeptIDs.Substring(0, strDeptIDs.Length - 1);
            }
            string strSubDptIDs = strDeptIDs;

            vbDepts.BaseCondition = strSubDptIDs.Length > 0 ? "(a.ID IN (" + strSubDptIDs + ") OR a.ID IN (" + strIDs + "))" : " a.ID IN (" + strIDs + ") ";
            return(vbDepts);
        }
        /// <summary>
        /// 根据部门的FloorCode获得子部门,包含自己
        /// </summary>
        /// <param name="iFloorCode"> >0 子部门层数, -1所有</param>
        /// <returns></returns>
        public ViewBase GetChildDeptsConSelf(int iFloorCode)
        {
            ViewBase vbDepts      = new ViewDepartment();
            string   strSubDptIDs = this.GetChildDeptID(base.ID, iFloorCode);

            vbDepts.BaseCondition = strSubDptIDs.Length > 0 ? "(a.ID IN (" + strSubDptIDs + ") OR a.ID = " + base.ID.ToString() + ")" : " 1<>1 ";
            return(vbDepts);
        }
        /// <summary>
        /// 根据层号得到部门
        /// </summary>
        /// <param name="iFloorCode"> ">0"根据层返回部门 "-1"返回所有部门</param>
        /// <returns></returns>
        public static ViewBase GetDeptsByFCode(int iFloorCode)
        {
            ViewBase vbDepts = new ViewDepartment();

            if (iFloorCode >= 0)
            {
                vbDepts.BaseCondition = "a.FloorCode=" + iFloorCode.ToString();
            }
            return(vbDepts);
        }
Exemple #10
0
        /// <summary>
        /// 绑定部门
        /// </summary>
        public string BindDept1()
        {
            string         strCount = "";
            ViewDepartment vbDepts  = new ViewDepartment(true);

            vbDepts.BaseCondition = "a.ParentID=0";
            this.m_strDeptHtml    = "<option value='-1'>├选择部门</option>";
            foreach (Department dept in vbDepts.Ens)
            {
                strCount            = "";
                this.m_strDeptHtml += "<option value='" + dept.ID.ToString() + "'>" + "├" + dept.Name + "</option>";
                this.BindChildDept1(dept.ID.ToString(), strCount);
            }
            return(m_strDeptHtml);
        }
Exemple #11
0
        /// <summary>
        /// 当前用户所在部门的所有字部门
        /// </summary>
        /// <returns></returns>
        public ViewBase GetChildDeptConSelf()
        {
            Department dpt      = new Department();
            string     strDepts = string.Empty;

            foreach (Department dept in this.Depts.Ens)
            {
                if (strDepts.Length > 0 && !strDepts.EndsWith(","))
                {
                    strDepts += ",";
                }
                strDepts += dpt.GetChildDeptID(dept.ID, -1);
            }
            strDepts = strDepts.Length > 0 && strDepts.EndsWith(",") ? strDepts.Substring(0, strDepts.Length - 1) : strDepts;
            ViewBase vwDept = new ViewDepartment();

            vwDept.BaseCondition = strDepts.Length > 0 ? "(a.ID IN (" + strDepts + ") OR a.ID IN(" + this.Depts.IDs + "))" : " a.ID IN(" + this.Depts.IDs + ")";
            return(vwDept);
        }
Exemple #12
0
        private List <ViewDepartment> GetChildDepartmentOrganization(IEnumerable <ViewDepartment> viewDepartments, int superiorDepartmentId)
        {
            List <ViewDepartment> departmentOrganizations = new List <ViewDepartment>();

            foreach (var item in viewDepartments.Where(x => x.SuperiorDepartmentId == superiorDepartmentId))
            {
                ViewDepartment departmentOrganization = new ViewDepartment()
                {
                    Id                   = item.Id,
                    DepartmentName       = item.DepartmentName,
                    DepartmentCode       = item.DepartmentCode,
                    Number               = item.Number,
                    IsDisable            = item.IsDisable,
                    Remarks              = item.Remarks,
                    PrincipalId          = item.PrincipalId,
                    SuperiorDepartmentId = item.SuperiorDepartmentId,
                    Children             = GetChildDepartmentOrganization(viewDepartments, item.Id)
                };
                departmentOrganizations.Add(departmentOrganization);
            }
            return(departmentOrganizations);
        }
Exemple #13
0
 public IActionResult GetUpdateDepartment(ViewDepartment department)
 {
     return(Ok(_departmentService.UpdateDepartment(department)));
 }
Exemple #14
0
 public IActionResult GetAddDepartment(ViewDepartment department)
 {
     return(Ok(_departmentService.AddDepartment(department)));
 }