Employee Profile and Prod bonus setup

This commit is contained in:
mashfiq 2025-01-09 10:44:51 +06:00
parent 5b834601eb
commit cde8907768
11 changed files with 293 additions and 215 deletions

View File

@ -542,6 +542,7 @@ namespace HRM.BO
void UpdatePayrollType(int empID, int payrollTypeID, DateTime dEffectDate);
//void SaveIntegration(List<HREmployee> oEmps);
int Save(Employee item);
Employee SaveEmployee(Employee item);
//void Delete(int id);
//void DeleteAll();
//string GenerateLoanNo(Employee oEmp, string sLoanName);

View File

@ -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<HREmployee> oHREmployee);
void DeleteChildData(string tableName, string columnName, int id);
List<HREmployee> GetAllHREmps();

View File

@ -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<object> employeeData)
{

View File

@ -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)

View File

@ -172,7 +172,7 @@
<div class="p-col-12 p-lg-12" align="right" style="margin-top: 20px;">
<button class="k-button k-primary" kendoButton icon="save"
(click)="saveGeneratedEmployee()">
(click)="SavePersonalInfo()">
<!-- (click)="SavePersonalInfo()"> -->
Save
</button>
@ -361,7 +361,7 @@
</div>
<div class="p-col-12 p-md-12 p-lg-4" style="margin-top: 11px;" align="right">
<button class="k-button k-primary" kendoButton icon="save"
(click)="saveGeneratedEmployee()">
(click)="SavePersonalInfo()">
<!-- (click)="SavePersonalInfo()"> -->
Save
</button>

View File

@ -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);

View File

@ -187,7 +187,7 @@
style="width:80%">Add</button>
</div>
</div>
<kendo-grid [kendoGridBinding]="prodBonusLine.prodBonusSupervisors" [sortable]="true" [style.height.%]="100"
<kendo-grid [kendoGridBinding]="prodBonusLine.prodBonusSupervisors" [sortable]="true" [style.height.px]="250"
[reorderable]="true">
<!-- [resizable]="true" [pageSize]="state.take" [skip]="state.skip"
[sort]="state.sort" [pageable]="true" (dataStateChange)="dataStateChange($event)">-->
@ -195,23 +195,23 @@
<!-- <ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
</ng-template> -->
</kendo-grid-column>
<kendo-grid-column field="employeeNo" title="Employee No" [width]="100">
<kendo-grid-column field="employeeNo" title="Employee No" [width]="80">
<!-- <ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
</ng-template> -->
</kendo-grid-column>
<kendo-grid-column field="devGrantParentName" title="top Parent (section)" [width]="120">
<kendo-grid-column field="devGrantParentName" title="Top Parent (section)" [width]="90">
</kendo-grid-column>
<kendo-grid-column field="devParentName" title="parent (floor)" [width]="120">
<kendo-grid-column field="devParentName" title="Parent (floor)" [width]="80">
</kendo-grid-column>
<kendo-grid-column field="devName" title="posted" [width]="120">
<kendo-grid-column field="devName" title="Posted" [width]="80">
</kendo-grid-column>
<kendo-grid-column field="bonusPercent" title="Bonus Percent" [width]="100">
<kendo-grid-column field="bonusPercent" title="Bonus Percent" [width]="80">
</kendo-grid-column>
<kendo-grid-column title="Actions" [width]="50">
<kendo-grid-column title="Actions" [width]="85">
<ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
<button type="button" kendoButton icon="delete" class="kt-delete"
style="width: fit-content;" (click)="onClickRemoveSupervisors(dataItem)">

View File

@ -593,11 +593,18 @@ export class ProductionBonusSetupComponent implements OnInit {
}
onClickRemoveSupervisors(data: any) {
debugger;
if (data.id == 0) {
const index = this.prodBonusLine.prodBonusSupervisors.findIndex(item => item.employeeID === data.employeeID);
if (index !== -1) {
this.prodBonusLine.prodBonusSupervisors.splice(index, 1);
}
} else {
const index = this.prodBonusLine.prodBonusSupervisors.findIndex(item => item.id === data.id);
if (index !== -1) {
this.prodBonusLine.prodBonusSupervisors.splice(index, 1);
}
}
}
clearFields() {
this.productionBonusSetup = new ProductionBonusSetup();
this.productionBonusSetup.fromDate = new Date();

View File

@ -31,7 +31,7 @@
</div>
<div class="p-col-12 p-md-6 p-lg-8 form-control-lg ">
<input formControlName="employeeId"[readonly]="true"
[(ngModel)]="employee.employeeNo" type="text" style="width:100%" pInputText required><!-- [readonly]="!newEmployee"-->
[(ngModel)]="employee.employeeNo" type="text" style="width:100%" pInputText><!-- [readonly]="!newEmployee"-->
</div>
<div class="p-col-12 p-md-6 p-lg-4" style="margin:auto">
<label for="txtempName">Name </label>
@ -229,7 +229,7 @@
</button>
</div>
<div class="p-col-6" align="right">
<button icon="save" kendoButton [primary]="true" (click)="saveGeneratedEmployee()">
<button icon="save" kendoButton [primary]="true" (click)="saveEmployee()">
Save
</button>
</div>

View File

@ -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() {

View File

@ -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);
}