Exemplo n.º 1
0
 /// <summary>
 /// [Chuc.Nguyen] - Xóa hoặc chuyển đổi trạng thái của Ngân Hàng(Tra_Certificate) sang IsDelete
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public Tra_ClassModel DeleteOrRemove(string id)
 {
     var model = new Tra_ClassModel();
     ActionService service = new ActionService(UserLogin);
     var baseServices = new Tra_ClassServices();
     //var baseService = new BaseService();
     bool isDelete = true;
     string status = "";
     var idItem = id.Split(',');
     foreach (var item in idItem)
     {
         var idInt = Guid.Empty;
         Guid.TryParse(item, out idInt);
         if (idInt != Guid.Empty)
         {
             var objs = new List<object>();
             objs.Add(Guid.Parse(item));
             var result = baseServices.GetData<Tra_TraineeEntity>(objs, ConstantSql.hrm_cat_sp_get_TraineeByClassID, UserLogin, ref status);
             if (result != null && result.Count > 0)
             {
                 isDelete = false;
                 break;
             }
         }
     }
     if (isDelete)
         model = service.DeleteOrRemove<Tra_ClassEntity, Tra_ClassModel>(id);
     else
     {
         status = ConstantMessages.YouMustDeleteDetailRecord.TranslateString();
         model.SetPropertyValue(Constant.ActionStatus, status);
     }
     return model;
 }
Exemplo n.º 2
0
        public  string ApprovedTraineeRegister (List<Guid> selectedIds , Guid UserId)
        {
            using (var context = new VnrHrmDataContext())
            {
                var message = string.Empty;
                var status = string.Empty;
                var UserLogin = string.Empty;
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var firstApproved = EnumDropDown.TraineeRegisterStatus.E_SUBMIT.ToString();
                var approved = EnumDropDown.TraineeRegisterStatus.E_APPROVED.ToString();
                var objTraineeRegister = new List<object>();
                objTraineeRegister.AddRange(new object[12]);
                objTraineeRegister[10] = 1;
                objTraineeRegister[11] = int.MaxValue - 1;
                var lstTraineeRegister = GetData<Tra_TraineeRegisterEntity>(objTraineeRegister, ConstantSql.hrm_tra_sp_get_TraineeRegister,UserLogin, ref status).ToList();

               var repo_UserApproved = new CustomBaseRepository<Sys_UserApprove>(unitOfWork);
               var lstUserApproved = repo_UserApproved.GetAll().Where(s => s.IsDelete == null).ToList();

                if (selectedIds.Count > 0)
                {
                    lstTraineeRegister = lstTraineeRegister.Where(s => selectedIds.Contains(s.ID)).ToList();
                }

                var traineeServices = new Tra_TraineeServices();
                var isTraineeInRequireDetail = traineeServices.IsAddTraineeDependOnRequirementDetail();
                var traineeTopicServices = new Tra_TraineeTopicServices();
                var planServices = new Tra_PlanServices();
                var lstObjPlan = new List<object>();
                lstObjPlan.Add(null);
                lstObjPlan.Add(null);
                lstObjPlan.Add(null);
                lstObjPlan.Add(null);
                lstObjPlan.Add(1);
                lstObjPlan.Add(int.MaxValue - 1);
                var lstPlan = planServices.GetData<Tra_PlanEntity>(lstObjPlan, ConstantSql.hrm_tra_sp_get_Plan,UserLogin, ref status).ToList();


                var planDetailServices = new Tra_PlanDetailServices();
                var lstObjPlanDetail = new List<object>();
                lstObjPlanDetail.Add(null);
                lstObjPlanDetail.Add(1);
                lstObjPlanDetail.Add(int.MaxValue - 1);
                var lstPlanDetail = planDetailServices.GetData<Tra_PlanDetailEntity>(lstObjPlanDetail, ConstantSql.hrm_tra_sp_get_PlanDetail, UserLogin, ref status).ToList();

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

                //var lstObjTraineeInClass = new List<object>();
                //lstObjTraineeInClass.Add(model.ClassID);
                //var lstTraineeInClass = classServices.GetData<Tra_ClassEntity>(lstObjTraineeInClass, ConstantSql.hrm_cat_sp_get_TraineeByClassID, ref status).ToList();

                var courseTopicServices = new Tra_TraineeTopicServices();
                var objCourseTopic = new List<object>();
                objCourseTopic.Add(1);
                objCourseTopic.Add(int.MaxValue - 1);
                var lstCourseTopic = courseTopicServices.GetData<Tra_CourseTopicEntity>(objCourseTopic, ConstantSql.hrm_tra_sp_get_CourseTopic, UserLogin, ref status);


                //var classEntity = lstClass.Where(s => s.ID == model.ClassID).FirstOrDefault();
                var profileServices = new Hre_ProfileServices();

                var requirementServices = new Tra_RequirementTrainServices();
                var objRequirement = new List<object>();
                objRequirement.AddRange(new object[7]);
                objRequirement[5] = 1;
                objRequirement[6] = int.MaxValue - 1;
                var lstRequirement = requirementServices.GetData<Tra_RequirementTrainEntity>(objRequirement, ConstantSql.hrm_tra_sp_get_RequirementTrain, UserLogin, ref status).ToList();

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

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

                foreach (var registerEntity in lstTraineeRegister)
                {
                    var classEntity = lstClass.Where(s => s.ID == registerEntity.ClassID).FirstOrDefault();
                    var traineeEntityInClass = lstObjTrainee.Where(s => s.ClassID == registerEntity.ClassID && registerEntity.ProfileID == s.ProfileID).ToList();

                    #region người duyệt đầu
                    if (registerEntity.UserApproveID1 != null && registerEntity.UserApproveID1.Value == UserId)
                    {
                        var userApprovedEntity = lstUserApproved.Where(s => registerEntity.UserApproveID1.Value == s.UserApproveID && s.Type == ApproveType.E_TRA_TRAINEEREGISTER.ToString()).FirstOrDefault();
                        if (userApprovedEntity != null)
                        {
                            if (userApprovedEntity.IsMasterApprove == null || userApprovedEntity.IsMasterApprove.Value == false)
                            {
                                registerEntity.Status = firstApproved;
                                message = Edit(registerEntity);
                            }
                        }
                    }
	                #endregion

                    #region người duyệt cuối
                    if (registerEntity.UserApproveID2 != null && registerEntity.UserApproveID2.Value == UserId)
                    {
                        var userApprovedEntity = lstUserApproved.Where(s => registerEntity.UserApproveID2.Value == s.UserApproveID && s.Type == ApproveType.E_TRA_TRAINEEREGISTER.ToString()).FirstOrDefault();
                        if (userApprovedEntity != null)
                        {
                            if (userApprovedEntity.IsMasterApprove != null && userApprovedEntity.IsMasterApprove.Value)
                            {
                                #region Cập Nhập Status lại vào bảng Tra_TraineeRegister
                                registerEntity.Status = approved;
                                message = Edit(registerEntity);
                                #endregion

                                #region Tạo hv vào bảng Tra_Trainee

                                if (isTraineeInRequireDetail)
                                {
                                    if (traineeEntityInClass.Count > 0)
                                    {
                                        message = ConstantMessages.WarningProfileHaveClass.ToString().TranslateString();
                                        return message;
                                    }
                                    if (registerEntity.ClassID != null)
                                    {
                                        if (classEntity != null && classEntity.PlanID != null)
                                        {
                                            var lstRequirementByPlanID = lstRequirement.Where(s => s.PlanID != null && s.PlanID.Value == classEntity.PlanID).ToList();
                                            foreach (var item in lstRequirementByPlanID)
                                            {
                                                var requirementDetailEntity = lstRequirementDetail.Where(s => item.ID == s.RequirementTrainID && s.CourseID == classEntity.CourseID && s.ProfileID == item.ProfileID).FirstOrDefault();
                                                if (requirementDetailEntity != null)
                                                {
                                                    var traineeEntity = new Tra_TraineeEntity();
                                                    traineeEntity.ProfileID = registerEntity.ProfileID.Value;
                                                    traineeEntity.ClassID = registerEntity.ClassID.Value;
                                                    traineeEntity.TraineeRegisterID = (Guid?)registerEntity.ID;
                                                    traineeServices.Add(traineeEntity);

                                                    var lstCourseTopicByCourseID = lstCourseTopic.Where(s => s.CourseID == classEntity.CourseID).ToList();
                                                    foreach (var courseTopic in lstCourseTopicByCourseID)
                                                    {
                                                        var traineeTopicEntity = new Tra_TraineeTopicEntity();
                                                        traineeTopicEntity.TopicID = courseTopic.TopicID;
                                                        traineeTopicEntity.TraineeID = traineeEntity.ID;
                                                        message = traineeTopicServices.Add(traineeTopicEntity);
                                                    }

                                                }
                                                else
                                                {
                                                    message = ConstantMessages.WarningProfileNotInRequirement.ToString().TranslateString();
                                                }
                                            }
                                        }
                                    }
                                }

                                if (classEntity != null)
                                {
                                    if (traineeEntityInClass.Count > 0)
                                    {
                                        message = ConstantMessages.WarningProfileHaveClass.ToString().TranslateString();
                                        return message;
                                    }

                                    var traineeEntity = new Tra_TraineeEntity();
                                    traineeEntity.ProfileID = registerEntity.ProfileID.Value;
                                    traineeEntity.ClassID = registerEntity.ClassID.Value;
                                    traineeEntity.TraineeRegisterID = (Guid?)registerEntity.ID;
                                    traineeServices.Add(traineeEntity);

                                    var lstCourseTopicByCourseID = lstCourseTopic.Where(s => s.CourseID == classEntity.CourseID).ToList();
                                    foreach (var courseTopic in lstCourseTopicByCourseID)
                                    {
                                        var traineeTopicEntity = new Tra_TraineeTopicEntity();
                                        traineeTopicEntity.TopicID = courseTopic.TopicID;
                                        traineeTopicEntity.TraineeID = traineeEntity.ID;
                                        message = traineeTopicServices.Add(traineeTopicEntity);
                                    }



                                }
                                #endregion
                            }
                        }
                    }
                    #endregion

                }
                return message;
            }
            
        }
