Exemplo n.º 1
0
        internal EmployeesQualificationsBLL GetLastEmployeeQualification(List <EmployeesQualificationsBLL> EmployeesQualificationsList, int EmployeeCodeID)
        {
            EmployeesQualificationsBLL LastEmployeeQualification = null;

            EmployeesQualificationsList.ForEach(x => x.GraduationDate = x.GraduationDate.HasValue ? x.GraduationDate.Value : Convert.ToDateTime(Globals.Calendar.UmAlquraToGreg(string.Format("{0}/{1}/{2}", "1", "1", x.GraduationYear)), new CultureInfo("en-US")));
            EmployeesQualificationsList.ForEach(x => x.GraduationYear = !string.IsNullOrEmpty(x.GraduationYear) ? x.GraduationYear : x.GraduationDate.HasValue ? x.GraduationDate.Value.Year.ToString() : string.Empty);

            LastEmployeeQualification = EmployeesQualificationsList.Where(x => x.EmployeeCode.EmployeeCodeID == EmployeeCodeID)
                                        .OrderByDescending(x => x.QualificationDegree.Weight)
                                        .OrderByDescending(x => x.GraduationDate)
                                        .OrderByDescending(x => x.GraduationYear)
                                        //.OrderByDescending(x => x.GraduationDate.HasValue ? x.GraduationDate.Value : Convert.ToDateTime(Globals.Calendar.UmAlquraToGreg(string.Format("{0}/{1}/{2}", "1", "1", x.GraduationYear)), new CultureInfo("en-US")))
                                        //.OrderByDescending(x => !string.IsNullOrEmpty(x.GraduationYear) ? x.GraduationYear : x.GraduationDate.Value.Year.ToString())
                                        .Take(1).FirstOrDefault();

            if (LastEmployeeQualification == null)
            {
                LastEmployeeQualification = new EmployeesQualificationsBLL()
                {
                    QualificationDegree   = new QualificationsDegreesBLL(),
                    Qualification         = new QualificationsBLL(),
                    GeneralSpecialization = new GeneralSpecializationsBLL()
                };
            }

            return(LastEmployeeQualification);
        }
