Example #1
0
        /// <summary>
        /// 组装数据
        /// </summary>
        /// <returns></returns>
        private EmployeeSalaryHistory MakeEmployeeSalary()
        {
            EmployeeSalaryHistory salaryHistory = new EmployeeSalaryHistory();

            salaryHistory.EmployeeAccountSet = _AccountSet;
            salaryHistory.HistoryId          = _EmployeeSalaryID;
            if (_AccountSet != null && _AccountSet.Items != null)
            {
                BindItemValueCollection _BindItemValueCollection = ExecutBindValue(_EmployeeID, _SalaryTime);
                //获取绑定值
                foreach (AccountSetItem item in _AccountSet.Items)
                {
                    if (item != null && item.AccountSetPara.FieldAttribute.Id == FieldAttributeEnum.BindField.Id)
                    {
                        item.CalculateResult = _BindItemValueCollection.GetBindItemValue(item.AccountSetPara.BindItem);
                    }
                }
                //todo 双薪
                //_AccountSet.CalculateItemList(_GetTax.GetIndividualIncomeTax(),null,1);
                _AccountSet.CalculateItemList(_GetTax.GetIndividualIncomeTax(), MakeEmployeeLastYearSalary(_EmployeeID), new HrmisUtility().EndMonthByYearMonth(_SalaryTime).Month);
            }
            salaryHistory.Description          = _Description;
            salaryHistory.SalaryDateTime       = _SalaryTime;
            salaryHistory.EmployeeSalaryStatus = EmployeeSalaryStatusEnum.TemporarySave;
            salaryHistory.AccountsBackName     = _BackAccountsName;
            salaryHistory.VersionNumber        = _VersionNum;
            return(salaryHistory);
        }
Example #2
0
 /// <summary>
 /// 遍历dt中的第employeeRow行,将dt中的该行的值赋值给salaryHistory
 /// </summary>
 private static void ValueItemInOneRow(DataTable dt, EmployeeSalaryHistory salaryHistory, int employeeRow)
 {
     for (int i = 0; i < salaryHistory.EmployeeAccountSet.Items.Count; i++)
     {
         AccountSetItem item   = salaryHistory.EmployeeAccountSet.Items[i];
         string         answer = GetItem(dt, employeeRow, item.AccountSetPara.AccountSetParaName);
         if (answer != "EmptyNull")
         {
             if (string.IsNullOrEmpty(answer))
             {
                 item.CalculateResult = 0;
             }
             else
             {
                 decimal tempdecimal;
                 if (!Decimal.TryParse(answer, out tempdecimal))
                 {
                     throw new ApplicationException(string.Format("数据:{0} 不是小数", answer));
                 }
                 else
                 {
                     item.CalculateResult = Convert.ToDecimal(answer);
                 }
             }
         }
     }
 }
        /// <summary>
        /// 发薪
        /// </summary>
        public int InsertEmployeeSalaryHistory(int employeeID, EmployeeSalaryHistory salary)
        {
            int        pkid;
            SqlCommand cmd = new SqlCommand();

            cmd.Parameters.Add(_ParmEmployeeID, SqlDbType.Int).Value   = employeeID;
            cmd.Parameters.Add(_ParmAccountSetID, SqlDbType.Int).Value =
                salary.EmployeeAccountSet.AccountSetID;
            cmd.Parameters.Add(_ParmAccountSetName, SqlDbType.NVarChar, 255).Value =
                salary.EmployeeAccountSet.AccountSetName;
            if (salary.EmployeeAccountSet.Items != null)
            {
                cmd.Parameters.Add(_ParmEmployeeAccountSetItems, SqlDbType.Image).Value =
                    SerializeAccountSetItemList(salary.EmployeeAccountSet.Items);
            }
            else
            {
                cmd.Parameters.Add(_ParmEmployeeAccountSetItems, SqlDbType.Image).Value = DBNull.Value;
            }
            cmd.Parameters.Add(_ParmStatus, SqlDbType.Int).Value = salary.EmployeeSalaryStatus.Id;
            cmd.Parameters.Add(_ParmSalaryDateTime, SqlDbType.DateTime).Value        = salary.SalaryDateTime;
            cmd.Parameters.Add(_ParmAccountsBackName, SqlDbType.NVarChar, 255).Value = salary.AccountsBackName;
            cmd.Parameters.Add(_ParmDescpriton, SqlDbType.NVarChar, 255).Value       = salary.Description;
            cmd.Parameters.Add(_ParmPKID, SqlDbType.Int).Direction = ParameterDirection.Output;
            SqlHelper.ExecuteNonQueryReturnPKID("InsertEmployeeSalaryHistory", cmd, out pkid);
            return(pkid);
        }