Exemplo n.º 3
0
        public Tra_TraineeModel Post([Bind]Tra_TraineeModel model)
        {
            #region Validate
            string message = string.Empty;
            var checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData<Tra_TraineeModel>(model, "Tra_Trainee", ref message);
            if (!checkValidate)
            {
                model.ActionStatus = message;
                return model;
            }
            #endregion
        
            var traineeServices = new Tra_TraineeServices();
            ActionService service = new ActionService(UserLogin);
            var isTraineeInRequireDetail = traineeServices.IsAddTraineeDependOnRequirementDetail();
            var traineeTopicServices = new Tra_TraineeTopicServices();
            var planServices = new Tra_PlanServices();
            var status = string.Empty;
            var lstObjPlan = new List<object>();
            lstObjPlan.Add(null);
            lstObjPlan.Add(null);
            lstObjPlan.Add(null);
            lstObjPlan.Add(null);
            lstObjPlan.Add(1);
            lstObjPlan.Add(int.MaxValue - 1);
            var lstPlan = planServices.GetData<Tra_PlanEntity>(lstObjPlan, ConstantSql.hrm_tra_sp_get_Plan, UserLogin, ref status).ToList();


            var planDetailServices = new Tra_PlanDetailServices();
            var lstObjPlanDetail = new List<object>();
            lstObjPlanDetail.Add(null);
            lstObjPlanDetail.Add(1);
            lstObjPlanDetail.Add(int.MaxValue - 1);
            var lstPlanDetail = planDetailServices.GetData<Tra_PlanDetailEntity>(lstObjPlanDetail, ConstantSql.hrm_tra_sp_get_PlanDetail, UserLogin, ref status).ToList();

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

            var lstObjTraineeInClass = new List<object>();
            lstObjTraineeInClass.Add(model.ClassID);
            var lstTraineeInClass = classServices.GetData<Tra_ClassEntity>(lstObjTraineeInClass, ConstantSql.hrm_cat_sp_get_TraineeByClassID, UserLogin, ref status).ToList();

            var courseTopicServices = new Tra_TraineeTopicServices();
            var objCourseTopic = new List<object>();
            objCourseTopic.Add(1);
            objCourseTopic.Add(int.MaxValue - 1);
            var lstCourseTopic = courseTopicServices.GetData<Tra_CourseTopicEntity>(objCourseTopic, ConstantSql.hrm_tra_sp_get_CourseTopic, UserLogin, ref status);


            var classEntity = lstClass.Where(s => s.ID == model.ClassID).FirstOrDefault();
            var profileServices = new Hre_ProfileServices();
            var profileEntity = profileServices.GetData<Hre_ProfileEntity>(model.ProfileID, ConstantSql.hrm_hr_sp_get_ProfileById, UserLogin, ref status).FirstOrDefault();

            var requirementServices = new Tra_RequirementTrainServices();
            var objRequirement = new List<object>();
            objRequirement.AddRange(new object[7]);
            objRequirement[5] = 1;
            objRequirement[6] = int.MaxValue - 1;
            var lstRequirement = requirementServices.GetData<Tra_RequirementTrainEntity>(objRequirement, ConstantSql.hrm_tra_sp_get_RequirementTrain, UserLogin, ref status).ToList();

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

            var objTrainee = new List<object>();
            objTrainee.AddRange(new object[15]);
            objTrainee[13] = 1;
            objTrainee[14] = int.MaxValue - 1;
            var lstObjTrainee = traineeServices.GetData<Tra_TraineeEntity>(objTrainee, ConstantSql.hrm_tra_sp_get_Trainee, UserLogin, ref status).ToList();
            var traineeEntity = lstObjTrainee.Where(s => s.ClassID == model.ClassID && model.ProfileID == s.ProfileID).ToList();

            #region Check Học Viên
            if(model.ID == Guid.Empty)
            {
                if (isTraineeInRequireDetail)
                {
                    if (traineeEntity.Count > 0)
                    {
                        model.ActionStatus = ConstantMessages.WarningProfileHaveClass.ToString().TranslateString();
                        return model;
                    }
                    if (classEntity != null)
                    {

                        if (classEntity.PlanID != null)
                        {
                            var lstRequirementByPlanID = lstRequirement.Where(s => s.PlanID != null && s.PlanID.Value == classEntity.PlanID).ToList();
                            foreach (var item in lstRequirementByPlanID)
                            {
                                var requirementDetailEntity = lstRequirementDetail.Where(s => item.ID == s.RequirementTrainID && s.CourseID == classEntity.CourseID && s.ProfileID == model.ProfileID).FirstOrDefault();
                                if (requirementDetailEntity != null)
                                {
                                    model = service.UpdateOrCreate<Tra_TraineeEntity, Tra_TraineeModel>(model);

                                    var lstCourseTopicByCourseID = lstCourseTopic.Where(s => s.CourseID == classEntity.CourseID).ToList();
                                    foreach (var courseTopic in lstCourseTopicByCourseID)
                                    {
                                        var traineeTopicEntity = new Tra_TraineeTopicEntity();
                                        traineeTopicEntity.TopicID = courseTopic.TopicID;
                                        traineeTopicEntity.TraineeID = model.ID;
                                        message = traineeTopicServices.Add(traineeTopicEntity);
                                    }
                                    // edit classID trong RequirementDetail
                                    requirementDetailEntity.ClassID = model.ClassID;
                                    message = requirementDetailServices.Edit(requirementDetailEntity);
                                }
                                else
                                {
                                    model.ActionStatus = ConstantMessages.WarningProfileNotInRequirement.ToString().TranslateString();
                                }
                            }
                        }
                        else
                        {
                            model.ActionStatus = ConstantMessages.WarningProfileNotInRequirement.ToString().TranslateString();
                        }
                        model.ActionStatus = ConstantMessages.WarningProfileNotInRequirement.ToString().TranslateString();
                    }
                    if (message == NotificationType.Success.ToString())
                    {
                        model.ActionStatus = message;
                    }
                    return model;

                    //if (classEntity != null)
                    //{
                    //    if (classEntity.PlanID != null)
                    //    {
                    //        var planEntity = lstPlan.Where(s => s.ID == classEntity.PlanID.Value).FirstOrDefault();
                    //        if (planEntity != null)
                    //        {
                    //            var lstPlanDetailByPlanID = lstPlanDetail.Where(s => s.PlanID == planEntity.ID).ToList();

                    //            foreach (var item in lstPlanDetailByPlanID)
                    //            {
                    //                var lstTraineeInClassForOrg = lstTraineeInClass.Where(s => s.OrgStructureID.Value == item.OrgStructureID.Value).ToList();
                    //                //Kiểm tra số lượng của plan detail với sumQuantity của plan
                    //                if (planEntity.SumQuantity == lstPlanDetailByPlanID.Sum(s => s.Quantity))
                    //                {
                    //                    if (lstTraineeInClass.Count < lstPlanDetailByPlanID.Sum(s => s.Quantity))
                    //                    {
                    //                        // Xử Lý kiểm tra nv có thuộc phòng ban trong plan detail ko
                    //                        if (profileEntity != null)
                    //                        {
                    //                            if (lstTraineeInClassForOrg.Count < item.Quantity)
                    //                            {
                    //                                if (profileEntity.OrgStructureID.Value == item.OrgStructureID.Value)
                    //                                {
                    //                                    var traineeEntity = new Tra_TraineeEntity();
                    //                                    model.OrgStructureID = profileEntity.OrgStructureID != null ? profileEntity.OrgStructureID.Value : profileEntity.OrgStructureID;

                    //                                    model = service.UpdateOrCreate<Tra_TraineeEntity, Tra_TraineeModel>(model);

                    //                                    var lstCourseTopicByCourseID = lstCourseTopic.Where(s => s.CourseID == classEntity.CourseID).ToList();
                    //                                    foreach (var courseTopic in lstCourseTopicByCourseID)
                    //                                    {
                    //                                        var traineeTopicEntity = new Tra_TraineeTopicEntity();
                    //                                        traineeTopicEntity.TopicID = courseTopic.TopicID;
                    //                                        traineeTopicEntity.TraineeID = model.ID;
                    //                                        message = traineeTopicServices.Add(traineeTopicEntity);
                    //                                    }
                    //                                    return model;  
                    //                                }
                    //                                model.ActionStatus = ConstantMessages.WarningProfileNotDependantOrgStructure.TranslateString();
                    //                            }
                    //                            else
                    //                            {
                    //                                model.ActionStatus = ConstantMessages.WarningTraineeOverLimit.TranslateString();
                    //                            }
                    //                        }
                    //                    }
                    //                    else
                    //                    {
                    //                        model.ActionStatus = ConstantMessages.WarningTraineeOverLimit.TranslateString();
                    //                    }
                    //                }
                    //                if (planEntity.SumQuantity > lstPlanDetailByPlanID.Sum(s => s.Quantity))
                    //                {
                    //                        model = service.UpdateOrCreate<Tra_TraineeEntity, Tra_TraineeModel>(model);
                    //                        var lstCourseTopicByCourseID = lstCourseTopic.Where(s => s.CourseID == classEntity.CourseID).ToList();
                    //                        foreach (var courseTopic in lstCourseTopicByCourseID)
                    //                        {
                    //                            var traineeTopicEntity = new Tra_TraineeTopicEntity();
                    //                            traineeTopicEntity.TopicID = courseTopic.TopicID;
                    //                            traineeTopicEntity.TraineeID = model.ID;
                    //                            message = traineeTopicServices.Add(traineeTopicEntity);
                    //                        }
                    //                        return model;  
                    //                }

                    //            }

                    //            return model;
                    //        }
                    //    }
                    //}

                }
                if (classEntity != null)
                {
                    if (traineeEntity.Count > 0)
                    {
                        model.ActionStatus = ConstantMessages.WarningProfileHaveClass.ToString().TranslateString();
                        return model;
                    }

                    model = service.UpdateOrCreate<Tra_TraineeEntity, Tra_TraineeModel>(model);

                    var lstCourseTopicByCourseID = lstCourseTopic.Where(s => s.CourseID == classEntity.CourseID).ToList();
                    if (lstCourseTopicByCourseID.Count == 0)
                    {
                        return model;
                    }
                    foreach (var courseTopic in lstCourseTopicByCourseID)
                    {
                        var traineeTopicEntity = new Tra_TraineeTopicEntity();
                        traineeTopicEntity.TopicID = courseTopic.TopicID;
                        traineeTopicEntity.TraineeID = model.ID;
                        model.ActionStatus = traineeTopicServices.Add(traineeTopicEntity);
                    }


                    return model;

                }
            }

            return service.UpdateOrCreate<Tra_TraineeEntity, Tra_TraineeModel>(model);

            



            #endregion
        }
