/// <summary> /// 统计人员流动情况 /// </summary> /// <param name="dt">统计时间,以该时间为基准,统计包括该月在内的近一年的情况</param> /// <param name="departmentID">部门编号</param> /// <returns>到统计时间为止,近一年的人员流动情况</returns> /// <param name="accountoperator"></param> public List <EmployeeComeAndLeave> ComeAndLeaveStatistics(DateTime dt, int departmentID, Account accountoperator) { List <Employee> allEmployeeSource = new GetEmployee().GetAllEmployeeBasicInfo(); List <EmployeeComeAndLeave> employeeComeAndLeaveList = new List <EmployeeComeAndLeave>(); dt = new DateTime(dt.Year, dt.Month, 1); //定位到dt当月第一天,如2009-3-1 List <Employee> endDtEmployeeList = null; for (int i = 11; i >= 0; i--) //从前面第11个月开始计算 { DateTime thisMonthlastDate = dt.AddMonths(-i).AddMonths(1).AddDays(-1); //这个月最后一天 List <Employee> outEndDtEmployeeList; EmployeeComeAndLeave employeeComeAndLeave = ComeAndLeaveStatisticsOnlyOneMonth(thisMonthlastDate, departmentID, accountoperator, endDtEmployeeList, out outEndDtEmployeeList, allEmployeeSource); endDtEmployeeList = outEndDtEmployeeList;//为了支持ComeAndLeaveStatisticsOnlyOneMonth被单独调用,且endDtEmployeeList不要重复读取数据 //endDtEmployeeList 此值要被带入下一个循环中 employeeComeAndLeaveList.Add(employeeComeAndLeave); } return(employeeComeAndLeaveList); }