using System; using System.Collections.Generic; using System.Text; using Ease.Core.DataAccess; using Ease.Core.Model; using Ease.Core.Utility; using HRM.BO; using HRM.BO.ess; using static iTextSharp.text.pdf.AcroFields; namespace HRM.DA.Service.ess { public class ProfileUpdateRequestService : ServiceTemplate, IProfileUpdateRequestService { private void MapObject(ProfileUpdateRequest item, DataReader dataReader) { base.SetObjectID(item, dataReader.GetInt32("purId").Value); item.RequestDate = dataReader.GetDateTime("Requestdate").Value; item.EmployeeNo = dataReader.GetString("EmployeeNo"); item.EmployeeName = dataReader.GetString("EmployeeName"); item.PURequestType = (EnumPURequestType)dataReader.GetInt32("PURequestType").Value; item.PURequestStatus = (EnumPURequestStatus)dataReader.GetInt32("PURequestStatus"); item.RequestEmpID = dataReader.GetInt32("RequestEmpID").Value; item.RequestRemarks = dataReader.GetString("RequestRemarks"); item.RequestDescription = dataReader.GetString("RequestDescription"); item.ApproveDate = dataReader.GetDateTime("ApproveDate"); item.ApproveBy = dataReader.GetInt32("ApproveBy"); item.ApproveRemarks = dataReader.GetString("ApproveRemarks"); item.PastInfo = dataReader.GetString("PastInfo"); item.MobileNo = dataReader.GetString("MobileNo"); item.NationalID = dataReader.GetString("NationalID"); item.BloodGroup = (EnumBloodGroup)dataReader.GetInt32("BloodGroup", 0); item.TIN = dataReader.GetString("TIN"); item.PassportNo = dataReader.GetString("PassportNo"); item.PassportIssuePlace = dataReader.GetString("PassportIssuePlace"); item.PassportIssueDate = dataReader.GetDateTime("PassportIssueDate"); item.PassportExpiryDate = dataReader.GetDateTime("PassportExpiryDate"); item.FatherName = dataReader.GetString("FatherName"); item.MotherName = dataReader.GetString("MotherName"); item.FatherOccupationID = dataReader.GetInt32("FatherOccupationID"); item.MotherOccupationID = dataReader.GetInt32("MotherOccupationID"); item.PermanentAddress = dataReader.GetString("PermanentAddress"); item.PermanentLandPhone = dataReader.GetString("PermanentLandPhone"); item.PermanentMobile = dataReader.GetString("PermanentMobile"); item.PermanentDistrictID = dataReader.GetInt32("PermanentDistrictID"); item.PermanentThanaID = dataReader.GetInt32("PermanentThanaID"); item.PresentAddress = dataReader.GetString("PresentAddress"); item.PresentLandPhone = dataReader.GetString("PresentLandPhone"); item.PresentMobile = dataReader.GetString("PresentMobile"); item.PresentDistrictID = dataReader.GetInt32("PresentDistrictID"); item.PresentThanaID = dataReader.GetInt32("PresentThanaID"); item.EmergencyContactPerson = dataReader.GetString("EmergencyContactPerson"); item.EmergencyAddress = dataReader.GetString("EmergencyAddress"); item.EmergencyLandPhone = dataReader.GetString("EmergencyLandPhone"); item.EmergencyMobileNo = dataReader.GetString("EmergencyMobileNo"); item.EmergencyRelationID = dataReader.GetInt32("EmergencyRelationID"); item.SpouseName = dataReader.GetString("SpouseName"); item.SpouseEducationLevelID = dataReader.GetInt32("SpouseEducationLevelID"); item.SpouseOccupationID = dataReader.GetInt32("SpouseOccupationID"); item.SpouseOccupationID = dataReader.GetInt32("SpouseOccupationID"); item.SpouseMarriageDate = dataReader.GetDateTime("SpouseMarriageDate"); item.ChildGender = (EnumGender)dataReader.GetInt32("ChildGender", 0); item.ChildName = dataReader.GetString("ChildName"); item.ChildBirthDate = dataReader.GetDateTime("ChildBirthDate"); item.ChildOccupationID = dataReader.GetInt32("ChildOccupationID"); item.ChildMaritalStatus = (EnumMaritalStatus)dataReader.GetInt32("ChildMaritalStatus", 0); item.ChildPassportNo = dataReader.GetString("ChildPassportNo"); item.ChildPassportIssuePlace = dataReader.GetString("ChildPassportIssuePlace"); item.ChildPassportIssueDate = dataReader.GetDateTime("ChildPassportIssueDate"); item.ChildPassportExpiryDate = dataReader.GetDateTime("ChildPassportExpiryDate"); item.AcademicEducationTypeID = dataReader.GetInt32("AcademicEducationTypeID"); item.AcademicDegreeID = dataReader.GetInt32("AcademicDegreeID"); item.AcademicDisciplineID = dataReader.GetInt32("AcademicDisciplineID"); item.AcademicUniversityBoardID = dataReader.GetInt32("AcademicUniversityBoardID"); item.AcademicPassingYear = dataReader.GetInt32("AcademicPassingYear"); item.AcademicResultID = dataReader.GetInt32("AcademicResultID"); item.AcademicGPA = dataReader.GetDouble("AcademicGPA"); item.AcademicOutOf = dataReader.GetDouble("AcademicOutOf"); item.AcademicInstitute = dataReader.GetString("AcademicInstitute"); item.AcademicExamHeldOn = dataReader.GetString("AcademicExamHeldOn"); item.AcademicHeightsEducation = dataReader.GetBoolean("AcademicHeightsEducation"); item.NomineeTypeID = dataReader.GetInt32("NomineeTypeID"); item.NomineeRelationID = dataReader.GetInt32("NomineeRelationID"); item.NomineePercent = dataReader.GetInt32("NomineePercent"); item.NomineeOccupationID = dataReader.GetInt32("NomineeOccupationID"); item.NomineeName = dataReader.GetString("NomineeName"); item.NomineeAddress = dataReader.GetString("NomineeAddress"); item.NomineeTelephone = dataReader.GetString("NomineeTelephone"); item.NomineeEmail = dataReader.GetString("NomineeEmail"); item.NominationDate = dataReader.GetDateTime("NominationDate"); item.NomineeDateOfBirth = dataReader.GetDateTime("NomineeDateOfBirth"); item.TrainingTypeId = dataReader.GetInt32("TrainingTypeId"); item.NatureOfTrainingId = dataReader.GetInt32("NatureOfTrainingId"); item.TrainingTitle = dataReader.GetString("TrainingTitle"); item.TrainingDescription = dataReader.GetString("TrainingDescription"); item.TrainingInstitutionId = dataReader.GetInt32("TrainingInstitutionId"); item.TrainingInstituteName = dataReader.GetString("TrainingInstituteName"); item.TrainingFromDate = dataReader.GetDateTime("TrainingFromDate"); item.TrainingToDate = dataReader.GetDateTime("TrainingToDate"); item.TrainingCountryId = dataReader.GetInt32("TrainingCountryId"); item.TrainingSponsoredType = (EnumSponsoredType)dataReader.GetInt32("TrainingSponsoredType", 0); item.TrainingAchievement = dataReader.GetString("TrainingAchievement"); item.TrainingMonth = dataReader.GetInt32("TrainingMonth"); item.TrainingDay = dataReader.GetInt32("TrainingDay"); item.TrainingHour = dataReader.GetInt32("TrainingHour"); item.Trainingfees = dataReader.GetInt32("Trainingfees"); item.TrainingOtherCost = dataReader.GetInt32("TrainingOtherCost"); item.ExperienceEmployer = dataReader.GetString("ExperienceEmployer"); item.ExperienceBusinessType = dataReader.GetString("ExperienceBusinessType"); item.ExperienceEmployerContactInfo = dataReader.GetString("ExperienceEmployerContactInfo"); item.ExperienceDesignation = dataReader.GetString("ExperienceDesignation"); item.ExperienceAddress = dataReader.GetString("ExperienceAddress"); item.ExperienceRole = dataReader.GetString("ExperienceRole"); item.ExperienceTelephone = dataReader.GetString("ExperienceTelephone"); item.ExperienceFrom = dataReader.GetDateTime("ExperienceFrom"); item.ExperienceTo = dataReader.GetDateTime("ExperienceFrom"); item.AdminRemarks = dataReader.GetString("AdminRemarks"); item.CreatedBy = dataReader.GetInt32("CreatedBy").Value; item.ModifiedBy = dataReader.GetInt32("ModifiedBy"); item.CreatedDate = dataReader.GetDateTime("CreationDate").Value; item.ModifiedDate = dataReader.GetDateTime("ModifiedDate"); this.SetObjectState(item, Ease.Core.ObjectState.Saved); } protected override T CreateObject(DataReader dataReader) { ProfileUpdateRequest profileUpdateRequest = new ProfileUpdateRequest(); MapObject(profileUpdateRequest, dataReader); return profileUpdateRequest as T; } protected ProfileUpdateRequest CreateObject(DataReader dataReader) { ProfileUpdateRequest profileUpdateRequest = new ProfileUpdateRequest(); MapObject(profileUpdateRequest, dataReader); return profileUpdateRequest; } public ProfileUpdateRequest GetProfileUpdateRequestById(int id) { ProfileUpdateRequest item = new ProfileUpdateRequest(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dataReader = new DataReader(ProfileUpdateRequestDA.GetById(tc, id)); if (dataReader.Read()) { item = this.CreateObject(dataReader); } dataReader.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return item; } public List GetAllByEmpId(int empId) { List items = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dataReader = new DataReader(ProfileUpdateRequestDA.GetAllByEmpId(tc, empId)); items = this.CreateObjects(dataReader); dataReader.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return items; } public int GetPURCountEmpIdAndStatus(int empId, EnumPURequestStatus status) { TransactionContext tc = null; int ans; try { tc = TransactionContext.Begin(); ans = ProfileUpdateRequestDA.GetAllByEmpIdAndStatus(tc, empId, status); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return ans; } public int TotalProfileUpdateRequested() { TransactionContext tc = null; int ans; try { tc = TransactionContext.Begin(); ans = ProfileUpdateRequestDA.TotalProfileUpdateRequested(tc); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return ans; } public List GetAll() { List items = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dataReader = new DataReader(ProfileUpdateRequestDA.GetAll(tc)); items = this.CreateObjects(dataReader); dataReader.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return items; } public void UpdateStatusToRejected(ProfileUpdateRequest item) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); //ProfileUpdateRequestDA.Delete(tc, id); item.PURequestStatus = EnumPURequestStatus.Reject; item.ApproveDate = DateTime.Now; item.ApproveBy = item.currentUserId; ProfileUpdateRequestDA.Update(tc, item); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public void RejectEmployeeRequestBulk(string ids, int rejectedby, DateTime RejectedTime) { TransactionContext tc = null; try { tc = TransactionContext.Begin(); //ProfileUpdateRequestDA.Delete(tc, id); ProfileUpdateRequestDA.RejectEmployeeRequestBulk(tc, ids,rejectedby,DateTime.Now); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public void UpdateEmployee(ProfileUpdateRequest item) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); switch (item.PURequestType) { case EnumPURequestType.Mobile: ProfileUpdateRequestDA.UpdateMobileNo(tc, item); ApproveAttachment(item, enumEmpFileUploadType.Mobile, 0); break; case EnumPURequestType.NationalID: ProfileUpdateRequestDA.UpdateNationalId(tc, item); ApproveAttachment(item, enumEmpFileUploadType.nationalID, 0); break; case EnumPURequestType.BloodGroup: ProfileUpdateRequestDA.UpdateBloodGroup(tc, item); ApproveAttachment(item, enumEmpFileUploadType.bloodGroup, 0); break; case EnumPURequestType.TIN: ProfileUpdateRequestDA.UpdateTIN(tc, item); ApproveAttachment(item, enumEmpFileUploadType.TIN, 0); break; case EnumPURequestType.PassportNO: ProfileUpdateRequestDA.PassportNO(tc, item); ApproveAttachment(item, enumEmpFileUploadType.passport, 0); break; case EnumPURequestType.Picture: ApproveAttachment(item, enumEmpFileUploadType.photo, 0); break; case EnumPURequestType.Father_Mother_Info: SaveParentsInfo(item); break; case EnumPURequestType.Permanent_Contact: SavePermanentContact(item); break; case EnumPURequestType.Present_Contact: SavePresentContact(item); break; case EnumPURequestType.Emergency_Contact: SaveEmergencyContact(item); break; case EnumPURequestType.Spouse: SaveSpouse(item); break; case EnumPURequestType.Children: SaveChildren(item); break; case EnumPURequestType.Education: int eduRef = SaveAcademic(item); ApproveAttachment(item, enumEmpFileUploadType.Education, eduRef); break; case EnumPURequestType.Nominee: int nomineeRef = SaveNominee(item); ApproveAttachment(item, enumEmpFileUploadType.Nominee, nomineeRef); break; case EnumPURequestType.Training: int trainRef = SaveTraining(item); ApproveAttachment(item, enumEmpFileUploadType.training, trainRef); break; case EnumPURequestType.Experience: int expRef = SaveExperience(item); ApproveAttachment(item, enumEmpFileUploadType.Experience, expRef); break; default: break; } ProfileUpdateRequestDA.UpdateProfilePercentage(tc, item.RequestEmpID); ProfileUpdateRequestDA.UpdateStatusToApproved(tc, item.ID,item.currentUserId,DateTime.Now); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } /*public int UpdateParcentInfoForNationalId(TransactionContext tc, ProfileUpdateRequest item) { string ans = ProfileUpdateRequestDA.NationalIdExistingData(tc, item); return 0; }*/ public int SaveParentsInfo(ProfileUpdateRequest item) { TransactionContext tc = null; Employee employee = new Employee(); EmployeeService employeeService = new EmployeeService(); try { employee = employeeService.Get(item.RequestEmpID); tc = TransactionContext.Begin(true); if (item.FatherName != "") employee.FatherName = item.FatherName; if (item.MotherName != "") employee.MotherName = item.MotherName; if (item.FatherOccupationID != null) employee.FatherOccupationId = item.FatherOccupationID.GetValueOrDefault(); if (item.MotherOccupationID != null) employee.MotherOccupationId = item.MotherOccupationID.GetValueOrDefault(); employee.ID = item.RequestEmpID; ProfileUpdateRequestDA.UpdateParentsInfo(tc, employee); tc.End(); return item.ID; } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public void ApproveAttachment(ProfileUpdateRequest item, enumEmpFileUploadType fileType, int refId) { TransactionContext tc = null; empFileupload empFileupload = new empFileupload(); HREmployeeService hrEmployeeService = new HREmployeeService(); try { empFileupload = hrEmployeeService.GetuploadedFileInProfileUpdate(item.RequestEmpID, item.RequestEmpID, fileType); if (empFileupload != null) { if (refId > 0) empFileupload.referenceID = refId; hrEmployeeService.ApproveUplaodFileInProfileUpdate(empFileupload); } } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public int SaveChildren(ProfileUpdateRequest item) { TransactionContext tc = null; EmpChildren child = new EmpChildren(); try { tc = TransactionContext.Begin(true); if (item.ChildName != "") child.Name = item.ChildName; if (item.ChildGender != null) child.Gender = item.ChildGender.GetValueOrDefault(); if (item.ChildBirthDate != null) child.BirthDate = item.ChildBirthDate.GetValueOrDefault(); if (item.ChildOccupationID != null) child.OccupationID = item.ChildOccupationID.GetValueOrDefault(); if (item.ChildMaritalStatus != null) child.MaritalStatus = item.ChildMaritalStatus.GetValueOrDefault(); if (item.ChildPassportNo != "") child.PassportNo = item.ChildPassportNo; if (item.ChildPassportIssuePlace != "") child.PassportIssuePlace = item.ChildPassportIssuePlace; if (item.ChildPassportIssueDate != null) child.PassportIssueDate = item.ChildPassportIssueDate.GetValueOrDefault(); if (item.ChildPassportExpiryDate != null) child.PassportExpDate = item.ChildPassportExpiryDate.GetValueOrDefault(); child.EmployeeID = item.RequestEmpID; this.SetObjectID(child, (HREmployeeDA.GetNewID(tc, "EmpChildren", "ChildID"))); HREmployeeDA.Insert(tc, child); tc.End(); return item.ID; } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public int SaveTraining(ProfileUpdateRequest item) { TransactionContext tc = null; EmpTraining training = new EmpTraining(); try { tc = TransactionContext.Begin(true); training.EmployeeID = item.RequestEmpID; training.Name = item.TrainingTitle; training.Description = item.TrainingDescription; training.Place = item.TrainingInstituteName; training.TrainingTypeID = item.TrainingTypeId.GetValueOrDefault(); training.NatureOfTrainingID = item.NatureOfTrainingId.GetValueOrDefault(); training.InstitutionID = item.TrainingInstitutionId.GetValueOrDefault(); training.FromDate = item.TrainingFromDate.GetValueOrDefault(); training.ToDate = item.TrainingToDate.GetValueOrDefault(); training.CountryID = item.TrainingCountryId.GetValueOrDefault(); training.SponsoredType = item.TrainingSponsoredType; training.Achievement = item.TrainingAchievement; training.TrainingMonth = item.TrainingMonth.GetValueOrDefault(); training.TrainingDay = item.TrainingDay.GetValueOrDefault(); training.TrainingHour = item.TrainingHour.GetValueOrDefault(); training.Fees = item.Trainingfees.GetValueOrDefault(); training.OtherCost = item.TrainingOtherCost.GetValueOrDefault(); this.SetObjectID(training, (HREmployeeDA.GetNewID(tc, "EmpTraining", "EmpTrainingID"))); HREmployeeDA.Insert(tc, training); tc.End(); return training.ID; } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public int SaveExperience(ProfileUpdateRequest item) { TransactionContext tc = null; EmpExperience experience = new EmpExperience(); try { tc = TransactionContext.Begin(true); experience.EmployeeID = item.RequestEmpID; experience.Employer = item.ExperienceEmployer; experience.ContactPerson = item.ExperienceEmployerContactInfo; experience.Designation = item.ExperienceDesignation; experience.Address = item.ExperienceAddress; experience.JobDescription = item.ExperienceRole; experience.Telephone = item.ExperienceTelephone; experience.FromDate = item.ExperienceFrom.GetValueOrDefault(); experience.ToDate = item.ExperienceTo.GetValueOrDefault(); this.SetObjectID(experience, (HREmployeeDA.GetNewID(tc, "EmpExperience", "ExperienceID"))); HREmployeeDA.Insert(tc, experience); tc.End(); return experience.ID; } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public int SaveAcademic(ProfileUpdateRequest item) { TransactionContext tc = null; EmpAcademic academic = new EmpAcademic(); try { tc = TransactionContext.Begin(true); if (item.AcademicEducationTypeID != null) academic.EducationTypeID = item.AcademicEducationTypeID.GetValueOrDefault(); if (item.AcademicDegreeID != null) academic.EducationLevelID = item.AcademicDegreeID.GetValueOrDefault(); if (item.AcademicDisciplineID != null) academic.DisciplineID = item.AcademicDisciplineID.GetValueOrDefault(); if (item.AcademicUniversityBoardID != null) academic.InstitutionID = item.AcademicUniversityBoardID.GetValueOrDefault(); if (item.AcademicInstitute != "") academic.InstituteName = item.AcademicInstitute; // if (item.AcademicExamHeldOn != "") if (item.AcademicPassingYear != null) academic.PassingYear = item.AcademicPassingYear.GetValueOrDefault(); if (item.AcademicResultID != null) academic.ResultTypeID = item.AcademicResultID.GetValueOrDefault(); if (item.AcademicGPA != null) academic.GPAOrMarks = item.AcademicGPA.GetValueOrDefault(); if (item.AcademicOutOf != null) academic.OutOf = item.AcademicOutOf.GetValueOrDefault(); academic.EmployeeID = item.RequestEmpID; this.SetObjectID(academic, (HREmployeeDA.GetNewID(tc, "EMPACADEMIC", "ACADEMICID"))); HREmployeeDA.Insert(tc, academic); tc.End(); return academic.ID; } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public int SaveNominee(ProfileUpdateRequest item) { TransactionContext tc = null; EmpNominee nominee = new EmpNominee(); try { tc = TransactionContext.Begin(true); if (item.NomineeNominationPurposeId != null) nominee.NominationPurposeID = item.NomineeNominationPurposeId.GetValueOrDefault(); if (item.NominationDate != null) nominee.NominationDate = item.NominationDate.GetValueOrDefault(); if (item.NomineeName != "") nominee.Name = item.NomineeName; if (item.NomineeRelationID != null) nominee.RelationID = item.NomineeRelationID.GetValueOrDefault(); if (item.NomineePercent != null) nominee.Percentage = item.NomineePercent.GetValueOrDefault(); if (item.NomineeDateOfBirth != null) nominee.BirthDate = item.NomineeDateOfBirth.GetValueOrDefault(); if (item.NomineeOccupationID != null) nominee.OccupationID = item.NomineeOccupationID.GetValueOrDefault(); if (item.NomineeAddress != "") nominee.Address = item.NomineeAddress; if (item.NomineeTelephone != "") nominee.TelePhone = item.NomineeTelephone; if (item.NomineeEmail != "") nominee.EmailAddress = item.NomineeEmail; nominee.EmployeeID = item.RequestEmpID; this.SetObjectID(nominee, (HREmployeeDA.GetNewID(tc, "EmpNominee", "NomineeID"))); HREmployeeDA.Insert(tc, nominee); tc.End(); return item.ID; } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public int SaveSpouse(ProfileUpdateRequest item) { TransactionContext tc = null; EmpSpouse spouse = new EmpSpouse(); try { tc = TransactionContext.Begin(true); if (item.SpouseName != "") spouse.Name = item.SpouseName; if (item.SpouseEducationLevelID != null) spouse.EducationLevelID = item.SpouseEducationLevelID.GetValueOrDefault(); if (item.SpouseOccupationID != null) spouse.OccupationID = item.SpouseOccupationID.GetValueOrDefault(); if (item.SpouseMarriageDate != null) spouse.MarriageDate = item.SpouseMarriageDate.GetValueOrDefault(); spouse.EmployeeID = item.RequestEmpID; this.SetObjectID(spouse, (HREmployeeDA.GetNewID(tc, "EmpSpouse", "SpouseID"))); HREmployeeDA.Insert(tc, spouse); tc.End(); return item.ID; } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public int SavePresentContact(ProfileUpdateRequest item) { TransactionContext tc = null; List contacts = new List(); EmpContact contact = null; HREmployeeService hrEmployeeService = new HREmployeeService(); try { contacts = hrEmployeeService.GetEmpContacts(item.RequestEmpID); if (contacts.Count > 0) { contact = contacts[0]; } else { contact = new EmpContact(); } tc = TransactionContext.Begin(true); if (item.PresentAddress != "") contact.PresentAddress = item.PresentAddress; if (item.PresentDistrictID != null) contact.PresentDistrictID = item.PresentDistrictID.GetValueOrDefault(); if (item.PresentThanaID != null) contact.PresentThanaID = item.PresentThanaID.GetValueOrDefault(); if (item.PresentMobile != "") contact.PresentMobile = item.PresentMobile; if (item.PresentLandPhone != "") contact.PresentTelephone = item.PresentLandPhone; contact.EmployeeID = item.RequestEmpID; if (contact.IsNew) { int id = tc.GenerateID("EMPContact", "CONTACTID"); base.SetObjectID(contact, id); HREmployeeDA.Insert(tc, contact); } else { ProfileUpdateRequestDA.UpdatePresentContact(tc, contact); } tc.End(); return item.ID; } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public int SavePermanentContact(ProfileUpdateRequest item) { TransactionContext tc = null; List contacts = new List(); EmpContact contact = null; HREmployeeService hrEmployeeService = new HREmployeeService(); try { contacts = hrEmployeeService.GetEmpContacts(item.RequestEmpID); if (contacts.Count > 0) { contact = contacts[0]; } else { contact = new EmpContact(); } tc = TransactionContext.Begin(true); contact.PermanentAddress = item.PermanentAddress; contact.PermanentDistrictID = item.PermanentDistrictID.GetValueOrDefault(); contact.PermanentThanaID = item.PermanentThanaID.GetValueOrDefault(); contact.PermanentMobile = item.PermanentMobile; contact.PermanentTelephone = item.PermanentLandPhone; contact.EmployeeID = item.RequestEmpID; if (contact.IsNew) { int id = tc.GenerateID("EMPContact", "CONTACTID"); base.SetObjectID(contact, id); HREmployeeDA.Insert(tc, contact); } else { ProfileUpdateRequestDA.UpdatePermanentContact(tc, contact); } tc.End(); return item.ID; } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public int SaveEmergencyContact(ProfileUpdateRequest item) { TransactionContext tc = null; List contacts = new List(); EmpContact contact = null; HREmployeeService hrEmployeeService = new HREmployeeService(); try { contacts = hrEmployeeService.GetEmpContacts(item.RequestEmpID); if (contacts.Count > 0) { contact = contacts[0]; } else { contact = new EmpContact(); } tc = TransactionContext.Begin(true); contact.EmergencyContactAddress = item.EmergencyAddress; contact.EmergencyContactPerson = item.EmergencyContactPerson; contact.EmergencyMobile = item.EmergencyMobileNo; contact.EmergencyTelephone = item.EmergencyLandPhone; contact.ContactPersonRelationId = item.EmergencyRelationID.GetValueOrDefault(); contact.EmployeeID = item.RequestEmpID; if (contact.IsNew) { int id = tc.GenerateID("EMPContact", "CONTACTID"); base.SetObjectID(contact, id); HREmployeeDA.Insert(tc, contact); } else { ProfileUpdateRequestDA.UpdateEmergencyContact(tc, contact); } tc.End(); return item.ID; } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public int Save(ProfileUpdateRequest item) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); if (item.IsNew) { int id = tc.GenerateID("ProfileUpdateRequest", "purId"); base.SetObjectID(item, id); ProfileUpdateRequestDA.Insert(tc, item); } else { ProfileUpdateRequestDA.Update(tc, item); } //if (item.PURequestStatus == EnumPURequestStatus.Requested) //{ // this.InitiateLetterRequestWorkFlow(tc, item, item.RequestEmpID, item.CreatedBy); //} tc.End(); return item.ID; } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public void InitiateLetterRequestWorkFlow(TransactionContext tc, ProfileUpdateRequest item, int initiateEmpID, int userID) { try { Employee emp = new EmployeeService().Get(tc, item.RequestEmpID); if (item.PURequestStatus == EnumPURequestStatus.Requested) { //string subject = "Employee:" + emp.Name + "[ " + emp.EmployeeNo + "]" + " has raised " + ClaimDesc + " on " + item.ClaimDate.ToString() + ". Your Approval is required"; string subject = "Employee:" + emp.Name + "[ " + emp.EmployeeNo + "]" + " has raised " + "Profile Update Request" + " on " + item.RequestDate.ToString() + ". Your Approval is required"; HRM.DA.WFManager om = new HRM.DA.WFManager(item); // om.InitiateProcess(tc, initiateEmpID, item.SetupID, item.ID, "", subject); //LetterRequestDA.UpdateLetterRequestStatus(tc, item.ObjectID, EnumLetterRequestStatus.Submitted); } } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } } }