Bonus Religion

This commit is contained in:
Mohaimen Hasan 2026-11-29 17:30:48 +06:00
parent ffcc0777dc
commit 79dd1108ee
14 changed files with 284 additions and 16 deletions

View File

@ -72,6 +72,17 @@ namespace HRM.BO
#endregion
#region ReligionIDs / ReligionNames : string (BonusReligion, not Bonus columns)
// Comma-separated ReligionIDs of this bonus (table BonusReligion).
// null = not loaded: Save leaves the BonusReligion rows untouched.
public string ReligionIDs { get; set; }
// Comma-separated religion names, for display only.
public string ReligionNames { get; set; }
#endregion
//#region Service Factory IBonusService : IBonusService

View File

@ -121,6 +121,36 @@ namespace HRM.DA
#endregion
#region BonusReligion
internal static void InsertReligion(TransactionContext tc, int bonusReligionID, int bonusID, int religionID)
{
tc.ExecuteNonQuery("INSERT INTO BonusReligion(BonusReligionID, BonusID, ReligionID) VALUES(%n, %n, %n)",
bonusReligionID, bonusID, religionID);
}
internal static void DeleteReligions(TransactionContext tc, int bonusID)
{
tc.ExecuteNonQuery("DELETE FROM BonusReligion WHERE BonusID=%n", bonusID);
}
internal static IDataReader GetReligions(TransactionContext tc, int bonusID)
{
return tc.ExecuteReader(
"SELECT br.BonusID, br.ReligionID, r.Name FROM BonusReligion br INNER JOIN Religion r ON r.ReligionID = br.ReligionID" +
" WHERE br.BonusID=%n ORDER BY r.SequenceNo, r.Name", bonusID);
}
internal static IDataReader GetReligionsByPayrollType(TransactionContext tc, int payrollTypeID)
{
return tc.ExecuteReader(
"SELECT br.BonusID, br.ReligionID, r.Name FROM BonusReligion br INNER JOIN Religion r ON r.ReligionID = br.ReligionID" +
" INNER JOIN Bonus b ON b.BonusID = br.BonusID WHERE b.PayrollTypeID=%n ORDER BY br.BonusID, r.SequenceNo, r.Name",
payrollTypeID);
}
#endregion
#region CC Wise Bonus Summary
internal static DataSet GetCCWiseBonusSummary(TransactionContext tc, DateTime bMonthDate, string bonus)
{

View File

@ -51,6 +51,76 @@ namespace HRM.DA
return oBonus;
}
#region BonusReligion
// Replaces the bonus's BonusReligion rows with oBonus.ReligionIDs ("1,3"; "" = none).
private void SaveReligions(TransactionContext tc, Bonus oBonus)
{
BonusDA.DeleteReligions(tc, oBonus.ID);
List<int> religionIDs = new List<int>();
foreach (string part in oBonus.ReligionIDs.Split(','))
{
int religionID;
if (int.TryParse(part.Trim(), out religionID) && religionID > 0 && !religionIDs.Contains(religionID))
religionIDs.Add(religionID);
}
foreach (int religionID in religionIDs)
{
int id = tc.GenerateID("BonusReligion", "BonusReligionID");
BonusDA.InsertReligion(tc, id, oBonus.ID, religionID);
}
FillReligions(tc, oBonus);
}
private void FillReligions(TransactionContext tc, Bonus oBonus)
{
List<string> ids = new List<string>();
List<string> names = new List<string>();
DataReader dr = new DataReader(BonusDA.GetReligions(tc, oBonus.ID));
while (dr.Read())
{
ids.Add(dr.GetInt32("ReligionID").Value.ToString());
names.Add(dr.GetString("Name"));
}
dr.Close();
oBonus.ReligionIDs = string.Join(",", ids);
oBonus.ReligionNames = string.Join(", ", names);
}
private void FillReligions(TransactionContext tc, List<Bonus> bonuses, int payrollTypeID)
{
if (bonuses == null || bonuses.Count == 0)
return;
Dictionary<int, List<string>> ids = new Dictionary<int, List<string>>();
Dictionary<int, List<string>> names = new Dictionary<int, List<string>>();
DataReader dr = new DataReader(BonusDA.GetReligionsByPayrollType(tc, payrollTypeID));
while (dr.Read())
{
int bonusID = dr.GetInt32("BonusID").Value;
if (!ids.ContainsKey(bonusID))
{
ids.Add(bonusID, new List<string>());
names.Add(bonusID, new List<string>());
}
ids[bonusID].Add(dr.GetInt32("ReligionID").Value.ToString());
names[bonusID].Add(dr.GetString("Name"));
}
dr.Close();
foreach (Bonus oBonus in bonuses)
{
oBonus.ReligionIDs = ids.ContainsKey(oBonus.ID) ? string.Join(",", ids[oBonus.ID]) : string.Empty;
oBonus.ReligionNames = names.ContainsKey(oBonus.ID) ? string.Join(", ", names[oBonus.ID]) : string.Empty;
}
}
#endregion
#region Service implementation
public Bonus Get(int id)
@ -68,6 +138,8 @@ namespace HRM.DA
}
oreader.Close();
if (!oBonus.IsNew)
FillReligions(tc, oBonus);
tc.End();
}
catch (Exception e)
@ -97,6 +169,8 @@ namespace HRM.DA
}
oreader.Close();
if (!oBonus.IsNew)
FillReligions(tc, oBonus);
}
catch (Exception e)
{
@ -125,6 +199,7 @@ namespace HRM.DA
DataReader dr = new DataReader(BonusDA.Get(tc, status, payrollTypeID));
bonuss = this.CreateObjects<Bonus>(dr);
dr.Close();
FillReligions(tc, bonuss, payrollTypeID);
tc.End();
}
@ -224,6 +299,9 @@ namespace HRM.DA
BonusDA.Update(tc, oBonus);
}
if (oBonus.ReligionIDs != null)
SaveReligions(tc, oBonus);
tc.End();
return oBonus.ID;
}
@ -246,6 +324,7 @@ namespace HRM.DA
try
{
tc = TransactionContext.Begin(true);
BonusDA.DeleteReligions(tc, id);
BonusDA.Delete(tc, id);
tc.End();
}

