From 66a1a366981d1b283a4ff64746912cb96137f47c Mon Sep 17 00:00:00 2001 From: Mohaimen Hasan Date: Tue, 17 Nov 2026 13:01:32 +0600 Subject: [PATCH] User Role Permission --- HRM.DA/DA/Users/UserRoleDA.cs | 4 +++- HRM.DA/Service/Users/UserRoleService.cs | 3 +++ .../user-role-list.component.html | 2 ++ .../user-role-list.component.ts | 21 +++++++++++++++++-- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/HRM.DA/DA/Users/UserRoleDA.cs b/HRM.DA/DA/Users/UserRoleDA.cs index 9f48769..cbd5ca7 100644 --- a/HRM.DA/DA/Users/UserRoleDA.cs +++ b/HRM.DA/DA/Users/UserRoleDA.cs @@ -72,7 +72,9 @@ namespace HRM.DA } return tc.ExecuteReader( - @"SELECT ur.*, u.LOGINID LoginID, u.USERNAME UserName,R.Name RoleName, u.EmployeeID employeeID FROM UserRole ur,[Users] u, Role R + @"SELECT ur.*, u.LOGINID LoginID, u.USERNAME UserName,R.Name RoleName, u.EmployeeID employeeID, + (SELECT e.PayrollTypeID FROM Employee e WHERE e.EmployeeID = u.EmployeeID) EmpPayrollTypeID + FROM UserRole ur,[Users] u, Role R WHERE ur.RoleID=r.RoleID and u.UserID =ur.UserID %q order by u.LoginID,R.Name", sqlClause); } diff --git a/HRM.DA/Service/Users/UserRoleService.cs b/HRM.DA/Service/Users/UserRoleService.cs index 4917b2a..2d8cb41 100644 --- a/HRM.DA/Service/Users/UserRoleService.cs +++ b/HRM.DA/Service/Users/UserRoleService.cs @@ -31,6 +31,9 @@ namespace HRM.DA oUserRole.ApprovedComputerName = oReader.GetString("ApprovedComputerName"); oUserRole.UserRoleStatus = (EnumAuthStatus)oReader.GetInt32("Status").Value; oUserRole.employeeID = oReader.GetInt32("employeeID",true, 0) ==0? null: oReader.GetInt32("employeeID"); + // Only the list query (UserRoleDA.Get by role type) carries EmpPayrollTypeID: the employee's payroll type. + int empPayrollTypeID = oReader.GetInt32("EmpPayrollTypeID", true, 0); + oUserRole.payrollTypeID = empPayrollTypeID == 0 ? null : empPayrollTypeID; oUserRole.loginIDView = oReader.GetString("LoginID", true, string.Empty); oUserRole.userNameView = oReader.GetString("userName", true, string.Empty); oUserRole.roleNameView = oReader.GetString("roleName", true, string.Empty); diff --git a/HRM.UI/ClientApp/src/app/authentication/user-role/user-role-list/user-role-list.component.html b/HRM.UI/ClientApp/src/app/authentication/user-role/user-role-list/user-role-list.component.html index 1c239c3..36a3849 100644 --- a/HRM.UI/ClientApp/src/app/authentication/user-role/user-role-list/user-role-list.component.html +++ b/HRM.UI/ClientApp/src/app/authentication/user-role/user-role-list/user-role-list.component.html @@ -73,6 +73,8 @@ +
diff --git a/HRM.UI/ClientApp/src/app/authentication/user-role/user-role-list/user-role-list.component.ts b/HRM.UI/ClientApp/src/app/authentication/user-role/user-role-list/user-role-list.component.ts index 0e5944e..7d61995 100644 --- a/HRM.UI/ClientApp/src/app/authentication/user-role/user-role-list/user-role-list.component.ts +++ b/HRM.UI/ClientApp/src/app/authentication/user-role/user-role-list/user-role-list.component.ts @@ -15,6 +15,9 @@ interface AssignmentRow { employeeID: number; loginID: string; userName: string; + /** Self Service only: the employee's payroll type. */ + payrollTypeID: number; + payrollTypeName: string; roles: string[]; rolesText: string; pending: boolean; @@ -56,6 +59,8 @@ export class UserRoleListComponent implements OnInit { activeView: 'assignments' | 'pending' = 'assignments'; listRoleType: EnumRoleType = EnumRoleType.Admin; currentUserID: number; + /** Payroll type names by ID, for the Self Service Payroll Type column. */ + payrollTypeNames = new Map(); // All assignments rows: AssignmentRow[] = []; @@ -85,6 +90,10 @@ export class UserRoleListComponent implements OnInit { this.currentUserID = resp?.userID; this.loadPending(); }); + this.userService.GetAllPayrollTypes().subscribe((resp: any[]) => { + this.payrollTypeNames = new Map((resp ?? []).map(p => [p.id, p.description] as [number, string])); + this.rows.forEach(r => r.payrollTypeName = this.payrollTypeName(r)); + }); this.RefreshControl(); } @@ -109,7 +118,7 @@ export class UserRoleListComponent implements OnInit { if (!row) { row = { key: 'u' + r.userID, userID: r.userID, employeeID: r.employeeID, loginID: r.loginIDView, - userName: r.userNameView, roles: [], rolesText: '', pending: false, statusText: '', + userName: r.userNameView, payrollTypeID: r.payrollTypeID, payrollTypeName: '', roles: [], rolesText: '', pending: false, statusText: '', }; byUser.set(r.userID, row); } @@ -120,7 +129,10 @@ export class UserRoleListComponent implements OnInit { } }); this.rows = Array.from(byUser.values()); - this.rows.forEach(r => r.rolesText = r.roles.join(', ')); + this.rows.forEach(r => { + r.rolesText = r.roles.join(', '); + r.payrollTypeName = this.payrollTypeName(r); + }); this.markPendingRows(); }, (err: any) => { @@ -133,6 +145,11 @@ export class UserRoleListComponent implements OnInit { ); } + private payrollTypeName(row: AssignmentRow): string { + const id = row.payrollTypeID; + return id ? (this.payrollTypeNames.get(id) ?? '') : ''; + } + private pendingFor(row: AssignmentRow): PendingGroup { return this.pendingGroups.find(g => g.roleType == this.listRoleType && g.userID == row.userID); }