public DataTable GetCompareUnusualAllowance(DateTime dateFrom, DateTime dateTo, string orderNmber, Guid? workplaceID, string statusProfile, string UserLogin, bool IsCreateTeamplate) { DataTable tb = CreateCompareUnusualAllowanceSchema(); using (var context = new VnrHrmDataContext()) { var monthSub = dateFrom.AddMonths(-1); string status = string.Empty; var profileServices = new Hre_ProfileServices(); var objProfile = new List<object>(); objProfile.Add(orderNmber); objProfile.Add(null); objProfile.Add(null); var lstProfile = profileServices.GetData<Hre_ProfileEntity>(objProfile, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, UserLogin, ref status); if (workplaceID != null) { lstProfile = lstProfile.Where(s => s.WorkPlaceID != null && s.WorkPlaceID.Value == workplaceID.Value).ToList(); } string _statusAll = EnumDropDown.StatusEmployee.E_ALL.ToString(); if (!string.IsNullOrEmpty(statusProfile) && statusProfile != _statusAll) { lstProfile = lstProfile.Where(s => s.Status == statusProfile).ToList(); } var lstProfileID = lstProfile.Select(s => s.ID).ToList(); var UnusCfgServices = new Cat_UnusualAllowanceCfgServices(); var objUnuCfg = new List<object>(); objUnuCfg.Add(null); objUnuCfg.Add(null); objUnuCfg.Add(null); objUnuCfg.Add(null); objUnuCfg.Add(1); objUnuCfg.Add(int.MaxValue - 1); var lstUnuCfg = UnusCfgServices.GetData<Cat_UnusualAllowanceCfgEntity>(objUnuCfg, ConstantSql.hrm_cat_sp_get_UnusualAllowanceCfg, UserLogin, ref status).Where(m => m.Type == EnumDropDown.UnusualEDType.E_UNUSUALALLOWANCE.ToString()).ToList(); var unuServices = new Sal_UnusualAllowanceServices(); var objUnu = new List<object>(); objUnu.AddRange(new object[9]); objUnu[7] = 1; objUnu[8] = int.MaxValue - 1; var lstUnu = unuServices.GetData<Sal_UnusualAllowanceEntity>(objUnu, ConstantSql.hrm_sal_sp_get_UnusualED, UserLogin, ref status); var pastDateFrom = dateFrom.AddMonths(-1); var pastDateTo = dateTo.AddMonths(-1); foreach (var item in lstUnuCfg) { DataRow dr = tb.NewRow(); dr[Sal_CompareUnusualAllowanceEntity.FieldNames.UnusualAllowanceCfgName] = item.UnusualAllowanceCfgName; var earing = EnumDropDown.EDType.E_EARNING.ToString(); var deduction = EnumDropDown.EDType.E_DEDUCTION.ToString(); var lstUnuByTypeID = lstUnu.Where(s => s.UnusualEDTypeID == item.ID && lstProfileID.Contains(s.ProfileID)).ToList(); var lstPastEaring = lstUnuByTypeID.Where(s => s.EDTypeCfg == earing && s.MonthStart >= pastDateFrom && s.MonthEnd <= pastDateTo).ToList(); var lstLastEaring = lstUnuByTypeID.Where(s => s.EDTypeCfg == earing && s.MonthStart >= dateFrom && s.MonthEnd <= dateTo).ToList(); var lstPastDeduction = lstUnuByTypeID.Where(s => s.EDTypeCfg == deduction && s.MonthStart >= pastDateFrom && s.MonthEnd <= pastDateTo).ToList(); var lstLastDeduction = lstUnuByTypeID.Where(s => s.EDTypeCfg == deduction && s.MonthStart >= dateFrom && s.MonthEnd <= dateTo).ToList(); if (tb.Columns.Contains("EEARING1")) { if (lstPastEaring.Count > 0) dr[Sal_CompareUnusualAllowanceEntity.FieldNames.EEARING1] = lstPastEaring.Sum(s => s.Amount); } if (tb.Columns.Contains("EEARING2")) { if (lstLastEaring.Count > 0) dr[Sal_CompareUnusualAllowanceEntity.FieldNames.EEARING2] = lstLastEaring.Sum(s => s.Amount); } if (tb.Columns.Contains("EDEDUCTION1")) { if (lstPastDeduction.Count > 0) dr[Sal_CompareUnusualAllowanceEntity.FieldNames.EDEDUCTION1] = lstPastDeduction.Sum(s => s.Amount); } if (tb.Columns.Contains("EDEDUCTION1")) { if (lstLastDeduction.Count > 0) dr[Sal_CompareUnusualAllowanceEntity.FieldNames.EDEDUCTION2] = lstLastDeduction.Sum(s => s.Amount); } tb.Rows.Add(dr); } return tb.ConfigTable(true); } }
public DataTable GetReportEvalutionData(int year, Guid? _TimesGetDataID, string orgStructureID, bool _IsCreateTemplate, DateTime? _dateStart, DateTime? _dateEnd, DateTime? _dateFrom, DateTime? _dateTo, Guid? _JobTitleID, Guid? _PositionID, Guid? _WorkPlaceID, Guid? _RankID,string userLogin) { using (var context = new VnrHrmDataContext()) { var unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); DataTable table = CreateReportEvalutionSchema(_dateFrom, _dateTo, userLogin); if (_IsCreateTemplate) return table; string status = string.Empty; List<Eva_EvalutionDataEntity> lstEvalutionDataEntity = new List<Eva_EvalutionDataEntity>(); DateTime _datetime = new DateTime(year, 01, 01); //Ngay goc DateTime datetimeNode = _dateEnd.Value; List<object> paraEvalutionData = new List<object>(); paraEvalutionData.AddRange(new object[17]); paraEvalutionData[0] = orgStructureID; paraEvalutionData[1] = year; paraEvalutionData[2] = _datetime; //paraEvalutionData[3] = time; paraEvalutionData[10] = _TimesGetDataID; paraEvalutionData[11] = _JobTitleID; paraEvalutionData[12] = _PositionID; paraEvalutionData[13] = _WorkPlaceID; paraEvalutionData[14] = _RankID; paraEvalutionData[15] = 1; paraEvalutionData[16] = int.MaxValue - 1; var evaServiceEvalutionData = new Eva_EvalutionDataServices(); //chi danh gia nhung nv ngay vao lam <= ngay goc var lstEvalutionData = evaServiceEvalutionData.GetData<Eva_EvalutionDataEntity>(paraEvalutionData, ConstantSql.hrm_eva_getdata_EvalutionData, userLogin, ref status); Guid[] lstSalaryClassIDs = null; Guid[] lstProfielIds = null; if (lstEvalutionData != null) { lstSalaryClassIDs = lstEvalutionData.Where(s => s.SalaryClassID != null).Select(s => s.SalaryClassID.Value).Distinct().ToArray(); lstProfielIds = lstEvalutionData.Where(s => s.ProfileID != null).Select(s => s.ProfileID.Value).Distinct().ToArray(); } #region luong co ban List<object> paraBasicSalary = new List<object>(); paraBasicSalary.AddRange(new object[10]); DateTime _dateMin = DateTime.MinValue; paraBasicSalary[2] = orgStructureID; paraBasicSalary[3] = _dateMin; paraBasicSalary[4] = datetimeNode; paraBasicSalary[5] = _dateMin; paraBasicSalary[6] = datetimeNode; paraBasicSalary[8] = 1; paraBasicSalary[9] = int.MaxValue - 1; var salServiceBasicSalary = new Sal_BasicSalaryServices(); var lstBasicSalary = salServiceBasicSalary.GetData<Sal_BasicSalaryEntity>(paraBasicSalary, ConstantSql.hrm_sal_sp_get_BasicPayroll, userLogin, ref status); if (lstBasicSalary != null && lstProfielIds != null) lstBasicSalary = lstBasicSalary.Where(s => lstProfielIds.Contains(s.ProfileID)).ToList(); List<object> paraSalaryRank = new List<object>(); paraSalaryRank.AddRange(new object[4]); paraSalaryRank[2] = 1; paraSalaryRank[3] = int.MaxValue; var catServiceSalaryRank = new Cat_SalaryRankServices(); var lstSalaryRank = catServiceSalaryRank.GetData<Cat_SalaryRankEntity>(paraSalaryRank, ConstantSql.hrm_cat_sp_get_SalaryRank, userLogin, ref status); if (lstSalaryRank != null && lstSalaryClassIDs != null) lstSalaryRank = lstSalaryRank.Where(s => s.DateOfEffect <= datetimeNode && lstSalaryClassIDs.Contains(s.SalaryClassID.Value)).ToList(); #endregion #region phu cap List<object> paraUnusualAllowance = new List<object>(); paraUnusualAllowance.AddRange(new object[9]); paraBasicSalary[3] = _dateMin; paraBasicSalary[4] = datetimeNode; paraUnusualAllowance[7] = 1; paraUnusualAllowance[8] = int.MaxValue - 1; var salServiceUnusualAllowance = new Sal_UnusualAllowanceServices(); var lstUnusualAllowance = salServiceUnusualAllowance.GetData<Sal_UnusualAllowanceEntity>(paraUnusualAllowance, ConstantSql.hrm_sal_sp_get_UnusualED, userLogin, ref status); List<Guid> lstUnusualAllowanceIDs = null; if (lstUnusualAllowance != null) { //lstUnusualAllowance = lstUnusualAllowance.Where(s => s.MonthEnd <= datetimeNode || (s.MonthStart <= datetimeNode && s.MonthEnd == null)).ToList(); lstUnusualAllowanceIDs = lstUnusualAllowance.Where(s => s.UnusualEDTypeID != null).Select(s => s.UnusualEDTypeID.Value).Distinct().ToList(); } #endregion #region loai phu cap List<object> paraUnusualAllowanceCfg = new List<object>(); paraUnusualAllowanceCfg.AddRange(new object[6]); paraUnusualAllowanceCfg[4] = 1; paraUnusualAllowanceCfg[5] = int.MaxValue - 1; var catServiceUnusualAllowanceCfg = new Cat_UnusualAllowanceCfgServices(); var lstUnusualAllowanceCfg = catServiceUnusualAllowanceCfg.GetData<Cat_UnusualAllowanceCfgEntity>(paraUnusualAllowanceCfg, ConstantSql.hrm_cat_sp_get_UnusualAllowanceCfg, userLogin, ref status); if (lstUnusualAllowanceCfg != null && lstUnusualAllowanceIDs != null) lstUnusualAllowanceCfg = lstUnusualAllowanceCfg.Where(s => lstUnusualAllowanceIDs.Contains(s.ID)).ToList(); #endregion #region lay lich su danh gia List<Eva_PerformanceEntity> lstPerformance = null; int _yearFrom = DateTime.MinValue.Year; int _yearTo = DateTime.MinValue.Year; if (_dateFrom != null && _dateTo != null) { _yearFrom = _dateFrom.Value.Year; _yearTo = _dateTo.Value.Year; var evaServicePerformance = new Eva_PerformanceServices(); List<object> paraPerformance = new List<object>(); paraPerformance.AddRange(new object[20]); paraPerformance[2] = orgStructureID; paraPerformance[18] = 1; paraPerformance[19] = int.MaxValue - 1; lstPerformance = evaServicePerformance.GetData<Eva_PerformanceEntity>(paraPerformance, ConstantSql.hrm_eva_sp_get_PerformanceGeneral, userLogin, ref status); if (lstPerformance != null) lstPerformance = lstPerformance.Where(s => s.YearEvaluation != null).ToList(); if (lstPerformance.Count != 0) lstPerformance = lstPerformance.Where(s => s.YearEvaluation.Value.Year >= _yearFrom && s.YearEvaluation.Value.Year <= _yearTo).ToList(); } #endregion DateTime dateFirstKi = _dateStart.Value; foreach (var item in lstEvalutionData) { DataRow row = table.NewRow(); #region thong tin nhan vien row[Eva_ReportEvalutionDataEntity.FieldNames.CodeEmp] = item.CodeEmp; row[Eva_ReportEvalutionDataEntity.FieldNames.ProfileName] = item.ProfileName; row[Eva_ReportEvalutionDataEntity.FieldNames.E_DEPARTMENT] = item.E_DEPARTMENT; row[Eva_ReportEvalutionDataEntity.FieldNames.E_DIVISION] = item.E_DIVISION; row[Eva_ReportEvalutionDataEntity.FieldNames.E_SECTION] = item.E_SECTION; row[Eva_ReportEvalutionDataEntity.FieldNames.E_TEAM] = item.E_TEAM; row[Eva_ReportEvalutionDataEntity.FieldNames.E_UNIT] = item.E_UNIT; row[Eva_ReportEvalutionDataEntity.FieldNames.GroupCode] = item.CostCentreCode; row[Eva_ReportEvalutionDataEntity.FieldNames.LocationByGroupCode] = item.WorkPlaceCode; row[Eva_ReportEvalutionDataEntity.FieldNames.ReportEvalutionDataNode] = datetimeNode; #endregion #region tham nien if (item.DateOfBirth != null) row[Eva_ReportEvalutionDataEntity.FieldNames.Age] = DateTime.Today.Year - item.DateOfBirth.Value.Year; if (item.DateHire != null) { row[Eva_ReportEvalutionDataEntity.FieldNames.Entering] = item.DateHire; double dayServiceYear; dayServiceYear = datetimeNode.Subtract(item.DateHire.Value).TotalDays; double _TotalYear = dayServiceYear / 360; double _tempYear = 0; if (_TotalYear > 0) { string[] parts = _TotalYear.ToString().Split('.'); double _intMonth = double.Parse(parts[0]); if (parts.Length > 1) { double _modMonth = double.Parse("0." + parts[1]) * 12; if (_modMonth >= 10) { _tempYear = _intMonth + (_modMonth / 100); } else { _tempYear = _intMonth + (_modMonth / 10); } } row[Eva_ReportEvalutionDataEntity.FieldNames.ServiceYear] = String.Format("{0:0.0}", _tempYear); ; } if (item.DateHire.Value > dateFirstKi) { if (_TotalYear > 0) row[Eva_ReportEvalutionDataEntity.FieldNames.ServiceYearKi] = String.Format("{0:0.0}", _tempYear); } else { row[Eva_ReportEvalutionDataEntity.FieldNames.ServiceYearKi] = 1.0; } } #endregion var objBasicSalary = lstBasicSalary.Where(s => s.ProfileID == item.ProfileID).FirstOrDefault(); if (objBasicSalary != null) row[Eva_ReportEvalutionDataEntity.FieldNames.BasicSalary] = double.Parse(objBasicSalary.GrossAmount); row[Eva_ReportEvalutionDataEntity.FieldNames.Rank] = item.SalaryClassName; row[Eva_ReportEvalutionDataEntity.FieldNames.QualificationAbilitytitle] = item.AbilityTitleVNI; if (item.SalaryClassID != null) { var objSalaryRank = lstSalaryRank.Where(s => s.SalaryClassID == item.SalaryClassID).FirstOrDefault(); if (objSalaryRank != null) row[Eva_ReportEvalutionDataEntity.FieldNames.RankZone] = objSalaryRank.SalaryRankName; } row[Eva_ReportEvalutionDataEntity.FieldNames.JobTitle] = item.JobTitleName; Guid[] lstUnusualAllowanceProfileCfgIds = null; if (lstUnusualAllowance != null) { lstUnusualAllowance = lstUnusualAllowance.Where(s => s.ProfileID == item.ProfileID && s.UnusualEDTypeID != null).ToList(); lstUnusualAllowanceProfileCfgIds = lstUnusualAllowance.Select(s => s.UnusualEDTypeID.Value).ToArray(); } if (lstUnusualAllowanceCfg != null && lstUnusualAllowanceProfileCfgIds != null) lstUnusualAllowanceCfg = lstUnusualAllowanceCfg.Where(s => lstUnusualAllowanceProfileCfgIds.Contains(s.ID)).ToList(); double? totalUnusualAllowance = 0; if (lstUnusualAllowanceCfg != null) { foreach (var itemUnusualAllowanceCfg in lstUnusualAllowanceCfg) { var objUnusualAllowance = lstUnusualAllowance.Where(s => s.UnusualEDTypeID == itemUnusualAllowanceCfg.ID).OrderByDescending(s => s.MonthEnd).FirstOrDefault(); if (objUnusualAllowance != null) { row[itemUnusualAllowanceCfg.Code] = objUnusualAllowance.Amount; totalUnusualAllowance += objUnusualAllowance.Amount; } } } #region lich su danh gia if (_dateFrom != null && _dateTo != null && lstPerformance != null) { _yearFrom = _dateFrom.Value.Year; _yearTo = _dateTo.Value.Year; var lstPerformanceProfile = lstPerformance.Where(s => s.ProfileID == item.ProfileID).OrderByDescending(s => s.YearEvaluation).ToList(); if (lstPerformanceProfile.Count != 0) { while (_yearTo >= _yearFrom) { var objPerformanceFirst = lstPerformanceProfile.Where(s => s.YearEvaluation.Value.Year == _yearTo).OrderByDescending(s => s.YearEvaluation).FirstOrDefault(); _yearTo -= 1; var objPerformance = lstPerformanceProfile.Where(s => s.YearEvaluation.Value.Year == _yearTo).OrderByDescending(s => s.YearEvaluation).FirstOrDefault(); int _yeartemp = _yearTo + 1; if (objPerformanceFirst != null && objPerformanceFirst.Level1Name != null) { if (objPerformanceFirst.RankID != null && objPerformance != null && objPerformance.Level1Name != null && objPerformance.RankID != null) { if (objPerformanceFirst.RankID != objPerformance.RankID) { row["Year" + _yeartemp] = "(" + objPerformanceFirst.Level1Name + ")"; row["Year" + _yearTo] = "(" + objPerformance.Level1Name + ")"; _yearTo -= 1; while (_yearTo >= _yearFrom) { var objPerformanceYear = lstPerformanceProfile.Where(s => s.YearEvaluation.Value.Year == _yearTo).OrderByDescending(s => s.YearEvaluation).FirstOrDefault(); if (objPerformanceYear != null && objPerformanceYear.Level1Name != null) row["Year" + _yearTo] = "(" + objPerformanceYear.Level1Name + ")"; _yearTo -= 1; } } else { row["Year" + _yeartemp] = objPerformanceFirst.Level1Name; } } else { row["Year" + _yeartemp] = objPerformanceFirst.Level1Name; } } } } row[Eva_ReportEvalutionDataEntity.FieldNames.HistoryDateFrom] = _dateFrom.Value.ToShortDateString(); } #endregion if (totalUnusualAllowance > 0) row[Eva_ReportEvalutionDataEntity.FieldNames.TotalSalaryAllowance] = totalUnusualAllowance; if (item.Year != null) row[Eva_ReportEvalutionDataEntity.FieldNames.Year] = item.Year; //if (item.Time !=null) // row[Eva_ReportEvalutionDataEntity.FieldNames.Time] = item.Time; #region lan danh gia if (item.TimeEvalutionData != null) row[Eva_ReportEvalutionDataEntity.FieldNames.TimeEvalutionData] = item.TimeEvalutionData; if (item.TimeEvalutionDataCode != null) row[Eva_ReportEvalutionDataEntity.FieldNames.TimeEvalutionDataCode] = item.TimeEvalutionDataCode; #endregion #region C1->C32 if (item.C1 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C1] = item.C1; if (item.C2 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C2] = item.C2; if (item.C3 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C3] = item.C3; if (item.C4 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C4] = item.C4; if (item.C5 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C5] = item.C5; if (item.C6 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C6] = item.C6; if (item.C7 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C7] = item.C7; if (item.C8 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C8] = item.C8; if (item.C9 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C9] = item.C9; if (item.C10 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C10] = item.C10; if (item.C11 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C11] = item.C11; if (item.C12 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C12] = item.C12; if (item.C13 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C13] = item.C13; if (item.C14 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C14] = item.C14; if (item.C15 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C15] = item.C15; if (item.C16 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C16] = item.C16; if (item.C17 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C17] = item.C17; if (item.C18 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C18] = item.C18; if (item.C19 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C19] = item.C19; if (item.C20 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C20] = item.C20; if (item.C21 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C21] = item.C21; if (item.C22 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C22] = item.C22; if (item.C23 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C23] = item.C23; if (item.C24 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C24] = item.C24; if (item.C25 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C25] = item.C25; if (item.C26 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C26] = item.C26; if (item.C27 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C27] = item.C27; if (item.C28 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C28] = item.C28; if (item.C29 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C29] = item.C29; if (item.C30 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C30] = item.C30; if (item.C31 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C31] = item.C31; if (item.C32 != null) row[Eva_ReportEvalutionDataEntity.FieldNames.C32] = item.C32; #endregion #region Bo sung //int _tempC1 = 0; //int _TempC2 = 0; //int _tempC3 = 0; //int _tempC4 = 0; //int _tempC5 = 0; //int _tempC6 = 0; //int _tempC7 = 0; //int _tempC8 = 0; //int _tempC9 = 0; //#region TotalC1C2 //if (item.C1 != null) // _tempC1 = item.C1.Value; //if (item.C2 != null) // _TempC2 = item.C2.Value; //if (item.C1 != null || item.C2 != null) // row[Eva_ReportEvalutionDataEntity.FieldNames.TotalC1C2] = _tempC1 + _TempC2; //#endregion //#region TotalC3C4C5C6C7 //if (item.C3 != null) // _tempC3 = item.C3.Value; //if (item.C4 != null) // _tempC4 = item.C4.Value; //if (item.C5 != null) // _tempC5 = item.C5.Value; //if (item.C6 != null) // _tempC6 = item.C6.Value; //if (item.C7 != null) // _tempC7 = item.C7.Value; //if (item.C3 != null || item.C4 != null || item.C5 != null || item.C6 != null || item.C7 != null) // row[Eva_ReportEvalutionDataEntity.FieldNames.TotalC3C4C5C6C7] = _tempC3 + _tempC4 + _tempC5 + _tempC6 + _tempC7; //#endregion //#region TotalC1C2C3C4C5C6C7 //if (item.C1 != null || item.C2 != null || item.C3 != null || item.C4 != null || item.C5 != null || item.C6 != null || item.C7 != null) // row[Eva_ReportEvalutionDataEntity.FieldNames.TotalC1C2C3C4C5C6C7] = _tempC1 + _TempC2 + _tempC3 + _tempC4 + _tempC5 + _tempC6 + _tempC7; //#endregion //#region TotalC8C9 //if (item.C8 != null) // _tempC8 = item.C8.Value; //if (item.C9 != null) // _tempC9 = item.C9.Value; //if (item.C8 != null || item.C9 != null) // row[Eva_ReportEvalutionDataEntity.FieldNames.TotalC8C9] = _tempC8 + _tempC9; //#endregion #endregion #region thoi gian danh gia row[Eva_ReportEvalutionDataEntity.FieldNames.DateStart] = _dateStart; row[Eva_ReportEvalutionDataEntity.FieldNames.DateEnd] = _dateEnd; #endregion table.Rows.Add(row); } return table.ConfigTable(); // #endregion } }
public DataTable GetReportHaveChildUsunual(string orderNumberOrg, DateTime? dateFrom, DateTime? dateTo, string UserLogin, bool IsCreateTemplate) { DataTable table = CreateReportHaveChildUsunualSchema(); if (IsCreateTemplate) { return table; } using (var context = new VnrHrmDataContext()) { string status = string.Empty; var unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); var orgTypeServices = new Cat_OrgStructureTypeServices(); var objOrgType = new List<object>(); objOrgType.Add(null); objOrgType.Add(null); objOrgType.Add(1); objOrgType.Add(int.MaxValue - 1); var lstOrgType = orgTypeServices.GetData<Cat_OrgStructureTypeEntity>(objOrgType, ConstantSql.hrm_cat_sp_get_OrgStructureType, UserLogin, ref status).ToList(); var orgServices = new Cat_OrgStructureServices(); var objOrg = new List<object>(); objOrg.Add(null); objOrg.Add(null); objOrg.Add(null); objOrg.Add(1); objOrg.Add(int.MaxValue - 1); var lstOrg = orgServices.GetData<Cat_OrgStructureEntity>(objOrg, ConstantSql.hrm_cat_sp_get_OrgStructure, UserLogin, ref status).ToList(); //if (lstOrgType != null) //{ // lstOrg = lstOrg.Where(s => s.OrgStructureTypeID != null && s.OrgStructureTypeID == lstOrgType.ID).ToList(); //} var lstOrgNumber = lstOrg.Select(s => s.OrderNumber).ToList(); var strOrderNumber = string.Join(",", lstOrgNumber); var profileServices = new Hre_ProfileServices(); var objProfile = new List<object>(); objProfile.Add(strOrderNumber); objProfile.Add(null); objProfile.Add(null); var lstProfile = profileServices.GetData<Hre_ProfileEntity>(objProfile, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, UserLogin, ref status).ToList(); var relativeServices = new Hre_RelativesServices(); var objRelative = new List<object>(); objRelative.AddRange(new object[11]); objRelative[9] = 1; objRelative[10] = int.MaxValue - 1; var lstRelatives = relativeServices.GetData<Hre_RelativesEntity>(objRelative, ConstantSql.hrm_hr_sp_get_Relatives, UserLogin, ref status).ToList(); var repoCat_OrgStructure = new CustomBaseRepository<Cat_OrgStructure>(unitOfWork); var repoCat_OrgStructureType = new Cat_OrgStructureTypeRepository(unitOfWork); var orgs = repoCat_OrgStructure.FindBy(s => s.IsDelete == null).ToList(); var orgTypes = repoCat_OrgStructureType.FindBy(s => s.IsDelete == null).ToList(); var UnusualAllowance = new Sal_UnusualAllowanceServices(); var objUnusualAllowance = new List<object>(); objUnusualAllowance.AddRange(new object[7]); objUnusualAllowance[3] = dateFrom; objUnusualAllowance[4] = dateTo; objUnusualAllowance[5] = 1; objUnusualAllowance[6] = int.MaxValue - 1; List<Sal_UnusualAllowanceEntity> listUnusualAllowance = UnusualAllowance.GetData<Sal_UnusualAllowanceEntity>(objUnusualAllowance, ConstantSql.hrm_sal_sp_get_UnusualEDChildCare, UserLogin, ref status); //lọc nhân viên có hưởng phụ cấp con nhỏ lstProfile = lstProfile.Where(m => listUnusualAllowance.Any(t => t.ProfileID == m.ID)).ToList(); foreach (var item in lstProfile) { DataRow dr = table.NewRow(); var lstRelativeByProfileID = lstRelatives.Where(s => s.ProfileID == item.ID).ToList(); if (lstRelativeByProfileID.Count == 0) { continue; } Guid? orgId = item.OrgStructureID; var unit = LibraryService.GetNearestParent(orgId, OrgUnit.E_UNIT, orgs, orgTypes); var division = LibraryService.GetNearestParent(orgId, OrgUnit.E_DIVISION, orgs, orgTypes); var department = LibraryService.GetNearestParent(orgId, OrgUnit.E_DEPARTMENT, orgs, orgTypes); var section = LibraryService.GetNearestParent(orgId, OrgUnit.E_SECTION, orgs, orgTypes); dr[Sal_ReportHaveChildUsunualEntity.FieldNames.CodeEmp] = item.CodeEmp; dr[Sal_ReportHaveChildUsunualEntity.FieldNames.ProfileName] = item.ProfileName; dr[Sal_ReportHaveChildUsunualEntity.FieldNames.E_UNIT] = item.E_UNIT; dr[Sal_ReportHaveChildUsunualEntity.FieldNames.E_DIVISION] = item.E_DIVISION; dr[Sal_ReportHaveChildUsunualEntity.FieldNames.E_DEPARTMENT] = item.E_DEPARTMENT; dr[Sal_ReportHaveChildUsunualEntity.FieldNames.E_TEAM] = item.E_TEAM; dr[Sal_ReportHaveChildUsunualEntity.FieldNames.E_SECTION] = item.E_SECTION; if (lstRelativeByProfileID.Count > 0) { var count = 0; foreach (var relative in lstRelativeByProfileID) { var _tmp = new DateTime(); count++; if (count == 11) { break; } if (relative.YearOfBirth != null) { var strYearOfBirth = relative.YearOfBirth.Split('/'); var newYOB = new DateTime(int.Parse(strYearOfBirth[2]), int.Parse(strYearOfBirth[1]), int.Parse(strYearOfBirth[0])); var dateCheck = DateTime.Now; var age = (dateCheck.Subtract(_tmp).TotalDays / 30) / 12; dr[Sal_ReportHaveChildUsunualEntity.FieldNames.RelativeName + count] = relative.RelativeName; dr[Sal_ReportHaveChildUsunualEntity.FieldNames.DateBorn + count] = newYOB; } } } table.Rows.Add(dr); } return table.ConfigTable(true); } }