Example #4
0
        /// <summary>
        /// 赋值并保存,将dt中的值赋值给salary
        /// </summary>
        /// <param name="salary"></param>
        /// <param name="dt"></param>
        private void ValueItemsAndSave(IEnumerable <EmployeeSalary> salary, DataTable dt)
        {
            foreach (EmployeeSalary employeeSalary in salary)
            {
                //员工姓名在dt中的列号
                int employeeRow = GetEmployeeRow(dt, employeeSalary.Employee.Account.Name);
                //该员工不存在则继续查找下一个
                if (employeeRow == -1)
                {
                    continue;
                }
                EmployeeSalaryHistory salaryHistory = employeeSalary.EmployeeSalaryHistoryList[0];

                //赋值备注
                string description = GetItem(dt, employeeRow, _RemarkName);
                if (description != "EmptyNull")
                {
                    salaryHistory.Description = description;
                }

                if (salaryHistory.EmployeeAccountSet.Items != null)
                {
                    //对一条记录赋值
                    ValueItemInOneRow(dt, salaryHistory, employeeRow);
                }
                //保存该条信息
                SaveEmployeeSalary(employeeSalary.Employee.Account.Id, salaryHistory);
            }
        }
Example #5
0
        protected override void Validation()
        {
            //判断帐套参数是否为空
            if (_AccountSet == null)
            {
                BllUtility.ThrowException(BllExceptionConst._EmployeeAccountSet_AccountSet_IsNull);
            }
            //判断数据库中装套是否存在
            else if (_DalAccountSet.GetWholeAccountSetByPKID(_AccountSet.AccountSetID) == null)
            {
                BllUtility.ThrowException(BllExceptionConst._EmployeeAccountSet_AccountSet_NotExist);
            }
            //判断数据库中是否存在
            EmployeeSalaryHistory history = _DalEmployeeSalary.GetEmployeeSalaryHistoryByPKID(_EmployeeSalaryID);

            if (history == null)
            {
                BllUtility.ThrowException(BllExceptionConst._Employee_Salary_NotExist);
            }
            //判断流程是否正在封帐阶段
            else if (history.EmployeeSalaryStatus != EmployeeSalaryStatusEnum.AccountClosed)
            {
                BllUtility.ThrowException(BllExceptionConst._Employee_Salary_Not_Closed);
            }
        }
        public EmployeeSalaryHistory GetEmployeeSalaryHistoryByPKID(int pkid)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.Parameters.Add(_ParmPKID, SqlDbType.Int).Value = pkid;
            using (SqlDataReader sdr = SqlHelper.ExecuteReader("GetEmployeeSalaryHistoryByPKID", cmd))
            {
                while (sdr.Read())
                {
                    EmployeeSalaryHistory salaryHistory = new EmployeeSalaryHistory();
                    salaryHistory.EmployeeAccountSet = new AccountSet((int)sdr[_DBAccountSetID], sdr[_DBAccountSetName].ToString());
                    salaryHistory.HistoryId          = (int)sdr[_DBPKID];
                    byte[] employeeAccountSetItems = sdr[_DBEmployeeAccountSetItems] as byte[];
                    if (employeeAccountSetItems != null)
                    {
                        salaryHistory.EmployeeAccountSet.Items = DeserializeAccountSetItems(employeeAccountSetItems);
                    }
                    salaryHistory.EmployeeSalaryStatus = EmployeeSalaryStatusEnum.GetEmployeeSalaryStatusEnum((int)sdr[_DBStatus]);
                    salaryHistory.AccountsBackName     = sdr[_DBAccountsBackName].ToString();
                    salaryHistory.VersionNumber        = (int)sdr[_DBVersionNumber];
                    salaryHistory.SalaryDateTime       = Convert.ToDateTime(sdr[_DBSalaryDateTime]);
                    salaryHistory.Description          = sdr[_DBDescpriton].ToString();
                    return(salaryHistory);
                }
            }
            return(null);
        }
