public virtual Result Update() { try { Result result = null; #region Validation Employee must be Contractor (Saudi / Non-Saudi) EmployeesCodesBLL EmployeeCode = new EmployeesCodesBLL().GetByEmployeeCodeID(this.EmployeeCode.EmployeeCodeID); if (EmployeeCode.EmployeeCurrentJob.OrganizationJob.Rank.RankCategory.RankCategoryID == (int)RanksCategoriesEnum.Employee || EmployeeCode.EmployeeCurrentJob.OrganizationJob.Rank.RankCategory.RankCategoryID == (int)RanksCategoriesEnum.SaudiLabor || EmployeeCode.EmployeeCurrentJob.OrganizationJob.Rank.RankCategory.RankCategoryID == (int)RanksCategoriesEnum.User || EmployeeCode.EmployeeCurrentJob.OrganizationJob.Rank.RankCategory.RankCategoryID == (int)RanksCategoriesEnum.Army) { result = new Result(); result.Entity = this; result.EnumType = typeof(ContractorsBasicSalariesValidationEnum); result.EnumMember = ContractorsBasicSalariesValidationEnum.RejectedBecauseOfEmployeeMustBeContractualEmployee.ToString(); return(result); } #endregion ContractorsBasicSalaries ContractorBasicSalary = new ContractorsBasicSalaries(); ContractorBasicSalary.ContractorBasicSalaryID = this.ContractorBasicSalaryID; ContractorBasicSalary.EmployeeCodeID = this.EmployeeCode.EmployeeCodeID; ContractorBasicSalary.BasicSalary = this.BasicSalary; ContractorBasicSalary.TransfareAllowance = this.TransfareAllowance; ContractorBasicSalary.LastUpdatedDate = DateTime.Now; ContractorBasicSalary.LastUpdatedBy = this.LoginIdentity.EmployeeCodeID; int UpdateResult = new ContractorsBasicSalariesDAL().Update(ContractorBasicSalary); if (UpdateResult != 0) { result = new Result(); result.Entity = this; result.EnumType = typeof(ContractorsBasicSalariesValidationEnum); result.EnumMember = ContractorsBasicSalariesValidationEnum.Done.ToString(); } return(result); } catch { throw; } }
internal ContractorsBasicSalariesBLL MapContractorBasicSalary(ContractorsBasicSalaries ContractorBasicSalary) { try { ContractorsBasicSalariesBLL ContractorBasicSalaryBLL = null; if (ContractorBasicSalary != null) { ContractorBasicSalaryBLL = new ContractorsBasicSalariesBLL() { ContractorBasicSalaryID = ContractorBasicSalary.ContractorBasicSalaryID, EmployeeCode = new EmployeesCodesBLL().MapEmployeeCode(ContractorBasicSalary.EmployeesCodes), BasicSalary = ContractorBasicSalary.BasicSalary, TransfareAllowance = ContractorBasicSalary.TransfareAllowance.HasValue ? ContractorBasicSalary.TransfareAllowance.Value : 0, CreatedDate = ContractorBasicSalary.CreatedDate.HasValue ? ContractorBasicSalary.CreatedDate.Value : DateTime.Now, //CreatedBy = new EmployeesCodesBLL().MapEmployeeCode(ContractorBasicSalary.CreatedByNav) }; } return(ContractorBasicSalaryBLL); } 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; } }