department permission and multiple employeeid inputs

This commit is contained in:
mashfiq 2026-01-15 14:17:51 +06:00
parent 947692280e
commit d9460f525d
11 changed files with 224 additions and 87 deletions

View File

@ -42,6 +42,7 @@ namespace HRM.BO
List<DataPermission> getUsersByUserType(EnumUserType userType); List<DataPermission> getUsersByUserType(EnumUserType userType);
void InsertDataPermission(DataPermission item); void InsertDataPermission(DataPermission item);
int Save(DataPermission item); int Save(DataPermission item);
void Save(List<DataPermission> oDataPermissions);
void Delete(int id); void Delete(int id);
} }

View File

@ -44,24 +44,7 @@ namespace HRM.DA
#region Get Function #region Get Function
internal static IDataReader Get(TransactionContext tc, EnumStatus status) #region GetUsersByUserType
{
if (EnumStatus.Active == status || EnumStatus.Inactive == status)
{
return tc.ExecuteReader("SELECT * FROM Religion Where Status=%n Order By SequenceNo", status);
}
else
{
return tc.ExecuteReader("SELECT * FROM Religion Order By SequenceNo");
}
}
internal static IDataReader Get(TransactionContext tc, int ID)
{
return tc.ExecuteReader("SELECT * FROM Religion WHERE ReligionID=%n", ID);
}
#region
internal static IDataReader GetUsersByUserType(TransactionContext tc, EnumUserType type) internal static IDataReader GetUsersByUserType(TransactionContext tc, EnumUserType type)
{ {
return tc.ExecuteReader("SELECT * FROM Users where UserType = %n", type); return tc.ExecuteReader("SELECT * FROM Users where UserType = %n", type);
@ -81,6 +64,7 @@ namespace HRM.DA
} }
} }
#endregion #endregion
internal static void InsertDataPermission(TransactionContext tc, DataPermission item) internal static void InsertDataPermission(TransactionContext tc, DataPermission item)
{ {
item.CreatedDate = DateTime.Now; item.CreatedDate = DateTime.Now;
@ -113,6 +97,17 @@ namespace HRM.DA
userid, payrolltypeid, userid, payrolltypeid, userid, payrolltypeid); userid, payrolltypeid, userid, payrolltypeid, userid, payrolltypeid);
} }
internal static bool PermissionAlreadyExsits(TransactionContext tc, DataPermission item)
{
bool Exist = false;
string sql = SQLParser.MakeSQL("SELECT COUNT(*) FROM DATAPERMISSION WHERE USERID=%n AND REFERENCEID=%n AND PERMISSIONTYPE=%n AND PAYROLLTYPEID=%n", item.UserID, item.ReferenceID, item.PermissionType, item.PayrollTypeID);
Object obj =
tc.ExecuteScalar(sql);
Exist = Convert.ToInt32(obj) > 0 ? true : false;
return Exist;
}
#endregion #endregion
#region Delete function #region Delete function

View File