Example #7
0
 protected override void Validation()
 {
     _EmployeeSalaryList = new List <EmployeeSalary>();
     //获取所有员工
     _EmployeeList = _GetEmployee.GetEmployeeWithCurrentMonthDimissionEmployee(_SalaryTime, _CompanyId, _DepartmentId);
     foreach (Employee employee in _EmployeeList)
     {
         EmployeeSalaryHistory salaryHistory =
             _DalEmployeeSalary.GetEmployeeSalaryHistoryByEmployeeIdAndDateTime(employee.Account.Id, _SalaryTime);
         //判断当月工资是否存在
         if (salaryHistory == null)
         {
             BllUtility.ThrowException(BllExceptionConst._Employee_Salary_NotExist);
         }
         //判断当月工资状态是否没有封帐
         else if (salaryHistory.EmployeeSalaryStatus != EmployeeSalaryStatusEnum.AccountClosed)
         {
             BllUtility.ThrowException(BllExceptionConst._Employee_Salary_Not_Closed);
         }
         var employeeSalary = new EmployeeSalary(employee.Account.Id);
         employeeSalary.Employee = employee;
         employeeSalary.EmployeeSalaryHistoryList = new List <EmployeeSalaryHistory>();
         employeeSalary.EmployeeSalaryHistoryList.Add(salaryHistory);
         _EmployeeSalaryList.Add(employeeSalary);
     }
 }
        private static int InnerUpdateEmployeeSalaryHistory(int employeeID, EmployeeSalaryHistory salary)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.Parameters.Add(_ParmPKID, SqlDbType.Int).Value         = salary.HistoryId;
            cmd.Parameters.Add(_ParmEmployeeID, SqlDbType.Int).Value   = employeeID;
            cmd.Parameters.Add(_ParmAccountSetID, SqlDbType.Int).Value =
                salary.EmployeeAccountSet.AccountSetID;
            cmd.Parameters.Add(_ParmAccountSetName, SqlDbType.NVarChar, 255).Value =
                salary.EmployeeAccountSet.AccountSetName;
            if (salary.EmployeeAccountSet.Items != null)
            {
                cmd.Parameters.Add(_ParmEmployeeAccountSetItems, SqlDbType.Image).Value =
                    SerializeAccountSetItemList(salary.EmployeeAccountSet.Items);
            }
            else
            {
                cmd.Parameters.Add(_ParmEmployeeAccountSetItems, SqlDbType.Image).Value = DBNull.Value;
            }
            cmd.Parameters.Add(_ParmStatus, SqlDbType.Int).Value = salary.EmployeeSalaryStatus.Id;
            cmd.Parameters.Add(_ParmSalaryDateTime, SqlDbType.DateTime).Value        = salary.SalaryDateTime;
            cmd.Parameters.Add(_ParmAccountsBackName, SqlDbType.NVarChar, 255).Value = salary.AccountsBackName;
            cmd.Parameters.Add(_ParmDescpriton, SqlDbType.NVarChar, 255).Value       = salary.Description;
            cmd.Parameters.Add(_ParmVersionNumber, SqlDbType.Int).Value = ++salary.VersionNumber;
            return(SqlHelper.ExecuteNonQuery("UpdateEmployeeSalaryHistory", cmd));
        }
