示例#1
0
        /// <summary>
        ///  删除节点
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int DeleteNode(T_OrgFolder model, int id)
        {
            if (id <= 0 || model == null)
            {
                return(0);
            }
            //删除前查询当前组织机构下是否有人员
            var query = DBSession.IBane_UserDAL.Select(s => s.org_id == id);

            if (query != null && query.Count > 0)
            {
                return(2);//2表示当前组织机构下还有人员数据
            }
            //查询其他同辈节点
            var count = Select(s => s.folder_pid == model.folder_pid && s.folder_id != id);
            int mark  = Delete(s => s.folder_id == id);

            if (mark > 0 && (count == null || count.Count == 0))
            {
                //没有同辈节点
                Modify(new T_OrgFolder {
                    have_child = false
                }, s => s.folder_id == model.folder_pid, "have_child");
            }
            if (mark > 0)
            {
                DBSession.IT_OrgUserRelationDAL.Delete(s => s.folder_id == id);
            }
            return(mark);
        }
示例#2
0
        /// <summary>
        ///  添加节点
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int AddNode(OrgTreeModel model)
        {
            if (null == model)
            {
                return(0);
            }
            T_OrgFolder folder = new T_OrgFolder
            {
                folder_name = model.name,
                folder_pid  = model.pId,
                create_id   = HCQ2UI_Helper.OperateContext.Current.Usr.user_id,
                create_name = HCQ2UI_Helper.OperateContext.Current.Usr.user_name,
                create_time = DateTime.Now,
                have_child  = false
            };

            Add(folder);
            if (folder.folder_pid > 0)
            {
                Modify(new T_OrgFolder {
                    have_child = true
                }, s => s.folder_id == folder.folder_pid, "have_child");
            }
            return(folder.folder_id);
        }
示例#3
0
        /// <summary>
        ///  编辑节点
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int EditNode(OrgTreeModel model)
        {
            if (model == null)
            {
                return(0);
            }
            T_OrgFolder folder = new T_OrgFolder
            {
                folder_id   = model.id,
                folder_name = model.name
            };

            return(Modify(folder, s => s.folder_id == folder.folder_id, "folder_name"));
        }
示例#4
0
        /// <summary>
        ///  删除节点
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int DeleteNode(T_OrgFolder model, int id)
        {
            if (id <= 0 || model == null)
            {
                return(0);
            }
            var count = Select(s => s.folder_pid == model.folder_pid && s.folder_id != id);
            int mark  = Delete(s => s.folder_id == id);

            if (mark > 0 && (count == null || count.Count == 0))
            {
                Modify(new T_OrgFolder {
                    have_child = false
                }, s => s.folder_id == model.folder_pid, "have_child");
            }
            if (mark > 0)
            {
                DBSession.IT_OrgUserRelationDAL.Delete(s => s.folder_id == id);
            }
            return(mark);
        }