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 UpdatePayrollType(int empID, int payrollTypeID, DateTime dEffectDate);
//void SaveIntegration(List<HREmployee> oEmps); //void SaveIntegration(List<HREmployee> oEmps);
int Save(Employee item); int Save(Employee item);
Employee SaveEmployee(Employee item);
//void Delete(int id); //void Delete(int id);
//void DeleteAll(); //void DeleteAll();
//string GenerateLoanNo(Employee oEmp, string sLoanName); //string GenerateLoanNo(Employee oEmp, string sLoanName);

View File

@ -2358,7 +2358,7 @@ namespace HRM.BO
#region parent's function definition #region parent's function definition
HREmployee Get(int id); HREmployee Get(int id);
int SavePersonalInfo(HREmployee employee); HREmployee SavePersonalInfo(HREmployee employee);
void SaveEmployeeProfileUpload(List<HREmployee> oHREmployee); void SaveEmployeeProfileUpload(List<HREmployee> oHREmployee);
void DeleteChildData(string tableName, string columnName, int id); void DeleteChildData(string tableName, string columnName, int id);
List<HREmployee> GetAllHREmps(); List<HREmployee> GetAllHREmps();

View File

@ -1985,6 +1985,39 @@ namespace HRM.DA
#endregion #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) public int SaveHnmEmployee(List<object> employeeData)
{ {

View File

@ -2723,7 +2723,7 @@ namespace HRM.DA
tc.End(); tc.End();
} }
public int SavePersonalInfo(HREmployee employee) public HREmployee SavePersonalInfo(HREmployee employee)
{ {
TransactionContext tc = null; TransactionContext tc = null;
try try
@ -2738,7 +2738,7 @@ namespace HRM.DA
if (employee.IsNew) if (employee.IsNew)
{ {
this.SetObjectID(employee, (HREmployeeDA.GetNewID(tc))); this.SetObjectID(employee, (HREmployeeDA.GetNewID(tc)));
employee.EmployeeNo = this.GetNextEmployeeNo(tc);
HREmployeeDA.Insert(tc, employee); HREmployeeDA.Insert(tc, employee);
} }
else else
@ -2750,7 +2750,7 @@ namespace HRM.DA
tc.End(); tc.End();
return employee.ID; return employee;
} }
catch (Exception e) catch (Exception e)
{ {
@ -2764,7 +2764,35 @@ namespace HRM.DA
#endregion #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) 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;"> <div class="p-col-12 p-lg-12" align="right" style="margin-top: 20px;">
<button class="k-button k-primary" kendoButton icon="save" <button class="k-button k-primary" kendoButton icon="save"
(click)="saveGeneratedEmployee()"> (click)="SavePersonalInfo()">
<!-- (click)="SavePersonalInfo()"> --> <!-- (click)="SavePersonalInfo()"> -->
Save Save
</button> </button>
@ -361,7 +361,7 @@
</div> </div>
<div class="p-col-12 p-md-12 p-lg-4" style="margin-top: 11px;" align="right"> <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" <button class="k-button k-primary" kendoButton icon="save"
(click)="saveGeneratedEmployee()"> (click)="SavePersonalInfo()">
<!-- (click)="SavePersonalInfo()"> --> <!-- (click)="SavePersonalInfo()"> -->
Save Save
</button> </button>

View File

@ -386,29 +386,29 @@ export class GeneralComponent implements OnInit {
} }
public saveGeneratedEmployee() { // public saveGeneratedEmployee() {
debugger // debugger
if (this.active == false) { // if (this.active == false) {
this.loadingPanel.ShowLoadingPanel = true; // this.loadingPanel.ShowLoadingPanel = true;
this.employeeService.generateEmployeeNo().subscribe( // this.employeeService.generateEmployeeNo().subscribe(
(resp) => { // (resp) => {
this.employeeService.hrEmployee.employeeNo = resp as string; // this.employeeService.hrEmployee.employeeNo = resp as string;
}, // },
(err) => { // (err) => {
this.notificationService.showError(err); // this.notificationService.showError(err);
this.loadingPanel.ShowLoadingPanel = false; // this.loadingPanel.ShowLoadingPanel = false;
}, // },
() => { // () => {
this.loadingPanel.ShowLoadingPanel = false; setTimeout(() => { // this.loadingPanel.ShowLoadingPanel = false; setTimeout(() => {
this.SavePersonalInfo(); // this.SavePersonalInfo();
}, 1000); // }, 1000);
} // }
); // );
} // }
else{ // else{
this.SavePersonalInfo(); // this.SavePersonalInfo();
} // }
} // }
SavePersonalInfo() { SavePersonalInfo() {
// console.log(this.hrEmployee.banglaName); // console.log(this.hrEmployee.banglaName);
// return; // return;
@ -424,12 +424,18 @@ export class GeneralComponent implements OnInit {
if (this.hrEmployee.lastName !== null) { if (this.hrEmployee.lastName !== null) {
this.hrEmployee.name += ' ' + this.hrEmployee.lastName; this.hrEmployee.name += ' ' + this.hrEmployee.lastName;
} }
if (this.employeeService.hrEmployee.employeeNo.length > 0) { // if (this.employeeService.hrEmployee.employeeNo.length > 0) {
this.hrEmployee.employeeNo = this.employeeService.hrEmployee.employeeNo; // this.hrEmployee.employeeNo = this.employeeService.hrEmployee.employeeNo;
} // }
this.employeeService.saveHrPersonalInfo(this.hrEmployee).subscribe( this.employeeService.saveHrPersonalInfo(this.hrEmployee).subscribe(
(resp: any) => { (resp: HrEmployee) => {
this.hrEmployee.id = resp; 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) => { (err: any) => {
console.log(err); console.log(err);

View File

@ -187,7 +187,7 @@
style="width:80%">Add</button> style="width:80%">Add</button>
</div> </div>
</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"> [reorderable]="true">
<!-- [resizable]="true" [pageSize]="state.take" [skip]="state.skip" <!-- [resizable]="true" [pageSize]="state.take" [skip]="state.skip"
[sort]="state.sort" [pageable]="true" (dataStateChange)="dataStateChange($event)">--> [sort]="state.sort" [pageable]="true" (dataStateChange)="dataStateChange($event)">-->
@ -195,23 +195,23 @@
<!-- <ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex"> <!-- <ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
</ng-template> --> </ng-template> -->
</kendo-grid-column> </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 kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
</ng-template> --> </ng-template> -->
</kendo-grid-column> </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>
<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>
<kendo-grid-column field="devName" title="posted" [width]="120"> <kendo-grid-column field="devName" title="Posted" [width]="80">
</kendo-grid-column> </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>
<kendo-grid-column title="Actions" [width]="50"> <kendo-grid-column title="Actions" [width]="85">
<ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex"> <ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
<button type="button" kendoButton icon="delete" class="kt-delete" <button type="button" kendoButton icon="delete" class="kt-delete"
style="width: fit-content;" (click)="onClickRemoveSupervisors(dataItem)"> style="width: fit-content;" (click)="onClickRemoveSupervisors(dataItem)">

View File

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

View File

@ -31,7 +31,7 @@
</div> </div>
<div class="p-col-12 p-md-6 p-lg-8 form-control-lg "> <div class="p-col-12 p-md-6 p-lg-8 form-control-lg ">
<input formControlName="employeeId"[readonly]="true" <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>
<div class="p-col-12 p-md-6 p-lg-4" style="margin:auto"> <div class="p-col-12 p-md-6 p-lg-4" style="margin:auto">
<label for="txtempName">Name </label> <label for="txtempName">Name </label>
@ -229,7 +229,7 @@
</button> </button>
</div> </div>
<div class="p-col-6" align="right"> <div class="p-col-6" align="right">
<button icon="save" kendoButton [primary]="true" (click)="saveGeneratedEmployee()"> <button icon="save" kendoButton [primary]="true" (click)="saveEmployee()">
Save Save
</button> </button>
</div> </div>

View File

@ -229,7 +229,8 @@ export class EmployeePayrollProfileComponent implements OnInit {
createForm() { createForm() {
this.employeeForm = new FormBuilder().group({ this.employeeForm = new FormBuilder().group({
isNew: ['', Validators.required], isNew: ['', Validators.required],
employeeId: ['', Validators.required], // employeeId: ['', Validators.required],
employeeId: [''],
name: ['', Validators.required], name: ['', Validators.required],
mobileNo: [''], mobileNo: [''],
emailAddress: [''], emailAddress: [''],
@ -276,7 +277,7 @@ export class EmployeePayrollProfileComponent implements OnInit {
this.employee.joiningDate = new Date(this.employee.joiningDate); this.employee.joiningDate = new Date(this.employee.joiningDate);
}, },
(err: any) => { (err: any) => {
this.notificationService.showError(err.error);
}, },
() => { () => {
debugger; debugger;
@ -298,7 +299,8 @@ export class EmployeePayrollProfileComponent implements OnInit {
}, },
(err: any) => { (err: any) => {
console.log(err); // console.log(err);
this.notificationService.showError(err.error);
}, },
() => { () => {
this.empLineManager = new SearchEmployee(); this.empLineManager = new SearchEmployee();
@ -332,32 +334,32 @@ export class EmployeePayrollProfileComponent implements OnInit {
} }
} }
public saveGeneratedEmployee() { // public saveGeneratedEmployee() {
debugger; // debugger;
if (this.newEmployee === true) { // if (this.newEmployee === true) {
this.loadingPanelService.ShowLoadingPanel = true; // this.loadingPanelService.ShowLoadingPanel = true;
this.employeeService.generateEmployeeNo().subscribe( // this.employeeService.generateEmployeeNo().subscribe(
(resp) => { // (resp) => {
this.employee.employeeNo = resp as string; // this.employee.employeeNo = resp as string;
}, // },
(err) => { // (err) => {
this.notificationService.showError(err); // this.notificationService.showError(err);
this.loadingPanelService.ShowLoadingPanel = false; // this.loadingPanelService.ShowLoadingPanel = false;
}, // },
() => { // () => {
this.loadingPanelService.ShowLoadingPanel = false; // this.loadingPanelService.ShowLoadingPanel = false;
setTimeout(() => { // setTimeout(() => {
this.saveEmployee(); // this.saveEmployee();
}, 1000); // }, 1000);
} // }
); // );
} // }
else { // else {
this.saveEmployee(); // this.saveEmployee();
} // }
} // }
saveEmployee() { saveEmployee() {

View File

@ -243,7 +243,7 @@ namespace HRM.UI.Controllers
[Route("saveEmployee")] [Route("saveEmployee")]
public ActionResult SaveEmployee(Employee item) public ActionResult SaveEmployee(Employee item)
{ {
int ans; Employee ans;
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
if (item.IsNew == true) if (item.IsNew == true)
@ -260,7 +260,8 @@ namespace HRM.UI.Controllers
try try
{ {
ans = _EmployeeService.Save(item); //ans = _EmployeeService.Save(item);
ans = _EmployeeService.SaveEmployee(item);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -549,7 +550,7 @@ namespace HRM.UI.Controllers
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
} }
return Ok(item.ID); return Ok(item);
} }