Example #9
0
 protected override void Validation()
 {
     _EmployeeSalaryList = new List <EmployeeSalary>();
     //获取所有员工
     _EmployeeList = _GetEmployee.GetEmployeeWithCurrentMonthDimissionEmployee(_SalaryTime, _CompanyId,
                                                                               _DepartmentID);
     foreach (Employee employee in _EmployeeList)
     {
         //获取员工当月工资
         EmployeeSalaryHistory salaryHistory =
             _DalEmployeeSalary.GetEmployeeSalaryHistoryByEmployeeIdAndDateTime(employee.Account.Id, _SalaryTime);
         //判断当月工资是否存在
         if (salaryHistory == null)
         {
             throw new ApplicationException(employee.Account.Name +
                                            BllUtility.GetResourceMessage(
                                                BllExceptionConst._Employee_Salary_NotExist));
         }
         //当月工资是否已封帐
         if (Equals(salaryHistory.EmployeeSalaryStatus, EmployeeSalaryStatusEnum.AccountClosed))
         {
             throw new ApplicationException(employee.Account.Name +
                                            BllUtility.GetResourceMessage(
                                                BllExceptionConst._Employee_Salary_Closed));
         }
         var employeeSalary = new EmployeeSalary(employee.Account.Id);
         employeeSalary.Employee = employee;
         employeeSalary.EmployeeSalaryHistoryList = new List <EmployeeSalaryHistory>();
         employeeSalary.EmployeeSalaryHistoryList.Add(salaryHistory);
         _EmployeeSalaryList.Add(employeeSalary);
     }
 }
        private EmployeeSalaryHistory MakeEmployeeSalaryWithoutAccountSet()
        {
            EmployeeSalaryHistory salaryHistory = new EmployeeSalaryHistory();

            Model.PayModule.AccountSet temp = new Model.PayModule.AccountSet(0, string.Empty);
            salaryHistory.EmployeeAccountSet = temp;

            salaryHistory.Description          = _Description;
            salaryHistory.SalaryDateTime       = _SalaryTime;
            salaryHistory.EmployeeSalaryStatus = EmployeeSalaryStatusEnum.TemporarySave;
            salaryHistory.AccountsBackName     = _BackAccountsName;
            return(salaryHistory);
        }
        /// <summary>
        /// 更新薪水
        /// </summary>
        /// <param name="employeeID"></param>
        /// <param name="salary"></param>
        /// <returns></returns>
        public int UpdateEmployeeSalaryHistory(int employeeID, EmployeeSalaryHistory salary)
        {
            //注释掉该代码可以模拟测试,锁定是为了单线程访问
            lock (LockObj)
            {
                //判断是否是脏数据
                int updateVersion = GetEmployeeSalaryHistoryByPKID(salary.HistoryId).VersionNumber;
                if (updateVersion != salary.VersionNumber)
                {
                    throw new ApplicationException(_DirtyData);
                }

                return(InnerUpdateEmployeeSalaryHistory(employeeID, salary));
            }
        }
        public List <EmployeeSalary> GetEmployeeSalaryByCondition(DateTime salaryTime, int accountSetId)
        {
            List <EmployeeSalary> employeeSalarys = new List <EmployeeSalary>();
            SqlCommand            cmd             = new SqlCommand();

            //cmd.Parameters.Add(_ParmName, SqlDbType.NVarChar,50).Value = name;
            cmd.Parameters.Add(_ParmSalaryDateTime, SqlDbType.DateTime).Value = salaryTime;
            //cmd.Parameters.Add(_ParmDepartmentID, SqlDbType.Int).Value = departmentId;
            //cmd.Parameters.Add(_ParmpositionID, SqlDbType.Int).Value = positionId;
            cmd.Parameters.Add(_ParmAccountSetID, SqlDbType.Int).Value = accountSetId;
            //cmd.Parameters.Add(_ParmEmployeeType, SqlDbType.Int).Value = employeeType;
            using (SqlDataReader sdr = SqlHelper.ExecuteReader("GetEmployeeSalaryByCondition", cmd))
            {
                while (sdr.Read())
                {
                    EmployeeSalary salary = new EmployeeSalary((int)sdr[_DBEmployeeId]);
                    //salary.EmployeeName = sdr[_DBEmployeeName].ToString();
                    salary.EmployeeSalaryHistoryList = new List <EmployeeSalaryHistory>();
                    EmployeeSalaryHistory salaryHistory = new EmployeeSalaryHistory();
                    salaryHistory.HistoryId          = (int)sdr[_DBPKID];
                    salaryHistory.EmployeeAccountSet = new AccountSet((int)sdr[_DBAccountSetID], sdr[_DBAccountSetName].ToString());

                    byte[] employeeAccountSetItems = sdr[_DBEmployeeAccountSetItems] as byte[];
                    if (employeeAccountSetItems != null)
                    {
                        salaryHistory.EmployeeAccountSet.Items = DeserializeAccountSetItems(employeeAccountSetItems);
                    }
                    salaryHistory.EmployeeSalaryStatus = EmployeeSalaryStatusEnum.GetEmployeeSalaryStatusEnum((int)sdr[_DBStatus]);
                    salaryHistory.AccountsBackName     = sdr[_DBAccountsBackName].ToString();
                    salaryHistory.VersionNumber        = (int)sdr[_DBVersionNumber];
                    salaryHistory.SalaryDateTime       = Convert.ToDateTime(sdr[_DBSalaryDateTime]);
                    salaryHistory.Description          = sdr[_DBDescpriton].ToString();
                    salary.EmployeeSalaryHistoryList.Add(salaryHistory);
                    employeeSalarys.Add(salary);
                }
            }
            return(employeeSalarys);
        }
Example #13
0
        /// <summary>
        /// 组装薪水数据
        /// </summary>
        /// <returns></returns>
        private EmployeeSalaryHistory MakeEmployeeSalary()
        {
            EmployeeSalaryHistory salaryHistory = new EmployeeSalaryHistory();

            salaryHistory.EmployeeAccountSet = _AccountSet;
            salaryHistory.HistoryId          = _EmployeeSalaryID;
            if (_AccountSet.Items != null)
            {
                foreach (AccountSetItem item in _AccountSet.Items)
                {
                    if (item.AccountSetPara.FieldAttribute.GetType().Equals(FieldAttributeEnum.CalculateField))
                    {
                        //to do caculate
                    }
                }
            }
            salaryHistory.Description          = _Description;
            salaryHistory.SalaryDateTime       = _SalaryTime;
            salaryHistory.EmployeeSalaryStatus = EmployeeSalaryStatusEnum.AccountReopened;
            salaryHistory.AccountsBackName     = _BackAccountsName;
            salaryHistory.VersionNumber        = _VersionNum;
            return(salaryHistory);
        }
