Exemple #1
0
 public ActionResult UpdateWorkingPosition(string selectedIds)
 {
     var service = new Hre_StopWorkingServices();
     var message = service.UpdateWorkingPosition(selectedIds, UserLogin);
     return Json(message);
 }
Exemple #2
0
        // Xuất template đăng ký tạm hoãn theo mẫu word
        public ActionResult ExportListSuspenseByTemplate(List<Guid> selectedIds, string valueFields)
        {
            DateTime DateStart = DateTime.Now;
            string messages = string.Empty;
            string dirpath = Common.GetPath(Common.DownloadURL); ;
            if (!Directory.Exists(dirpath))
                Directory.CreateDirectory(dirpath);

            string status = string.Empty;
            var contractServices = new Hre_StopWorkingServices();
            var actionService = new ActionService(UserLogin);
            var objs = new List<object>();
            string strIDs = string.Empty;
            foreach (var item in selectedIds)
            {
                strIDs += Common.DotNetToOracle(item.ToString()) + ",";
            }
            if (strIDs.IndexOf(",") > 0)
                strIDs = strIDs.Substring(0, strIDs.Length - 1);
            objs.Add(strIDs);
            var lstStopWorking = actionService.GetData<Hre_StopWorkingEntity>(objs, ConstantSql.hrm_hr_sp_get_StopWorkingByListId, ref status);
            if (lstStopWorking == null)
                return null;
            int i = 0;
            var lstStopWorkingID = lstStopWorking.Select(s => s.ID).Distinct().ToList();
            String suffix = DateStart.ToString("_ddMMyyyyHHmmss");
            string folferPath = string.Empty;
            string folderName = "ExportHre_Contract" + suffix;
            var objContract = new List<object>();
            objContract.AddRange(new object[21]);
            objContract[19] = 1;
            objContract[20] = int.MaxValue - 1;
            var lstContract = actionService.GetData<Hre_ContractEntity>(objContract, ConstantSql.hrm_hr_sp_get_Contract, ref status).ToList();

            var objAppendixContarct = new List<object>();
            objAppendixContarct.AddRange(new object[7]);
            objAppendixContarct[5] = 1;
            objAppendixContarct[6] = int.MaxValue - 1;
            var lstAppendixContract = actionService.GetData<Hre_AppendixContractEntity>(objAppendixContarct, ConstantSql.hrm_hr_sp_get_AppendixContract, ref status).ToList();
            if (lstStopWorkingID.Count > 1)
            {
                folferPath = dirpath + "/" + folderName;
                Directory.CreateDirectory(folferPath);
            }
            else
            {
                folferPath = dirpath;
            }
            var fileDoc = string.Empty;
            foreach (var stopWorking in lstStopWorking)
            {
                var contractEntity = lstContract.Where(s => s.ProfileID == stopWorking.ProfileID.Value).OrderByDescending(s => s.DateUpdate).FirstOrDefault();

                var exportService = new Cat_ExportServices();
                Cat_ExportEntity template = null;
                string outputPath = string.Empty;
                List<object> lstObjExport = new List<object>();
                lstObjExport.Add(null);
                lstObjExport.Add(null);
                lstObjExport.Add(null);
                lstObjExport.Add(null);
                lstObjExport.Add(1);
                lstObjExport.Add(10000000);

                template = actionService.GetData<Cat_ExportEntity>(Guid.Parse(valueFields), ConstantSql.hrm_cat_sp_get_ExportById, ref status).FirstOrDefault();
                if (contractEntity != null)
                {
                    var appendixContract = lstAppendixContract.Where(s => s.ContractID == contractEntity.ID).OrderByDescending(s => s.DateUpdate).FirstOrDefault();
                    stopWorking.ContractTypeName = contractEntity.ContractTypeName;
                    stopWorking.DateStartFormat = contractEntity.DateStart.ToString("dd/MM/yyyy");
                    stopWorking.Salary = contractEntity.Salary != null ? contractEntity.Salary : 0;
                    stopWorking.ContractNo = contractEntity.ContractNo != null ? contractEntity.ContractNo : string.Empty;
                    stopWorking.YearOfBirth = contractEntity.YearOfBirth;
                    stopWorking.MonthOfBirth = contractEntity.MonthOfBirth;
                    stopWorking.DayOfBirth = contractEntity.DayOfBirth;

                    if (contractEntity.DateSigned.HasValue)
                    {
                        stopWorking.DateSignedFormat = contractEntity.DateSigned.Value.ToString("dd/MM/yyyy");
                    }

                    if (contractEntity.DateEnd.HasValue)
                    {
                        stopWorking.DateEndFormat = contractEntity.DateEnd.Value.ToString("dd/MM/yyyy");
                    }


                    if (appendixContract != null)
                    {
                        if (appendixContract.DateEndAppendixContract.HasValue)
                        {
                            stopWorking.DateEndAppendixContractFormat = appendixContract.DateEndAppendixContract.Value.ToString("dd/MM/yyyy");
                        }
                    }
                }
                if (stopWorking.RequestDate.HasValue)
                {
                    stopWorking.RequestDateString = stopWorking.RequestDate.Value.ToString("dd/MM/yyyy");
                }

                if (stopWorking.DateStop.HasValue)
                {
                    stopWorking.DateStopString = stopWorking.DateStop.Value.ToString("dd/MM/yyyy");
                }

                if (stopWorking.DateComeBack.HasValue)
                {
                    stopWorking.DateComeBackString = stopWorking.DateComeBack.Value.ToString("dd/MM/yyyy");
                }

                if (stopWorking.DateExpired.HasValue)
                {
                    stopWorking.DateExpiredString = stopWorking.DateExpired.Value.ToString("dd/MM/yyyy");
                }

                if (stopWorking.DateHire.HasValue)
                {
                    stopWorking.DateHireString = stopWorking.DateHire.Value.ToString("dd/MM/yyyy");
                }

                if (template == null)
                {
                    messages = "Error";
                    return Json(messages, JsonRequestBehavior.AllowGet);
                }

                string templatepath = Common.GetPath(Common.TemplateURL + template.TemplateFile);

                if (!System.IO.File.Exists(templatepath))
                {
                    messages = "NotTemplate";
                    return Json(messages, JsonRequestBehavior.AllowGet);
                }
                outputPath = folferPath + "/" + Common.ChuyenTVKhongDau(stopWorking.ProfileName) + suffix + i.ToString() + "_" + template.TemplateFile;
                fileDoc = NotificationType.Success.ToString() + "," + Common.DownloadURL + "/" + Common.ChuyenTVKhongDau(stopWorking.ProfileName) + suffix + i.ToString() + "_" + template.TemplateFile;
                if (!System.IO.File.Exists(templatepath))
                {
                    messages = "NotTemplate";
                    return Json(messages, JsonRequestBehavior.AllowGet);
                }
                var lststopWorking = new List<Hre_StopWorkingEntity>();
                lststopWorking.Add(stopWorking);
                ExportService.ExportWord(outputPath, templatepath, lststopWorking);
            }
            if (lstStopWorkingID.Count > 1)
            {
                var fileZip = Common.MultiExport("", true, folderName);
                return Json(fileZip);
            }
            return Json(fileDoc);
        }