Exemplo n.º 4
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;
        }
Exemplo n.º 5
0
        public DataTable GetReportTraineeByMonth(DateTime Month, Guid? CourseID, bool IsCreateTemplate, string UserLogin)
        {
            DataTable table = CreateReportTraineeByMonth();
            if (IsCreateTemplate)
            {
                return table;
            }
            string status = string.Empty;

            var classServices = new Tra_ClassServices();
            var traineeServices = new Tra_TraineeServices();
            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();
            if (lstClass == null || lstClass.Count == 0)
            {
                return table;
            }
            lstClass = lstClass.Where(s => s.StartDate != null && s.StartDate.Value.Month == Month.Month && s.StartDate.Value.Year == Month.Year).ToList();
            if (CourseID != null)
            {
                lstClass = lstClass.Where(s => s.CourseID != null && s.CourseID == CourseID).ToList();
            }
            var lstClassId = lstClass.Select(s => s.ID).ToList();


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

            if (lsttrainee == null || lsttrainee.Count == 0)
            {
                return table;
            }

            lsttrainee = lsttrainee.Where(s => lstClassId.Contains(s.ClassID)).ToList();

            if (lsttrainee == null || lsttrainee.Count == 0)
            {
                return table;
            }

            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();

            foreach (var trainee in lsttrainee)
            {
                DataRow dr = table.NewRow();
                var classbytrainee = lstClass.Where(s => s.ID == trainee.ClassID).FirstOrDefault();
                dr[Tra_ReportTraineeByMonthEntity.FieldNames.CodeEmp] = trainee.CodeEmp;
                dr[Tra_ReportTraineeByMonthEntity.FieldNames.ProfileName] = trainee.ProfileName;
                dr[Tra_ReportTraineeByMonthEntity.FieldNames.E_DEPARTMENT] = trainee.E_DEPARTMENT;
                dr[Tra_ReportTraineeByMonthEntity.FieldNames.E_DIVISION] = trainee.E_DIVISION;
                dr[Tra_ReportTraineeByMonthEntity.FieldNames.E_SECTION] = trainee.E_SECTION;
                dr[Tra_ReportTraineeByMonthEntity.FieldNames.E_TEAM] = trainee.E_TEAM;
                dr[Tra_ReportTraineeByMonthEntity.FieldNames.E_UNIT] = trainee.E_UNIT;
                dr[Tra_ReportTraineeByMonthEntity.FieldNames.ClassName] = trainee.ClassName;
                if (classbytrainee != null)
                {
                    var coursebyclass = lstCourse.Where(s => s.ID == classbytrainee.CourseID).FirstOrDefault();
                    dr[Tra_ReportTraineeByMonthEntity.FieldNames.CourseName] = coursebyclass != null ? coursebyclass.CourseName : null;
                }
                if (trainee.StartDate != null)
                {
                    dr[Tra_ReportTraineeByMonthEntity.FieldNames.StartDate] = trainee.StartDate;
                }

                dr[Tra_ReportTraineeByMonthEntity.FieldNames.Month] = Month;
                dr[Tra_ReportTraineeByMonthEntity.FieldNames.WorkPlace] = trainee.WorkPlaceName;
                table.Rows.Add(dr);
            }
            return table;
        }