Example #14
0
        protected override void Validation()
        {
            //判断帐套参数是否为空
            if (_AccountSet != null && _AccountSet.AccountSetID != 0)
            {
                //判断数据库中装套是否存在
                if (_DalAccountSet.GetWholeAccountSetByPKID(_AccountSet.AccountSetID) == null)
                {
                    BllUtility.ThrowException(BllExceptionConst._EmployeeAccountSet_AccountSet_NotExist);
                }
            }
            //判断数据库是否存在记录
            EmployeeSalaryHistory history = _DalEmployeeSalary.GetEmployeeSalaryHistoryByPKID(_EmployeeSalaryID);

            if (history == null)
            {
                BllUtility.ThrowException(BllExceptionConst._Employee_Salary_NotExist);
            }
            else if (history.EmployeeSalaryStatus == EmployeeSalaryStatusEnum.AccountClosed)
            {
                BllUtility.ThrowException(BllExceptionConst._Employee_Salary_Closed);
            }
        }
Example #15
0
        ///// <summary>
        ///// 移除离职人员
        ///// </summary>
        ///// <param name="EmployeeList"></param>
        ///// <param name="dt"></param>
        ///// <returns></returns>
        //public List<Employee> RemoveDimissionhAndBorrowed(List<Employee> EmployeeList, DateTime dt)
        //{
        //    List<Employee> returnEmployee = new List<Employee>();
        //    DateTime dtFrom = new DateTime(dt.Year, dt.Month, 1);
        //    DateTime dtTo = dtFrom.AddMonths(1).AddDays(-1);

        //    for (int i = 0; i < EmployeeList.Count; i++)
        //    {
        //        //外借员工
        //        if (EmployeeList[i].EmployeeType == EmployeeTypeEnum.BorrowedEmployee)
        //        {
        //            continue;
        //        }
        //        //根据入职离职时间
        //        Employee employee = _GetEmployee.GetEmployeeBasicInfoByAccountID(EmployeeList[i].Account.Id);
        //        if (employee.EmployeeDetails == null || employee.EmployeeDetails.Work == null)
        //        {
        //            continue;
        //        }
        //        DateTime employeeFromDate = DateTime.Compare(employee.EmployeeDetails.Work.ComeDate, dtFrom) > 0
        //                                        ? employee.EmployeeDetails.Work.ComeDate
        //                                        : dtFrom;
        //        DateTime employeeToDate;
        //        if (employee.EmployeeType == EmployeeTypeEnum.DimissionEmployee &&
        //            employee.EmployeeDetails.Work.DimissionInfo != null)
        //        {
        //            employeeToDate =
        //                DateTime.Compare(employee.EmployeeDetails.Work.DimissionInfo.DimissionDate, dtTo) < 0
        //                    ? employee.EmployeeDetails.Work.DimissionInfo.DimissionDate
        //                    : dtTo;
        //        }
        //        else
        //        {
        //            employeeToDate = dtTo;
        //        }
        //        if (DateTime.Compare(employeeFromDate, employeeToDate) > 0)
        //        {
        //            continue;
        //        }
        //        returnEmployee.Add(EmployeeList[i]);
        //    }
        //    return returnEmployee;
        //}

        /// <summary>
        /// 统计某个时间段内的某个部门以及其所有子部门的员工的薪资情况
        /// </summary>
        /// <param name="startDt">统计的开始时间</param>
        /// <param name="endDt">统计的结束时间</param>
        /// <param name="departmentID">统计的部门编号</param>
        /// <param name="item">统计项--帐套项的List</param>
        /// <returns></returns>
        /// <param name="companyID"></param>
        /// <param name="isIncludeChildDeptMember"></param>
        /// <param name="loginUser"></param>
        public List <EmployeeSalaryAverageStatistics> AverageStatistics(DateTime startDt, DateTime endDt, int departmentID, AccountSetPara item,
                                                                        int companyID, bool isIncludeChildDeptMember, Account loginUser)
        {
            List <EmployeeSalaryAverageStatistics> iRet = new List <EmployeeSalaryAverageStatistics>();
            //划分月份
            List <DateTime> Months = SplitMonth(startDt, endDt);
            //查出每个月份月底这个时间点的,某一部门及其所有子部门(包括改过名字部门)
            List <Department> AllDepartment = GetAllDepartment(Months, departmentID);

            AllDepartment = Tools.RemoteUnAuthDeparetment(AllDepartment, AuthType.HRMIS, loginUser, HrmisPowers.A607);
            //构建返回的List
            foreach (Department department in AllDepartment)
            {
                EmployeeSalaryAverageStatistics employeeSalaryAverageStatistics = new EmployeeSalaryAverageStatistics();
                employeeSalaryAverageStatistics.Department = department;

                EmployeeSalaryStatisticsItem employeeSalaryStatisticsSumItem = new EmployeeSalaryStatisticsItem();
                employeeSalaryStatisticsSumItem.ItemID   = item.AccountSetParaID;
                employeeSalaryStatisticsSumItem.ItemName = item.AccountSetParaName;
                EmployeeSalaryStatisticsItem employeeSalaryStatisticsAverageItem = new EmployeeSalaryStatisticsItem();
                employeeSalaryStatisticsAverageItem.ItemName = item.AccountSetParaName + "均值";
                EmployeeSalaryStatisticsItem employeeSalaryStatisticsEmployeeCountItem = new EmployeeSalaryStatisticsItem();
                employeeSalaryStatisticsEmployeeCountItem.ItemName = "人数";

                employeeSalaryAverageStatistics.SumItem           = employeeSalaryStatisticsSumItem;
                employeeSalaryAverageStatistics.AverageItem       = employeeSalaryStatisticsAverageItem;
                employeeSalaryAverageStatistics.EmployeeCountItem = employeeSalaryStatisticsEmployeeCountItem;
                iRet.Add(employeeSalaryAverageStatistics);
            }
            //计算每个月
            for (int j = 0; j < Months.Count; j++)
            {
                //得到这个月的所有部门
                List <Department> departmentList = _GetDepartmentHistory.GetDepartmentNoStructByDateTime(Months[j]);
                departmentList =
                    Tools.RemoteUnAuthDeparetment(departmentList, AuthType.HRMIS, loginUser, HrmisPowers.A607);
                List <Employee> EmployeesSourceTemp =
                    _GetEmployee.GetEmployeeWithCurrentMonthDimissionEmployee(
                        new HrmisUtility().StartMonthByYearMonth(Months[j]), companyID);
                EmployeesSourceTemp =
                    HrmisUtility.RemoteUnAuthEmployee(EmployeesSourceTemp, AuthType.HRMIS, loginUser, HrmisPowers.A607);
                //List<Employee> EmployeesSource = RemoveDimissionAndBorrowed(EmployeesSourceTemp, Months[j]);

                List <Account> accountSource = EmployeeUtility.GetAccountListFromEmployeeList(EmployeesSourceTemp);
                for (int k = 0; k < AllDepartment.Count; k++)
                {
                    //查找这个月,这个部门中的所有人,包括子部门
                    AllDepartment[k].Members =
                        FindAllEmployeeByDepAndTime(departmentList, AllDepartment[k], Months[j], accountSource, isIncludeChildDeptMember);
                    //累计计算每月员工个数
                    iRet[k].EmployeeCountItem.CalculateValue = iRet[k].EmployeeCountItem.CalculateValue +
                                                               AllDepartment[k].Members.Count;

                    //循环部门里的员工
                    foreach (Account account in AllDepartment[k].AllMembers)
                    {
                        //查找某时,某人的薪资历史
                        EmployeeSalaryHistory employeeSalaryHistory =
                            _GetEmployeeAccountSet.GetEmployeeSalaryHistoryByEmployeeIdAndDateTime
                                (account.Id, Months[j]);
                        if (employeeSalaryHistory == null ||
                            employeeSalaryHistory.EmployeeAccountSet == null ||
                            employeeSalaryHistory.EmployeeAccountSet.Items == null)
                        {
                            continue;
                        }
                        AccountSetItem accountSetItem =
                            employeeSalaryHistory.EmployeeAccountSet.FindAccountSetItemByParaID(item.AccountSetParaID);
                        if (accountSetItem == null)
                        {
                            continue;
                        }
                        iRet[k].SumItem.CalculateValue =
                            iRet[k].SumItem.CalculateValue + accountSetItem.CalculateResult;
                    }
                }
            }
            for (int k = 0; k < AllDepartment.Count; k++)
            {
                //计算平均值
                if (iRet[k].EmployeeCountItem.CalculateValue == 0)
                {
                    iRet[k].AverageItem.CalculateValue = 0;
                }
                else
                {
                    iRet[k].AverageItem.CalculateValue = iRet[k].SumItem.CalculateValue / iRet[k].EmployeeCountItem.CalculateValue;
                }
                //计算每月平均员工人数
                iRet[k].EmployeeCountItem.CalculateValue = iRet[k].EmployeeCountItem.CalculateValue / Months.Count;

                iRet[k].AverageItem.CalculateValue       = Convert.ToDecimal(iRet[k].AverageItem.CalculateValue.ToString("0.00"));
                iRet[k].EmployeeCountItem.CalculateValue = Convert.ToDecimal(iRet[k].EmployeeCountItem.CalculateValue.ToString("0.00"));
                iRet[k].SumItem.CalculateValue           = Convert.ToDecimal(iRet[k].SumItem.CalculateValue.ToString("0.00"));
            }
            return(iRet);
        }
 public int ImportEmployeeSalaryHistory(int employeeID, EmployeeSalaryHistory salary)
 {
     return(InnerUpdateEmployeeSalaryHistory(employeeID, salary));
 }