Exemple #3
0
 public ActionResult ApproveComBack(string selectedIds)
 {
     var service = new Hre_StopWorkingServices();
     var message = service.ActionApprovedComeBack(selectedIds, UserLogin);
     return Json(message);
 }
Exemple #4
0
 public ActionResult CancelStopWorking(string selectedIds)
 {
     var service = new Hre_StopWorkingServices();
     var message = service.ActionCancel(selectedIds, UserLogin);
     return Json(message);
 }
Exemple #5
0
 public ActionResult ActionCancelComback(string selectedIds)
 {
     var service = new Hre_StopWorkingServices();
     var message = service.ActionCancelComback(selectedIds);
     return Json(message);
 }
Exemple #6
0
        public DataTable GetReportTraineeJoinCourse(Guid[] rankIds, string[] courseIds, string orderNumber, bool IsCreateTemplate, DateTime? dateSeniory, string UserLogin)
        {

            DataTable table = CreateReportTraineeJoinCourseSchema();
            if (IsCreateTemplate)
            {
                return table;
            }
            using (var context = new VnrHrmDataContext())
            {
                string status = string.Empty;

                var dateCheck = DateTime.Now;
                //var dateSeniotyConfig = "31/03/N";
                // var strDateSeniorty = dateSeniotyConfig.Split('/');
                var dateCheckConfig = DateTime.Now;

                //if (dateCheckConfig.Day <= int.Parse(strDateSeniorty[0]) && dateCheckConfig.Month <= int.Parse(strDateSeniorty[1]))
                //{
                //    dateCheckConfig = new DateTime(dateCheckConfig.Year - 1, dateCheckConfig.Month, dateCheckConfig.Day);
                //}
                if (dateSeniory != null)
                {
                    dateCheckConfig = dateSeniory.Value;
                }

                var profileServices = new Hre_ProfileServices();
                var objProfile = new List<object>();
                objProfile.AddRange(new object[17]);
                objProfile[2] = orderNumber;
                objProfile[15] = 1;
                objProfile[16] = int.MaxValue - 1;
                //objProfile.Add(orderNumber);
                //objProfile.Add(null);
                //objProfile.Add(null);
                var lstProfile = profileServices.GetData<Hre_ProfileEntity>(objProfile, ConstantSql.hrm_hr_sp_get_ProfileAll, UserLogin, ref status).Where(s => s.DateQuit == null).ToList();
                //var lstProfile = profileServices.GetData<Hre_ProfileEntity>(objProfile, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, ref status).ToList();
                var lstProfileID = lstProfile.Select(s => s.ID).ToList();

                var orgsService = new Cat_OrgStructureServices();
                var objOrg = new List<object>();
                objOrg.AddRange(new object[5]);
                objOrg[3] = 1;
                objOrg[4] = int.MaxValue - 1;
                var lstallorgs = orgsService.GetData<Cat_OrgStructureEntity>(objOrg, ConstantSql.hrm_cat_sp_get_OrgStructure, UserLogin, ref status).ToList();

                var courseServices = new Tra_CourseServices();
                var objCourse = new List<object>();
                objCourse.AddRange(new object[11]);
                objCourse[9] = 1;
                objCourse[10] = int.MaxValue - 1;
                var lstCourse = courseServices.GetData<Tra_CourseEntity>(objCourse, ConstantSql.hrm_tra_sp_get_Course, UserLogin, ref status).ToList();
                if (courseIds != null)
                {
                    lstCourse = lstCourse.Where(s => courseIds.Contains(s.Code)).ToList();
                }

                var jobTitleServices = new Cat_JobTitleServices();
                var objJobtitle = new List<object>();
                objJobtitle.Add(null);
                objJobtitle.Add(null);
                objJobtitle.Add(null);
                objJobtitle.Add(1);
                objJobtitle.Add(int.MaxValue - 1);
                var lstJobtitle = jobTitleServices.GetData<Cat_JobTitleEntity>(objJobtitle, ConstantSql.hrm_cat_sp_get_JobTitle, UserLogin, ref status).ToList();

                var classServices = new Tra_ClassServices();
                var objClass = new List<object>();
                objClass.Add(null);
                objClass.Add(null);
                objClass.Add(null);
                objClass.Add(null);
                objClass.Add(null);
                objClass.Add(null);
                objClass.Add(null);
                objClass.Add(null);
                objClass.Add(1);
                objClass.Add(int.MaxValue - 1);
                var lstClass = classServices.GetData<Tra_ClassEntity>(objClass, ConstantSql.hrm_tra_sp_get_Class, UserLogin, ref status).ToList();

                var salaryClassServices = new Cat_SalaryClassServices();
                var objSalaryClass = new List<object>();
                objSalaryClass.Add(null);
                objSalaryClass.Add(1);
                objSalaryClass.Add(int.MaxValue - 1);
                var lstSalaryClass = salaryClassServices.GetData<Cat_SalaryClassEntity>(objSalaryClass, ConstantSql.hrm_cat_sp_get_SalaryClass, UserLogin, ref status).ToList();
                if (rankIds != null)
                {
                    lstSalaryClass = lstSalaryClass.Where(s => rankIds.Contains(s.ID)).ToList();
                }

                var rankServices = new Cat_SalaryRankServices();
                var objRank = new List<object>();
                objRank.Add(null);
                objRank.Add(null);
                objRank.Add(1);
                objRank.Add(int.MaxValue - 1);
                var lstRank = rankServices.GetData<Cat_SalaryRankEntity>(objRank, ConstantSql.hrm_cat_sp_get_SalaryRank, UserLogin, ref status).ToList();

                var traineeServices = new Tra_TraineeServices();
                var objTrainee = new List<object>();
                objTrainee.AddRange(new object[15]);
                objTrainee[13] = 1;
                objTrainee[14] = int.MaxValue - 1;
                var lstTrainee = rankServices.GetData<Tra_TraineeEntity>(objTrainee, ConstantSql.hrm_tra_sp_get_Trainee, UserLogin, ref status).ToList();

                var workingHistoryServices = new Hre_WorkHistoryServices();
                var objWorking = new List<object>();
                objWorking.AddRange(new object[17]);
                objWorking[15] = 1;
                objWorking[16] = int.MaxValue - 1;
                var lstWorking = workingHistoryServices.GetData<Hre_WorkHistoryEntity>(objWorking, ConstantSql.hrm_hr_sp_get_WorkHistory, UserLogin, ref status).ToList();


                var stopWorkingServices = new Hre_StopWorkingServices();
                var objStopWorking = new List<object>();
                objStopWorking.AddRange(new object[17]);
                objStopWorking[15] = 1;
                objStopWorking[16] = int.MaxValue - 1;
                var lstStopWorking = stopWorkingServices.GetData<Hre_StopWorkingEntity>(objStopWorking, ConstantSql.hrm_hr_sp_get_StopWorking, UserLogin, ref status).ToList();

                var traineeCertificateServices = new Tra_TraineeCertificateServices();
                var objTraineeCertificate = new List<object>();
                objTraineeCertificate.Add(1);
                objTraineeCertificate.Add(int.MaxValue - 1);
                var lstTraineeCertificate = traineeCertificateServices.GetData<Tra_TraineeCertificateEntity>(objTraineeCertificate, ConstantSql.hrm_tra_sp_get_TraineeCertificate, UserLogin, ref status).ToList();
                var lstTraineeIDFromTraineeCertificate = lstTraineeCertificate.Select(s => s.TraineeID).ToList();

                var requirmentDetailServices = new Tra_RequirementTrainDetailServices();
                var objRequirementDetail = new List<object>();
                objRequirementDetail.Add(null);
                objRequirementDetail.Add(1);
                objRequirementDetail.Add(int.MaxValue - 1);
                var lstRequirementDetail = requirmentDetailServices.GetData<Tra_RequirementTrainDetailEntity>(objRequirementDetail, ConstantSql.hrm_tra_sp_get_RequirementDetail, UserLogin, ref status).ToList();

                //if(lstTrainee != null)
                //{
                //    lstTrainee = lstTrainee.Where(s => lstProfileID.Contains(s.ProfileID)).ToList();
                //}

                if (lstTraineeCertificate != null)
                {
                    lstTrainee = lstTrainee.Where(s => !lstTraineeIDFromTraineeCertificate.Contains(s.ID)).ToList();
                }

                foreach (var item in lstCourse)
                {
                    string[] arrCourse = new string[1];
                    if (!string.IsNullOrEmpty(item.CourseListID))
                    {
                        arrCourse = item.CourseListID.Split(',').ToArray();
                    }

                    string[] arrJobtitle = new string[1];
                    int[] arrOrg = new int[1];
                    if (!string.IsNullOrEmpty(item.JobTitleListCode1))
                    {
                        arrJobtitle = item.JobTitleListCode1.Split(',').ToArray();
                    }
                    if (!string.IsNullOrEmpty(item.OrgListCode1))
                    {
                        arrOrg = item.OrgListCode1.Split(',').Select(s => int.Parse(s)).ToArray();
                    }

                    var lstJobtitleByJobtitleCode = lstJobtitle.Where(s => arrJobtitle.Contains(s.Code)).Select(s => s.ID).ToList();
                    var lstOrgByOrderNumber = lstallorgs.Where(s => arrOrg.Contains(s.OrderNumber)).Select(s => s.ID).ToList();
                    string[] _ranklistID = new string[1];
                    if (!string.IsNullOrEmpty(item.RankListID))
                    {
                        _ranklistID = item.RankListID.Split(',').ToArray();
                    }

                    // var lstClassByCourseID = lstClass.Where(s => s.CourseID == item.ID && arrCourse.Contains(s.CourseID)).ToList();
                    var salaryClassEntity = lstSalaryClass.Where(s => _ranklistID.Contains(s.Code)).ToList();
                    var lstSalaryClassID = salaryClassEntity.Select(s => s.ID).ToList();

                    var lstTraineePassedCourse = new List<Tra_TraineeEntity>();
                    // var lstTraineeForProfile = lstProfile.Where(s => s.CodeEmp == "M26423");
                    if (arrCourse[0] != null)
                    {
                        lstTraineePassedCourse = lstTrainee.Where(s => arrCourse.Contains(s.CourseCode) && s.Status == EnumDropDown.TraineeStatus.E_PASSED.ToString()).ToList();
                        int soLuongKhoaTienQUyet = arrCourse.Count();
                        var lstCheckTraineePassedCourse = lstTraineePassedCourse.GroupBy(m => m.ProfileID).Where(m => m.Count() >= soLuongKhoaTienQUyet).ToList();
                        var lstProfileIDPassedCourse = lstCheckTraineePassedCourse.Select(s => s.Key).Distinct().ToList();
                        lstProfile = lstProfile.Where(s => lstProfileIDPassedCourse.Contains(s.ID)).ToList();
                    }

                    foreach (var profileEntity in lstProfile)
                    {
                        var traineePassCourse = lstTrainee.Where(s => s.CourseID == item.ID && profileEntity.ID == s.ProfileID && s.Status == EnumDropDown.TraineeStatus.E_PASSED.ToString()).FirstOrDefault();
                        if (traineePassCourse != null)
                        {
                            continue;
                        }
                        Guid? orgId = profileEntity.OrgStructureID;
                        //    var org = lstOrg.FirstOrDefault(s => s.ID == profileEntity.OrgStructureID);
                        //   var orgOrg = LibraryService.GetNearestParentEntity(orgId, OrgUnit.E_DEPARTMENT, lstOrg, lstOrgType);
                        DataRow dr = table.NewRow();
                        bool flag = false;
                        var lstTraineeByProfileID = lstTrainee.Where(s => s.ProfileID == profileEntity.ID && arrCourse.Contains(s.CourseCode)).ToList();
                        dr[Tra_ReportTraineeJoinCourseEntity.FieldNames.ID] = profileEntity.ID != null ? profileEntity.ID : Guid.Empty;
                        dr[Tra_ReportTraineeJoinCourseEntity.FieldNames.CodeEmp] = profileEntity.CodeEmp != null ? profileEntity.CodeEmp : string.Empty;
                        dr[Tra_ReportTraineeJoinCourseEntity.FieldNames.TraineeName] = profileEntity.ProfileName != null ? profileEntity.ProfileName : string.Empty;
                        dr[Tra_ReportTraineeJoinCourseEntity.FieldNames.IDNo] = profileEntity.IDNo != null ? profileEntity.IDNo : string.Empty;
                        dr[Tra_ReportTraineeJoinCourseEntity.FieldNames.OrgStructureName] = profileEntity.OrgStructureName != null ? profileEntity.OrgStructureName : string.Empty;
                        dr[Tra_ReportTraineeJoinCourseEntity.FieldNames.E_UNIT] = profileEntity.E_UNIT != null ? profileEntity.E_UNIT : string.Empty;
                        dr[Tra_ReportTraineeJoinCourseEntity.FieldNames.E_DIVISION] = profileEntity.E_DIVISION != null ? profileEntity.E_DIVISION : string.Empty;
                        dr[Tra_ReportTraineeJoinCourseEntity.FieldNames.E_DEPARTMENT] = profileEntity.E_DEPARTMENT != null ? profileEntity.E_DEPARTMENT : string.Empty;
                        dr[Tra_ReportTraineeJoinCourseEntity.FieldNames.E_SECTION] = profileEntity.E_SECTION != null ? profileEntity.E_SECTION : string.Empty;
                        dr[Tra_ReportTraineeJoinCourseEntity.FieldNames.E_TEAM] = profileEntity.E_TEAM != null ? profileEntity.E_TEAM : string.Empty;
                        dr[Tra_ReportTraineeJoinCourseEntity.FieldNames.JobTitleName] = profileEntity.JobTitleName != null ? profileEntity.JobTitleName : string.Empty;
                        dr[Tra_ReportTraineeJoinCourseEntity.FieldNames.PositionName] = profileEntity.PositionName != null ? profileEntity.PositionName : string.Empty;
                        dr[Tra_ReportTraineeJoinCourseEntity.FieldNames.CourseName] = item.CourseName != null ? item.CourseName : string.Empty;

                        //var profileEntity = lstProfile.Where(s => s.ID == trainee.ProfileID && s.SalaryClassID != null).FirstOrDefault();
                        var stopWorkingEntity = lstStopWorking.Where(s => s.ProfileID.Value == profileEntity.ID).OrderByDescending(s => s.DateUpdate).FirstOrDefault();

                        //var workingEntity = new Hre_WorkHistoryEntity();
                        var lstWorkingByProfileID = lstWorking.Where(s => s.ProfileID == profileEntity.ID && lstSalaryClassID.Contains(s.SalaryClassID == null ? Guid.Empty : s.SalaryClassID.Value)).ToList();
                        if (lstJobtitleByJobtitleCode.Count > 0)
                        {
                            lstWorkingByProfileID = lstWorkingByProfileID.Where(s => lstJobtitleByJobtitleCode.Contains(s.JobTitleID != null ? s.JobTitleID.Value : Guid.Empty)).ToList();

                        }
                        if (lstOrgByOrderNumber.Count > 0)
                        {
                            lstWorkingByProfileID = lstWorkingByProfileID.Where(s => lstOrgByOrderNumber.Contains(s.OrganizationStructureID != null ? s.OrganizationStructureID.Value : Guid.Empty)).ToList();
                        }
                        var workingEntity = lstWorkingByProfileID.OrderByDescending(s => s.DateUpdate).FirstOrDefault();

                        var dateSuspend = new TimeSpan();
                        var dateSeniority = new TimeSpan();
                        double dateResult = 0;
                        double monthSeniority = 0;
                        if (profileEntity.DateHire == null)
                        {
                            continue;
                        }
                        dateSeniority = dateCheckConfig.Subtract(profileEntity.DateHire.Value);

                        if (stopWorkingEntity != null && stopWorkingEntity.DateStop != null && stopWorkingEntity.DateComeBack != null)
                        {
                            dateSuspend = stopWorkingEntity.DateComeBack.Value.Subtract(stopWorkingEntity.DateStop.Value);
                            dateResult = dateSeniority.Subtract(dateSuspend).TotalDays / 30;
                            monthSeniority = Math.Floor(dateResult);
                        }

                        dateSeniority = dateCheckConfig.Subtract(profileEntity.DateHire.Value);
                        monthSeniority = Math.Floor(dateSeniority.TotalDays / 30);

                        dr[Tra_ReportTraineeJoinCourseEntity.FieldNames.Seniority] = monthSeniority;


                        #region KT điều kiện seniority và maxSeniority != null
                        if (item.Seniority != null && item.MaxSeniority != null)
                        {
                            if (monthSeniority >= item.Seniority && item.MaxSeniority >= monthSeniority)
                            {

                                if (salaryClassEntity != null)
                                {
                                    if (workingEntity != null)
                                    {
                                        // if (profileEntity.SalaryClassID != workingEntity.SalaryClassID)
                                        // {
                                        var dateCheckRank = dateCheck.Subtract(workingEntity.DateEffective).TotalDays / 30;
                                        var monthRank = Math.Floor(dateCheckRank);
                                        if (item.TimeOnCurrentRank != null)
                                        {
                                            if (monthRank < item.TimeOnCurrentRank)
                                            {
                                                flag = true;
                                                // table.Rows.Add(dr);
                                            }
                                        }

                                        //}

                                    }
                                }

                            }
                            else
                            {
                                flag = true;
                            }
                        }
                        #endregion

                        #region KT điều kiện seniority != null && maxSeniority == null
                        if (item.Seniority != null && item.MaxSeniority == null)
                        {
                            if (monthSeniority >= item.Seniority)
                            {
                                if (salaryClassEntity != null)
                                {
                                    if (workingEntity != null)
                                    {
                                        //  if (profileEntity.SalaryClassID != workingEntity.SalaryClassID)
                                        // {
                                        var dateCheckRank = dateCheck.Subtract(workingEntity.DateEffective).TotalDays / 30;
                                        var monthRank = Math.Floor(dateCheckRank);
                                        if (item.TimeOnCurrentRank != null)
                                        {
                                            if (monthRank < item.TimeOnCurrentRank)
                                            {
                                                flag = true;
                                                //  table.Rows.Add(dr);
                                            }
                                        }
                                        // }
                                    }
                                }
                            }
                            else
                            {
                                flag = true;
                            }
                        }
                        #endregion

                        #region KT điều kiện seniority == && maxSeniority != null
                        if (item.MaxSeniority != null && item.Seniority == null)
                        {
                            if (monthSeniority <= item.MaxSeniority)
                            {
                                if (salaryClassEntity != null)
                                {
                                    if (workingEntity != null)
                                    {
                                        // if (profileEntity.SalaryClassID != workingEntity.SalaryClassID)
                                        // {
                                        var dateCheckRank = dateCheck.Subtract(workingEntity.DateEffective).TotalDays / 30;
                                        var monthRank = Math.Floor(dateCheckRank);
                                        if (item.TimeOnCurrentRank != null)
                                        {
                                            if (item.TimeOnCurrentRank != null)
                                            {
                                                if (monthRank < item.TimeOnCurrentRank)
                                                {
                                                    flag = true;
                                                    // table.Rows.Add(dr);
                                                }
                                            }

                                        }

                                        //}

                                    }
                                }
                            }
                            else
                            {
                                flag = true;
                            }

                        }
                        #endregion

                        //#region kiem tra dk Seniority == null và MaxSeniority == null
                        //if (item.Seniority == null && item.MaxSeniority == null)
                        //{
                        //    if (salaryClassEntity != null)
                        //    {
                        //        if (workingEntity != null)
                        //        {
                        //           // if (profileEntity.SalaryClassID != workingEntity.SalaryClassID)
                        //           // {
                        //                var dateCheckRank = dateCheck.Subtract(workingEntity.DateEffective).TotalDays / 30;
                        //                var monthRank = Math.Floor(dateCheckRank);
                        //                if (item.TimeOnCurrentRank != null)
                        //                {
                        //                    if (item.TimeOnCurrentRank != null)
                        //                    {
                        //                        if (monthRank < item.TimeOnCurrentRank)
                        //                        {
                        //                            flag = true;
                        //                          //  table.Rows.Add(dr);
                        //                        }
                        //                    }

                        //                }
                        //            //}

                        //        }
                        //    }
                        //}
                        //#endregion


                        if (lstTraineeByProfileID.Count > 0)
                        {
                            foreach (var traineeEntity in lstTraineeByProfileID)
                            {
                                // dr[Tra_ReportTraineeJoinCourseEntity.FieldNames.Note] = traineeEntity.TeacherComment != null ? traineeEntity.TeacherComment : string.Empty;
                                double monthCourse = Math.Floor(dateCheck.Subtract(traineeEntity.EndDate.Value).TotalDays / 30);
                                var traineeInRequirementDetail = lstRequirementDetail.Where(s => s.CourseID == traineeEntity.ID && traineeEntity.ID == s.ProfileID && s.YearAnalyze != null && s.YearAnalyze.Value.Year == dateCheckConfig.Year).ToList();

                                if (traineeInRequirementDetail.Count >= 1)
                                {
                                    flag = true;
                                    continue;
                                }
                                if (traineeEntity.EndDate == null)
                                {
                                    flag = true;
                                    continue;
                                }

                                if (item.DurationMinCourse != null)
                                {
                                    if (monthCourse < item.DurationMinCourse)
                                    {
                                        flag = true;
                                        continue;
                                    }

                                }
                            }
                        }
                        else
                        {
                            var traineeInRequirementDetail = lstRequirementDetail.Where(s => s.CourseID == item.ID && profileEntity.ID == s.ProfileID && s.YearAnalyze != null && s.YearAnalyze.Value.Year == dateCheckConfig.Year).ToList();
                            if (traineeInRequirementDetail.Count >= 1)
                            {
                                flag = true;
                                continue;
                            }

                        }


                        if (flag == false)
                        {
                            if (salaryClassEntity != null)
                            {
                                if (workingEntity != null)
                                {
                                    // if (profileEntity.SalaryClassID != workingEntity.SalaryClassID)
                                    // {
                                    var dateCheckRank = dateCheck.Subtract(workingEntity.DateEffective).TotalDays / 30;
                                    var monthRank = Math.Floor(dateCheckRank);
                                    if (item.TimeOnCurrentRank != null)
                                    {
                                        if (item.TimeOnCurrentRank != null)
                                        {
                                            if (monthRank >= item.TimeOnCurrentRank)
                                            {
                                                flag = true;
                                                table.Rows.Add(dr);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        table.Rows.Add(dr);
                                    }
                                    // }
                                }
                            }
                        }
                    }
                }
            }

            return table;
        }
Exemple #7
0
        public DataTable GetReportProfile(List<Hre_ProfileEntity> lstprofile, Guid _CutOffDurationID, string UserLogin)
        {


            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (UnitOfWork)(new UnitOfWork(context));
                DataTable table = CreateReportProfileScheme();
                if (lstprofile == null)
                    return table;
                //var repoCat_OrgStructure = new Cat_OrgStructureRepository(unitOfWork);
                //var repoCat_OrgStructureType = new Cat_OrgStructureTypeRepository(unitOfWork);
                //var orgs = repoCat_OrgStructure.FindBy(s => s.Code != null).ToList();
                //var orgTypes = repoCat_OrgStructureType.FindBy(s => s.IsDelete == null).ToList();

                //hop dong
                string status = string.Empty;
                var hreServiceContract = new Hre_ContractServices();
                List<object> paraContract = new List<object>();
                paraContract.AddRange(new object[21]);
                paraContract[19] = 1;
                paraContract[20] = int.MaxValue;
                var lstContract = hreServiceContract.GetData<Hre_ContractEntity>(paraContract, ConstantSql.hrm_hr_sp_get_Contract, UserLogin, ref status);
                //ky cong
                string cutoff = Common.DotNetToOracle(_CutOffDurationID.ToString());
                var baseService = new BaseService();
                var objAtt_CutOffDurationEntity = baseService
                    .GetData<Att_CutOffDurationEntity>(cutoff, ConstantSql.hrm_att_sp_get_CutOffDurationById, UserLogin, ref status)
                    .FirstOrDefault();
                //
                DateTime _dateFrom = DateTime.MinValue;
                DateTime _dateTo = DateTime.MaxValue;
                if (objAtt_CutOffDurationEntity != null)
                {
                    if (objAtt_CutOffDurationEntity.DateStart != null)
                        _dateFrom = objAtt_CutOffDurationEntity.DateStart;
                    if (objAtt_CutOffDurationEntity.DateEnd != null)
                        _dateTo = objAtt_CutOffDurationEntity.DateEnd;
                }
                var salServiceBasicSalary = new Sal_BasicSalaryServices();
                List<object> paraBasicSalary = new List<object>();
                paraBasicSalary.AddRange(new object[4]);
                paraBasicSalary[0] = _dateFrom;
                paraBasicSalary[1] = _dateTo;
                paraBasicSalary[2] = 1;
                paraBasicSalary[3] = int.MaxValue - 1;
                var lstBasicSalary = salServiceBasicSalary.GetData<Sal_BasicSalaryEntity>(paraBasicSalary, ConstantSql.hrm_sal_sp_getdata_BasicSalaryByCutOff, UserLogin, ref status);
                //Hre_ProfilePartyUnion
                var repoHre_ProfilePartyUnion = new Hre_ProfilePartyUnionRepository(unitOfWork);
                var lstProfilePartyUnion = repoHre_ProfilePartyUnion.FindBy(s => s.IsDelete == null && s.IsTradeUnionist == true && s.YouthUnionEnrolledDate <= _dateTo).ToList();
                //Hre_StopWorking
                List<object> paraStopWorking = new List<object>();
                paraStopWorking.AddRange(new object[17]);
                paraStopWorking[6] = _dateFrom;
                paraStopWorking[7] = _dateTo;
                paraStopWorking[15] = 1;
                paraStopWorking[16] = int.MaxValue - 1;
                var hreServiceStopWorking = new Hre_StopWorkingServices();
                var lstStopWorking = hreServiceStopWorking.GetData<Hre_StopWorkingEntity>(paraStopWorking, ConstantSql.hrm_hr_sp_get_StopWorking, UserLogin, ref status);
                //Ins_ProfileInsuranceMonthly
                var repoProfileInsuranceMonthly = new Ins_ProfileInsuranceMonthlyRepository(unitOfWork);
                var lstProfileInsuranceMonthly = repoProfileInsuranceMonthly.FindBy(s => s.IsDelete == null && s.MonthYear >= _dateFrom && s.MonthYear <= _dateTo).ToList();

                foreach (var profile in lstprofile)
                {
                    if (profile != null)
                    {
                        var objContract = lstContract.Where(s => s.ProfileID == profile.ID).OrderByDescending(s => s.DateUpdate).FirstOrDefault();
                        var objBasicSalary = lstBasicSalary.Where(s => s.ProfileID == profile.ID).OrderByDescending(s => s.DateOfEffect).FirstOrDefault();
                        var objProfilePartyUnion = lstProfilePartyUnion.Where(s => s.ProfileID == profile.ID).OrderByDescending(s => s.YouthUnionEnrolledDate).FirstOrDefault();
                        var objStopWorking = lstStopWorking.Where(s => s.ProfileID == profile.ID).OrderByDescending(s => s.DateStop).FirstOrDefault();
                        var objProfileInsuranceMonthly = lstProfileInsuranceMonthly.Where(s => s.ProfileID == profile.ID).OrderByDescending(s => s.MonthYear).FirstOrDefault();
                        DataRow row = table.NewRow();
                        if (profile.CodeEmp != null)
                            row[Sal_ReportProfileEntity.FieldNames.CodeEmp] = profile.CodeEmp;
                        if (profile.ProfileName != null)
                            row[Sal_ReportProfileEntity.FieldNames.ProfileName] = profile.ProfileName;
                        if (profile.UnitNameOrg != null)
                            row[Sal_ReportProfileEntity.FieldNames.UnitNameOrg] = profile.UnitNameOrg;
                        if (profile.DepartmentNameOrg != null)
                            row[Sal_ReportProfileEntity.FieldNames.DepartmentNameOrg] = profile.DepartmentNameOrg;
                        if (profile.SectionNameOrg != null)
                            row[Sal_ReportProfileEntity.FieldNames.SectionNameOrg] = profile.SectionNameOrg;
                        if (profile.TeamNameOrg != null)
                            row[Sal_ReportProfileEntity.FieldNames.TeamNameOrg] = profile.TeamNameOrg;
                        if (profile.WorkPlaceName != null)
                            row[Sal_ReportProfileEntity.FieldNames.WorkPlaceName] = profile.WorkPlaceName;
                        if (profile.StatusSyn != null)
                            row[Sal_ReportProfileEntity.FieldNames.StatusSyn] = profile.StatusSyn;
                        if (objBasicSalary != null && objBasicSalary.SalaryClassName != null)
                            row[Sal_ReportProfileEntity.FieldNames.SalaryClassName] = objBasicSalary.SalaryClassName;
                        if (objBasicSalary != null && objBasicSalary.GrossAmount != null)
                            row[Sal_ReportProfileEntity.FieldNames.BasicSalary] = objBasicSalary.GrossAmount;
                        if (objBasicSalary != null && objBasicSalary.SalaryRankName != null)
                            row[Sal_ReportProfileEntity.FieldNames.SalaryRankName] = objBasicSalary.SalaryRankName;
                        if (profile.CostCentreCode != null)
                            row[Sal_ReportProfileEntity.FieldNames.CostCentreCode] = profile.CostCentreCode;
                        if (profile.IDNo != null)
                            row[Sal_ReportProfileEntity.FieldNames.IDNo] = profile.IDNo;
                        if (profile.DateOfBirth != null)
                            row[Sal_ReportProfileEntity.FieldNames.DateOfBirth] = profile.DateOfBirth;
                        if (profile.DateHire != null)
                            row[Sal_ReportProfileEntity.FieldNames.DateHire] = profile.DateHire;
                        if (objContract != null)
                        {
                            if (objContract.DateStart != null)
                                row[Sal_ReportProfileEntity.FieldNames.DateStart] = objContract.DateStart;
                            if (objContract.DateEnd != null)
                                row[Sal_ReportProfileEntity.FieldNames.DateEnd] = objContract.DateEnd;
                        }
                        //if (profile.WorkingPlace != null)
                        //    row[Sal_ReportProfileEntity.FieldNames.WorkingPlace] = profile.WorkingPlace;
                        if (objProfileInsuranceMonthly != null && objProfileInsuranceMonthly.IsUnEmpInsurance != null)
                            row[Sal_ReportProfileEntity.FieldNames.IsUnEmpInsurance] = objProfileInsuranceMonthly.IsUnEmpInsurance;
                        if (objProfileInsuranceMonthly != null && objProfileInsuranceMonthly.IsSocialInsurance != null)
                            row[Sal_ReportProfileEntity.FieldNames.IsSocialInsurance] = objProfileInsuranceMonthly.IsSocialInsurance;
                        if (objProfileInsuranceMonthly != null && objProfileInsuranceMonthly.IsHealthInsurance != null)
                            row[Sal_ReportProfileEntity.FieldNames.IsHealthInsurance] = objProfileInsuranceMonthly.IsHealthInsurance;
                        if (objProfilePartyUnion != null && objProfilePartyUnion.IsTradeUnionist != null)
                            row[Sal_ReportProfileEntity.FieldNames.IsTradeUnionist] = objProfilePartyUnion.IsTradeUnionist;
                        if (objStopWorking != null && objStopWorking.DateStop != null)
                            row[Sal_ReportProfileEntity.FieldNames.DateStop] = objStopWorking.DateStop;
                        if (profile.DateHire != null)
                            row[Sal_ReportProfileEntity.FieldNames.DateHire] = profile.DateHire;
                        table.Rows.Add(row);
                    }
                }
                return table.ConfigTable(true);
            }
        }