Exemple #1
0
        public DataTable GetReportHCByMonth(DateTime? DateSearch, Guid? orgID, bool isCreateTemplate, string userLogin)
        {

            DataTable table = CreateReportHCByMonthSchema(orgID);
            if (isCreateTemplate)
            {
                return table.ConfigTable();
            }

            using (var context = new VnrHrmDataContext())
            {
                string status = string.Empty;
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repoPosition = new CustomBaseRepository<Cat_Position>(unitOfWork);
                var orgStructureServices = new Cat_OrgStructureServices();

                var orgsService = new Cat_OrgStructureServices();
                var lstallorgs = orgsService.GetDataNotParam<Cat_OrgStructure>(ConstantSql.hrm_cat_sp_get_AllOrg, userLogin, ref status).ToList();

                var lstorgs = lstallorgs.Where(s => s.ParentID == orgID).ToList();
                var lstOrgName = lstallorgs.Where(s => s.ID == orgID).FirstOrDefault();
                var listorgid = lstorgs.Select(s => new { s.ID, s.OrderNumber, s.Code, s.OrgStructureName }).ToList();
                var orgIDs = string.Empty;
                orderNumber = string.Empty;

                foreach (var item in listorgid)
                {
                    orderNumber += item.OrderNumber.ToString() + ",";
                    getChildOrgStructure(lstallorgs, item.ID);
                }
                if (orderNumber.IndexOf(',') > 0)
                    orderNumber = orderNumber.Substring(0, orderNumber.Length - 1);

                var lstObjOrgByOrderNumber = new List<object>();
                lstObjOrgByOrderNumber.Add(orderNumber);
                var lstOrgByOrderNumber = orgsService.GetData<Cat_OrgStructure>(lstObjOrgByOrderNumber, ConstantSql.hrm_cat_sp_get_OrgStructureByOrderNumber, userLogin, ref status).Select(s => s.ID).ToList();

                List<object> listObj = new List<object>();
                listObj.Add(orderNumber);
                listObj.Add(string.Empty);
                listObj.Add(string.Empty);
                var lstprofile = GetData<Hre_ProfileEntity>(listObj, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, userLogin, ref status).ToList();

                var PositionServices = new Cat_PositionServices();
                var lstObjPosition = new List<object>();
                lstObjPosition.Add(null);
                lstObjPosition.Add(null);
                lstObjPosition.Add(1);
                lstObjPosition.Add(int.MaxValue - 1);
                var lstPosition = GetData<Cat_PositionEntity>(lstObjPosition, ConstantSql.hrm_cat_sp_get_Position, userLogin, ref status).ToList();

                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().Translate<Cat_OrgStructureType>();

                var PlanHeadCountServices = new Hre_PlanHeadCountServices();
                var objPlanHeadCount = new List<object>();
                objPlanHeadCount.Add(null);
                objPlanHeadCount.Add(1);
                objPlanHeadCount.Add(int.MaxValue - 1);
                var lstobjPlanHeadCount = orgTypeServices.GetData<Hre_PlanHeadCountEntity>(objPlanHeadCount, ConstantSql.hrm_hr_sp_get_PlanHeadCount, userLogin, ref status).ToList();

                foreach (var item in lstOrgByOrderNumber)
                {
                    DataRow row = table.NewRow();
                    var lstpositionbyOrg = lstPosition.Where(s => s.OrgStructureID == item).ToList();
                    if (lstpositionbyOrg.Count == 0)
                    {
                        continue;
                    }

                    foreach (var position in lstpositionbyOrg)
                    {
                        Guid? orgId = item;
                        var org = lstallorgs.FirstOrDefault(s => s.ID == item);
                        var E_DIVISION = LibraryService.GetNearestParent(orgId, OrgUnit.E_DIVISION, lstallorgs, lstOrgType);
                        var E_DEPARTMENT = LibraryService.GetNearestParent(orgId, OrgUnit.E_DEPARTMENT, lstallorgs, lstOrgType);
                        var E_SECTION = LibraryService.GetNearestParent(orgId, OrgUnit.E_SECTION, lstallorgs, lstOrgType);
                        var countFirstOfMonth = lstprofile.Where(s => s.DateOfEffect != null && s.PositionID == position.ID && s.DateOfEffect.Value.Month <= DateSearch.Value.Month).Count();
                        var newHiring = lstprofile.Where(s => s.DateHire != null && s.PositionID == position.ID && s.DateHire.Value.Month == DateSearch.Value.Month).Count();
                        var resignInMonth = lstprofile.Where(s => s.DateQuit != null && s.PositionID == position.ID && s.DateQuit.Value.Month == DateSearch.Value.Month).Count();
                        var tranferInMonth = lstprofile.Where(s => s.DateOfEffect != null &&
                            (s.PositionID == position.ID && s.DateOfEffect.Value.Month < DateSearch.Value.Month)
                            && (s.PositionID != position.ID && s.DateOfEffect.Value.Month >= DateSearch.Value.Month)).Count();
                        var joinInMonth = lstprofile.Where(s => s.DateOfEffect != null &&
                         (s.PositionID == position.ID && s.DateOfEffect.Value.Month >= DateSearch.Value.Month)
                         && (s.PositionID != position.ID && s.DateOfEffect.Value.Month < DateSearch.Value.Month)).Count();
                        var headcount = lstobjPlanHeadCount.Where(s => s.OrgStructureID == item && s.PostionID == position.ID).FirstOrDefault();
                        row[Hre_ReportHCByMonthEntity.FieldNames.Division] = E_DIVISION != null ? E_DIVISION.OrgStructureName : null;
                        row[Hre_ReportHCByMonthEntity.FieldNames.Department] = E_DEPARTMENT != null ? E_DEPARTMENT.OrgStructureName : null;
                        row[Hre_ReportHCByMonthEntity.FieldNames.Section] = E_SECTION != null ? E_SECTION.OrgStructureName : null;
                        row[Hre_ReportHCByMonthEntity.FieldNames.Position] = position.PositionName;
                        row[Hre_ReportHCByMonthEntity.FieldNames.FirstOfMonth] = countFirstOfMonth;
                        row[Hre_ReportHCByMonthEntity.FieldNames.NewHiring] = newHiring;
                        row[Hre_ReportHCByMonthEntity.FieldNames.Resign] = resignInMonth;
                        row[Hre_ReportHCByMonthEntity.FieldNames.Transfer] = tranferInMonth;
                        row[Hre_ReportHCByMonthEntity.FieldNames.Join] = joinInMonth;
                        row[Hre_ReportHCByMonthEntity.FieldNames.HeadcountBudget] = headcount != null ? headcount.HrPlanHC : null;
                        table.Rows.Add(row);
                    }
                }
                return table;
            }
        }