Example #17
0
 /// <summary>
 /// 保存信息
 /// </summary>
 private void SaveEmployeeSalary(int employeeID, EmployeeSalaryHistory salary)
 {
     _DalEmployeeSalary.ImportEmployeeSalaryHistory(employeeID, salary);
 }
Example #18
0
        /// <summary>
        /// 根据部门分组
        /// </summary>
        /// <param name="startDt"></param>
        /// <param name="endDt"></param>
        /// <param name="departmentID"></param>
        /// <param name="item"></param>
        /// <param name="companyID"></param>
        /// <param name="isIncludeChildDeptMember"></param>
        /// <returns></returns>
        /// <param name="loginUser"></param>
        public List <EmployeeSalaryStatistics> TimeSpanStatisticsGroupByDepartment(DateTime startDt, DateTime endDt, int departmentID,
                                                                                   AccountSetPara item, int companyID, bool isIncludeChildDeptMember, Account loginUser)
        {
            List <EmployeeSalaryStatistics> iRet = new List <EmployeeSalaryStatistics>();
            //划分月份
            List <DateTime> Months = SplitMonth(startDt, endDt);
            //查出每个月份月底这个时间点的,某一部门及其所有子部门(包括改过名字部门)
            List <Department> AllDepartment = GetAllDepartment(Months, departmentID);

            AllDepartment = Tools.RemoteUnAuthDeparetment(AllDepartment, AuthType.HRMIS, loginUser, HrmisPowers.A607);

            //计算每个月
            for (int j = 0; j < Months.Count; j++)
            {
                EmployeeSalaryStatistics employeeSalaryStatistics = new EmployeeSalaryStatistics();
                employeeSalaryStatistics.SalaryDay = Months[j];
                employeeSalaryStatistics.EmployeeSalaryStatisticsItemList = new List <EmployeeSalaryStatisticsItem>();

                //得到这个月的所有部门
                List <Department> departmentList = _GetDepartmentHistory.GetDepartmentNoStructByDateTime(Months[j]);
                departmentList =
                    Tools.RemoteUnAuthDeparetment(departmentList, AuthType.HRMIS, loginUser, HrmisPowers.A607);
                List <Employee> EmployeesSource =
                    _GetEmployee.GetEmployeeWithCurrentMonthDimissionEmployee(
                        new HrmisUtility().StartMonthByYearMonth(Months[j]), companyID);
                EmployeesSource =
                    HrmisUtility.RemoteUnAuthEmployee(EmployeesSource, AuthType.HRMIS, loginUser, HrmisPowers.A607);
                List <Account> accountSource = EmployeeUtility.GetAccountListFromEmployeeList(EmployeesSource);
                for (int k = 0; k < AllDepartment.Count; k++)
                {
                    EmployeeSalaryStatisticsItem employeeSalaryStatisticsItem = new EmployeeSalaryStatisticsItem();
                    employeeSalaryStatisticsItem.ItemName = AllDepartment[k].DepartmentName;
                    employeeSalaryStatisticsItem.ItemID   = AllDepartment[k].DepartmentID;
                    //查找这个月,这个部门中的所有人,包括子部门
                    AllDepartment[k].Members =
                        FindAllEmployeeByDepAndTime(departmentList, AllDepartment[k], Months[j], accountSource, isIncludeChildDeptMember);

                    //循环部门里的员工
                    foreach (Account account in AllDepartment[k].AllMembers)
                    {
                        //查找某时,某人的薪资历史
                        EmployeeSalaryHistory employeeSalaryHistory =
                            _GetEmployeeAccountSet.GetEmployeeSalaryHistoryByEmployeeIdAndDateTime
                                (account.Id, Months[j]);
                        if (employeeSalaryHistory == null ||
                            employeeSalaryHistory.EmployeeAccountSet == null ||
                            employeeSalaryHistory.EmployeeAccountSet.Items == null)
                        {
                            continue;
                        }
                        AccountSetItem accountSetItem =
                            employeeSalaryHistory.EmployeeAccountSet.FindAccountSetItemByParaID(item.AccountSetParaID);
                        if (accountSetItem == null)
                        {
                            continue;
                        }
                        employeeSalaryStatisticsItem.CalculateValue =
                            employeeSalaryStatisticsItem.CalculateValue + accountSetItem.CalculateResult;
                    }
                    employeeSalaryStatistics.EmployeeSalaryStatisticsItemList.Add(employeeSalaryStatisticsItem);
                }
                iRet.Add(employeeSalaryStatistics);
            }
            return(iRet);
        }
