public Message UpdateCompanyInfo(Employee objUI, DateTime department, DateTime title,DateTime hospital) { Message msg = null; try { if (objUI != null) { // Get current group in dbContext Employee objDb = GetById(objUI.ID); if (objDb != null) { // Check valid update date if (IsValidUpdateDate(objUI, objDb, out msg)) { new EmployeeLogDao().WriteLogForUpdateCompany(objUI, ELogAction.Update); if (department == title) { if (department != new DateTime()) { EmployeeDepartmentJobTitleTracking deptTracking = new EmployeeDepartmentJobTitleTracking(); deptTracking.EmployeeId = objDb.ID; deptTracking.DepartmentName = new DepartmentDao().GetById(objUI.DepartmentId).DepartmentName; deptTracking.JobTitleName = new JobTitleLevelDao().GetById(objUI.TitleId).DisplayName; deptTracking.StartDate = department; deptTracking.CreatedDate = department; deptTracking.CreatedBy = objUI.UpdatedBy; deptTracking.UpdatedDate = department; deptTracking.UpdatedBy = objUI.UpdatedBy; EmployeeDepartmentJobTitleTrackingDao deptDao = new EmployeeDepartmentJobTitleTrackingDao(); deptDao.Insert(deptTracking); } } else { if (objDb.DepartmentId != objUI.DepartmentId) { EmployeeDepartmentJobTitleTracking deptTracking = new EmployeeDepartmentJobTitleTracking(); deptTracking.EmployeeId = objDb.ID; deptTracking.DepartmentName = new DepartmentDao().GetById(objUI.DepartmentId).DepartmentName; deptTracking.JobTitleName = new JobTitleLevelDao().GetById(objDb.TitleId).DisplayName; deptTracking.StartDate = department; deptTracking.CreatedDate = department; deptTracking.CreatedBy = objUI.UpdatedBy; deptTracking.UpdatedDate = department; deptTracking.UpdatedBy = objUI.UpdatedBy; EmployeeDepartmentJobTitleTrackingDao deptDao = new EmployeeDepartmentJobTitleTrackingDao(); deptDao.Insert(deptTracking); } if (objDb.TitleId != objUI.TitleId) { EmployeeDepartmentJobTitleTrackingDao deptDao = new EmployeeDepartmentJobTitleTrackingDao(); EmployeeDepartmentJobTitleTracking deptTracking = new EmployeeDepartmentJobTitleTracking(); deptTracking.EmployeeId = objDb.ID; deptTracking.DepartmentName = new DepartmentDao().GetById(objUI.DepartmentId).DepartmentName; deptTracking.JobTitleName = new JobTitleLevelDao().GetById(objUI.TitleId).DisplayName; deptTracking.StartDate = title; deptTracking.CreatedDate = title; deptTracking.CreatedBy = objUI.UpdatedBy; deptTracking.UpdatedDate = title; deptTracking.UpdatedBy = objUI.UpdatedBy; deptDao.Insert(deptTracking); } } if (objDb.InsuranceHospitalID != objUI.InsuranceHospitalID && hospital != null) { if (hospital != new DateTime()) { EmployeeInsuranceHospitalTracking hospitalTracking = new EmployeeInsuranceHospitalTracking(); hospitalTracking.EmployeeId = objDb.ID; hospitalTracking.InsuranceHospitalID = objUI.InsuranceHospitalID; hospitalTracking.StartDate = hospital; hospitalTracking.CreatedDate = hospital; hospitalTracking.CreatedBy = objUI.UpdatedBy; hospitalTracking.UpdatedDate = hospital; hospitalTracking.UpdatedBy = objUI.UpdatedBy; InsuranceHospitalDao hospitalDao = new InsuranceHospitalDao(); hospitalDao.Insert(hospitalTracking); objDb.InsuranceHospitalID = objUI.InsuranceHospitalID; } } objDb.DepartmentId = objUI.DepartmentId; objDb.TitleId = objUI.TitleId; // Update info by objUI objDb.JR = objUI.JR; objDb.JRApproval = objUI.JRApproval; objDb.Project = objUI.Project; objDb.ManagerId = objUI.ManagerId; objDb.StartDate = objUI.StartDate; objDb.ContractedDate = objUI.ContractedDate; objDb.LaborUnion = objUI.LaborUnion; objDb.LaborUnionDate = objUI.LaborUnionDate; objDb.UpdateDate = DateTime.Now; objDb.UpdatedBy = objUI.UpdatedBy; objDb.TaxID = objUI.TaxID; objDb.TaxIssueDate = objUI.TaxIssueDate; objDb.SocialInsuranceNo = objUI.SocialInsuranceNo; objDb.InsuranceHospitalID = objUI.InsuranceHospitalID; objDb.LocationCode = objUI.LocationCode; // Submit changes to dbContext dbContext.SubmitChanges(); // Show success message msg = new Message(MessageConstants.I0001, MessageType.Info, "Employee '" + objDb.FirstName + " " + objDb.MiddleName + " " + objDb.LastName + "'", "updated"); } } } } catch { msg = new Message(MessageConstants.E0007, MessageType.Error); } return msg; }
public Message InsertTracking(Employee objUI) { Message msg = null; try { // Insert Department Tracking EmployeeDepartmentJobTitleTracking deptTracking = new EmployeeDepartmentJobTitleTracking(); deptTracking.EmployeeId = objUI.ID; deptTracking.DepartmentName = objUI.Department.DepartmentName; deptTracking.JobTitleName = objUI.JobTitleLevel.DisplayName; deptTracking.StartDate = objUI.StartDate; deptTracking.CreatedDate = objUI.CreateDate; deptTracking.CreatedBy = objUI.CreatedBy; deptTracking.UpdatedDate = objUI.UpdateDate; deptTracking.UpdatedBy = objUI.UpdatedBy; EmployeeDepartmentJobTitleTrackingDao deptDao = new EmployeeDepartmentJobTitleTrackingDao(); msg = deptDao.Insert(deptTracking); //Insert Insurance Hospital Tracking if (!string.IsNullOrEmpty(objUI.InsuranceHospitalID)) { EmployeeInsuranceHospitalTracking hospitalTracking = new EmployeeInsuranceHospitalTracking(); hospitalTracking.EmployeeId = objUI.ID; hospitalTracking.InsuranceHospitalID = objUI.InsuranceHospitalID; hospitalTracking.StartDate = objUI.StartDate; hospitalTracking.CreatedDate = objUI.CreateDate; hospitalTracking.CreatedBy = objUI.CreatedBy; hospitalTracking.UpdatedDate = objUI.UpdateDate; hospitalTracking.UpdatedBy = objUI.UpdatedBy; InsuranceHospitalDao hospitalDao = new InsuranceHospitalDao(); msg = hospitalDao.Insert(hospitalTracking); } msg = new Message(MessageConstants.I0001, MessageType.Info, "Employee '" + objUI.FirstName + " " + objUI.MiddleName + " " + objUI.LastName + "'", "added"); } catch { msg = new Message(MessageConstants.E0007, MessageType.Error); } return msg; }
public Message Update(Employee objUI, DateTime department, DateTime title, DateTime hospital) { Message msg = null; try { if (objUI != null) { Employee objDb = GetById(objUI.ID); if (objDb != null) { // Check valid update date if (IsValidUpdateDate(objUI, objDb, out msg)) { new EmployeeLogDao().WriteLogForEmployee(null, objUI, ELogAction.Update); objDb.FirstName = objUI.FirstName; objDb.MiddleName = objUI.MiddleName; objDb.LastName = objUI.LastName; objDb.DOB = objUI.DOB; objDb.POB = objUI.POB; objDb.Major = objUI.Major; objDb.PlaceOfOrigin = objUI.PlaceOfOrigin; objDb.OtherDegree = objUI.OtherDegree; objDb.Nationality = objUI.Nationality; objDb.IDNumber = objUI.IDNumber; objDb.IssueDate = objUI.IssueDate; objDb.Gender = objUI.Gender; objDb.Religion = objUI.Religion; objDb.MarriedStatus = objUI.MarriedStatus; objDb.EmpStatusId = objUI.EmpStatusId; objDb.JR = objUI.JR; objDb.Project = objUI.Project; objDb.ManagerId = objUI.ManagerId; objDb.JRApproval = objUI.JRApproval; objDb.StartDate = objUI.StartDate; objDb.ContractedDate = objUI.ContractedDate; if (department == title) { if (department != new DateTime()) { EmployeeDepartmentJobTitleTracking deptTracking = new EmployeeDepartmentJobTitleTracking(); deptTracking.EmployeeId = objDb.ID; deptTracking.DepartmentName = new DepartmentDao().GetById(objUI.DepartmentId).DepartmentName; deptTracking.JobTitleName = new JobTitleLevelDao().GetById(objUI.TitleId).DisplayName; deptTracking.StartDate = department; deptTracking.CreatedDate = department; deptTracking.CreatedBy = objUI.UpdatedBy; deptTracking.UpdatedDate = department; deptTracking.UpdatedBy = objUI.UpdatedBy; EmployeeDepartmentJobTitleTrackingDao deptDao = new EmployeeDepartmentJobTitleTrackingDao(); deptDao.Insert(deptTracking); } } else { EmployeeDepartmentJobTitleTrackingDao deptDao = new EmployeeDepartmentJobTitleTrackingDao(); if (objDb.DepartmentId != objUI.DepartmentId) { EmployeeDepartmentJobTitleTracking deptTracking = new EmployeeDepartmentJobTitleTracking(); deptTracking.EmployeeId = objDb.ID; deptTracking.DepartmentName = new DepartmentDao().GetById(objUI.DepartmentId).DepartmentName; deptTracking.JobTitleName = new JobTitleLevelDao().GetById(objDb.TitleId).DisplayName; deptTracking.StartDate = department; deptTracking.CreatedDate = department; deptTracking.CreatedBy = objUI.UpdatedBy; deptTracking.UpdatedDate = department; deptTracking.UpdatedBy = objUI.UpdatedBy; deptDao.Insert(deptTracking); } if (objDb.TitleId != objUI.TitleId) { EmployeeDepartmentJobTitleTracking titleTracking = new EmployeeDepartmentJobTitleTracking(); titleTracking.EmployeeId = objDb.ID; titleTracking.DepartmentName = new DepartmentDao().GetById(objUI.DepartmentId).DepartmentName; titleTracking.JobTitleName = new JobTitleLevelDao().GetById(objUI.TitleId).DisplayName; titleTracking.StartDate = title; titleTracking.CreatedDate = title; titleTracking.CreatedBy = objUI.UpdatedBy; titleTracking.UpdatedDate = title; titleTracking.UpdatedBy = objUI.UpdatedBy; deptDao.Insert(titleTracking); } } if (objDb.InsuranceHospitalID != objUI.InsuranceHospitalID && hospital != null) { if (hospital != new DateTime()) { EmployeeInsuranceHospitalTracking hospitalTracking = new EmployeeInsuranceHospitalTracking(); hospitalTracking.EmployeeId = objDb.ID; hospitalTracking.InsuranceHospitalID = objUI.InsuranceHospitalID; hospitalTracking.StartDate = hospital; hospitalTracking.CreatedDate = hospital; hospitalTracking.CreatedBy = objUI.UpdatedBy; hospitalTracking.UpdatedDate = hospital; hospitalTracking.UpdatedBy = objUI.UpdatedBy; InsuranceHospitalDao hospitalDao = new InsuranceHospitalDao(); hospitalDao.Insert(hospitalTracking); objDb.InsuranceHospitalID = objUI.InsuranceHospitalID; } } objDb.DepartmentId = objUI.DepartmentId; objDb.TitleId = objUI.TitleId; objDb.LaborUnion = objUI.LaborUnion; objDb.LaborUnionDate = objUI.LaborUnionDate; objDb.HomePhone = objUI.HomePhone; objDb.CellPhone = objUI.CellPhone; objDb.Floor = objUI.Floor; objDb.ExtensionNumber = objUI.ExtensionNumber; objDb.SeatCode = objUI.SeatCode; objDb.SkypeId = objUI.SkypeId; objDb.YahooId = objUI.YahooId; objDb.PersonalEmail = objUI.PersonalEmail; objDb.OfficeEmail = objUI.OfficeEmail; objDb.EmergencyContactName = objUI.EmergencyContactName; objDb.EmergencyContactPhone = objUI.EmergencyContactPhone; objDb.EmergencyContactRelationship = objUI.EmergencyContactRelationship; objDb.PermanentAddress = objUI.PermanentAddress; objDb.PermanentArea = objUI.PermanentArea; objDb.PermanentDistrict = objUI.PermanentDistrict; objDb.PermanentCityProvince = objUI.PermanentCityProvince; objDb.PermanentCountry = objUI.PermanentCountry; objDb.TempAddress = objUI.TempAddress; objDb.TempArea = objUI.TempArea; objDb.TempDistrict = objUI.TempDistrict; objDb.TempCityProvince = objUI.TempCityProvince; objDb.TempCountry = objUI.TempCountry; objDb.BankName = objUI.BankName; objDb.BankAccount = objUI.BankAccount; objDb.Remarks = objUI.Remarks; objDb.UpdateDate = DateTime.Now; objDb.UpdatedBy = objUI.UpdatedBy; objDb.VnFirstName = objUI.VnFirstName; objDb.VnMiddleName = objUI.VnMiddleName; objDb.VnLastName = objUI.VnLastName; objDb.VnPOB = objUI.VnPOB; objDb.VnPlaceOfOrigin = objUI.VnPlaceOfOrigin; objDb.Degree = objUI.Degree; objDb.Race = objUI.Race; objDb.IDIssueLocation = objUI.IDIssueLocation; objDb.VnIDIssueLocation = objUI.VnIDIssueLocation; objDb.TaxID = objUI.TaxID; objDb.TaxIssueDate = objUI.TaxIssueDate; objDb.SocialInsuranceNo = objUI.SocialInsuranceNo; objDb.InsuranceHospitalID = objUI.InsuranceHospitalID; objDb.VnPermanentAddress = objUI.VnPermanentAddress; objDb.VnPermanentArea = objUI.VnPermanentArea; objDb.VnPermanentDistrict = objUI.VnPermanentDistrict; objDb.VnPermanentCityProvince = objUI.VnPermanentCityProvince; objDb.VnPermanentCountry = objUI.VnPermanentCountry; objDb.VnTempAddress = objUI.VnTempAddress; objDb.VnTempArea = objUI.VnTempArea; objDb.VnTempDistrict = objUI.VnTempDistrict; objDb.VnTempCityProvince = objUI.VnTempCityProvince; objDb.VnTempCountry = objUI.VnTempCountry; objDb.ResignedAllowance = objUI.ResignedAllowance; objDb.ResignedDate = objUI.ResignedDate; objDb.ResignedReason = objUI.ResignedReason; objDb.LocationCode = objUI.LocationCode; // Submit changes to dbContext dbContext.SubmitChanges(); // Show success message msg = new Message(MessageConstants.I0001, MessageType.Info, "Employee '" + objDb.FirstName + " " + objDb.MiddleName + " " + objDb.LastName + "'", "updated"); } } } } catch(Exception ex) { // Show system error msg = new Message(MessageConstants.E0007, MessageType.Error); } return msg; }