Exemplo n.º 2
0
        public virtual Result Update()
        {
            try
            {
                Result result = null;

                #region Validation for GeneralSpecializationID EmployeeQualifications
                EmployeesQualificationsBLL EmployeeQualificationBLL = new EmployeesQualificationsBLL().GetByExactSpecializationID(this.ExactSpecializationID);
                if (EmployeeQualificationBLL != null)
                {
                    if (EmployeeQualificationBLL.GeneralSpecialization.GeneralSpecializationID != this.GeneralSpecialization.GeneralSpecializationID)
                    {
                        result            = new Result();
                        result.Entity     = null;
                        result.EnumType   = typeof(ExactSpecializationsValidationEnum);
                        result.EnumMember = ExactSpecializationsValidationEnum.RejectedBecauseOfThisExactSpecializationExistsInEmployeesQualifications.ToString();
                        return(result);
                    }
                }
                #endregion

                ExactSpecializations ExactSpecialization = new ExactSpecializations();
                ExactSpecialization.ExactSpecializationID   = this.ExactSpecializationID;
                ExactSpecialization.GeneralSpecializationID = this.GeneralSpecialization.GeneralSpecializationID;
                ExactSpecialization.ExactSpecializationName = this.ExactSpecializationName;  //QualificationDegreeID
                ExactSpecialization.LastUpdatedDate         = DateTime.Now;
                ExactSpecialization.LastUpdatedBy           = this.LoginIdentity.EmployeeCodeID;
                int UpdateResult = new ExactSpecializationsDAL().Update(ExactSpecialization);
                if (UpdateResult != 0)
                {
                    result            = new Result();
                    result.Entity     = this;
                    result.EnumType   = typeof(ExactSpecializationsValidationEnum);
                    result.EnumMember = ExactSpecializationsValidationEnum.Done.ToString();
                }

                return(result);
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 3
0
        //public List<ChartsAxis> GetQualificationsBasedOnAssigningsAsRanksCategories(int QualificationDegreeID, int QualificationID, int GeneralSpecializationID, int OrganizationID)
        //{
        //    try
        //    {
        //        List<int> OrganizationIDsList = new OrganizationsStructuresBLL().GetByOrganizationIDsWithhAllChilds(OrganizationID);

        //        // Get actual employees Based On Assignings by date
        //        List<vwActualEmployeesBasedOnAssignings> ActualEmployeesBasedOnAssignings = new AssigningsDAL().GetActualEmployeeBasedOnAssignings().Where(x => OrganizationIDsList.Contains(x.OrganizationID.Value)).ToList();

        //        List<int> EmployeesCodesIDs = new List<int>();
        //        ActualEmployeesBasedOnAssignings.ForEach(x => EmployeesCodesIDs.Add(x.EmployeeCodeID));

        //        List<EmployeesQualificationsBLL> EmployeesQualificationsList = new EmployeesQualificationsBLL().GetEmployeesQualifications(EmployeesCodesIDs);

        //        List<EmployeesQualificationsBLL> EmployeesQualificationsOfActualEmployeesList = new List<EmployeesQualificationsBLL>();

        //        ActualEmployeesBasedOnAssignings.ForEach(x => EmployeesQualificationsOfActualEmployeesList.Add(new EmployeesQualificationsBLL().GetLastEmployeeQualification(EmployeesQualificationsList, x.EmployeeCodeID)));

        //        EmployeesQualificationsOfActualEmployeesList = EmployeesQualificationsOfActualEmployeesList.Where(x => x.QualificationDegree.QualificationDegreeID == QualificationDegreeID
        //                                                                                                            && (QualificationID != 0 ? x.Qualification.QualificationID == QualificationID : x.Qualification.QualificationID == x.Qualification.QualificationID)
        //                                                                                                            && (GeneralSpecializationID != 0 ? x.GeneralSpecialization.GeneralSpecializationID == GeneralSpecializationID : x.GeneralSpecialization.GeneralSpecializationID == x.GeneralSpecialization.GeneralSpecializationID)).ToList();

        //        ActualEmployeesBasedOnAssignings.RemoveAll(x => !EmployeesQualificationsOfActualEmployeesList.Any(y => y.EmployeeCode.EmployeeCodeID == x.EmployeeCodeID));

        //        var query = ActualEmployeesBasedOnAssignings.GroupBy(x => x.RankCategoryName)
        //                                                    .Select(y => new
        //                                                    {
        //                                                        RankCategoryName = y.Key,
        //                                                        RecordCount = y.Count()
        //                                                    }).ToList();

        //        List<ChartsAxis> ChartAxisList = new List<ChartsAxis>();
        //        foreach (var item in query)
        //            ChartAxisList.Add(new ChartsAxis { KeyName = item.RankCategoryName, Value = item.RecordCount });

        //        return ChartAxisList;
        //    }
        //    catch
        //    {
        //        throw;
        //    }
        //}

        public IQueryable <EmployeesQualificationBasedOnAssigngingsDTO> GetQualificationsBasedOnAssigningsAsRanksCategoriesDetails(int QualificationDegreeID, int QualificationID, int GeneralSpecializationID, int OrganizationID)
        {
            try
            {
                List <int> OrganizationIDsList = new OrganizationsStructuresBLL().GetByOrganizationIDsWithhAllChilds(OrganizationID);

                // Get actual employees Based On Assignings by date
                List <vwActualEmployeesBasedOnAssignings> ActualEmployeesBasedOnAssignings = new AssigningsDAL().GetActualEmployeeBasedOnAssignings().Where(x => OrganizationIDsList.Contains(x.OrganizationID.Value)).ToList();

                List <int> EmployeesCodesIDs = new List <int>();
                ActualEmployeesBasedOnAssignings.ForEach(x => EmployeesCodesIDs.Add(x.EmployeeCodeID));

                List <EmployeesQualificationsBLL> EmployeesQualificationsList = new EmployeesQualificationsBLL().GetEmployeesQualifications(EmployeesCodesIDs);

                List <EmployeesQualificationsBLL> EmployeesQualificationsOfActualEmployeesList = new List <EmployeesQualificationsBLL>();

                ActualEmployeesBasedOnAssignings.ForEach(x => EmployeesQualificationsOfActualEmployeesList.Add(new EmployeesQualificationsBLL().GetLastEmployeeQualification(EmployeesQualificationsList, x.EmployeeCodeID)));

                EmployeesQualificationsOfActualEmployeesList = EmployeesQualificationsOfActualEmployeesList.Where(x => x.QualificationDegree.QualificationDegreeID == QualificationDegreeID &&
                                                                                                                  (QualificationID != 0 ? x.Qualification.QualificationID == QualificationID : x.Qualification.QualificationID == x.Qualification.QualificationID) &&
                                                                                                                  (GeneralSpecializationID != 0 ? x.GeneralSpecialization.GeneralSpecializationID == GeneralSpecializationID : x.GeneralSpecialization.GeneralSpecializationID == x.GeneralSpecialization.GeneralSpecializationID)).ToList();

                ActualEmployeesBasedOnAssignings.RemoveAll(x => !EmployeesQualificationsOfActualEmployeesList.Any(y => y.EmployeeCode.EmployeeCodeID == x.EmployeeCodeID));

                var query = ActualEmployeesBasedOnAssignings.Select(y => new EmployeesQualificationBasedOnAssigngingsDTO(y.EmployeeCodeNo,
                                                                                                                         y.EmployeeNameAr,
                                                                                                                         y.OrganizationName,
                                                                                                                         y.JobName,
                                                                                                                         y.RankCategoryName,
                                                                                                                         y.RankName,
                                                                                                                         EmployeesQualificationsOfActualEmployeesList.FirstOrDefault(x => x.EmployeeCode.EmployeeCodeID == y.EmployeeCodeID).QualificationDegree.QualificationDegreeName,
                                                                                                                         EmployeesQualificationsOfActualEmployeesList.FirstOrDefault(x => x.EmployeeCode.EmployeeCodeID == y.EmployeeCodeID).Qualification.QualificationName,
                                                                                                                         EmployeesQualificationsOfActualEmployeesList.FirstOrDefault(x => x.EmployeeCode.EmployeeCodeID == y.EmployeeCodeID).GeneralSpecialization.GeneralSpecializationName,
                                                                                                                         y.Sorting
                                                                                                                         ));

                return(query.AsQueryable());
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 4
0
        internal EmployeesQualificationsBLL GetLastEmployeeQualification(int EmployeeCodeID)
        {
            EmployeesQualificationsBLL LastEmployeeQualification = null;

            LastEmployeeQualification = this.GetEmployeeQualificationByEmployeeCodeID(EmployeeCodeID).OrderByDescending(x => x.QualificationDegree.Weight)
                                        //.OrderByDescending(x => x.GraduationDate.HasValue ? x.GraduationDate.Value)
                                        .Take(1).FirstOrDefault();
            if (LastEmployeeQualification == null)
            {
                LastEmployeeQualification = new EmployeesQualificationsBLL()
                {
                    QualificationDegree   = new QualificationsDegreesBLL(),
                    Qualification         = new QualificationsBLL(),
                    GeneralSpecialization = new GeneralSpecializationsBLL()
                };
            }

            return(LastEmployeeQualification);
        }
Exemplo n.º 5
0
        public virtual Result Update()
        {
            try
            {
                Result result = null;

                #region Validation for QualificationID EmployeeQualifications
                EmployeesQualificationsBLL EmployeeQualificationBLL = new EmployeesQualificationsBLL().GetByQualificationID(this.QualificationID);
                if (EmployeeQualificationBLL != null)
                {
                    if (EmployeeQualificationBLL.QualificationDegree.QualificationDegreeID != this.QualificationDegree.QualificationDegreeID)
                    {
                        result            = new Result();
                        result.Entity     = null;
                        result.EnumType   = typeof(QualificationsValidationEnum);
                        result.EnumMember = QualificationsValidationEnum.RejectedBecauseOfThisQualificationExistsInEmployeesQualifications.ToString();
                        return(result);
                    }
                }
                #endregion

                #region Validation for QualificationID JobsCategoriesQualifications
                JobsCategoriesQualificationsBLL JobsCategoriesQualificationsBLL = new JobsCategoriesQualificationsBLL().GetByQualificationID(this.QualificationID);
                if (JobsCategoriesQualificationsBLL != null)
                {
                    if (JobsCategoriesQualificationsBLL.QualificationDegree.QualificationDegreeID != this.QualificationDegree.QualificationDegreeID)
                    {
                        result            = new Result();
                        result.Entity     = null;
                        result.EnumType   = typeof(QualificationsValidationEnum);
                        result.EnumMember = QualificationsValidationEnum.RejectedBecauseOfThisQualificationExistsInJobsCategoriesQualifications.ToString();
                        return(result);
                    }
                }
                #endregion

                Qualifications Qualification = new Qualifications();
                Qualification.QualificationID       = this.QualificationID;
                Qualification.QualificationDegreeID = this.QualificationDegree.QualificationDegreeID;
                Qualification.QualificationName     = this.QualificationName; //QualificationDegreeID
                Qualification.DirectPoints          = this.DirectPoints;
                Qualification.IndirectPoints        = this.IndirectPoints;
                Qualification.LastUpdatedDate       = DateTime.Now;
                Qualification.LastUpdatedBy         = this.LoginIdentity.EmployeeCodeID;

                int UpdateResult = new QualificationsDAL().Update(Qualification);
                if (UpdateResult != 0)
                {
                    result            = new Result();
                    result.Entity     = this;
                    result.EnumType   = typeof(QualificationsValidationEnum);
                    result.EnumMember = QualificationsValidationEnum.Done.ToString();
                }

                return(result);
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 6
0
        public virtual int AddHiringNewEmployee(EmployeesBLL EmployeesBLL, EmployeesCodesBLL EmployeesCodesBLL, EmployeesCareersHistoryBLL EmployeesCareersHistoryBLL, EmployeesQualificationsBLL EmployeesQualificationsBLL, ContractorsBasicSalariesBLL ContractorsBasicSalariesBLL, List <EmployeesAllowancesBLL> EmployeesAllowancesBLLLst)
        {
            try
            {
                EmployeesDAL employeeDal = new EmployeesDAL();
                Employees    employee    = new Employees()
                {
                    EmployeeIDNo              = this.EmployeeIDNo,
                    FirstNameAr               = this.FirstNameAr,
                    MiddleNameAr              = this.MiddleNameAr,
                    GrandFatherNameAr         = this.GrandFatherNameAr,
                    FifthNameAr               = this.FifthNameAr,
                    LastNameAr                = this.LastNameAr,
                    FirstNameEn               = this.FirstNameEn,
                    MiddleNameEn              = this.MiddleNameEn,
                    GrandFatherNameEn         = this.GrandFatherNameEn,
                    FifthNameEn               = this.FifthNameEn,
                    LastNameEn                = this.LastNameEn,
                    EmployeeBirthDate         = (DateTime)this.EmployeeBirthDate.Value.Date,
                    EmployeeBirthPlace        = this.EmployeeBirthPlace,
                    EmployeeMobileNo          = this.EmployeeMobileNo,
                    EmployeePassportNo        = this.EmployeePassportNo,
                    EmployeeEMail             = this.EmployeeEMail,
                    EmployeeIDIssueDate       = this.EmployeeIDIssueDate != null ? (DateTime)this.EmployeeIDIssueDate.Value.Date : (DateTime?)null,
                    EmployeePassportSource    = this.EmployeePassportSource,
                    EmployeePassportIssueDate = this.EmployeePassportIssueDate != null ? (DateTime)this.EmployeePassportIssueDate.Value.Date : (DateTime?)null,
                    EmployeePassportEndDate   = this.EmployeePassportEndDate != null ? (DateTime)this.EmployeePassportEndDate.Value.Date : (DateTime?)null,
                    EmployeeIDExpiryDate      = this.EmployeeIDExpiryDate,
                    EmployeeIDCopyNo          = this.EmployeeIDCopyNo,
                    EmployeeIDIssuePlace      = this.EmployeeIDIssuePlace,
                    DependentCount            = this.DependentCount,
                    MaritalStatusID           = this.MaritalStatus.MaritalStatusID,
                    GenderID      = this.Gender.GenderID,
                    NationalityID = this.Nationality.CountryID,
                    CreatedDate   = DateTime.Now,
                    CreatedBy     = this.LoginIdentity.EmployeeCodeID,
                };
                EmployeesCodes employeesCode = new EmployeesCodes()
                {
                    EmployeeCodeNo = EmployeesCodesBLL.EmployeeCodeNo,
                    EmployeeTypeID = EmployeesCodesBLL.EmployeeType.EmployeeTypeID,
                    IsActive       = true,
                    CreatedDate    = DateTime.Now,
                    CreatedBy      = this.LoginIdentity.EmployeeCodeID
                };

                EmployeesCareersHistory employeeCareerHistory = new EmployeesCareersHistory()
                {
                    CareerHistoryTypeID  = EmployeesCareersHistoryBLL.CareerHistoryType.CareerHistoryTypeID,
                    CareerDegreeID       = EmployeesCareersHistoryBLL.CareerDegree.CareerDegreeID,
                    OrganizationJobID    = EmployeesCareersHistoryBLL.OrganizationJob.OrganizationJobID,
                    JoinDate             = EmployeesCareersHistoryBLL.JoinDate.Date,
                    TransactionStartDate = EmployeesCareersHistoryBLL.JoinDate.Date,
                    IsActive             = true,
                    CreatedBy            = this.LoginIdentity.EmployeeCodeID,
                    CreatedDate          = DateTime.Now
                };
                EmployeesQualifications employeeQualification = new EmployeesQualifications();
                employeeQualification.QualificationDegreeID   = EmployeesQualificationsBLL.QualificationDegree.QualificationDegreeID;
                employeeQualification.QualificationID         = EmployeesQualificationsBLL.Qualification.QualificationID;
                employeeQualification.GeneralSpecializationID = EmployeesQualificationsBLL.GeneralSpecialization.GeneralSpecializationID;
                employeeQualification.ExactSpecializationID   = EmployeesQualificationsBLL.ExactSpecialization.ExactSpecializationID == 0 ? (int?)null : EmployeesQualificationsBLL.ExactSpecialization.ExactSpecializationID;
                employeeQualification.UniSchName          = EmployeesQualificationsBLL.UniSchName;
                employeeQualification.Department          = EmployeesQualificationsBLL.Department;
                employeeQualification.FullGPA             = EmployeesQualificationsBLL.FullGPA;
                employeeQualification.GPA                 = EmployeesQualificationsBLL.GPA;
                employeeQualification.StudyPlace          = EmployeesQualificationsBLL.StudyPlace;
                employeeQualification.GraduationDate      = EmployeesQualificationsBLL.GraduationDate;
                employeeQualification.GraduationYear      = EmployeesQualificationsBLL.GraduationYear;
                employeeQualification.Percentage          = EmployeesQualificationsBLL.Percentage;
                employeeQualification.QualificationTypeID = EmployeesQualificationsBLL.QualificationType.QualificationTypeID == 0 ? (int?)null : EmployeesQualificationsBLL.QualificationType.QualificationTypeID;
                employeeQualification.CreatedDate         = DateTime.Now;
                employeeQualification.CreatedBy           = this.LoginIdentity.EmployeeCodeID;

                ContractorsBasicSalaries contractorBasicSalary = new ContractorsBasicSalaries();
                contractorBasicSalary.BasicSalary        = ContractorsBasicSalariesBLL.BasicSalary;
                contractorBasicSalary.TransfareAllowance = ContractorsBasicSalariesBLL.TransfareAllowance;
                contractorBasicSalary.CreatedDate        = DateTime.Now;
                contractorBasicSalary.CreatedBy          = this.LoginIdentity.EmployeeCodeID;

                List <EmployeesAllowances> employeesAllowancesList = new List <EmployeesAllowances>();
                foreach (var EmployeeAllowanceBLL in EmployeesAllowancesBLLLst)
                {
                    employeesAllowancesList.Add(new EmployeesAllowances()
                    {
                        AllowanceID        = EmployeeAllowanceBLL.Allowance.AllowanceID,
                        AllowanceStartDate = EmployeeAllowanceBLL.AllowanceStartDate,
                        IsActive           = EmployeeAllowanceBLL.IsActive,
                        CreatedBy          = this.LoginIdentity.EmployeeCodeID,
                        CreatedDate        = DateTime.Now
                    });
                }


                employee.EmployeesCodes = new List <EmployeesCodes>();
                employee.EmployeesCodes.Add(employeesCode);
                employeesCode.EmployeesCareersHistory = new List <EmployeesCareersHistory>();
                employeesCode.EmployeesCareersHistory.Add(employeeCareerHistory);
                employeesCode.EmployeesQualifications = new List <EmployeesQualifications>();
                employeesCode.EmployeesQualifications.Add(employeeQualification);
                #region check if the new employee is contractor then add financial advantages to him
                OrganizationsJobsBLL OrganizationsJobsBLL = new OrganizationsJobsBLL().GetByOrganizationJobID(employeeCareerHistory.OrganizationJobID);
                if (OrganizationsJobsBLL.Rank.RankCategory.RankCategoryID == (int)RanksCategoriesEnum.ContractualExpats || OrganizationsJobsBLL.Rank.RankCategory.RankCategoryID == (int)RanksCategoriesEnum.ContractualSaudis)
                {
                    employeesCode.ContractorsBasicSalaries = new List <ContractorsBasicSalaries>();
                    employeesCode.ContractorsBasicSalaries.Add(contractorBasicSalary);
                    employeeCareerHistory.EmployeesAllowances = employeesAllowancesList;
                }
                #endregion
                employeeDal.Insert(employee);
                return(this.EmployeeID);
            }
            catch
            {
                throw;
            }
        }