private void btn撤销_Click(object sender, EventArgs e)
        {
            if (currNode != null)
            {
                if (MessageBox.Show("确实要撤销当前节点吗?", "撤销提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, 0, false) == DialogResult.Yes)
                {
                    SalaryNode salaryNode = treeList1.GetDataRecordByNode(currNode) as SalaryNode;
                    if (salaryNode != null)
                    {
                        if (salaryNode.代码 == "")
                        {
                            MessageBox.Show("撤销失败:不能撤销根节点!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2, 0, false);
                        }
                        else
                        {
                            salaryNode.已撤销 = true;
                            salaryNode.Save();

                            foreach (SalaryNode child in salaryNode.子节点)
                            {
                                child.已撤销 = true;
                                child.Save();
                            }

                            MessageBox.Show("撤销成功!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2, 0, false);
                        }
                    }
                }
            }
        }
        private void btn重新启用_Click(object sender, EventArgs e)
        {
            if (currNode != null)
            {
                SalaryNode salaryNode = treeList1.GetDataRecordByNode(currNode) as SalaryNode;
                if (salaryNode != null)
                {
                    salaryNode.已撤销 = false;
                    salaryNode.Save();

                    if (salaryNode.类型 == (int)节点类型.薪级)
                    {
                        SalaryNode parent = salaryNode.父节点;
                        if (parent != null)
                        {
                            parent.已撤销 = false;
                            parent.Save();
                        }
                    }

                    if (salaryNode.类型 == (int)节点类型.薪等)
                    {
                        foreach (SalaryNode child in salaryNode.子节点)
                        {
                            child.已撤销 = false;
                            child.Save();
                        }
                    }

                    MessageBox.Show("启用成功!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2, 0, false);
                }
            }
        }
        private void treeList1_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        {
            currNode = e.Node;
            SalaryNode salaryNode = treeList1.GetDataRecordByNode(currNode) as SalaryNode;

            treeList1.OptionsBehavior.Editable = salaryNode != null && salaryNode.代码 != "";
        }
        private void PrivateSalaryTreeView_Load(object sender, EventArgs e)
        {
            nodes = SalaryNode.GetAll().FindAll(a => a.已撤销 == false);

            treeList1.DataSource = nodes;
            treeList1.ExpandAll();
        }
Example #5
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            //清除原来的数据
            currRows.Clear();
            currSalaryGrade = null;
            if (e.Node.Tag != null)
            {
                currSalaryGrade = e.Node.Tag as SalaryNode;

                if (AccessController.CheckGrade(currSalaryGrade.标识))
                {
                    //创建当前薪等下的所有薪级的录入记录
                    currRows = StepPayRate.GetAll().FindAll(a => a.薪等标识 == currSalaryGrade.标识);
                    if (currRows.Count > 0)
                    {
                        StepPayRate step = currRows[0];
                        lbl设定时间.Text = step.设定时间.ToString("yyyy/M/d");
                        lbl执行时间.Text = step.执行日期.ToString("yyyy/M/d");
                    }
                }
                else
                {
                    MessageBox.Show("你没有权限浏览该薪等的职级工资标准。");
                }
            }
            gridControl1.DataSource = currRows;
            gridControl1.RefreshDataSource();
        }
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            //清除原来的数据
            currInputRows.Clear();
            btn确定.Enabled   = false;
            currSalaryGrade = null;
            if (e.Node.Tag != null)
            {
                currSalaryGrade = e.Node.Tag as SalaryNode;

                if (AccessController.CheckGrade(currSalaryGrade.标识))
                {
                    btn确定.Enabled = true;
                    //创建当前薪等下的所有薪级的录入记录
                    foreach (SalaryNode step in currSalaryGrade.子节点)
                    {
                        if (step.已撤销)
                        {
                            continue;
                        }

                        PayRateInput pInput = PayRateInput.GetEditing(step.标识, this.是验证录入);
                        //如果没有初次录入
                        if (pInput == null)
                        {
                            pInput = new PayRateInput();

                            pInput.执行日期   = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
                            pInput.薪等标识   = currSalaryGrade.标识;
                            pInput.薪级标识   = step.标识;
                            pInput.是验证录入  = this.是验证录入;
                            pInput.双人录入结果 = "";
                            //找验证录入
                            PayRateInput pInputOther = PayRateInput.GetEditing(step.标识, !this.是验证录入);
                            if (pInputOther != null)
                            {
                                pInput.编号 = pInputOther.编号;
                            }
                            pInput.Save();
                        }
                        currInputRows.Add(pInput);
                        dateEdit1.DateTime = pInput.执行日期;
                    }
                }
                else
                {
                    MessageBox.Show("你没有权限设置该薪等的职级工资。");
                }
            }
            gridControl1.DataSource = currInputRows;
            gridControl1.RefreshDataSource();
        }
Example #7
0
        private void PayRateInput_Load(object sender, EventArgs e)
        {
            this.Text = "职级工资标准表";

            SalaryNode root     = SalaryNode.GetSalaryNode("");
            TreeNode   rootNode = treeView1.Nodes.Add(root.标识.ToString(), root.称);

            //生成薪等
            foreach (SalaryNode grade in root.子节点)
            {
                if (AccessController.CheckGrade(grade.标识))
                {
                    TreeNode gradeNode = rootNode.Nodes.Add(grade.标识.ToString(), grade.称);
                    gradeNode.Tag = grade;
                }
            }
        }
        private void PayRateInput_Load(object sender, EventArgs e)
        {
            this.Text = "职级工资录入 - " + (this.是验证录入 ? "验证录入" : "初次录入");

            SalaryNode root     = SalaryNode.GetSalaryNode("");
            TreeNode   rootNode = treeView1.Nodes.Add(root.标识.ToString(), root.称);

            //生成薪等
            foreach (SalaryNode grade in root.子节点)
            {
                if (grade.已撤销 == false && AccessController.CheckGrade(grade.标识))
                {
                    TreeNode gradeNode = rootNode.Nodes.Add(grade.标识.ToString(), grade.称);
                    gradeNode.Tag = grade;
                }
            }
            treeView1.ExpandAll();
        }
Example #9
0
 private void gridView1_CustomRowCellEditForEditing(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e)
 {
     if (e.Column.FieldName == "薪级名称")
     {
         RepositoryItemImageComboBox comboBox = new RepositoryItemImageComboBox();
         comboBox.SelectedValueChanged += comboBox_SelectedValueChanged;
         EmpSalaryStepInput row   = gridView1.GetRow(e.RowHandle) as EmpSalaryStepInput;
         SalaryNode         grade = SalaryNode.GetSalaryNode(row.薪等标识);
         if (grade != null)
         {
             foreach (SalaryNode step in grade.子节点)
             {
                 ImageComboBoxItem item = new ImageComboBoxItem();
                 item.Description = step.称;
                 item.Value       = step.标识;
                 comboBox.Items.Add(item);
             }
             e.RepositoryItem = comboBox;
         }
     }
 }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (text节点名称.Text.Trim() == "")
            {
                MessageBox.Show("请输入节点的名称后再试");
            }
            else
            {
                if (currNode == null)
                {
                    MessageBox.Show("请选择一个节点");
                }
                else
                {
                    SalaryNode parent = treeList1.GetDataRecordByNode(currNode) as SalaryNode;
                    if (parent != null)
                    {
                        if (parent.类型 == (int)节点类型.薪级)
                        {
                            MessageBox.Show("错误:薪级不能创建子节点");
                        }
                        else
                        {
                            SalaryNode newNode = new SalaryNode();
                            newNode.称 = text节点名称.Text;
                            newNode.级 = parent.标识;
                            newNode.Save();

                            nodes.Add(newNode);
                            treeList1.RefreshDataSource();
                            treeList1.Refresh();
                            treeList1.ExpandAll();
                            treeList1.SetFocusedNode(currNode);

                            text节点名称.Text = "";
                        }
                    }
                }
            }
        }
        void SetButtonEnabled()
        {
            btnAdd.Enabled    = false;
            btnDelete.Enabled = false;
            btn撤销.Enabled     = false;
            btn重新启用.Enabled   = false;

            if (currNode != null)
            {
                SalaryNode salaryNode = treeList1.GetDataRecordByNode(currNode) as SalaryNode;
                if (salaryNode != null)
                {
                    btnAdd.Enabled = salaryNode.已撤销 == false && salaryNode.类型 != (int)节点类型.薪级;
                    if (salaryNode.代码 != "")
                    {
                        btnDelete.Enabled = salaryNode.已撤销 == false;
                        btn撤销.Enabled     = salaryNode.已撤销 == false;
                        btn重新启用.Enabled   = salaryNode.已撤销;
                    }
                }
            }
        }
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (currNode != null)
     {
         if (MessageBox.Show("确实删除当前节点吗?", "删除提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, 0, false) == DialogResult.Yes)
         {
             SalaryNode salaryNode = treeList1.GetDataRecordByNode(currNode) as SalaryNode;
             if (salaryNode != null)
             {
                 if (salaryNode.代码 == "" || salaryNode.已启用 || salaryNode.子节点.Count > 0)
                 {
                     MessageBox.Show("删除失败:根节点、已关联或者有子节点的节点!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2, 0, false);
                 }
                 else
                 {
                     treeList1.DeleteNode(currNode);
                     salaryNode.Delete();
                     MessageBox.Show("删除成功!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2, 0, false);
                 }
             }
         }
     }
 }
 private void SalaryTreeForm_Load(object sender, EventArgs e)
 {
     nodes = SalaryNode.GetAll();
     treeList1.DataSource = nodes;
     treeList1.ExpandAll();
 }
        public void Calculate()
        {
            try
            {
                decimal 标准职级工资, 个人职级工资;
                bool    是标准职级工资 = true;
                bool    工资系数    = false;

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

                #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_月底;
                    }
                }
                //重新计算有效的薪等薪级
                if (stepPayRate != null)
                {
                    封闭薪等 = stepPayRate.薪等标识;
                    封闭薪级 = stepPayRate.薪级标识;
                }

                PersonPayRate        personPayRate = null;
                List <PersonPayRate> pRates        = 工资计算器.个人职级工资表.FindAll(a => a.效 && a.员工编号 == this.员工编号).OrderByDescending(a => a.生效日期).ToList();
                if (pRates.Count > 0)
                {
                    personPayRate = pRates[0];
                    //津贴补助
                    津贴补助 = personPayRate.津贴1金额 + personPayRate.津贴2金额;
                }
                标准职级工资  = stepPayRate == null ? 0 : stepPayRate.工资额;
                个人职级工资  = personPayRate == null ? 0 : personPayRate.月薪;
                职级工资    = 个人职级工资 == 0 ? 标准职级工资 : 个人职级工资;
                是标准职级工资 = 个人职级工资 == 0;

                #endregion

                #region 获取薪等薪级名称

                薪等名称 = SalaryNode.GetName(封闭薪等);
                薪级名称 = SalaryNode.GetName(封闭薪级);

                #endregion

                #region 计算其它奖扣项

                //计算其它奖项
                List <OtherMoney> myOtherMoneyItems = 工资计算器.其它奖扣项.FindAll(a => a.员工编号 == this.员工编号 && a.类型 == "其它奖项");
                其它奖项 = myOtherMoneyItems.Sum(a => a.金额);

                //计算其它扣项
                myOtherMoneyItems = 工资计算器.其它奖扣项.FindAll(a => a.员工编号 == this.员工编号 && a.类型 == "其它扣项");
                其它扣项 = myOtherMoneyItems.Sum(a => a.金额);

                //计算工资降级
                myOtherMoneyItems = 工资计算器.其它奖扣项.FindAll(a => a.员工编号 == this.员工编号 && a.类型 == "工资降级");
                工资降级  = myOtherMoneyItems.Sum(a => a.金额);
                工资降级 += 表工资表.工资降级;

                //计算代垫费用
                myOtherMoneyItems = 工资计算器.其它奖扣项.FindAll(a => a.员工编号 == this.员工编号 && a.类型 == "代垫费用");
                其它代垫费用            = myOtherMoneyItems.Sum(a => a.金额);
                代垫费用 = 表工资表.代垫费用 + 其它代垫费用;
                #endregion

                #region 获取工资系数

                //获取工资系数
                EmpPayRate epRate = 工资计算器.工资系数表.Find(a => a.员工编号 == this.员工编号);
                if (epRate != null)
                {
                    工资系数 = epRate.系数;
                    工资系数 = true;
                }

                #endregion

                //有封闭工资的人才需要计算
                if (职级工资 > 0 || 其它奖项 != 0 || 其它扣项 != 0 || 工资降级 != 0 || 其它代垫费用 != 0)
                {
                    //2017.10.22 如果封闭工资没有设置职级工资,职级工资就是上表工资的工资标准
                    //主要针对没有封闭职级工资,但是有比较大的奖项在封闭工资系统发放的情况
                    if (职级工资 == 0)
                    {
                        职级工资 = 表工资表.表工资 + 工资降级;
                    }

                    #region 计算封闭出勤工资

                    //年休假工资
                    年休假工资 = 表工资表.未休年休假工资;

                    //清除老的还款记录
                    PersonRepayment.Clear(this.员工编号, this.年, this.月);

                    #region 自动创建还款记录

                    //自动创建还款记录
                    List <PersonBorrow> personBorrowList = PersonBorrow.GetMyBorrows(this.员工编号, this.年, this.月);
                    foreach (PersonBorrow borrowItem in personBorrowList)
                    {
                        //如果还有未还清的款
                        if (borrowItem.余额 > 0)
                        {
                            PersonRepayment pRepayment = PersonRepayment.AddPersonRepayment(borrowItem, this.年, this.月);
                            pRepayment.还款金额 = borrowItem.余额 > borrowItem.每月扣还 ? borrowItem.每月扣还 : borrowItem.余额;
                            pRepayment.员工编号 = this.员工编号;
                            pRepayment.创建人  = AccessController.CurrentUser.姓名;
                            pRepayment.创建时间 = DateTime.Now;
                            pRepayment.Save();
                        }
                    }
                    #endregion

                    #region 获取还款记录

                    List <PersonRepayment> prList = PersonRepayment.GetPersonRepayments(this.员工编号, this.年, this.月);
                    if (prList.Count > 0)
                    {
                        PersonRepayment 还款_提前借工资 = prList.Find(a => a.项目 == "提前借工资");
                        if (还款_提前借工资 != null)
                        {
                            提前借工资本月还款额 = 还款_提前借工资.还款金额;
                        }

                        PersonRepayment 还款_个人专用车费用 = prList.Find(a => a.项目 == "个人专用车费用");
                        if (还款_个人专用车费用 != null)
                        {
                            个人专用车费用本月还款额 = 还款_个人专用车费用.还款金额;
                        }
                    }

                    #endregion

                    #region 获取报销记录

                    List <PersonReimbursement> rbList = PersonReimbursement.GetPersonReimbursements(this.员工编号, this.年, this.月);
                    if (rbList.Count > 0)
                    {
                        PersonReimbursement 报销_月租房报销 = rbList.Find(a => a.项目 == "月租房报销");
                        if (报销_月租房报销 != null)
                        {
                            月租房报销费用本月实际报销额 = 报销_月租房报销.报销金额;
                        }

                        PersonReimbursement 报销_探亲飞机票 = rbList.Find(a => a.项目 == "探亲飞机票");
                        if (报销_探亲飞机票 != null)
                        {
                            探亲飞机票本月实际报销额 = 报销_探亲飞机票.报销金额;
                        }
                    }

                    #endregion

                    #region 获取绩效工资

                    EffectivePerformanceSalary 绩效考核 = EffectivePerformanceSalary.GetEffective(this.员工编号, this.年, this.月);
                    if (绩效考核 != null)
                    {
                        本月执行绩效工资额 = 绩效考核.绩效工资;
                        本月实得绩效工资额 = 绩效考核.实得工资;
                    }

                    #endregion

                    if (工资系数)
                    {
                        本月剩余月薪额 = (职级工资 + 表工资表.未休年休假工资) * 工资系数;
                    }

                    else
                    {
                        本月剩余月薪额 = 职级工资;
                    }

                    //2016.6.6 调整,将减掉的部分移到后面
                    //本月剩余月薪额 = 本月剩余月薪额 - 提前借工资本月还款额 - 个人专用车费用本月还款额 - 月租房报销费用本月实际报销额 - 探亲飞机票本月实际报销额 - 本月执行绩效工资额;

                    //计算挂考勤的工资
                    挂考勤的工资 = 本月剩余月薪额;

                    //排班天数
                    排班天数 = 表工资表.企业排班天数;

                    //出勤天数
                    实际出勤天数 = 表工资表.实际出勤天数;

                    //封闭出勤工资基准
                    封闭出勤工资计算标准 = 挂考勤的工资 - 工资降级 - 表工资表.表工资;
                    if (工资系数)
                    {
                        封闭出勤工资计算标准 = 封闭出勤工资计算标准 - 表工资表.未休年休假工资;
                    }
                    //剔除考核工资个人部分
                    封闭出勤工资计算标准 -= 本月执行绩效工资额;
                    //本次发放标准
                    本次发放标准 = 封闭出勤工资计算标准;

                    //出勤天数
                    班别 = 表工资表.班别.Trim();

                    decimal attDays = 实际出勤天数;
                    //封闭出勤工资中, 行政班出勤天数不能大于排班天数
                    if (班别 == "6") //行政班
                    {
                        attDays = 实际出勤天数 > 排班天数 ? 排班天数 : 实际出勤天数;
                    }

                    if (班别 == "6") //行政班
                    {
                        if (实际出勤天数 > 10)
                        {
                            封闭出勤工资 = 封闭出勤工资计算标准 - 封闭出勤工资计算标准 / (decimal)21.75 * (排班天数 - attDays);
                        }
                        else
                        {
                            封闭出勤工资 = (封闭出勤工资计算标准 / (decimal)21.75) * attDays;
                        }
                    }
                    else
                    {
                        if (班别 == "8") //特殊+业务代表+司机
                        {
                            封闭出勤工资 = (封闭出勤工资计算标准 / 排班天数) * attDays;
                        }
                        else
                        {
                            封闭出勤工资 = (封闭出勤工资计算标准 / 26) * attDays;
                        }
                    }

                    #endregion

                    //封闭奖扣合计
                    封闭奖扣合计 = 其它奖项 - 其它扣项;

                    //工资合计
                    //2016.6.6 调整 与上面对应
                    //原来  封闭工资合计 = 封闭出勤工资 + 封闭奖扣合计 + 津贴补助 + 本月实得绩效工资额;
                    封闭工资合计 = 封闭出勤工资 + 封闭奖扣合计 + 津贴补助 + 本月实得绩效工资额 - 提前借工资本月还款额 - 个人专用车费用本月还款额 - 月租房报销费用本月实际报销额 - 探亲飞机票本月实际报销额;
                    封闭工资合计 = Math.Round(封闭工资合计, 2, MidpointRounding.AwayFromZero);

                    //总应税工资
                    总应税工资 = 表工资表.合计应税工资额 + 封闭工资合计;  //上表税前应税工资(含年休假工资)加上封闭部分的工资

                    //工资发放总额
                    工资发放总额 = 表工资表.表工资总额 + 表工资表.未休年休假工资 + 封闭工资合计;    //上表工资总额不含年休假

                    //个税(总个税)
                    个人所得税 = GetTax(总应税工资);

                    //实发(含封闭和上表)
                    实发工资 = 总应税工资 - 个人所得税 - 代垫费用;
                    实发工资 = Math.Round(实发工资, 2, MidpointRounding.AwayFromZero);

                    #region 保存计算结果

                    //保存计算结果
                    pSal = PrivateSalary.AddPrivateSalary(this.员工编号, this.年, this.月, this.薪资组, this.日历组);

                    pSal.姓名 = 姓名;

                    pSal.职级工资    = 职级工资;
                    pSal.本次发放标准  = 本次发放标准;
                    pSal.是标准职级工资 = 是标准职级工资;
                    pSal.其它奖项    = 其它奖项;
                    pSal.其它扣项    = 其它扣项;
                    pSal.工资降级    = 工资降级;
                    pSal.其它代垫费用  = 其它代垫费用;
                    pSal.津贴补助    = 津贴补助;
                    pSal.工资系数    = 工资系数;
                    pSal.封闭出勤工资  = 封闭出勤工资;
                    pSal.封闭工资合计  = 封闭工资合计;
                    pSal.个人所得税   = 个人所得税;
                    pSal.总应税工资   = 总应税工资;
                    pSal.工资发放总额  = 工资发放总额;
                    pSal.实发工资    = 实发工资;

                    if (是标准职级工资)
                    {
                        pSal.薪等   = 封闭薪等;
                        pSal.薪级   = 封闭薪级;
                        pSal.薪等名称 = 薪等名称;
                        pSal.薪级名称 = 薪级名称;
                    }

                    pSal.职务名称 = PsHelper.GetValue(PsHelper.职务代码, this.表工资表.职务代码);

                    pSal.本月剩余月薪额        = 本月剩余月薪额;
                    pSal.提前借工资本月还款额     = 提前借工资本月还款额;
                    pSal.个人专用车费用本月还款额   = 个人专用车费用本月还款额;
                    pSal.月租房报销费用本月实际报销额 = 月租房报销费用本月实际报销额;
                    pSal.探亲飞机票本月实际报销额   = 探亲飞机票本月实际报销额;
                    pSal.本月执行绩效工资额      = 本月执行绩效工资额;
                    pSal.本月实得绩效工资额      = 本月实得绩效工资额;

                    pSal.Save();
                    #endregion
                }
            }
            catch (Exception e)
            {
                Error(e.Message);
            }
        }