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);
void InsertDataPermission(DataPermission item);
int Save(DataPermission item);
void Save(List<DataPermission> oDataPermissions);
void Delete(int id);
}

View File

@ -44,24 +44,7 @@ namespace HRM.DA
#region Get Function
internal static IDataReader Get(TransactionContext tc, EnumStatus status)
{
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
#region GetUsersByUserType
internal static IDataReader GetUsersByUserType(TransactionContext tc, EnumUserType type)
{
return tc.ExecuteReader("SELECT * FROM Users where UserType = %n", type);
@ -81,6 +64,7 @@ namespace HRM.DA
}
}
#endregion
internal static void InsertDataPermission(TransactionContext tc, DataPermission item)
{
item.CreatedDate = DateTime.Now;
@ -113,6 +97,17 @@ namespace HRM.DA
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
#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.Linq;
using System.Text;
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
{
@ -239,6 +240,40 @@ namespace HRM.DA
#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)
{
TransactionContext tc = null;

View File

@ -266,4 +266,7 @@ export class AuthService {
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">
<div class="p-col-12 p-lg-2">
<label for="txtDepartment">Category</label>
<label for="txtCategory">Category</label>
</div>
<div class="p-col-12 p-lg-4">
<app-dynamic-picker [dynamicPickerView]="_categoryPicker"

View File

@ -79,17 +79,21 @@ export class DataPermssionComponent implements OnInit {
this.isGrade = false;
this.isLocation = false;
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 == 4) { this.isLocation = true; }
else if (this._permissionType.value == 2) { this.isGrade = true; }
}
onUserChange(selectedUserID: any): void {
if(selectedUserID.id != null){
if (selectedUserID.id != null) {
this._selectedUser = selectedUserID;
this._userID = this._selectedUser.id;
if (this._userID != undefined && this._selectedPayroll != undefined)
this.loadGridView()
}
@ -116,7 +120,7 @@ export class DataPermssionComponent implements OnInit {
this.apiservice.selectedMenuName = 'User Data Permission';
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._locationPicker = new DynamicPicker(EnumDynamicpickerType.Location, false);
this.GetPayroll();
@ -163,39 +167,83 @@ export class DataPermssionComponent implements OnInit {
return;
}
var referenceid: number = 0;
if (this._permissionType.value == 3) { referenceid = this._departmentPicker.selectedID; }
else if (this._permissionType.value == 1) { referenceid = this._categoryPicker.selectedID; }
else if (this._permissionType.value == 4) { referenceid = this._locationPicker.selectedID; }
else if (this._permissionType.value == 2) { referenceid = this._gradePicker.selectedID; }
if (this._permissionType.value == 3) {
// referenceid = this._departmentPicker.selectedID;
if (this._departmentPicker != undefined) {
if (referenceid == 0) {
this.notificationService.showError("Please a Permission item");
return;
if (this._departmentPicker.selectedIDs.length <= 0) {
this.notificationService.showWarning("Please select a Departemnt");
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 = {
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.showSuccess(x.error);
},
() => {
this.loadingPanel.ShowLoadingPanel = false;
else {
var referenceid: number = 0;
if (this._permissionType.value == 1) { referenceid = this._categoryPicker.selectedID; }
else if (this._permissionType.value == 4) { referenceid = this._locationPicker.selectedID; }
else if (this._permissionType.value == 2) { referenceid = this._gradePicker.selectedID; }
},
);
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();
});
}

View File

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

View File

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

View File

@ -119,6 +119,9 @@
<div class="p-col-12 p-md-6">
<app-employee-picker (ItemSelected)="GetSelectedEmployee($event)"></app-employee-picker>
</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>

View File

@ -169,6 +169,9 @@ export class ReportViewerComponent implements OnInit {
public selectAllState: SelectAllCheckboxState = "unchecked";
multiselect = true;
multiEmpNo: string = '';
hiddenMultiEmpNo = true;
emps: any[];
ngOnInit() {
//debugger
@ -195,7 +198,20 @@ export class ReportViewerComponent implements OnInit {
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.loadBank();
@ -1149,7 +1165,7 @@ export class ReportViewerComponent implements OnInit {
this.topview = "decade";
this.apiService.selectedMenuName = 'Employee Wise Card Information';
}
else if (this.reportType === '721' ) {
else if (this.reportType === '721') {
this.hiddenFromDate = false;
this.hiddenToDate = false;
this.PDFTitle = 'Employee Basic Information';
@ -1508,7 +1524,18 @@ export class ReportViewerComponent implements OnInit {
if (this.selectedEmp !== undefined) {
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);
@ -1564,7 +1591,7 @@ export class ReportViewerComponent implements OnInit {
// this.loadGrid();
// }
// );
const data = {
reportid: this.reportType,
selectedReport: this.selectedReport,

View File

@ -1,32 +1,33 @@
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 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 Newtonsoft.Json;
using System.Data;
using System.Net;
using System.Reflection;
using HRM.DA;
using HRM.DA;
using HRM.DA.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.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
{
@ -1274,6 +1275,27 @@ namespace HRM.UI.Controllers
}
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}")]
public ActionResult loadDataPermission(int userid, int payrolltypeid)