Example #19
0
        /// <summary>
        /// 根据帐套项分组
        /// </summary>
        /// <param name="startDt"></param>
        /// <param name="endDt"></param>
        /// <param name="departmentID"></param>
        /// <param name="companyID"></param>
        /// <param name="items"></param>
        /// <returns></returns>
        /// <param name="loginUser"></param>
        public List <EmployeeSalaryStatistics> TimeSpanStatisticsGroupByParameter(DateTime startDt, DateTime endDt,
                                                                                  int departmentID, List <AccountSetPara> items, int companyID, Account loginUser)
        {
            List <EmployeeSalaryStatistics> iRet = new List <EmployeeSalaryStatistics>();

            #region 划分月份

            List <DateTime> Months = SplitMonth(startDt, endDt);
            //计算每个月
            for (int j = 0; j < Months.Count; j++)
            {
                EmployeeSalaryStatistics employeeSalaryStatistics = new EmployeeSalaryStatistics();
                employeeSalaryStatistics.SalaryDay = Months[j];

                employeeSalaryStatistics.EmployeeSalaryStatisticsItemList = new List <EmployeeSalaryStatisticsItem>();

                for (int i = 0; i < items.Count; i++)
                {
                    EmployeeSalaryStatisticsItem item = new EmployeeSalaryStatisticsItem();
                    item.ItemID   = items[i].AccountSetParaID;
                    item.ItemName = items[i].AccountSetParaName;
                    employeeSalaryStatistics.EmployeeSalaryStatisticsItemList.Add(item);
                }

                iRet.Add(employeeSalaryStatistics);
            }

            #endregion

            for (int j = 0; j < Months.Count; j++)
            {
                //根据月份、部门获取当时的部门
                List <Department> itsSource =
                    _GetDepartmentHistory.GetDepartmentListStructByDepartmentIDAndDateTime(departmentID, Months[j]);
                itsSource =
                    Tools.RemoteUnAuthDeparetment(itsSource, AuthType.HRMIS, loginUser, HrmisPowers.A607);
                //根据月份获取当时的员工信息
                List <Employee> EmployeesSource =
                    _GetEmployee.GetEmployeeWithCurrentMonthDimissionEmployee(
                        new HrmisUtility().StartMonthByYearMonth(Months[j]), companyID);
                EmployeesSource =
                    HrmisUtility.RemoteUnAuthEmployee(EmployeesSource, AuthType.HRMIS, loginUser, HrmisPowers.A607);
                //遍历部门,找到当时该部门的员工,然后分别获取当月的发薪历史
                foreach (Department department in itsSource)
                {
                    List <Employee> employees = FindEmployee(EmployeesSource, department);

                    foreach (Employee employee in employees)
                    {
                        EmployeeSalaryHistory employeeSalaryHistory =
                            _GetEmployeeAccountSet.GetEmployeeSalaryHistoryByEmployeeIdAndDateTime(employee.Account.Id,
                                                                                                   Months[j]);
                        if (employeeSalaryHistory == null ||
                            employeeSalaryHistory.EmployeeAccountSet == null ||
                            employeeSalaryHistory.EmployeeAccountSet.Items == null)
                        {
                            continue;
                        }
                        //循环每一个需要统计的项,累加结果
                        for (int i = 0; i < iRet[j].EmployeeSalaryStatisticsItemList.Count; i++)
                        {
                            AccountSetItem accountSetItem =
                                employeeSalaryHistory.EmployeeAccountSet.FindAccountSetItemByParaID(
                                    iRet[j].EmployeeSalaryStatisticsItemList[i].ItemID);
                            if (accountSetItem == null)
                            {
                                continue;
                            }
                            iRet[j].EmployeeSalaryStatisticsItemList[i].CalculateValue += accountSetItem.CalculateResult;
                        }
                    }
                }
            }
            return(iRet);
        }
Example #20
0
        /// <summary>
        /// 更新薪资
        /// </summary>
        protected override void ExcuteSelf()
        {
            EmployeeSalaryHistory salary = MakeEmployeeSalary();

            EmployeeSalaryID = _DalEmployeeSalary.UpdateEmployeeSalaryHistory(_EmployeeID, salary);
        }