Exemplo n.º 6
0
        public DataTable GetReportTraineeNotInRequirementDetail(DateTime? Month, string OrderNumber, Guid[] classID, bool IsCreateTemplate, Guid[] courseID, string UserLogin)
        {
            DataTable table = CreateTraineeNotInRequirementDetailSchema();
            if (IsCreateTemplate)
            {
                return table;
            }
            using (var context = new VnrHrmDataContext())
            {
                string status = string.Empty;
                var profileServices = new Hre_ProfileServices();
                //var objProfile = new List<object>();
                //objProfile.Add(OrderNumber);
                //objProfile.Add(null);
                //objProfile.Add(null);
                //var lstProfile = profileServices.GetData<Hre_ProfileEntity>(objProfile, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, ref status).ToList();

                var service = new BaseService();
                List<object> lstObj = new List<object>();
                lstObj.Add(OrderNumber);
                lstObj.Add(null);
                lstObj.Add(null);
                var lstProfileidEntity = service.GetData<Hre_ProfileIdEntity>(lstObj, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrgN, UserLogin, ref status);
                List<Guid> lstProfileID = null;
                if (lstProfileidEntity != null)
                {
                    lstProfileID = lstProfileidEntity.Select(s => s.ID).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 = new List<Tra_ClassEntity>();


                if (Month != null)
                {
                    lstClass = classServices.GetData<Tra_ClassEntity>(objClass, ConstantSql.hrm_tra_sp_get_Class, UserLogin, ref status).Where(s => s.StartDate != null && s.StartDate.Value.Month == Month.Value.Month && s.StartDate.Value.Year == Month.Value.Year).ToList();
                }
                else
                {
                    lstClass = classServices.GetData<Tra_ClassEntity>(objClass, ConstantSql.hrm_tra_sp_get_Class, UserLogin, ref status).ToList();
                }

                if (classID != null)
                {
                    lstClass = lstClass.Where(s => classID.Contains(s.ID)).ToList();
                }
                if (courseID != null)
                {
                    lstClass = lstClass.Where(s => courseID.Contains(s.CourseID)).ToList();
                }
                //if (RequirementTrainIDs != null)
                //{
                //    lstClass = lstClass.Where(s => s.RequirementTrainID!=null && courseID.Contains((Guid)s.RequirementTrainID)).ToList();
                //}
                var lstClassIDs = lstClass.Select(s => s.ID).ToList();

                var requirementDetailServices = new Tra_RequirementTrainDetailServices();
                var objRequirementDetail = new List<object>();
                objRequirementDetail.Add(null);
                objRequirementDetail.Add(1);
                objRequirementDetail.Add(int.MaxValue - 1);
                var lstRequirementDetail = requirementDetailServices.GetData<Tra_RequirementTrainDetailEntity>(objRequirementDetail, ConstantSql.hrm_tra_sp_get_RequirementDetail, 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 lstTraniee = traineeServices.GetData<Tra_TraineeEntity>(objTrainee, ConstantSql.hrm_tra_sp_get_Trainee, UserLogin, ref status).ToList();
                if (lstProfileID != null)
                {
                    lstTraniee = lstTraniee.Where(s => lstProfileID.Contains(s.ProfileID)).ToList();
                }
                if (lstClassIDs != null)
                {
                    lstTraniee = lstTraniee.Where(s => lstClassIDs.Contains(s.ClassID)).ToList();
                }


                var lstTraineeID = lstTraniee.Select(s => s.ProfileID).ToList();
                var stt = 1;
                #region lấy Org và OrgType

                //var orgServices = new Cat_OrgStructureServices();
                //var lstObjOrg = new List<object>();
                //lstObjOrg.Add(null);
                //lstObjOrg.Add(null);
                //lstObjOrg.Add(null);
                //lstObjOrg.Add(1);
                //lstObjOrg.Add(int.MaxValue - 1);
                //var lstOrg = orgServices.GetData<Cat_OrgStructureEntity>(lstObjOrg, ConstantSql.hrm_cat_sp_get_OrgStructure, ref status).ToList();

                //var orgTypeService = new Cat_OrgStructureTypeServices();
                //var lstObjOrgType = new List<object>();
                //lstObjOrgType.Add(null);
                //lstObjOrgType.Add(null);
                //lstObjOrgType.Add(1);
                //lstObjOrgType.Add(int.MaxValue - 1);
                //var lstOrgType = orgTypeService.GetData<Cat_OrgStructureTypeEntity>(lstObjOrgType, ConstantSql.hrm_cat_sp_get_OrgStructureType, ref status).ToList();
                #endregion

                foreach (var item in lstTraniee)
                {
                    DataRow dr = table.NewRow();
                    var traineeNotInRequirementEntity = lstRequirementDetail.Where(s => item.ProfileID == s.ProfileID.Value).FirstOrDefault();
                    //var _objProfile = lstProfile.Where(s => s.ID == item.ProfileID).FirstOrDefault();
                    //Guid? orgId = item.OrgStructureID;
                    //var org = lstOrg.FirstOrDefault(s => s.ID == item.OrgStructureID);
                    //var E_DEPARTMENT = LibraryService.GetNearestParentEntity(orgId, OrgUnit.E_DEPARTMENT, lstOrg, lstOrgType);
                    if (traineeNotInRequirementEntity == null)
                    {
                        dr[Tra_ReportTraineeNotInRequirementDetailEntity.FieldNames.STT] = stt++;
                        dr[Tra_ReportTraineeNotInRequirementDetailEntity.FieldNames.CodeEmp] = item.CodeEmp;
                        dr[Tra_ReportTraineeNotInRequirementDetailEntity.FieldNames.ProfileName] = item.ProfileName;
                        //dr[Tra_ReportTraineeNotInRequirementDetailEntity.FieldNames.SectionName] = E_DEPARTMENT != null ? E_DEPARTMENT.OrgStructureName : null;
                        dr[Tra_ReportTraineeNotInRequirementDetailEntity.FieldNames.E_DEPARTMENT] = item.E_DEPARTMENT;
                        dr[Tra_ReportTraineeNotInRequirementDetailEntity.FieldNames.E_DIVISION] = item.E_DIVISION;
                        dr[Tra_ReportTraineeNotInRequirementDetailEntity.FieldNames.E_SECTION] = item.E_SECTION;
                        dr[Tra_ReportTraineeNotInRequirementDetailEntity.FieldNames.E_TEAM] = item.E_TEAM;
                        dr[Tra_ReportTraineeNotInRequirementDetailEntity.FieldNames.E_UNIT] = item.E_UNIT;
                        dr[Tra_ReportTraineeNotInRequirementDetailEntity.FieldNames.ClassName] = item.ClassName;
                        dr[Tra_ReportTraineeNotInRequirementDetailEntity.FieldNames.CourseName] = item.CourseName;
                        dr[Tra_ReportTraineeNotInRequirementDetailEntity.FieldNames.Notes] = traineeNotInRequirementEntity == null ? string.Empty : traineeNotInRequirementEntity.Comment;
                        table.Rows.Add(dr);
                    }
                }
                return table;
            }
        }
Exemplo n.º 7
0
        public DataTable GetReportTransferTrainee(string codeEmp, string profileName, string orgStructureID, Guid? courseID, Guid? classID, Guid? classOldID, bool IsCreateTemplate, string UserLogin)
        {
            DataTable table = CreateReportTransferTrainee();
            if (IsCreateTemplate)
            {
                return table;
            }
            string status = string.Empty;

            var classServices = new Tra_ClassServices();
            var traineeServices = new Tra_TraineeServices();
            var objTrainee = new List<object>();
            objTrainee.AddRange(new object[15]);
            objTrainee[9] = profileName;
            objTrainee[1] = codeEmp;
            objTrainee[8] = orgStructureID;
            objTrainee[13] = 1;
            objTrainee[14] = int.MaxValue - 1;

            var lstTrainee = traineeServices.GetData<Tra_TraineeEntity>(objTrainee, ConstantSql.hrm_tra_sp_get_Trainee, UserLogin, ref status).Where(s => s.ClassOldID != null).ToList();

            if (courseID != null)
            {
                lstTrainee = lstTrainee.Where(s => s.CourseID != null && s.CourseID == courseID).ToList();
            }

            if (classID != null)
            {
                lstTrainee = lstTrainee.Where(s => s.ClassID != null && s.ClassID == classID).ToList();
            }

            if (classOldID != null)
            {
                lstTrainee = lstTrainee.Where(s => s.ClassOldID != null && s.ClassOldID == classOldID).ToList();
            }

            if (lstTrainee == null || lstTrainee.Count == 0)
            {
                return table;
            }

            foreach (var trainee in lstTrainee)
            {
                DataRow dr = table.NewRow();
                dr[Tra_ReportTransferTraineeEntity.FieldNames.CodeEmp] = trainee.CodeEmp;
                dr[Tra_ReportTransferTraineeEntity.FieldNames.ProfileName] = trainee.ProfileName;
                dr[Tra_ReportTransferTraineeEntity.FieldNames.E_DEPARTMENT] = trainee.E_DEPARTMENT;
                dr[Tra_ReportTransferTraineeEntity.FieldNames.E_DIVISION] = trainee.E_DIVISION;
                dr[Tra_ReportTransferTraineeEntity.FieldNames.E_SECTION] = trainee.E_SECTION;
                dr[Tra_ReportTransferTraineeEntity.FieldNames.E_TEAM] = trainee.E_TEAM;
                dr[Tra_ReportTransferTraineeEntity.FieldNames.E_UNIT] = trainee.E_UNIT;
                dr[Tra_ReportTransferTraineeEntity.FieldNames.ClassName] = trainee.ClassName;
                dr[Tra_ReportTransferTraineeEntity.FieldNames.ClassNameOld] = trainee.ClassNameOld;
                dr[Tra_ReportTransferTraineeEntity.FieldNames.CourseName] = trainee.CourseName;
                dr[Tra_ReportTraineeByMonthEntity.FieldNames.WorkPlace] = trainee.WorkPlaceName;
                table.Rows.Add(dr);
            }

            return table;
        }
Exemplo n.º 8
0
        /// <summary>
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Tra_AddPointModel GetById(string id)
        {
            Tra_AddPointModel result = new Tra_AddPointModel();
            List<Guid> SelectedIds = new List<Guid>();

            if (!string.IsNullOrEmpty(id))
            {
                SelectedIds = id.Split(',').Select(s => Guid.Parse(s)).ToList();
            }

            if (SelectedIds != null && SelectedIds.Count > 0)
            {
               
                //Guid[] traineeID = null;
                var message = string.Empty;
                string status = string.Empty;

                List<Guid> lstClassID = new List<Guid>();
                List<Guid> lstTraineeID = new List<Guid>();
                #region load data
                var traineeServices = new Tra_TraineeServices();
                var objTrainee = new List<object>();
                objTrainee.AddRange(new object[15]);
                objTrainee[13] = 1;
                objTrainee[14] = int.MaxValue - 1;
                List<Tra_TraineeEntity> lstTrainee = traineeServices.GetData<Tra_TraineeEntity>(objTrainee, ConstantSql.hrm_tra_sp_get_Trainee, UserLogin, ref status);


                var courseSevices = new Tra_CourseServices();
                var objCoures = new List<object>();
                objCoures.AddRange(new object[11]);
                objCoures[9] = 1;
                objCoures[10] = int.MaxValue - 1;
                List<Tra_CourseEntity> lstCourse = courseSevices.GetData<Tra_CourseEntity>(objCoures, ConstantSql.hrm_tra_sp_get_Course, UserLogin, ref status);

                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);
                List<Tra_ClassEntity> lstClass = classServices.GetData<Tra_ClassEntity>(objClass, ConstantSql.hrm_tra_sp_get_Class, UserLogin, ref status);

                var traineeTopicServices = new Tra_TraineeTopicServices();
                var objTraineeTopic = new List<object>();
                objTraineeTopic.Add(1);
                objTraineeTopic.Add(int.MaxValue -1);
                var lstTraineeTopic = traineeTopicServices.GetData<Tra_TraineeTopicEntity>(objTraineeTopic, ConstantSql.hrm_tra_sp_get_TraineeTopic, UserLogin, ref status).ToList();

                var scoreTopicServices = new Tra_ScoreTopicServices();
                var objScoreTopic = new List<object>();
                objScoreTopic.Add(1);
                objScoreTopic.Add(int.MaxValue - 1);
                var lstScoreTopic = scoreTopicServices.GetData<Tra_ScoreTopicEntity>(objScoreTopic, ConstantSql.hrm_tra_sp_get_ScoreTopic, UserLogin, ref status).ToList();

                var courseTopicServices = new Tra_TraineeTopicServices();
                var objCourseTopic = new List<object>();
                objCourseTopic.Add(1);
                objCourseTopic.Add(int.MaxValue - 1);
                List<Tra_CourseTopicEntity> lstCourseTopic = courseTopicServices.GetData<Tra_CourseTopicEntity>(objCourseTopic, ConstantSql.hrm_tra_sp_get_CourseTopic, UserLogin, ref status);

                var traineeScoreServices = new Tra_TraineeScoreServices();
                var objTraineeScore = new List<object>();
                objTraineeScore.Add(1);
                objTraineeScore.Add(int.MaxValue - 1);
                var lstTraineeScore = traineeScoreServices.GetData<Tra_TraineeScoreEntity>(objTraineeScore, ConstantSql.hrm_tra_sp_get_TraineeScore, UserLogin, ref status).ToList();

                if (SelectedIds != null)
                {
                    lstTrainee = lstTrainee.Where(s => SelectedIds.Contains(s.ID)).ToList();
                    lstTraineeID = lstTrainee.Select(s => s.ID).ToList();
                    lstClassID = lstTrainee.Select(s => s.ClassID).Distinct().ToList();
                }
                if (lstClassID.Count > 1)
                {
                    DataTable tb = new DataTable();
                    result.ActionStatus = ConstantMessages.PlsChooseTraineeSameClass.ToString();
                    result.Ids = id;
                    result.Table = tb;
                    return result;
                }
                DataTable table = new DataTable();
                table.Columns.Add(Tra_TraineeScoreEntity.FieldNames.ID);
                table.Columns.Add(Tra_TraineeScoreEntity.FieldNames.CodeEmp);
                table.Columns.Add(Tra_TraineeScoreEntity.FieldNames.ProfileName);
                if (lstClassID.Count == 1)
                {
                    var isSimple = false;
                    Guid firstClass = lstClassID[0];
                    var courseEntity = lstClass.Where(s => s.ID == firstClass).Select(s => new { s.CourseID, s.IsComplex }).FirstOrDefault();

                    if (courseEntity != null)
                    {
                        var lstCourseTopicByCourseID = lstCourseTopic.Where(s => courseEntity.CourseID == s.CourseID).ToList();
                        if (courseEntity.IsComplex == null || courseEntity.IsComplex == false)
                        {
                            isSimple = true;
                        }
                        if (lstCourseTopicByCourseID.Count == 0)
                        {
                            DataTable tb = new DataTable();
                            result.ActionStatus = ConstantMessages.CourseNoHaveTopic.ToString();
                            result.Ids = id;
                            result.Table = tb;
                            return result;
                        }
                        if (isSimple == false)
                        {
                           
                            foreach (var trainee in lstTrainee)
                            {
                                DataRow dr = table.NewRow();
                                dr[Tra_TraineeScoreEntity.FieldNames.ID] = trainee.ID != null ? trainee.ID : Guid.Empty;
                                dr[Tra_TraineeScoreEntity.FieldNames.CodeEmp] = trainee.CodeEmp != null ? trainee.CodeEmp : string.Empty;
                                dr[Tra_TraineeScoreEntity.FieldNames.ProfileName] = trainee.ProfileName != null ? trainee.ProfileName : string.Empty;
                                var lstTopicbyCourseID = lstCourseTopic.Where(s => s.CourseID == courseEntity.CourseID).Select(s => new { s.CourseID, s.TopicID, s.IsComplex, s.Code }).ToList();
                                foreach (var item in lstTopicbyCourseID)
                                {
                                    
                                    var traineeTopicEnity = lstTraineeTopic.Where(s => s.TraineeID == trainee.ID && item.TopicID == s.TopicID).FirstOrDefault();
                                  
                                    var lstTraineeScoreByTraineeTopicID = lstTraineeScore.Where(s => traineeTopicEnity != null && s.TraineeTopicID == traineeTopicEnity.ID).ToList(); 
                                    var classeEntity = lstClass.Where(s => s.ID == trainee.ClassID).FirstOrDefault();
                                   
                                    Double value = 0;

                                    if (item.IsComplex == null || item.IsComplex == true)
                                    {
                                        isSimple = true;
                                        if (classeEntity != null)
                                        {
                                            var courseEntityByCourseID = lstCourse.Where(s => s.ID == classeEntity.CourseID).FirstOrDefault();
                                            if (courseEntityByCourseID != null)
                                            {
                                                var lstScoreTopicByTopicID = lstScoreTopic.Where(s => item.TopicID == s.TopicID).OrderBy(s => s.DateCreate).ToList();
                                                foreach (var scoreTopic in lstScoreTopicByTopicID)
                                                {
                                                    var traineeScoreEntity = lstTraineeScore.Where(s => traineeTopicEnity != null && s.ScoreTypeID == scoreTopic.ScoreTypeID && traineeTopicEnity.ID == s.TraineeTopicID).FirstOrDefault();
                                                    if (!table.Columns.Contains(item.Code + "_" + scoreTopic.Code))
                                                    {
                                                        table.Columns.Add(item.Code + "_" + scoreTopic.Code);
                                                    }
                                                    if (table.Columns.Contains(item.Code + "_" + scoreTopic.Code))
                                                    {
                                                        if (traineeScoreEntity != null && traineeScoreEntity.Score != null)
                                                        {
                                                            dr[item.Code + "_" + scoreTopic.Code] = traineeScoreEntity != null ? traineeScoreEntity.Score.Value : 0;
                                                        }
                                                        else
                                                        {
                                                            dr[item.Code + "_" + scoreTopic.Code] = null;
                                                        }

                                                    }
                                                }
                                               
                                            }
                                        }
                                        
                                    }
                                    else
                                    {
                                        isSimple = false;
                                        break;
                                    }
                                }
                                table.Rows.Add(dr);
                            }
                            //  var a = table;
                        }
                    }
                }
                result.Table = table;
                return result;
                #endregion
            }
            return null;
        }
Exemplo n.º 9
0
        // Son.Vo - Thêm học viên vào lớp học
        public string AddTraineeToClass(List<Guid> lstTraineeIDs, Guid classID, string UserLogin)
        {
            using (var context = new VnrHrmDataContext())
            {
                string status = string.Empty;
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                string message = string.Empty;
                var planServices = new Tra_PlanServices();
                #region Tin.Nguyen
                var lstObjPlan = new List<object>();
                lstObjPlan.Add(null);
                lstObjPlan.Add(null);
                lstObjPlan.Add(null);
                lstObjPlan.Add(1);
                lstObjPlan.Add(int.MaxValue - 1);
                var lstPlan = planServices.GetData<Tra_PlanEntity>(lstObjPlan, ConstantSql.hrm_tra_sp_get_Plan, UserLogin, ref status).ToList();

                var planDetailServices = new Tra_PlanDetailServices();
                var lstObjPlanDetail = new List<object>();
                lstObjPlanDetail.Add(null);
                lstObjPlanDetail.Add(1);
                lstObjPlanDetail.Add(int.MaxValue - 1);
                var lstPlanDetail = planDetailServices.GetData<Tra_PlanDetailEntity>(lstObjPlanDetail, ConstantSql.hrm_tra_sp_get_PlanDetail, 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 lstObjTraineeInClass = new List<object>();
                lstObjTraineeInClass.Add(classID);
                var lstTraineeInClass = classServices.GetData<Tra_ClassEntity>(lstObjTraineeInClass, ConstantSql.hrm_cat_sp_get_TraineeByClassID, UserLogin, ref status).ToList();

                var traineeTopicServices = new Tra_TraineeTopicServices();
                var courseTopicServices = new Tra_TraineeTopicServices();
                var objCourseTopic = new List<object>();
                objCourseTopic.Add(1);
                objCourseTopic.Add(int.MaxValue - 1);
                var lstCourseTopic = courseTopicServices.GetData<Tra_CourseTopicEntity>(objCourseTopic, ConstantSql.hrm_tra_sp_get_CourseTopic, UserLogin, ref status);

                var classEntity = lstClass.Where(s => s.ID == classID).FirstOrDefault();
                var profileServices = new Hre_ProfileServices();
                var objProfile = new List<object>();
                objProfile.AddRange(new object[18]);
                objProfile[16] = 1;
                objProfile[17] = int.MaxValue - 1;
                var lstProfileSelected = profileServices.GetData<Hre_ProfileEntity>(objProfile, ConstantSql.hrm_hr_sp_get_Profile, UserLogin, ref status).ToList();
                if(lstTraineeIDs != null)
                {
                    lstProfileSelected = lstProfileSelected.Where(s => lstTraineeIDs.Contains(s.ID)).ToList();
                }

                var traineeServices = new Tra_TraineeServices();

                var requirementServices = new Tra_RequirementTrainServices();
                var objRequirement = new List<object>();
                objRequirement.AddRange(new object[7]);
                objRequirement[5] = 1;
                objRequirement[6] = int.MaxValue - 1;
                var lstRequirement = requirementServices.GetData<Tra_RequirementTrainEntity>(objRequirement, ConstantSql.hrm_tra_sp_get_RequirementTrain, UserLogin, ref status).ToList();

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

                foreach (var profileEntity in lstProfileSelected)
                {
                    if (classEntity != null)
                    {
                        if (classEntity.PlanID != null)
                        {
                            var planEntity = lstPlan.Where(s => s.ID == classEntity.PlanID.Value).FirstOrDefault();
                            if (planEntity != null)
                            {
                                var lstPlanDetailByPlanID = lstPlanDetail.Where(s => s.PlanID == planEntity.ID).ToList();

                                foreach (var item in lstPlanDetailByPlanID)
                                {
                                    var lstTraineeInClassForOrg = lstTraineeInClass.Where(s => s.OrgStructureID.Value == item.OrgStructureID.Value).ToList();
                                    //Kiểm tra số lượng của plan detail với sumQuantity của plan
                                    if (planEntity.SumQuantity == lstPlanDetailByPlanID.Sum(s => s.Quantity))
                                    {
                                        if (lstTraineeInClass.Count < lstPlanDetailByPlanID.Sum(s => s.Quantity))
                                        {
                                            // Xử Lý kiểm tra nv có thuộc phòng ban trong plan detail ko
                                            if (profileEntity != null)
                                            {
                                                if (lstTraineeInClassForOrg.Count < item.Quantity)
                                                {
                                                    if (profileEntity.OrgStructureID.Value == item.OrgStructureID.Value)
                                                    {
                                                        var traineeEntity = new Tra_TraineeEntity();
                                                      
                                                        traineeEntity.ProfileID = profileEntity.ID;
                                                        traineeEntity.ClassID = classID;
                                                        traineeEntity.OrgStructureID = profileEntity.OrgStructureID != null ? profileEntity.OrgStructureID.Value : profileEntity.OrgStructureID;

                                                        message = traineeServices.Add(traineeEntity);
                                                        


                                                        var lstCourseTopicByCourseID = lstCourseTopic.Where(s => s.CourseID == classEntity.CourseID).ToList();
                                                        foreach (var courseTopic in lstCourseTopicByCourseID)
                                                        {
                                                            var traineeTopicEntity = new Tra_TraineeTopicEntity();
                                                            traineeTopicEntity.TopicID = courseTopic.TopicID;
                                                            traineeTopicEntity.TraineeID = traineeEntity.ID;
                                                            message = traineeTopicServices.Add(traineeTopicEntity);
                                                        }
                                                        return message;
                                                    }
                                                    message = ConstantMessages.WarningProfileNotDependantOrgStructure.TranslateString();
                                                }
                                                else
                                                {
                                                    message = ConstantMessages.WarningTraineeOverLimit.TranslateString();
                                                }
                                            }
                                        }
                                        else
                                        {
                                            message = ConstantMessages.WarningTraineeOverLimit.TranslateString();
                                        }
                                    }
                                    if (planEntity.SumQuantity > lstPlanDetailByPlanID.Sum(s => s.Quantity))
                                    {
                                        var traineeEntity = new Tra_TraineeEntity();

                                        traineeEntity.ProfileID = profileEntity.ID;
                                        traineeEntity.ClassID = classID;
                                        traineeEntity.OrgStructureID = profileEntity.OrgStructureID != null ? profileEntity.OrgStructureID.Value : profileEntity.OrgStructureID;

                                        message = traineeServices.Add(traineeEntity);



                                        var lstCourseTopicByCourseID = lstCourseTopic.Where(s => s.CourseID == classEntity.CourseID).ToList();
                                        foreach (var courseTopic in lstCourseTopicByCourseID)
                                        {
                                            var traineeTopicEntity = new Tra_TraineeTopicEntity();
                                            traineeTopicEntity.TopicID = courseTopic.TopicID;
                                            traineeTopicEntity.TraineeID = traineeEntity.ID;
                                            message = traineeTopicServices.Add(traineeTopicEntity);
                                        }
                                        return message;
                                    }

                                }

                                return message;
                            }
                        }
                    }
                }
                #endregion
                return message;
            }
        }
Exemplo n.º 10
0
        public ActionResult TransferTraineeForClass(List<Guid> selectedIds, Guid classID, Guid tranferClassID)
        {

            var services = new Tra_ClassServices();
            var message = string.Empty;
            message = services.TransferTraineeForClass(selectedIds, classID, tranferClassID, UserLogin);
            return Json(message, JsonRequestBehavior.AllowGet);
        }