View File

@ -105,7 +105,7 @@ export class EssComponentUploaderComponent implements OnInit {
private loadUploadDeadline(): void {
this.basicService.getComponentUploadDeadline().subscribe(
(resp: any) => {
//this.deadlinePassed = !!resp && resp.allowed === false;
this.deadlinePassed = !!resp && resp.allowed === false;
this.uploadDeadline = (resp && resp.deadline) ? new Date(resp.deadline) : null;
if (resp && resp.salaryMonth) { this.salaryMonth = new Date(resp.salaryMonth); }
},

View File

@ -41,6 +41,15 @@ export class BasicEntryControlComponent implements OnInit {
//basiccontrol: BasicEntryFormControl<any>;
applyBanglaFont: boolean = false;
get isValid() { return this.form.controls[this.basiccontrol.controlID].valid; }
// the control's own placeholder, else "Select <label>" (e.g. "Select Religion")
get multiSelectPlaceholder(): string {
const own = (this.basiccontrol.placeholder || '').trim();
if (own != '') {
return own;
}
const label = (this.basiccontrol.label || '').trim();
return label != '' ? 'Select ' + label : 'Select';
}
constructor(public bsview: basicformbuilderService) {

View File

@ -13,7 +13,7 @@
<fieldset style="padding: 0px;">
<div class="form-row-wrapper">
@for (ctl of this.basicMasterView.entryFrom.controls; track ctl) {
<div class="form-row">
<div class="form-row" [ngClass]="getRowClass(ctl)">
<app-basic-from-control [basiccontrol]="ctl" [form]="form"></app-basic-from-control>
</div>
}

View File

@ -1,5 +1,5 @@
import {HttpClient} from '@angular/common/http';
import {BasicEntryForm, EnumDynamicControlType} from './Basic-Entry-form';
import {BasicEntryForm, BasicEntryFormControl, EnumDynamicControlType} from './Basic-Entry-form';
import {Component, Input, OnInit, Output, EventEmitter, ElementRef, ChangeDetectionStrategy} from '@angular/core';
import {FormGroup} from '@angular/forms';
import {BasicMasterView, EnumFormView} from './Basic-Master-View';
@ -75,9 +75,21 @@ export class BasicEntryFormComponent implements OnInit {
}
// e.g. "Are you sure you want to save this Bonus?" / "...update this Bonus?"
private getSaveConfirmMessage(): string {
const caption = (this.basicMasterView.caption || '').trim();
const action = this.basicMasterView.entryFrom.isNew == false ? 'update' : 'save';
return caption != ''
? `Are you sure you want to ${action} this ${caption}?`
: `Are you sure you want to ${action}?`;
}
onSubmit() {
this.notificationService.confirm('Do you sure you want to save?', () => {
this.notificationService.showActiveConfirm('Confirmation', this.getSaveConfirmMessage()).then((isConfirmed) => {
if (!isConfirmed) {
return;
}
this.payLoad = JSON.stringify(this.form.value);
this.basicMasterView.entryFrom.controls.forEach(x => {
if (x.controlType == EnumDynamicControlType.DropDownEnumData) {
@ -91,6 +103,9 @@ export class BasicEntryFormComponent implements OnInit {
} else if (x.controlType == EnumDynamicControlType.DateTime) {
var ddate: Date = this.intl.parseDate(this.form.controls[x.controlID].value);
x.value = ddate.toDateString();
} else if (x.controlType == EnumDynamicControlType.MultiSelectServerData) {
const selected = this.form.controls[x.controlID].value;
x.value = Array.isArray(selected) ? selected.join(',') : '';
} else {
x.value = String(this.form.controls[x.controlID].value);
}
@ -119,12 +134,8 @@ export class BasicEntryFormComponent implements OnInit {
this.AutogeneratedCode();
}
});
},
() => {
// User canceled, do nothing
//this.notificationService.showInfo('Save operation canceled.');
});
}
@ -244,6 +255,38 @@ export class BasicEntryFormComponent implements OnInit {
this.opened = true;
}
// Layout of the two-per-line field grid, worked out only when the form has a multi-select
// (any other form returns '' and keeps the theme's own rule: an odd last field is full width).
// A multi-select always takes the full line; a field left without a partner before it,
// or at the end, takes the full line too; every other field shares its line.
public getRowClass(ctl: BasicEntryFormControl): string {
const controls = this.basicMasterView.entryFrom.controls;
if (!controls.some(x => x.controlType == EnumDynamicControlType.MultiSelectServerData)) {
return '';
}
const full = new Set<BasicEntryFormControl>();
let openField: BasicEntryFormControl = null; // field waiting for a partner on its right
controls.forEach(x => {
if (x.controlType == EnumDynamicControlType.MultiSelectServerData) {
if (openField != null) {
full.add(openField);
openField = null;
}
full.add(x);
} else if (openField == null) {
openField = x;
} else {
openField = null;
}
});
if (openField != null) {
full.add(openField);
}
return full.has(ctl) ? 'form-row-full' : 'form-row-half';
}
public scrollToTop(): void {
const element = this.elementRef.nativeElement;
element.scrollIntoView({ behavior: 'smooth', block: 'start' });

View File

@ -41,6 +41,17 @@
[style.width]="textFieldWidth">
</kendo-dropdownlist>
}
@case (8) {
<kendo-multiselect [id]="basiccontrol.controlID" [formControlName]="basiccontrol.controlID"
[data]="this.basiccontrol.dropDownValues"
[textField]="'dataValue'"
[valueField]="'keyValue'"
[valuePrimitive]="true"
[autoClose]="false"
[placeholder]="multiSelectPlaceholder"
[style.width]="textFieldWidth">
</kendo-multiselect>
}
}
</div>
@if (!isValid) {

View File

@ -8,7 +8,10 @@ export enum EnumDynamicControlType {
CheckBox,
DateTime,
NumText,
IntNumText
IntNumText,
// Kendo multi-select fed from a master object ('Object|Get|IDField|TextField').
// The value travels as comma-separated IDs, e.g. "1,3".
MultiSelectServerData
}
export enum EnumDefaultValidatorType {
@ -97,6 +100,10 @@ export class BasicEntryFormControl {
codeAutoGenerate: boolean = false;
treeViewTier: number;
treeViewparentID?: number;
// MultiSelectServerData only: load the list filtered by the current payroll type.
multiSelectPayrollTypeSearch: boolean = false;
// MultiSelectServerData only: placeholder text; when empty it is "Select <label>".
placeholder: string;
constructor(
Label: string,

View File

@ -168,6 +168,30 @@ export class BasicMasterViewComponent implements OnInit {
}
if (ctl.controlType == EnumDynamicControlType.MultiSelectServerData) {
this.bsView.GetMultiSelectValue(ctl).subscribe(data => {
const values: ControlDropDownValue[] = [];
const arrData: any[] = data || [];
arrData.forEach(row => {
let id: number = 0;
let text;
Object.keys(row).forEach(key => {
if (key.toLowerCase() == ctl.dropdownValue[2].toLowerCase()) {
id = row[key];
}
if (key.toLowerCase() == ctl.dropdownValue[3].toLowerCase()) {
text = row[key];
}
});
if (id != 0 && text != undefined) {
values.push(new ControlDropDownValue(id, text));
}
});
// replaced, not appended, so a reload (status change) does not duplicate the list
ctl.dropDownValues = values;
});
}
});
//for showing active inactive button
// if (this.selectedTreeNode != undefined) {
@ -551,10 +575,32 @@ export class BasicMasterViewComponent implements OnInit {
}
public Delete(row: DataItem, rowindex: any) {
if (confirm('Are you sure to Delete?') == false) {
return;
// e.g. 'Are you sure you want to delete this Bonus "Festival Bonus"?'
private getDeleteConfirmMessage(row: DataItem): string {
const caption = (this.BMasterView.caption || '').trim();
let name = '';
if (row != undefined && row != null) {
const nameKey = Object.keys(row).find(k => k.toLowerCase() == 'name');
if (nameKey != undefined && row[nameKey] != undefined && row[nameKey] != null) {
name = String(row[nameKey]).trim();
}
}
let message = caption != '' ? `Are you sure you want to delete this ${caption}` : 'Are you sure you want to delete this item';
if (name != '') {
message = message + ` "${name}"`;
}
return message + '?';
}
public Delete(row: DataItem, rowindex: any) {
this.notification.showActiveConfirm('Confirmation', this.getDeleteConfirmMessage(row)).then((isConfirmed) => {
if (isConfirmed) {
this.DeleteConfirmed(row, rowindex);
}
});
}
private DeleteConfirmed(row: DataItem, rowindex: any) {
this.setIDValue(row);
this.loadingService.ShowLoadingPanel = true;

View File

@ -92,6 +92,9 @@ export class basicformbuilderService {
// }
//}
else if (question.controlType == EnumDynamicControlType.MultiSelectServerData) {
fromctl = new FormControl(this.toMultiSelectValue(question.value));
}
else {
fromctl = new FormControl(question.value || '');
}
@ -102,6 +105,16 @@ export class basicformbuilderService {
return new FormGroup(group);
}
// "1,3" -> [1, 3] (MultiSelectServerData keeps its value as comma-separated IDs)
private toMultiSelectValue(value: any): number[] {
if (value == undefined || value == null || String(value).trim() == '') {
return [];
}
return String(value).split(',')
.map(x => Number(x.trim()))
.filter(x => !isNaN(x) && x != 0);
}
search(): Observable<any> {
var functionName = 'Get/Null';
return this._apiService.httpGet<any>('/BasicBuilder/GetMasterViewData/' +
@ -117,6 +130,12 @@ export class basicformbuilderService {
}
GetMultiSelectValue(Dtpcontrol: BasicEntryFormControl): Observable<any> {
return this._apiService.httpGet<any>('/BasicBuilder/GetMasterViewData/' +
Dtpcontrol.dropdownValue[0] + '/' + 'Get/1/' + (Dtpcontrol.multiSelectPayrollTypeSearch == true));
//1 == Status-Active
}
GetByID(): Observable<any> {
return this._apiService.httpGet<any>('/BasicBuilder/Get/' +

View File

@ -37,6 +37,7 @@ export class BonusBasicEntryComponent implements OnInit {
this.msv.searchPayrolltype = true;
this.msv.listViewColumn.push(new BasicMasterListColumn('Code', 'Code', EnumColumnDataTypes.String));
this.msv.listViewColumn.push(new BasicMasterListColumn('Name', 'Name', EnumColumnDataTypes.String));
this.msv.listViewColumn.push(new BasicMasterListColumn('Religion', 'ReligionNames', EnumColumnDataTypes.String));
//this.msv.listViewColumn.push(new BasicMasterListColumn('Status', 'Status', EnumColumnDataTypes.String));
@ -49,6 +50,7 @@ export class BonusBasicEntryComponent implements OnInit {
this.msv.entryFrom.AddControl('Code', 'Code', EnumDynamicControlType.TextBox, '', true, EnumDefaultValidatorType.Custom, 256, 2);
this.msv.entryFrom.AddControl('Name', 'Name', EnumDynamicControlType.TextBox, '', true, EnumDefaultValidatorType.Custom, 256, 2);
this.msv.entryFrom.AddControl('Name in Bangla', 'NameInBangla', EnumDynamicControlType.TextBox, '', false, EnumDefaultValidatorType.Custom, 256, 2);
this.msv.entryFrom.AddControl('Religion', 'ReligionIDs', EnumDynamicControlType.MultiSelectServerData, 'Religion|Get|ID|Name', false);
}
}

View File

@ -1108,7 +1108,12 @@ $mf: '#{$std} app-basic-entry-form';
min-width: 0;
}
// An odd number of fields: the last one has no partner on its right, so it takes the full width
#{$mf} .form-row-wrapper > .form-row:last-child:nth-child(odd) {
#{$mf} .form-row-wrapper > .form-row:last-child:nth-child(odd):not(.form-row-half) {
grid-column: 1 / -1;
}
// Forms with a multi-select: Basic-Entry-Form.component works the layout out per field
// (form-row-full / form-row-half), since a full-line multi-select breaks the odd/even count
#{$mf} .form-row-wrapper > .form-row.form-row-full {
grid-column: 1 / -1;
}

View File

@ -120,6 +120,11 @@ namespace HRM.UI.Controllers
{
ptr.SetValue(obj, Convert.ToInt32(item.value), null);
}
else if (item.controlType == EnumDynamicControlType.MultiSelectServerData)
{
// comma-separated IDs; an empty value is set too, so clearing every selection is saved
ptr.SetValue(obj, item.value ?? string.Empty, null);
}
}
}
}
@ -473,7 +478,8 @@ namespace HRM.UI.Controllers
CheckBox,
DateTime,
NumText,
IntNumText
IntNumText,
MultiSelectServerData
}
public enum enumfromViewType