Пример #1
0
        /// <summary>
        /// 获取子机构
        /// </summary>
        /// <param name="code">机构代码</param>
        /// <param name="allSon">是否所有后裔</param>
        /// <returns>子栏目的集合</returns>
        public static List <SalaryNode> GetSubSalaryNodes(string code, bool allSon)
        {
            List <SalaryNode> list   = new List <SalaryNode>();
            SalaryNode        parent = GetSalaryNode(code);

            if (parent != null)
            {
                BinaryOperator bo = new BinaryOperator("上级", parent.标识, BinaryOperatorType.Equal);
                if (allSon)
                {
                    if (parent.代码 == "")
                    {
                        bo = new BinaryOperator("类型", 0, BinaryOperatorType.Greater);
                    }
                    else
                    {
                        bo = new BinaryOperator("代码", code + ".%", BinaryOperatorType.Like);
                    }
                }

                XPCollection objset = new XPCollection(MyHelper.XpoSession, typeof(SalaryNode), bo, new SortProperty("序号", SortingDirection.Ascending));

                foreach (SalaryNode SalaryNode in objset)
                {
                    list.Add(SalaryNode);
                }
            }
            return(list);
        }
Пример #2
0
        /// <summary>
        /// 查找最后一个孩子的代码
        /// </summary>
        /// <param name="code">代码</param>
        /// <returns>如果找到就返回 true, 否则返回 false</returns>
        public string GetLastChildSalaryNodeCode(string code)
        {
            SalaryNode parent = GetSalaryNode(code);

            if (parent != null)
            {
                List <SalaryNode> chidren = GetSubSalaryNodes(parent.标识);

                SalaryNodeCompareByCode comparer = new SalaryNodeCompareByCode();
                chidren.Sort(comparer);

                if (chidren.Count > 0)
                {
                    return(chidren[chidren.Count - 1].代码);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Пример #3
0
        /// <summary>
        /// 获取所有机构
        /// </summary>
        /// <returns></returns>
        public static List <SalaryNode> GetAll()
        {
            SalaryNode        root = GetSalaryNode("");
            List <SalaryNode> all  = GetSubSalaryNodes("", true);

            all.Insert(0, root);
            return(all);
        }
Пример #4
0
        /// <summary>
        /// 重新加载结构树
        /// </summary>
        public static void ReloadSalaryNodeTree()
        {
            SalaryNodeSet = null;
            SalaryNodeSet = SalaryNode.GetAll();
            foreach (SalaryNode org in SalaryNodeSet)
            {
                org.Resolve();
            }
            SalaryNodeCompareByCode comparer = new SalaryNodeCompareByCode();

            SalaryNodeSet.Sort(comparer);
        }
Пример #5
0
        //获取祖先
        private List <SalaryNode> GetForefathers()
        {
            List <SalaryNode> list   = new List <SalaryNode>();
            SalaryNode        parent = this.Parent;

            while (parent != null)
            {
                list.Insert(0, parent);
                parent = SalaryNode.GetSalaryNode(parent.级);
            }
            return(list);
        }
Пример #6
0
        protected override void OnSaving()
        {
            if (string.IsNullOrEmpty(this.称))
            {
                throw new Exception("名称不能为空。");
            }
            SalaryNode parent = GetSalaryNode(this.级);

            if (parent == null)
            {
                throw new Exception("指定的父节点不存在。");
            }
            else
            {
                //如果还没有分配位置标识
                if (string.IsNullOrEmpty(this.代码))
                {
                    this.代码  = GetNewCode(parent);
                    this.已启用 = false;
                    this.序号  = (parent.子节点.Count + 1).ToString(); //自动分配一个顺序号
                    this.类型  = parent.类型 + 1;
                    SalaryNode foundByCode = GetSalaryNode(this.代码);
                    if (foundByCode != null)
                    {
                        throw new Exception(String.Format("分配代码失败:系统中已存在同代码({0})的单元,请稍后再试。", this.代码));
                    }
                }
                else
                {
                    //如果移动目录
                    SalaryTreeNode cn = new SalaryTreeNode(this.代码);
                    if (cn.ParentNodePosition != parent.代码)
                    {
                        throw new Exception("节点的位置不能改变。");
                    }
                }
            }
            SalaryNode found = GetSalaryNode(this.级, this.称);

            if (found != null && found.标识 != this.标识)
            {
                throw new Exception("在同一个层中不能重复创建同名的节点单元。");
            }
            if (this.类型 == (int)节点类型.薪等)
            {
                if (this.Parent == null || this.Parent.代码 != "")
                {
                    throw new Exception("薪等类型的机构,只能从属于根节点。");
                }
            }
            base.OnSaving();
        }
Пример #7
0
 public static SalaryNode AddNew(SalaryNode parent, SalaryNode newSalaryNode)
 {
     if (newSalaryNode.标识 == 0)
     {
         if (parent == null || !parent.CheckExists())
         {
             throw new Exception("指定的父节点不存在。");
         }
         newSalaryNode.级 = parent.标识;
         newSalaryNode.Save();
     }
     return(newSalaryNode);
 }
Пример #8
0
        /// <summary>
        /// 获取一个新的编码
        /// </summary>
        /// <param name="parent">父节点</param>
        /// <returns></returns>
        private string GetNewCode(SalaryNode parent)
        {
            long   nextSeq    = 1;
            string parentcode = ""; //默认为根

            if (parent != null)
            {
                parentcode = parent.代码;
            }
            string last = GetLastChildSalaryNodeCode(parentcode); //父栏目的最后一个子栏目的位置

            if (last == null)                                     //如果父栏目下没有子栏目
            {
                nextSeq = 1;
                SalaryTreeNode cn = new SalaryTreeNode(parentcode, nextSeq);
                return(cn.Position);
            }
            else
            {
                SalaryTreeNode cn = new SalaryTreeNode(last);
                return(cn.NextSibling);
            }
        }
Пример #9
0
        /// <summary>
        /// 分解
        /// </summary>
        public void Resolve()
        {
            _薪等 = "";
            _薪级 = "";

            SalaryNode salaryNode = this;

            while (salaryNode != null)
            {
                switch (salaryNode.类型)
                {
                case (int)节点类型.薪等:
                    _薪等 = salaryNode.薪等;
                    ClearEmptyData(ref _薪等);
                    break;

                case (int)节点类型.薪级:
                    _薪级 = salaryNode.薪级;
                    ClearEmptyData(ref _薪级);
                    break;
                }
                salaryNode = 工资等级表.Find(org => org.标识 == salaryNode.级);
            }
        }
        public void Calculate()
        {
            decimal 标准职务工资, 个人职务工资;

            是标准职务工资 = true;
            满勤奖_显示  = "—";
            年休假_显示  = "—";
            津贴补助_显示 = "—";

            //获取薪酬信息
            GetPayInfo();

            //获取上表工资标准
            SalaryBaseInfo sbi = PsHelper.GetSalaryGrade(员工编号, 期间_开始);

            if (sbi != null)
            {
                表工资标准 = sbi.表工资标准;
                年休假工资 = sbi.年休假工资;
                满勤奖金额 = sbi.满勤奖金额;

                满勤奖_显示 = 满勤奖金额 > 0 ? 满勤奖金额.ToString("#0.##") : "—";
                年休假_显示 = 年休假工资 > 0 ? 年休假工资.ToString("#0.##") : "—";;
            }

            #region 计算职务工资

            StepPayRate        stepPayRate = null;
            List <StepPayRate> rates       = 标准职务工资表.FindAll(a => a.薪级标识 == 薪级_月初).OrderByDescending(a => a.执行日期).ToList();
            if (rates.Count > 0)
            {
                stepPayRate = rates[0];
                开始执行日期      = 开始执行日期_月初;
            }
            //月底职级
            List <StepPayRate> rates_月底 = 标准职务工资表.FindAll(a => a.薪级标识 == 薪级_月底).OrderByDescending(a => a.执行日期).ToList();
            if (rates.Count > 0)
            {
                StepPayRate stepPayRate_月底 = rates[0];
                //如果月底职级改变,去工资低的
                if (stepPayRate_月底.标识 != stepPayRate.标识)
                {
                    stepPayRate = stepPayRate.工资额 < stepPayRate_月底.工资额 ? stepPayRate : stepPayRate_月底;
                    开始执行日期      = 开始执行日期_月底;
                }
            }

            PersonPayRate        personPayRate = null;
            List <PersonPayRate> pRates        = 个人职务工资表.FindAll(a => a.生效日期 == 期间_开始 && a.员工编号 == this.员工编号).OrderByDescending(a => a.生效日期).ToList();
            if (isRealtime)
            {
                pRates = 个人职务工资表.FindAll(a => a.效 && a.员工编号 == this.员工编号).OrderByDescending(a => a.生效日期).ToList();
            }
            if (pRates.Count > 0)
            {
                personPayRate = pRates[0];
                开始执行日期        = personPayRate.生效日期;
                //津贴补助
                津贴补助    = personPayRate.津贴1金额 + personPayRate.津贴2金额;
                津贴补助_显示 = 津贴补助 > 0 ? 津贴补助.ToString("#0.##") : "—";
            }
            标准职务工资  = stepPayRate == null ? 0 : stepPayRate.工资额;
            个人职务工资  = personPayRate == null ? 0 : personPayRate.月薪;
            职务工资    = 个人职务工资 == 0 ? 标准职务工资 : 个人职务工资;
            是标准职务工资 = 个人职务工资 == 0;
            //2017-7-23 加上年休假工资
            职级工资 = 职务工资 + 年休假工资;

            //重新计算有效的薪等薪级
            工资职级 = " - ";
            if (stepPayRate != null && 是标准职务工资)
            {
                封闭薪等 = stepPayRate.薪等标识;
                封闭薪级 = stepPayRate.薪级标识;

                SalaryNode grade = SalaryNode.工资等级表.Find(a => a.标识 == 封闭薪等);
                if (grade != null)
                {
                    薪等 = grade.称;
                }

                grade = SalaryNode.工资等级表.Find(a => a.标识 == 封闭薪级);
                if (grade != null)
                {
                    薪级 = grade.称;
                }

                工资职级 = 薪等 + 薪级;
            }

            #endregion

            SalaryResult sr = SalaryResult.GetFromCache(员工编号, 年, 月);
            公司编码 = sr == null ? employeeInfo.公司 : sr.公司编号;
            职务等级 = sr == null ? employeeInfo.职务等级 : sr.职务等级;
            职级   = PsHelper.GetSupvsrLvDescr(职务等级);
        }
Пример #11
0
        /// <summary>
        /// 通过 Id 获取线路
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static SalaryNode GetSalaryNode(int id)
        {
            SalaryNode obj = (SalaryNode)MyHelper.XpoSession.GetObjectByKey(typeof(SalaryNode), id);

            return(obj);
        }
Пример #12
0
        public static string GetName(int id)
        {
            SalaryNode node = 工资等级表.Find(a => a.标识 == id);

            return(node == null ? "" : node.称);
        }