Exemple #2
0
        public DataTable GetReportMonthlyHC(DateTime DateSearch, List<Guid?> lstjobTitles, Guid orgID, Guid? orgTypeId, bool isCreateTemplate, string userLogin)
        {

            DataTable table = CreateReportMonthlyHCSchema();
            if (isCreateTemplate)
            {
                return table;
            }
            string status = string.Empty;
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var serviceProfile = new Hre_ProfileServices();
                var baseService = new BaseService();
                var lstObjProfileIDs = new List<object>();

                var orgsService = new Cat_OrgStructureServices();
                var lstallorgs = orgsService.GetDataNotParam<Cat_OrgStructure>(ConstantSql.hrm_cat_sp_get_AllOrg, userLogin, ref status).ToList();

                var lstorgs = lstallorgs.Where(s => s.ParentID == orgID).ToList();

                var listorgid = lstorgs.Select(s => new { s.ID, s.OrderNumber, s.OrgStructureTypeID }).ToList();


                //Xử Lý lấy tất cả nhân viên trong phòng ban đã chọn và group 1 cấp
                var orgIDs = string.Empty;
                orderNumber = string.Empty;
                foreach (var item in listorgid)
                {
                    orderNumber += item.OrderNumber.ToString() + ",";
                    getChildOrgStructure(lstallorgs, item.ID);
                }
                if (orderNumber.IndexOf(',') > 0)
                    orderNumber = orderNumber.Substring(0, orderNumber.Length - 1);
                if (orderNumber == string.Empty)
                    return table;

                var lstObjOrgByOrderNumber = new List<object>();
                lstObjOrgByOrderNumber.Add(orderNumber);
                var lstOrgByOrderNumber = orgsService.GetData<Cat_OrgStructure>(lstObjOrgByOrderNumber, ConstantSql.hrm_cat_sp_get_OrgStructureByOrderNumber, userLogin ,ref status).Select(s => new { s.ID, s.OrderNumber, s.OrgStructureName, s.OrgStructureTypeID, s.ParentID }).ToList();
                if (orgTypeId != null)
                {
                    lstOrgByOrderNumber = lstOrgByOrderNumber.Where(s => s.OrgStructureTypeID == orgTypeId).ToList();
                }

                List<object> listObj = new List<object>();
                listObj.Add(orderNumber);
                listObj.Add(string.Empty);
                listObj.Add(string.Empty);


                var headCountService = new Hre_PlanHeadCountServices();
                var lstObjPlanHeadCount = new List<object>();
                lstObjPlanHeadCount.Add(null);
                lstObjPlanHeadCount.Add(1);
                lstObjPlanHeadCount.Add(10000000);
                var lstPlanHeadCount = GetData<Hre_PlanHeadCountEntity>(lstObjPlanHeadCount, ConstantSql.hrm_hr_sp_get_PlanHeadCount, userLogin, ref status).ToList();

                var lstProfile = GetData<Hre_ProfileEntity>(listObj, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, userLogin, ref status).Where(s => s.DateHire != null && s.DateQuit == null && s.DateHire <= DateSearch).ToList();
                var lstprofileWorking = GetData<Hre_ProfileEntity>(listObj, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, userLogin, ref status).Where(s => s.DateHire != null && s.StatusSyn == null && s.DateHire.Value.Year == DateSearch.Year && s.DateQuit == null).ToList();
                var lstprofileQuit = GetData<Hre_ProfileEntity>(listObj, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, userLogin, ref status).Where(s => s.DateQuit != null && s.DateQuit.Value.Year == DateSearch.Year).ToList();

                var jobtitleService = new Cat_JobTitleServices();
                var lstObjJobtitle = new List<object>();
                lstObjJobtitle.Add(null);
                lstObjJobtitle.Add(null);
                lstObjJobtitle.Add(null);
                lstObjJobtitle.Add(1);
                lstObjJobtitle.Add(100000);

                var lstJobtitle = GetData<Cat_JobTitleEntity>(lstObjJobtitle, ConstantSql.hrm_cat_sp_get_JobTitle, userLogin, ref status).ToList();

                if (lstjobTitles != null && lstjobTitles[0] != null && lstjobTitles[0] != Guid.Empty)
                {
                    lstprofileWorking = lstprofileWorking.Where(s => s.JobTitleID != null && lstjobTitles.Contains(s.JobTitleID.Value)).ToList();
                    lstprofileQuit = lstprofileQuit.Where(s => s.JobTitleID != null && lstjobTitles.Contains(s.JobTitleID.Value)).ToList();
                    lstJobtitle = lstJobtitle.Where(s => lstjobTitles.Contains(s.ID)).ToList();
                }
                if (lstprofileWorking == null || lstorgs == null || lstprofileQuit == null)
                {
                    return table;
                }

                foreach (var org in lstOrgByOrderNumber)
                {
                    DataRow row = table.NewRow();
                    var parentOrg = lstallorgs.Where(s => s.ID == org.ParentID).FirstOrDefault();
                    row[Hre_ReportMonthlyHCEntity.FieldNames.OrgStructureParentName] = parentOrg != null ? parentOrg.OrgStructureName : string.Empty;
                    row[Hre_ReportMonthlyHCEntity.FieldNames.OrgStructureName] = org != null ? org.OrgStructureName : string.Empty;

                    //xử lý đếm nhân viên của phòng ban con
                    var IDsCount = string.Empty;
                    orderNumber = string.Empty;
                    orderNumber += org.OrderNumber.ToString() + ",";
                    getChildOrgStructure(lstallorgs, org.ID);

                    if (orderNumber.IndexOf(',') > 0)
                        orderNumber = orderNumber.Substring(0, orderNumber.Length - 1);

                    var lstObjOrgByOrderNumberCount = new List<object>();
                    lstObjOrgByOrderNumberCount.Add(orderNumber);
                    var lstOrgByOrderNumberCount = orgsService.GetData<Cat_OrgStructure>(lstObjOrgByOrderNumberCount, ConstantSql.hrm_cat_sp_get_OrgStructureByOrderNumber, userLogin, ref status).Select(s => new { s.ID, s.OrgStructureTypeID }).ToList();
                    if (orgTypeId != null)
                    {
                        lstOrgByOrderNumberCount = lstOrgByOrderNumberCount.Where(s => s.OrgStructureTypeID == orgTypeId).ToList();
                    }
                    var lstOrgGroupByType = lstOrgByOrderNumberCount.Select(s => s.ID).ToList();


                    bool addTitle = false;


                    foreach (var jobtitle in lstJobtitle)
                    {
                        DataRow row1 = table.NewRow();
                        var countingPlanHeadCount = 0;
                        var counttingProfileWorking = 0;
                        var countingProfileQuit = 0;


                        if (jobtitle.OrgStructureID != null)
                        {
                            if (jobtitle.OrgStructureID == orgID)
                            {
                                row1[Hre_ReportMonthlyHCEntity.FieldNames.JobTitleName] = jobtitle != null ? jobtitle.JobTitleName : string.Empty;

                                #region Approved
                                var countProfile = 0;
                                var totalProfile = 0;
                                var lstProfileWorkingByJobTitleID = lstprofileWorking.Where(s => jobtitle.ID == s.JobTitleID && lstOrgGroupByType.Contains(s.OrgStructureID.Value)).Select(p => new { p.ID, p.DateHire, p.StatusSyn }).ToList();
                                if (lstProfileWorkingByJobTitleID.Where(s => s.DateHire.Value.Month == 01).ToList() != null)
                                {
                                    countProfile = lstProfileWorkingByJobTitleID.Where(s => s.DateHire.Value.Month == 01).ToList().Count();
                                    //   countingProfileQuit += countProfileQuit;
                                    totalProfile += countProfile;
                                    //row1[Hre_ReportMonthlyHCEntity.FieldNames.AppJan] = totalProfile;
                                }
                                if (lstProfileWorkingByJobTitleID.Where(s => s.DateHire.Value.Month == 02).ToList() != null)
                                {
                                    countProfile = lstProfileWorkingByJobTitleID.Where(s => s.DateHire.Value.Month == 02).ToList().Count();
                                    //    countingProfileQuit += countProfileQuit;
                                    totalProfile += countProfile;
                                    //row1[Hre_ReportMonthlyHCEntity.FieldNames.AppFeb] = totalProfile;
                                }
                                if (lstProfileWorkingByJobTitleID.Where(s => s.DateHire.Value.Month == 03).ToList() != null)
                                {
                                    countProfile = lstProfileWorkingByJobTitleID.Where(s => s.DateHire.Value.Month == 03).ToList().Count();
                                    //    countingProfileQuit += countProfileQuit;
                                    totalProfile += countProfile;
                                    // row1[Hre_ReportMonthlyHCEntity.FieldNames.AppMar] = totalProfile;
                                }
                                if (lstProfileWorkingByJobTitleID.Where(s => s.DateHire.Value.Month == 04).ToList() != null)
                                {
                                    countProfile = lstProfileWorkingByJobTitleID.Where(s => s.DateHire.Value.Month == 04).ToList().Count();
                                    //    countingProfileQuit += countProfileQuit;
                                    totalProfile += countProfile;
                                    // row1[Hre_ReportMonthlyHCEntity.FieldNames.AppApr] = totalProfile;
                                }
                                if (lstProfileWorkingByJobTitleID.Where(s => s.DateHire.Value.Month == 05).ToList() != null)
                                {
                                    countProfile = lstProfileWorkingByJobTitleID.Where(s => s.DateHire.Value.Month == 05).ToList().Count();
                                    //  countingProfileQuit += countProfileQuit;
                                    totalProfile += countProfile;
                                    // row1[Hre_ReportMonthlyHCEntity.FieldNames.AppMay] = totalProfile;
                                }
                                if (lstProfileWorkingByJobTitleID.Where(s => s.DateHire.Value.Month == 06).ToList() != null)
                                {
                                    countProfile = lstProfileWorkingByJobTitleID.Where(s => s.DateHire.Value.Month == 06).ToList().Count();
                                    //   countingProfileQuit += countProfileQuit;
                                    totalProfile += countProfile;
                                    //row1[Hre_ReportMonthlyHCEntity.FieldNames.AppJun] = totalProfile;
                                }
                                if (lstProfileWorkingByJobTitleID.Where(s => s.DateHire.Value.Month == 07).ToList() != null)
                                {
                                    countProfile = lstProfileWorkingByJobTitleID.Where(s => s.DateHire.Value.Month == 07).ToList().Count();
                                    //   countingProfileQuit += countProfileQuit;
                                    totalProfile += countProfile;
                                    //row1[Hre_ReportMonthlyHCEntity.FieldNames.AppJul] = totalProfile;
                                }
                                if (lstProfileWorkingByJobTitleID.Where(s => s.DateHire.Value.Month == 08).ToList() != null)
                                {
                                    countProfile = lstProfileWorkingByJobTitleID.Where(s => s.DateHire.Value.Month == 08).ToList().Count();
                                    // countingProfileQuit += countProfileQuit;
                                    totalProfile += countProfile;
                                    //row1[Hre_ReportMonthlyHCEntity.FieldNames.AppAug] = totalProfile;
                                }
                                if (lstProfileWorkingByJobTitleID.Where(s => s.DateHire.Value.Month == 09).ToList() != null)
                                {
                                    countProfile = lstProfileWorkingByJobTitleID.Where(s => s.DateHire.Value.Month == 09).ToList().Count();
                                    //  countingProfileQuit += countProfileQuit;
                                    totalProfile += countProfile;
                                    row1[Hre_ReportMonthlyHCEntity.FieldNames.AppSep] = totalProfile;
                                }
                                if (lstProfileWorkingByJobTitleID.Where(s => s.DateHire.Value.Month == 10).ToList() != null)
                                {
                                    countProfile = lstProfileWorkingByJobTitleID.Where(s => s.DateHire.Value.Month == 10).ToList().Count();
                                    //  countingProfileQuit += countProfileQuit;
                                    totalProfile += countProfile;
                                    // row1[Hre_ReportMonthlyHCEntity.FieldNames.AppOct] = totalProfile;
                                }
                                if (lstProfileWorkingByJobTitleID.Where(s => s.DateHire.Value.Month == 11).ToList() != null)
                                {
                                    countProfile = lstProfileWorkingByJobTitleID.Where(s => s.DateHire.Value.Month == 11).ToList().Count();
                                    //countingProfileQuit += countProfileQuit;
                                    totalProfile += countProfile;
                                    row1[Hre_ReportMonthlyHCEntity.FieldNames.AppNov] = totalProfile;
                                }
                                if (lstProfileWorkingByJobTitleID.Where(s => s.DateHire.Value.Month == 12).ToList() != null)
                                {
                                    countProfile = lstProfileWorkingByJobTitleID.Where(s => s.DateHire.Value.Month == 12).ToList().Count();
                                    // countingProfileQuit += countProfileQuit;
                                    totalProfile += countProfile;
                                    //row1[Hre_ReportMonthlyHCEntity.FieldNames.AppDec] = totalProfile;
                                }


                                row1[Hre_ReportMonthlyHCEntity.FieldNames.AppJan] = totalProfile;
                                row1[Hre_ReportMonthlyHCEntity.FieldNames.AppFeb] = totalProfile;
                                row1[Hre_ReportMonthlyHCEntity.FieldNames.AppMar] = totalProfile;
                                row1[Hre_ReportMonthlyHCEntity.FieldNames.AppApr] = totalProfile;
                                row1[Hre_ReportMonthlyHCEntity.FieldNames.AppMay] = totalProfile;
                                row1[Hre_ReportMonthlyHCEntity.FieldNames.AppJun] = totalProfile;
                                row1[Hre_ReportMonthlyHCEntity.FieldNames.AppJul] = totalProfile;
                                row1[Hre_ReportMonthlyHCEntity.FieldNames.AppAug] = totalProfile;
                                row1[Hre_ReportMonthlyHCEntity.FieldNames.AppSep] = totalProfile;
                                row1[Hre_ReportMonthlyHCEntity.FieldNames.AppOct] = totalProfile;
                                row1[Hre_ReportMonthlyHCEntity.FieldNames.AppNov] = totalProfile;
                                row1[Hre_ReportMonthlyHCEntity.FieldNames.AppDec] = totalProfile;
                                row1[Hre_ReportMonthlyHCEntity.FieldNames.AppYear] = totalProfile;


                                #endregion

                                #region  Actual HC
                                double countProfileWorking = 0;
                                double totalProfileWorking = 0;

                                var lstProfileByJobTitleID = lstProfile.Where(s => jobtitle.ID == s.JobTitleID && lstOrgGroupByType.Contains(s.OrgStructureID.Value)).Select(p => new { p.ID, p.DateHire, p.StatusSyn, p.DateQuit }).ToList();


                                if (lstProfileByJobTitleID.Where(s => s.DateHire.Value.Month == 01).ToList() != null)
                                {
                                    countProfileWorking = lstProfileByJobTitleID.Where(s => s.DateHire.Value.Month == 01).ToList().Count();
                                    //   counttingProfileWorking += countProfileWorking;
                                    totalProfileWorking += countProfileWorking;
                                    row1[Hre_ReportMonthlyHCEntity.FieldNames.ActJan] = countProfileWorking;
                                }
                                if (lstProfileByJobTitleID.Where(s => s.DateHire.Value.Month == 02).ToList() != null)
                                {
                                    countProfileWorking = lstProfileByJobTitleID.Where(s => s.DateHire.Value.Month == 02).ToList().Count();
                                    //  counttingProfileWorking += countProfileWorking;
                                    totalProfileWorking += countProfileWorking;
                                    row1[Hre_ReportMonthlyHCEntity.FieldNames.ActFeb] = countProfileWorking;
                                }
                                if (lstProfileByJobTitleID.Where(s => s.DateHire.Value.Month == 03).ToList() != null)
                                {
                                    countProfileWorking = lstProfileByJobTitleID.Where(s => s.DateHire.Value.Month == 03).ToList().Count();
                                    //   counttingProfileWorking += countProfileWorking;
                                    totalProfileWorking += countProfileWorking;
                                    row1[Hre_ReportMonthlyHCEntity.FieldNames.ActMar] = countProfileWorking;
                                }
                                if (lstProfileByJobTitleID.Where(s => s.DateHire.Value.Month == 04).ToList() != null)
                                {
                                    countProfileWorking = lstProfileByJobTitleID.Where(s => s.DateHire.Value.Month == 04).ToList().Count();
                                    //  counttingProfileWorking += countProfileWorking;
                                    totalProfileWorking += countProfileWorking;
                                    row1[Hre_ReportMonthlyHCEntity.FieldNames.ActApr] = countProfileWorking;
                                }
                                if (lstProfileByJobTitleID.Where(s => s.DateHire.Value.Month == 05).ToList() != null)
                                {
                                    countProfileWorking = lstProfileByJobTitleID.Where(s => s.DateHire.Value.Month == 05).ToList().Count();
                                    //  counttingProfileWorking += countProfileWorking;
                                    totalProfileWorking += countProfileWorking;
                                    row1[Hre_ReportMonthlyHCEntity.FieldNames.ActMay] = countProfileWorking;
                                }
                                if (lstProfileByJobTitleID.Where(s => s.DateHire.Value.Month == 06).ToList() != null)
                                {
                                    countProfileWorking = lstProfileByJobTitleID.Where(s => s.DateHire.Value.Month == 06).ToList().Count();
                                    // counttingProfileWorking += countProfileWorking;
                                    totalProfileWorking += countProfileWorking;
                                    row1[Hre_ReportMonthlyHCEntity.FieldNames.ActJun] = countProfileWorking;
                                }
                                if (lstProfileByJobTitleID.Where(s => s.DateHire.Value.Month == 07).ToList() != null)
                                {
                                    countProfileWorking = lstProfileByJobTitleID.Where(s => s.DateHire.Value.Month == 07).ToList().Count();
                                    //  counttingProfileWorking += countProfileWorking;
                                    totalProfileWorking += countProfileWorking;
                                    row1[Hre_ReportMonthlyHCEntity.FieldNames.ActJul] = countProfileWorking;
                                }
                                if (lstProfileByJobTitleID.Where(s => s.DateHire.Value.Month == 08).ToList() != null)
                                {
                                    countProfileWorking = lstProfileByJobTitleID.Where(s => s.DateHire.Value.Month == 08).ToList().Count();
                                    // counttingProfileWorking += countProfileWorking;
                                    totalProfileWorking += countProfileWorking;
                                    row1[Hre_ReportMonthlyHCEntity.FieldNames.ActAug] = countProfileWorking;
                                }
                                if (lstProfileByJobTitleID.Where(s => s.DateHire.Value.Month == 09).ToList() != null)
                                {
                                    countProfileWorking = lstProfileByJobTitleID.Where(s => s.DateHire.Value.Month == 09).ToList().Count();
                                    // counttingProfileWorking += countProfileWorking;
                                    totalProfileWorking += countProfileWorking;
                                    row1[Hre_ReportMonthlyHCEntity.FieldNames.ActSep] = countProfileWorking;
                                }
                                if (lstProfileByJobTitleID.Where(s => s.DateHire.Value.Month == 10).ToList() != null)
                                {
                                    countProfileWorking = lstProfileByJobTitleID.Where(s => s.DateHire.Value.Month == 10).ToList().Count();
                                    // counttingProfileWorking += countProfileWorking;
                                    totalProfileWorking += countProfileWorking;
                                    row1[Hre_ReportMonthlyHCEntity.FieldNames.ActOct] = countProfileWorking;
                                }
                                if (lstProfileByJobTitleID.Where(s => s.DateHire.Value.Month == 11).ToList() != null)
                                {
                                    countProfileWorking = lstProfileByJobTitleID.Where(s => s.DateHire.Value.Month == 11).ToList().Count();
                                    // counttingProfileWorking += countProfileWorking;
                                    totalProfileWorking += countProfileWorking;
                                    row1[Hre_ReportMonthlyHCEntity.FieldNames.ActNov] = countProfileWorking;
                                }
                                if (lstProfileByJobTitleID.Where(s => s.DateHire.Value.Month == 12).ToList() != null)
                                {
                                    countProfileWorking = lstProfileByJobTitleID.Where(s => s.DateHire.Value.Month == 12).ToList().Count();
                                    // counttingProfileWorking += countProfileWorking;
                                    totalProfileWorking += countProfileWorking;
                                    row1[Hre_ReportMonthlyHCEntity.FieldNames.ActDec] = countProfileWorking;
                                }
                                double total = 0;
                                if (totalProfileWorking / 12 < 1 && totalProfileWorking / 12 > 0)
                                {
                                    total = 1;
                                }
                                else
                                {
                                    total = Math.Round(totalProfileWorking / 12);
                                }
                                row1[Hre_ReportMonthlyHCEntity.FieldNames.ActYear] = totalProfileWorking;
                                #endregion

                                #region Leaver HC
                                var countProfileQuit = 0;
                                var totalQuit = 0;
                                var lstProfileQuitByJobTitleID = lstprofileQuit.Where(s => jobtitle.ID == s.JobTitleID && lstOrgGroupByType.Contains(s.OrgStructureID.Value)).Select(p => new { p.ID, p.DateHire, p.StatusSyn, p.DateQuit }).ToList();

                                if (lstProfileQuitByJobTitleID.Where(s => s.DateQuit.Value.Month == 01).ToList() != null)
                                {
                                    countProfileQuit = lstProfileQuitByJobTitleID.Where(s => s.DateQuit.Value.Month == 01).ToList().Count();
                                    //   countingProfileQuit += countProfileQuit;
                                    totalQuit += countProfileQuit;
                                    row1[Hre_ReportMonthlyHCEntity.FieldNames.LeaJan] = countProfileQuit;
                                }
                                if (lstProfileQuitByJobTitleID.Where(s => s.DateQuit.Value.Month == 02).ToList() != null)
                                {
                                    countProfileQuit = lstProfileQuitByJobTitleID.Where(s => s.DateQuit.Value.Month == 02).ToList().Count();
                                    //    countingProfileQuit += countProfileQuit;
                                    totalQuit += countProfileQuit;
                                    row1[Hre_ReportMonthlyHCEntity.FieldNames.LeaFeb] = countProfileQuit;
                                }
                                if (lstProfileQuitByJobTitleID.Where(s => s.DateQuit.Value.Month == 03).ToList() != null)
                                {
                                    countProfileQuit = lstProfileQuitByJobTitleID.Where(s => s.DateQuit.Value.Month == 03).ToList().Count();
                                    //    countingProfileQuit += countProfileQuit;
                                    totalQuit += countProfileQuit;
                                    row1[Hre_ReportMonthlyHCEntity.FieldNames.LeaMar] = countProfileQuit;
                                }
                                if (lstProfileQuitByJobTitleID.Where(s => s.DateQuit.Value.Month == 04).ToList() != null)
                                {
                                    countProfileQuit = lstProfileQuitByJobTitleID.Where(s => s.DateQuit.Value.Month == 04).ToList().Count();
                                    //    countingProfileQuit += countProfileQuit;
                                    totalQuit += countProfileQuit;
                                    row1[Hre_ReportMonthlyHCEntity.FieldNames.LeaApr] = countProfileQuit;
                                }
                                if (lstProfileQuitByJobTitleID.Where(s => s.DateQuit.Value.Month == 05).ToList() != null)
                                {
                                    countProfileQuit = lstProfileQuitByJobTitleID.Where(s => s.DateQuit.Value.Month == 05).ToList().Count();
                                    //  countingProfileQuit += countProfileQuit;
                                    totalQuit += countProfileQuit;
                                    row1[Hre_ReportMonthlyHCEntity.FieldNames.LeaMay] = countProfileQuit;
                                }
                                if (lstProfileQuitByJobTitleID.Where(s => s.DateQuit.Value.Month == 06).ToList() != null)
                                {
                                    countProfileQuit = lstProfileQuitByJobTitleID.Where(s => s.DateQuit.Value.Month == 06).ToList().Count();
                                    //   countingProfileQuit += countProfileQuit;
                                    totalQuit += countProfileQuit;
                                    row1[Hre_ReportMonthlyHCEntity.FieldNames.LeaJun] = countProfileQuit;
                                }
                                if (lstProfileQuitByJobTitleID.Where(s => s.DateQuit.Value.Month == 07).ToList() != null)
                                {
                                    countProfileQuit = lstProfileQuitByJobTitleID.Where(s => s.DateQuit.Value.Month == 07).ToList().Count();
                                    //   countingProfileQuit += countProfileQuit;
                                    totalQuit += countProfileQuit;
                                    row1[Hre_ReportMonthlyHCEntity.FieldNames.LeaJul] = countProfileQuit;
                                }
                                if (lstProfileQuitByJobTitleID.Where(s => s.DateQuit.Value.Month == 08).ToList() != null)
                                {
                                    countProfileQuit = lstProfileQuitByJobTitleID.Where(s => s.DateQuit.Value.Month == 08).ToList().Count();
                                    // countingProfileQuit += countProfileQuit;
                                    totalQuit += countProfileQuit;
                                    row1[Hre_ReportMonthlyHCEntity.FieldNames.LeaAug] = countProfileQuit;
                                }
                                if (lstProfileQuitByJobTitleID.Where(s => s.DateQuit.Value.Month == 09).ToList() != null)
                                {
                                    countProfileQuit = lstProfileQuitByJobTitleID.Where(s => s.DateQuit.Value.Month == 09).ToList().Count();
                                    //  countingProfileQuit += countProfileQuit;
                                    totalQuit += countProfileQuit;
                                    row1[Hre_ReportMonthlyHCEntity.FieldNames.LeaSep] = countProfileQuit;
                                }
                                if (lstProfileQuitByJobTitleID.Where(s => s.DateQuit.Value.Month == 10).ToList() != null)
                                {
                                    countProfileQuit = lstProfileQuitByJobTitleID.Where(s => s.DateQuit.Value.Month == 10).ToList().Count();
                                    //  countingProfileQuit += countProfileQuit;
                                    totalQuit += countProfileQuit;
                                    row1[Hre_ReportMonthlyHCEntity.FieldNames.LeaOct] = countProfileQuit;
                                }
                                if (lstProfileQuitByJobTitleID.Where(s => s.DateQuit.Value.Month == 11).ToList() != null)
                                {
                                    countProfileQuit = lstProfileQuitByJobTitleID.Where(s => s.DateQuit.Value.Month == 11).ToList().Count();
                                    //  countingProfileQuit += countProfileQuit;
                                    totalQuit += countProfileQuit;
                                    row1[Hre_ReportMonthlyHCEntity.FieldNames.LeaNov] = countProfileQuit;
                                }
                                if (lstProfileQuitByJobTitleID.Where(s => s.DateQuit.Value.Month == 12).ToList() != null)
                                {
                                    countProfileQuit = lstProfileQuitByJobTitleID.Where(s => s.DateQuit.Value.Month == 12).ToList().Count();
                                    // countingProfileQuit += countProfileQuit;
                                    totalQuit += countProfileQuit;
                                    row1[Hre_ReportMonthlyHCEntity.FieldNames.LeaDec] = countProfileQuit;
                                }
                                row1[Hre_ReportMonthlyHCEntity.FieldNames.LeaYear] = totalQuit;
                                #endregion
                                //if (totalQuit == 0 && totalProfileWorking == 0)
                                //{
                                //    continue;
                                //}
                                //if (lstProfileQuitByJobTitleID.Count == 0 && lstProfileWorkingByJobTitleID.Count == 0)
                                //{
                                //    continue;
                                //}
                                if (!addTitle)
                                {
                                    table.Rows.Add(row);
                                    addTitle = true;
                                }
                                table.Rows.Add(row1);
                            }

                        }
                    }

                }

                DataRow datarow = table.NewRow();
                datarow[1] = "Total GT";

                for (int i = 3; i < table.Columns.Count; i++)
                {
                    int gt = 0;
                    for (int j = 0; j < table.Rows.Count; j++)
                    {
                        var valueRow = table.Rows[j][i].ToString();
                        if (!string.IsNullOrEmpty(valueRow) && !string.IsNullOrWhiteSpace(valueRow))
                        {
                            var value = int.Parse(valueRow);
                            if (value >= 0)
                            {
                                gt += value;

                            }
                        }
                    }
                    datarow[i] = gt;
                }

                table.Rows.Add(datarow);
                return table;
            }
        }