diff --git a/HRM.BO/Employee/Employee.cs b/HRM.BO/Employee/Employee.cs index 398da3e..d82d0e1 100644 --- a/HRM.BO/Employee/Employee.cs +++ b/HRM.BO/Employee/Employee.cs @@ -542,6 +542,7 @@ namespace HRM.BO void UpdatePayrollType(int empID, int payrollTypeID, DateTime dEffectDate); //void SaveIntegration(List oEmps); int Save(Employee item); + Employee SaveEmployee(Employee item); //void Delete(int id); //void DeleteAll(); //string GenerateLoanNo(Employee oEmp, string sLoanName); diff --git a/HRM.BO/HREmployee/HREmployee.cs b/HRM.BO/HREmployee/HREmployee.cs index 3dc58e1..37c0921 100644 --- a/HRM.BO/HREmployee/HREmployee.cs +++ b/HRM.BO/HREmployee/HREmployee.cs @@ -2358,7 +2358,7 @@ namespace HRM.BO #region parent's function definition HREmployee Get(int id); - int SavePersonalInfo(HREmployee employee); + HREmployee SavePersonalInfo(HREmployee employee); void SaveEmployeeProfileUpload(List oHREmployee); void DeleteChildData(string tableName, string columnName, int id); List GetAllHREmps(); diff --git a/HRM.DA/Service/Employee/EmployeeService.cs b/HRM.DA/Service/Employee/EmployeeService.cs index db0d389..9c7ebac 100644 --- a/HRM.DA/Service/Employee/EmployeeService.cs +++ b/HRM.DA/Service/Employee/EmployeeService.cs @@ -1985,6 +1985,39 @@ namespace HRM.DA #endregion } } + public Employee SaveEmployee(Employee oEmployee) + { + TransactionContext tc = null; + try + { + tc = TransactionContext.Begin(true); + if (oEmployee.IsNew) + { + int id = tc.GenerateID("Employee", "EmployeeID"); + base.SetObjectID(oEmployee, id); + oEmployee.EmployeeNo = new HREmployeeService().GetNextEmployeeNo(tc); + EmployeeDA.Insert(tc, oEmployee); + } + else + { + EmployeeDA.Update(tc, oEmployee); + } + + tc.End(); + return oEmployee; + } + catch (Exception e) + { + #region Handle Exception + + if (tc != null) + tc.HandleError(); + ExceptionLog.Write(e); + throw new ServiceException(e.Message, e); + + #endregion + } + } public int SaveHnmEmployee(List employeeData) { diff --git a/HRM.DA/Service/HREmployee/HREmployeeService.cs b/HRM.DA/Service/HREmployee/HREmployeeService.cs index 0194551..88bd3c6 100644 --- a/HRM.DA/Service/HREmployee/HREmployeeService.cs +++ b/HRM.DA/Service/HREmployee/HREmployeeService.cs @@ -2723,7 +2723,7 @@ namespace HRM.DA tc.End(); } - public int SavePersonalInfo(HREmployee employee) + public HREmployee SavePersonalInfo(HREmployee employee) { TransactionContext tc = null; try @@ -2738,7 +2738,7 @@ namespace HRM.DA if (employee.IsNew) { this.SetObjectID(employee, (HREmployeeDA.GetNewID(tc))); - + employee.EmployeeNo = this.GetNextEmployeeNo(tc); HREmployeeDA.Insert(tc, employee); } else @@ -2750,7 +2750,7 @@ namespace HRM.DA tc.End(); - return employee.ID; + return employee; } catch (Exception e) { @@ -2764,7 +2764,35 @@ namespace HRM.DA #endregion } } + public string GetNextEmployeeNo(TransactionContext tc) + { + string nextEmployeeNo = string.Empty; + try + { + + object obj = tc.ExecuteScalar("SELECT MAX(Cast(EmployeeNo AS Decimal(18,0)))+1 FROM EMPLOYEE"); + if (obj == DBNull.Value) + { + nextEmployeeNo = "1"; + } + else + { + nextEmployeeNo = Convert.ToString(obj); + } + + } + catch (Exception e) + { + #region Handle Exception + if (tc != null) + tc.HandleError(); + ExceptionLog.Write(e); + throw new Exception(e.Message, e); + #endregion + } + return nextEmployeeNo; + } public int Save(HREmployee employee) diff --git a/HRM.UI/ClientApp/src/app/core-hr/employee-profile/general/general.component.html b/HRM.UI/ClientApp/src/app/core-hr/employee-profile/general/general.component.html index b15d497..8895666 100644 --- a/HRM.UI/ClientApp/src/app/core-hr/employee-profile/general/general.component.html +++ b/HRM.UI/ClientApp/src/app/core-hr/employee-profile/general/general.component.html @@ -172,7 +172,7 @@
@@ -361,7 +361,7 @@
diff --git a/HRM.UI/ClientApp/src/app/core-hr/employee-profile/general/general.component.ts b/HRM.UI/ClientApp/src/app/core-hr/employee-profile/general/general.component.ts index 0564111..4694dae 100644 --- a/HRM.UI/ClientApp/src/app/core-hr/employee-profile/general/general.component.ts +++ b/HRM.UI/ClientApp/src/app/core-hr/employee-profile/general/general.component.ts @@ -386,29 +386,29 @@ export class GeneralComponent implements OnInit { } - public saveGeneratedEmployee() { - debugger - if (this.active == false) { - this.loadingPanel.ShowLoadingPanel = true; - this.employeeService.generateEmployeeNo().subscribe( - (resp) => { - this.employeeService.hrEmployee.employeeNo = resp as string; - }, - (err) => { - this.notificationService.showError(err); - this.loadingPanel.ShowLoadingPanel = false; - }, - () => { - this.loadingPanel.ShowLoadingPanel = false; setTimeout(() => { - this.SavePersonalInfo(); - }, 1000); - } - ); - } - else{ - this.SavePersonalInfo(); - } - } + // public saveGeneratedEmployee() { + // debugger + // if (this.active == false) { + // this.loadingPanel.ShowLoadingPanel = true; + // this.employeeService.generateEmployeeNo().subscribe( + // (resp) => { + // this.employeeService.hrEmployee.employeeNo = resp as string; + // }, + // (err) => { + // this.notificationService.showError(err); + // this.loadingPanel.ShowLoadingPanel = false; + // }, + // () => { + // this.loadingPanel.ShowLoadingPanel = false; setTimeout(() => { + // this.SavePersonalInfo(); + // }, 1000); + // } + // ); + // } + // else{ + // this.SavePersonalInfo(); + // } + // } SavePersonalInfo() { // console.log(this.hrEmployee.banglaName); // return; @@ -424,12 +424,18 @@ export class GeneralComponent implements OnInit { if (this.hrEmployee.lastName !== null) { this.hrEmployee.name += ' ' + this.hrEmployee.lastName; } - if (this.employeeService.hrEmployee.employeeNo.length > 0) { - this.hrEmployee.employeeNo = this.employeeService.hrEmployee.employeeNo; - } + // if (this.employeeService.hrEmployee.employeeNo.length > 0) { + // this.hrEmployee.employeeNo = this.employeeService.hrEmployee.employeeNo; + // } this.employeeService.saveHrPersonalInfo(this.hrEmployee).subscribe( - (resp: any) => { - this.hrEmployee.id = resp; + (resp: HrEmployee) => { + if(resp != undefined){ + this.hrEmployee.id = resp.id; + if (this.active == false) { + this.hrEmployee.employeeNo = resp.employeeNo; + this.employeeService.hrEmployee.employeeNo = resp.employeeNo; + } + } }, (err: any) => { console.log(err); diff --git a/HRM.UI/ClientApp/src/app/payroll-ot/production-bonus-setup/production-bonus-setup.component.html b/HRM.UI/ClientApp/src/app/payroll-ot/production-bonus-setup/production-bonus-setup.component.html index 005413c..6825223 100644 --- a/HRM.UI/ClientApp/src/app/payroll-ot/production-bonus-setup/production-bonus-setup.component.html +++ b/HRM.UI/ClientApp/src/app/payroll-ot/production-bonus-setup/production-bonus-setup.component.html @@ -187,7 +187,7 @@ style="width:80%">Add
- @@ -195,23 +195,23 @@ - + - + - + - + - + - +
-
diff --git a/HRM.UI/ClientApp/src/app/payroll/career-and-profile/employee-payroll-profile/employee-payroll-profile.component.ts b/HRM.UI/ClientApp/src/app/payroll/career-and-profile/employee-payroll-profile/employee-payroll-profile.component.ts index f59d255..1505470 100644 --- a/HRM.UI/ClientApp/src/app/payroll/career-and-profile/employee-payroll-profile/employee-payroll-profile.component.ts +++ b/HRM.UI/ClientApp/src/app/payroll/career-and-profile/employee-payroll-profile/employee-payroll-profile.component.ts @@ -229,7 +229,8 @@ export class EmployeePayrollProfileComponent implements OnInit { createForm() { this.employeeForm = new FormBuilder().group({ isNew: ['', Validators.required], - employeeId: ['', Validators.required], + // employeeId: ['', Validators.required], + employeeId: [''], name: ['', Validators.required], mobileNo: [''], emailAddress: [''], @@ -276,7 +277,7 @@ export class EmployeePayrollProfileComponent implements OnInit { this.employee.joiningDate = new Date(this.employee.joiningDate); }, (err: any) => { - + this.notificationService.showError(err.error); }, () => { debugger; @@ -298,7 +299,8 @@ export class EmployeePayrollProfileComponent implements OnInit { }, (err: any) => { - console.log(err); + // console.log(err); + this.notificationService.showError(err.error); }, () => { this.empLineManager = new SearchEmployee(); @@ -332,32 +334,32 @@ export class EmployeePayrollProfileComponent implements OnInit { } } - public saveGeneratedEmployee() { + // public saveGeneratedEmployee() { - debugger; - if (this.newEmployee === true) { - this.loadingPanelService.ShowLoadingPanel = true; - this.employeeService.generateEmployeeNo().subscribe( - (resp) => { - this.employee.employeeNo = resp as string; - }, - (err) => { - this.notificationService.showError(err); - this.loadingPanelService.ShowLoadingPanel = false; - }, - () => { - this.loadingPanelService.ShowLoadingPanel = false; - setTimeout(() => { - this.saveEmployee(); - }, 1000); - } - ); + // debugger; + // if (this.newEmployee === true) { + // this.loadingPanelService.ShowLoadingPanel = true; + // this.employeeService.generateEmployeeNo().subscribe( + // (resp) => { + // this.employee.employeeNo = resp as string; + // }, + // (err) => { + // this.notificationService.showError(err); + // this.loadingPanelService.ShowLoadingPanel = false; + // }, + // () => { + // this.loadingPanelService.ShowLoadingPanel = false; + // setTimeout(() => { + // this.saveEmployee(); + // }, 1000); + // } + // ); - } - else { - this.saveEmployee(); - } - } + // } + // else { + // this.saveEmployee(); + // } + // } saveEmployee() { diff --git a/HRM.UI/Controllers/Employee/EmployeeController.cs b/HRM.UI/Controllers/Employee/EmployeeController.cs index 76ccb8d..2e2e6a0 100644 --- a/HRM.UI/Controllers/Employee/EmployeeController.cs +++ b/HRM.UI/Controllers/Employee/EmployeeController.cs @@ -243,7 +243,7 @@ namespace HRM.UI.Controllers [Route("saveEmployee")] public ActionResult SaveEmployee(Employee item) { - int ans; + Employee ans; CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); if (item.IsNew == true) @@ -260,7 +260,8 @@ namespace HRM.UI.Controllers try { - ans = _EmployeeService.Save(item); + //ans = _EmployeeService.Save(item); + ans = _EmployeeService.SaveEmployee(item); } catch (Exception ex) { @@ -549,7 +550,7 @@ namespace HRM.UI.Controllers return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } - return Ok(item.ID); + return Ok(item); }