@ -1,13 +1,14 @@
using System; using Ease.Core.DataAccess;
using Ease.Core.Model;
using Ease.Core.Utility;
using HRM.BO;
using HRM.DA;
using HRM.Service;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using HRM.BO;
using HRM.DA;
using Ease.Core.DataAccess;
using Ease.Core.Model;
using Ease.Core.Utility;
namespace HRM.DA namespace HRM.DA
{ {
@ -239,6 +240,40 @@ namespace HRM.DA
#endregion #endregion
} }
} }
public void Save(List<DataPermission> oDataPermissions)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
int id = tc.GenerateID("DataPermission", "DataPermissionID");
foreach (DataPermission oDataPermission in oDataPermissions)
{
bool exists = DataPermissionDA.PermissionAlreadyExsits(tc, oDataPermission);
if (oDataPermission.IsNew && !exists)
{
base.SetObjectID(oDataPermission, id);
DataPermissionDA.Insert(tc, oDataPermission);
id++;
}
else
{
//DataPermissionDA.Update(tc, oDataPermission);
}
}
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException("Failed to Save Leave Year: " + e.Message, e);
#endregion
}
}
public void Delete(int id) public void Delete(int id)
{ {
TransactionContext tc = null; TransactionContext tc = null;

View File

@ -266,4 +266,7 @@ export class AuthService {
GetOperationDate() { GetOperationDate() {
return this.apiService.httpGet<Date>('/Authentication/getOperationDate'); return this.apiService.httpGet<Date>('/Authentication/getOperationDate');
} }
addPermissions(data: DataPermission[]) {
return this.apiService.httpPost<any>('/Authentication/addPermissions', data);
}
} }

View File

@ -72,7 +72,7 @@
<ng-container *ngIf="this.isCategory == true"> <ng-container *ngIf="this.isCategory == true">
<div class="p-col-12 p-lg-2"> <div class="p-col-12 p-lg-2">
<label for="txtDepartment">Category</label> <label for="txtCategory">Category</label>
</div> </div>
<div class="p-col-12 p-lg-4"> <div class="p-col-12 p-lg-4">
<app-dynamic-picker [dynamicPickerView]="_categoryPicker" <app-dynamic-picker [dynamicPickerView]="_categoryPicker"

View File

@ -79,17 +79,21 @@ export class DataPermssionComponent implements OnInit {
this.isGrade = false; this.isGrade = false;
this.isLocation = false; this.isLocation = false;
this._permissionType = selectedPermissionType; this._permissionType = selectedPermissionType;
if (this._permissionType.value == 3) { this.isDepartment = true; } if (this._permissionType.value == 3) {
this.isDepartment = true;
/*this._departmentPicker.multiSelect = true;*/
this._departmentPicker.checkChildren = false;
}
else if (this._permissionType.value == 1) { this.isCategory = true; } else if (this._permissionType.value == 1) { this.isCategory = true; }
else if (this._permissionType.value == 4) { this.isLocation = true; } else if (this._permissionType.value == 4) { this.isLocation = true; }
else if (this._permissionType.value == 2) { this.isGrade = true; } else if (this._permissionType.value == 2) { this.isGrade = true; }
} }
onUserChange(selectedUserID: any): void { onUserChange(selectedUserID: any): void {
if(selectedUserID.id != null){ if (selectedUserID.id != null) {
this._selectedUser = selectedUserID; this._selectedUser = selectedUserID;
this._userID = this._selectedUser.id; this._userID = this._selectedUser.id;
if (this._userID != undefined && this._selectedPayroll != undefined) if (this._userID != undefined && this._selectedPayroll != undefined)
this.loadGridView() this.loadGridView()
} }
@ -116,7 +120,7 @@ export class DataPermssionComponent implements OnInit {
this.apiservice.selectedMenuName = 'User Data Permission'; this.apiservice.selectedMenuName = 'User Data Permission';
this._categoryPicker = new DynamicPicker(EnumDynamicpickerType.Category, false); this._categoryPicker = new DynamicPicker(EnumDynamicpickerType.Category, false);
this._departmentPicker = new DynamicPicker(EnumDynamicpickerType.Department, false); this._departmentPicker = new DynamicPicker(EnumDynamicpickerType.Department, true);
this._gradePicker = new DynamicPicker(EnumDynamicpickerType.Grade, false); this._gradePicker = new DynamicPicker(EnumDynamicpickerType.Grade, false);
this._locationPicker = new DynamicPicker(EnumDynamicpickerType.Location, false); this._locationPicker = new DynamicPicker(EnumDynamicpickerType.Location, false);
this.GetPayroll(); this.GetPayroll();
@ -163,39 +167,83 @@ export class DataPermssionComponent implements OnInit {
return; return;
} }
var referenceid: number = 0;
if (this._permissionType.value == 3) { referenceid = this._departmentPicker.selectedID; } if (this._permissionType.value == 3) {
else if (this._permissionType.value == 1) { referenceid = this._categoryPicker.selectedID; } // referenceid = this._departmentPicker.selectedID;
else if (this._permissionType.value == 4) { referenceid = this._locationPicker.selectedID; } if (this._departmentPicker != undefined) {
else if (this._permissionType.value == 2) { referenceid = this._gradePicker.selectedID; }
if (referenceid == 0) { if (this._departmentPicker.selectedIDs.length <= 0) {
this.notificationService.showError("Please a Permission item"); this.notificationService.showWarning("Please select a Departemnt");
return; return;
}
debugger;
// const data = [];
let datapermissions: DataPermission[] = [];
this._departmentPicker.selectedIDs.forEach(selectedID => {
// let item = {
// userID: this._selectedUser.id,
// payrollTypeID: this._selectedPayroll,
// permissionTypeID: this._permissionType.value,
// refitemid: selectedID,
// permissionStatus: 2
// };
// data.push(item);
let datapermission: DataPermission = new DataPermission();
datapermission.userID = this._selectedUser.id;
datapermission.payrollTypeID = this._selectedPayroll;
datapermission.permissionType = this._permissionType.value;
datapermission.referenceID = selectedID;
datapermission.permissionStatus = EnumMenuPermissionStatus.Added;
datapermissions.push(datapermission);
});
this.loadingPanel.ShowLoadingPanel = true;
this.userService.addPermissions(datapermissions).subscribe(
(resp) => {
this.notificationService.showSuccess("Added permission successfully.");
this.loadGridView();
this.loadingPanel.ShowLoadingPanel = false;
},
(x) => {
this.loadingPanel.ShowLoadingPanel = false;
this.notificationService.showError(x.error);
}
);
}
} }
const data = { else {
userID: this._selectedUser.id, var referenceid: number = 0;
payrollTypeID: this._selectedPayroll, if (this._permissionType.value == 1) { referenceid = this._categoryPicker.selectedID; }
permissionTypeID: this._permissionType.value, else if (this._permissionType.value == 4) { referenceid = this._locationPicker.selectedID; }
refitemid: referenceid, else if (this._permissionType.value == 2) { referenceid = this._gradePicker.selectedID; }
permissionStatus: 2
};
this.loadingPanel.ShowLoadingPanel = true;
this.userService.addPermission(data).subscribe(
(resp) => {
this.notificationService.showSuccess("Added permission successfully.");
this.loadGridView();
},
(x) => {
this.loadingPanel.ShowLoadingPanel = false;
this.notificationService.showSuccess(x.error);
},
() => {
this.loadingPanel.ShowLoadingPanel = false;
}, if (referenceid == 0) {
); this.notificationService.showWarning("Please select a Permission item");
return;
}
const data = {
userID: this._selectedUser.id,
payrollTypeID: this._selectedPayroll,
permissionTypeID: this._permissionType.value,
refitemid: referenceid,
permissionStatus: 2
};
this.loadingPanel.ShowLoadingPanel = true;
this.userService.addPermission(data).subscribe(
(resp) => {
this.notificationService.showSuccess("Added permission successfully.");
this.loadGridView();
},
(x) => {
this.loadingPanel.ShowLoadingPanel = false;
this.notificationService.showError(x.error);
},
() => {
this.loadingPanel.ShowLoadingPanel = false;
},
);
}
} }
@ -211,7 +259,7 @@ export class DataPermssionComponent implements OnInit {
}, },
() => { () => {
this.notificationService.showSuccess("data deleted successfully."); this.notificationService.showSuccess("Data deleted successfully.");
this.loadGridView(); this.loadGridView();
}); });
} }

