public static DataTable TurnToEmployeeReimburseStatisticsDataTable (List <EmployeeReimburseStatistics> statistics, StatisticsTableTypeEnum statisticsTableTypeEnum) { int employeeCount = 0; DataTable ret_dt = new DataTable(); if (statistics == null || statistics.Count == 0 || statistics[0].EmployeeReimburseStatisticsItemList == null || statistics[0].EmployeeReimburseStatisticsItemList.Count == 0) { return(ret_dt); } ret_dt.Columns.Add("."); if (statisticsTableTypeEnum == StatisticsTableTypeEnum.Department) { ret_dt.Columns.Add("人数"); } foreach (EmployeeReimburseStatisticsItem item in statistics[0].EmployeeReimburseStatisticsItemList) { ret_dt.Columns.Add(item.ItemName); } foreach (EmployeeReimburseStatistics statistic in statistics) { DataRow dr = ret_dt.NewRow(); if (statisticsTableTypeEnum == StatisticsTableTypeEnum.Department) { dr[0] = statistic.Department.DepartmentName; dr[1] = statistic.Department.Members.Count; if (dr[0].ToString() == "总计") { dr[1] = employeeCount; } employeeCount += statistic.Department.Members.Count; } else { dr[0] = statistic.Employee.Account.Name; } foreach (EmployeeReimburseStatisticsItem item in statistic.EmployeeReimburseStatisticsItemList) { dr[item.ItemName] = decimal.Round(item.CalculateValue, 2, MidpointRounding.AwayFromZero); } ret_dt.Rows.Add(dr); } return(ret_dt); }
public static DataTable TurnToEmployeeSalaryStatisticsDataTable (List <Model.PayModule.EmployeeSalaryStatistics> statistics, StatisticsTableTypeEnum statisticsTableTypeEnum) { DataTable ret_dt = new DataTable(); if (statistics == null || statistics.Count == 0 || statistics[0].EmployeeSalaryStatisticsItemList == null || statistics[0].EmployeeSalaryStatisticsItemList.Count == 0) { return(ret_dt); } ret_dt.Columns.Add("."); ret_dt.Columns.Add("人数"); foreach (EmployeeSalaryStatisticsItem item in statistics[0].EmployeeSalaryStatisticsItemList) { ret_dt.Columns.Add(item.ItemName); } foreach (Model.PayModule.EmployeeSalaryStatistics statistic in statistics) { DataRow dr = ret_dt.NewRow(); if (statisticsTableTypeEnum == StatisticsTableTypeEnum.Department) { dr[0] = statistic.Department.DepartmentName; dr[1] = statistic.Department.AllMembers.Count; } if (statisticsTableTypeEnum == StatisticsTableTypeEnum.Position) { dr[0] = statistic.Position.Name; dr[1] = statistic.Position.Members.Count; } foreach (EmployeeSalaryStatisticsItem item in statistic.EmployeeSalaryStatisticsItemList) { dr[item.ItemName] = decimal.Round(item.CalculateValue, 2, MidpointRounding.AwayFromZero); } ret_dt.Rows.Add(dr); } return(ret_dt); }