public EmployeesCareersHistoryBLL MapEmployeeCareerHistory(EmployeesCareersHistory EmployeeCareerHistory) { try { EmployeesCareersHistoryBLL EmployeeCareerHistoryBLL = null; if (EmployeeCareerHistory != null) { EmployeeCareerHistoryBLL = new EmployeesCareersHistoryBLL() { EmployeeCareerHistoryID = EmployeeCareerHistory.EmployeeCareerHistoryID, CareerHistoryType = new CareersHistoryTypesBLL().MapCareerHistoryType(EmployeeCareerHistory.CareersHistoryTypes), CareerDegree = new CareersDegreesBLL().MapCareerDegree(EmployeeCareerHistory.CareersDegrees), OrganizationJob = new OrganizationsJobsBLL().MapOrganizationJob(EmployeeCareerHistory.OrganizationsJobs), EmployeeCode = new EmployeesCodesBLL() { EmployeeCodeID = EmployeeCareerHistory.EmployeeCodeID, EmployeeCodeNo = EmployeeCareerHistory.EmployeesCodes.EmployeeCodeNo, Employee = new EmployeesBLL().MapEmployee(EmployeeCareerHistory.EmployeesCodes.Employees) }, JoinDate = EmployeeCareerHistory.JoinDate, TransactionStartDate = EmployeeCareerHistory.TransactionStartDate, TransactionEndDate = EmployeeCareerHistory.TransactionEndDate, IsActive = EmployeeCareerHistory.IsActive, CreatedDate = EmployeeCareerHistory.CreatedDate, }; } return(EmployeeCareerHistoryBLL); } catch (Exception ex) { throw ex; } }
private int ChangeCurrentJobByEmployeeCodeID(int EmployeeCodeID) { List <EmployeesCareersHistoryBLL> ObjList = new EmployeesCodesBLL().GetCareerHistoryByEmployeeCodeID(EmployeeCodeID).OrderByDescending(x => x.JoinDate).ToList(); foreach (var item in ObjList) { EmployeesCareersHistory EmployeeCareerHistory = new EmployeesCareersHistory() { EmployeeCareerHistoryID = item.EmployeeCareerHistoryID, LastUpdatedBy = this.LoginIdentity != null ? this.LoginIdentity.EmployeeCodeID : (int?)null, LastUpdatedDate = DateTime.Now, }; if (ObjList.IndexOf(item) == 0) { EmployeeCareerHistory.IsActive = true; } else { EmployeeCareerHistory.IsActive = false; } new EmployeesCareersHistoryDAL().UpdateIsActive(EmployeeCareerHistory); } return(0); }
public Result DecreaseCareerDegree() { try { Result result = new Result(); #region Update record EmployeesCareersHistory EmployeeCareerHistory = new EmployeesCareersHistory() { EmployeeCareerHistoryID = this.EmployeeCareerHistoryID, CareerDegreeID = this.CareerDegree.CareerDegreeID - 1, LastUpdatedBy = this.LoginIdentity != null ? this.LoginIdentity.EmployeeCodeID : (int?)null, LastUpdatedDate = DateTime.Now, }; new EmployeesCareersHistoryDAL().UpdateCareerDegree(EmployeeCareerHistory); #endregion result.Entity = this; result.EnumType = typeof(CareersHistoryValidationEnum); result.EnumMember = CareersHistoryValidationEnum.Done.ToString(); return(result); } catch { throw; } }
public Result UpdateTransactionStartDate(int EmployeeCareerHistoryID, DateTime TransactionStartDate, int LastUpdatedBy) { try { Result result = new Result(); EmployeesCareersHistory EmployeeCareerHistory = new EmployeesCareersHistory() { EmployeeCareerHistoryID = EmployeeCareerHistoryID, JoinDate = TransactionStartDate, TransactionStartDate = TransactionStartDate, LastUpdatedBy = LastUpdatedBy, LastUpdatedDate = DateTime.Now }; new EmployeesCareersHistoryDAL().UpdateTransactionStartDate(EmployeeCareerHistory); result.Entity = this; result.EnumType = typeof(CareersHistoryValidationEnum); result.EnumMember = CareersHistoryValidationEnum.Done.ToString(); return(result); } catch { throw; } }
public int GetOnGoingExperienceDays(EmployeesCareersHistory EmployeeHiringRecord, DateTime TillDate) { int experience = 0; if (EmployeeHiringRecord != null && EmployeeHiringRecord.EmployeeCareerHistoryID > 0) { experience = Convert.ToInt32((TillDate.Date - EmployeeHiringRecord.JoinDate.Date).TotalDays); } return(experience); }
public Result IncreaseCareerDegree(EmployeesCareersHistoryBLL EmpCareerHistory) { try { Result result = new Result(); int newCareerDegree = EmpCareerHistory.CareerDegree.CareerDegreeID + 1; #region Check newCareerDegree Exist In CareerDegree table. if (!new CareersDegreesBLL().GetCareersDegrees().Exists(c => c.CareerDegreeID == newCareerDegree)) { result.Entity = EmpCareerHistory; result.EnumType = typeof(CareersHistoryValidationEnum); result.EnumMember = CareersHistoryValidationEnum.RejectedBecauseOfCareerDegreeOutOfRange.ToString(); return(result); } #endregion // checking if new career degree & rank has 'basic salary' exists or not, if not exists skip if (EmpCareerHistory.OrganizationJob != null && EmpCareerHistory.OrganizationJob.Rank != null) { BasicSalariesBLL BasicSalary = new BasicSalariesBLL().GetBasicSalary(EmpCareerHistory.OrganizationJob.Rank.RankID, newCareerDegree); if (BasicSalary.BasicSalary <= 0) { result.Entity = EmpCareerHistory; result.EnumType = typeof(CareersHistoryValidationEnum); result.EnumMember = CareersHistoryValidationEnum.RejectedBecauseOfCareerDegreeOutOfRange.ToString(); return(result); } } #region Update record EmployeesCareersHistory EmployeeCareerHistory = new EmployeesCareersHistory() { EmployeeCareerHistoryID = EmpCareerHistory.EmployeeCareerHistoryID, CareerDegreeID = newCareerDegree, LastUpdatedBy = EmpCareerHistory.LoginIdentity != null ? EmpCareerHistory.LoginIdentity.EmployeeCodeID : (int?)null, LastUpdatedDate = DateTime.Now, }; new EmployeesCareersHistoryDAL().UpdateCareerDegree(EmployeeCareerHistory); #endregion result.Entity = EmpCareerHistory; result.EnumType = typeof(CareersHistoryValidationEnum); result.EnumMember = CareersHistoryValidationEnum.Done.ToString(); return(result); } catch { throw; } }
public void DeactivateAllCareerHistoryOfEmployee(int EmployeeCodeID) { try { List <EmployeesCareersHistory> EmployeesCareersHistoryList = new EmployeesCareersHistoryDAL().GetEmployeesCareersHistoryByEmployeeCodeID(EmployeeCodeID); EmployeesCareersHistory EmployeeCareerHistory = new EmployeesCareersHistory(); foreach (var item in EmployeesCareersHistoryList) { EmployeeCareerHistory = item; EmployeeCareerHistory.IsActive = false; EmployeeCareerHistory.LastUpdatedDate = DateTime.Now; EmployeeCareerHistory.LastUpdatedBy = this.LoginIdentity.EmployeeCodeID; new EmployeesCareersHistoryDAL().UpdateIsActive(EmployeeCareerHistory); } } catch (Exception ex) { throw ex; } }
public Result Add() { try { Result result = new Result(); EmployeesCareersHistoryBLL HiringRecord = this.GetHiringRecordByEmployeeCodeID(this.EmployeeCode.EmployeeCodeID); #region Check about is hiring exists before or not if (this.CareerHistoryType.CareerHistoryTypeID.Equals((int)CareersHistoryTypesEnum.Hiring)) { if (HiringRecord != null) { result.Entity = HiringRecord; result.EnumType = typeof(CareersHistoryValidationEnum); result.EnumMember = CareersHistoryValidationEnum.RejectedBecauseOfAlreadyHiringBefore.ToString(); return(result); } } #endregion #region TASK 260 : check new employee career history record date must be less than 'Join Date' of hiring record if (this.CareerHistoryType.CareerHistoryTypeID != (int)CareersHistoryTypesEnum.Hiring) { if (HiringRecord != null && HiringRecord.JoinDate.Date >= this.JoinDate.Date) { result.Entity = HiringRecord; result.EnumType = typeof(CareersHistoryValidationEnum); result.EnumMember = CareersHistoryValidationEnum.RejectedBecauseOfJoinDateMustBeLessThanHiringRecordJoinDate.ToString(); return(result); } } #endregion #region Create new record EmployeesCareersHistory EmployeeCareerHistory = new EmployeesCareersHistory() { EmployeeCodeID = this.EmployeeCode.EmployeeCodeID, CareerHistoryTypeID = this.CareerHistoryType.CareerHistoryTypeID, CareerDegreeID = this.CareerDegree.CareerDegreeID, OrganizationJobID = this.OrganizationJob.OrganizationJobID, JoinDate = this.JoinDate.Date, TransactionStartDate = this.JoinDate.Date, IsActive = false, CreatedBy = this.LoginIdentity.EmployeeCodeID, CreatedDate = DateTime.Now }; EmployeeCareerHistory.EmployeeCareerHistoryID = new EmployeesCareersHistoryDAL().Insert(EmployeeCareerHistory); #endregion #region Change current job ChangeCurrentJobByEmployeeCodeID(this.EmployeeCode.EmployeeCodeID); #endregion #region TASK 310: Break last assigning //EmployeesCareersHistoryBLL LastActiveCareerHistory = new EmployeesCareersHistoryBLL().GetEmployeeCurrentJob(this.EmployeeCode.EmployeeCodeID); //if (LastActiveCareerHistory != null && LastActiveCareerHistory.EmployeeCareerHistoryID > 0) //{ new BaseAssigningsBLL() { LoginIdentity = this.LoginIdentity } .BreakLastAssigning(this.EmployeeCode.EmployeeCodeID, EmployeeCareerHistory.JoinDate, AssigningsReasonsEnum.CreatedNewCareerHistory); //} #endregion result.Entity = this; result.EnumType = typeof(CareersHistoryValidationEnum); result.EnumMember = CareersHistoryValidationEnum.Done.ToString(); return(result); } catch (Exception ex) { throw ex; } }
public Result Update() { try { Result result = new Result(); #region Validation to check if EmployeeCareerHistory Exist in PromotionsRecordsEmployees as NewEmployeeCareerHistory or CurrentEmployeeCareerHistory //check if OrganizationJob Exist in PromotionsRecordsJobsVacancies as PromotionRecordJobVacancyID // Then Can't update OrganizationID,RankID,JobID List <PromotionsRecordsEmployeesBLL> PromotionsRecordsEmployeesList = new PromotionsRecordsEmployeesBLL().GetByEmployeeCareerHistoryID(this.EmployeeCareerHistoryID); if (PromotionsRecordsEmployeesList.Count != 0) { result.EnumType = typeof(CareersHistoryValidationEnum); result.EnumMember = CareersHistoryValidationEnum.RejectedBecauseOfExistsInPromotionsRecordsEmployees.ToString(); return(result); } #endregion #region Check about is hiring exists before or not if (this.CareerHistoryType.CareerHistoryTypeID.Equals((int)CareersHistoryTypesEnum.Hiring)) { EmployeesCareersHistoryBLL Hr = this.GetHiringRecordByEmployeeCodeID(this.EmployeeCode.EmployeeCodeID); if (Hr != null) { if (Hr.EmployeeCareerHistoryID != this.EmployeeCareerHistoryID) { result.Entity = Hr; result.EnumType = typeof(CareersHistoryValidationEnum); result.EnumMember = CareersHistoryValidationEnum.RejectedBecauseOfAlreadyHiringBefore.ToString(); return(result); } } } #endregion #region TASK 260 : check new employee career history record date must be less than 'Join Date' of hiring record if (this.CareerHistoryType.CareerHistoryTypeID != (int)CareersHistoryTypesEnum.Hiring) { EmployeesCareersHistoryBLL oo = this.GetHiringRecordByEmployeeCodeID(this.EmployeeCode.EmployeeCodeID); if (oo != null && oo.JoinDate.Date >= this.JoinDate.Date) { result.Entity = oo; result.EnumType = typeof(CareersHistoryValidationEnum); result.EnumMember = CareersHistoryValidationEnum.RejectedBecauseOfJoinDateMustBeLessThanHiringRecordJoinDate.ToString(); return(result); } } #endregion #region if the record is hiring ... Check about there is vacation transactions before new hiring date or not if (this.CareerHistoryType.CareerHistoryTypeID.Equals((int)CareersHistoryTypesEnum.Hiring)) { bool IsVacationExists = new BaseVacationsBLL().IsEmployeeVacationExistsBeforeDate(this.EmployeeCode.EmployeeCodeID, this.JoinDate.Date); if (IsVacationExists) { //result.Entity = Hr; result.EnumType = typeof(CareersHistoryValidationEnum); result.EnumMember = CareersHistoryValidationEnum.RejectedHiringDateUpdatingBecauseOfAlreadyActionsBefore.ToString(); return(result); } } #endregion #region Update record EmployeesCareersHistory EmployeeCareerHistory = new EmployeesCareersHistory() { EmployeeCareerHistoryID = this.EmployeeCareerHistoryID, CareerHistoryTypeID = this.CareerHistoryType.CareerHistoryTypeID, CareerDegreeID = this.CareerDegree.CareerDegreeID, OrganizationJobID = this.OrganizationJob.OrganizationJobID, JoinDate = this.JoinDate.Date, TransactionStartDate = this.JoinDate.Date, LastUpdatedBy = this.LoginIdentity != null ? this.LoginIdentity.EmployeeCodeID : (int?)null, LastUpdatedDate = DateTime.Now, IsActive = this.IsActive, }; new EmployeesCareersHistoryDAL().Update(EmployeeCareerHistory); #endregion #region Change current job ChangeCurrentJobByEmployeeCodeID(this.EmployeeCode.EmployeeCodeID); #endregion result.Entity = this; result.EnumType = typeof(CareersHistoryValidationEnum); result.EnumMember = CareersHistoryValidationEnum.Done.ToString(); return(result); } catch { throw; } }
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; } }