View File

@ -405,6 +405,7 @@ export class DynamicPicker {
selectedIDs: number[]; selectedIDs: number[];
selectedObjects: Array<Object>; selectedObjects: Array<Object>;
multiSelect: boolean; multiSelect: boolean;
checkChildren: boolean;
selecteditemText: string = ''; selecteditemText: string = '';
pickerType: EnumDynamicpickerType; pickerType: EnumDynamicpickerType;
payrollTypeID?: number; payrollTypeID?: number;
@ -419,6 +420,7 @@ export class DynamicPicker {
this.selectedIDs = []; this.selectedIDs = [];
this.selecteditemText = ''; this.selecteditemText = '';
this.multiSelect = Multiselect; this.multiSelect = Multiselect;
this.checkChildren = this.multiSelect ? true : false;
this.pickerType = PickerType; this.pickerType = PickerType;
this.payrollTypeID = undefined; this.payrollTypeID = undefined;
new DynamicPickerTypeDefination(PickerType, this, Multiselect); new DynamicPickerTypeDefination(PickerType, this, Multiselect);

View File

@ -100,7 +100,8 @@ export class DynamicPickerComponent implements OnInit, OnChanges, AfterContentCh
this.checkMode = 'single'; this.checkMode = 'single';
} }
return { return {
checkChildren: true, // checkChildren: true,
checkChildren: this.dynamicPickerView.checkChildren,
checkParents: false, checkParents: false,
enabled: this.dynamicPickerView.multiSelect, enabled: this.dynamicPickerView.multiSelect,
mode: this.checkMode, mode: this.checkMode,

View File

@ -119,6 +119,9 @@
<div class="p-col-12 p-md-6"> <div class="p-col-12 p-md-6">
<app-employee-picker (ItemSelected)="GetSelectedEmployee($event)"></app-employee-picker> <app-employee-picker (ItemSelected)="GetSelectedEmployee($event)"></app-employee-picker>
</div> </div>
<div *ngIf="hiddenMultiEmpNo && multiselect" class="p-col-12 p-md-6">
<input id="empNos" [(ngModel)]="multiEmpNo" style="width:100%" type="text" [placeholder]="'Input EmployeeIds'" pInputText>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -169,6 +169,9 @@ export class ReportViewerComponent implements OnInit {
public selectAllState: SelectAllCheckboxState = "unchecked"; public selectAllState: SelectAllCheckboxState = "unchecked";
multiselect = true; multiselect = true;
multiEmpNo: string = '';
hiddenMultiEmpNo = true;
emps: any[];
ngOnInit() { ngOnInit() {
//debugger //debugger
@ -195,7 +198,20 @@ export class ReportViewerComponent implements OnInit {
this.loadingPanel.ShowLoadingPanel = false; this.loadingPanel.ShowLoadingPanel = false;
}); });
} }
this.employeeService.getAllEmployeeNameAndNo().subscribe(
(x) => {
//console.log(x);
this.emps = x;
},
(x) => {
// console.log(x);
this.loadingPanel.ShowLoadingPanel = false;
},
() => {
this.setReportColumns(this.reportType);
this.loadingPanel.ShowLoadingPanel = false;
}
);
this.setSelectableSettings(); this.setSelectableSettings();
this.loadBank(); this.loadBank();
@ -1149,7 +1165,7 @@ export class ReportViewerComponent implements OnInit {
this.topview = "decade"; this.topview = "decade";
this.apiService.selectedMenuName = 'Employee Wise Card Information'; this.apiService.selectedMenuName = 'Employee Wise Card Information';
} }
else if (this.reportType === '721' ) { else if (this.reportType === '721') {
this.hiddenFromDate = false; this.hiddenFromDate = false;
this.hiddenToDate = false; this.hiddenToDate = false;
this.PDFTitle = 'Employee Basic Information'; this.PDFTitle = 'Employee Basic Information';
@ -1508,7 +1524,18 @@ export class ReportViewerComponent implements OnInit {
if (this.selectedEmp !== undefined) { if (this.selectedEmp !== undefined) {
this.empIds = this.selectedEmp.employeeID.toString(); this.empIds = this.selectedEmp.employeeID.toString();
} }
// debugger; if (this.multiEmpNo != null && this.multiEmpNo != '') {
debugger;
const list = this.multiEmpNo.split(',');
this.empIds = '';
list.forEach(element => {
if (this.empIds !== '') {
this.empIds += ',';
}
let e = this.emps.find(e => e.employeeNo === element.trim());
this.empIds += e != undefined ? e.id : '';
});
}
// console.log(this.empIds); // console.log(this.empIds);
@ -1564,7 +1591,7 @@ export class ReportViewerComponent implements OnInit {
// this.loadGrid(); // this.loadGrid();
// } // }
// ); // );
const data = { const data = {
reportid: this.reportType, reportid: this.reportType,
selectedReport: this.selectedReport, selectedReport: this.selectedReport,

View File

@ -1,32 +1,33 @@
using AutoMapper; using AutoMapper;
using HRM.DA;
using HRM.UI.DTOs.Auth;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.IdentityModel.Tokens;
using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using System.Linq;
using System.Security.Claims;
using System.Security.Cryptography;
using System.Threading.Tasks;
using HRM.BO; using HRM.BO;
using System.Net.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.Options;
using HRM.UI.Api;
using System.Text;
using HRM.BO.Configuration; using HRM.BO.Configuration;
using Newtonsoft.Json; using HRM.DA;
using System.Data; using HRM.DA;
using System.Net;
using System.Reflection;
using HRM.DA.Service; using HRM.DA.Service;
using HRM.Service; using HRM.Service;
using HRM.DA; using HRM.UI.Api;
using HRM.UI.DTOs.Auth;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.IdentityModel.Tokens.Jwt;
using System.IO; using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Reflection;
using System.Security.Claims;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace HRM.UI.Controllers namespace HRM.UI.Controllers
{ {
@ -1274,6 +1275,27 @@ namespace HRM.UI.Controllers
} }
return Ok(dataPermission.ID); return Ok(dataPermission.ID);
} }
[HttpPost("addPermissions")]
public ActionResult addPermissions(List<DataPermission> dataPermissions)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
foreach (var item in dataPermissions)
{
item.PermissionStatus = EnumMenuPermissionStatus.Approved;
item.CreatedBy = currentUser.UserID;
item.CreatedDate = DateTime.Now;
}
_dataPermissionService.Save(dataPermissions);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpGet("loadDataPermission/{userid}/{payrolltypeid}")] [HttpGet("loadDataPermission/{userid}/{payrolltypeid}")]
public ActionResult loadDataPermission(int userid, int payrolltypeid) public ActionResult loadDataPermission(int userid, int payrolltypeid)