CEL_Payroll/Payroll.Report/Class/rptRewardStatement.cs

582 lines
30 KiB
C#
Raw Permalink Normal View History

2024-09-17 14:30:13 +06:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Payroll.BO;
using Ease.CoreV35.Model;
namespace Payroll.Report
{
public class rptRewardStatement
{
Employee _employee = null;
DateTime _rewardYear;
DataSet _dsRewardStatement = null;
int _currentYear;
int _previousYear;
public rptRewardStatement() { }
public void ShowReport(string employeeNo, DateTime rewardYear)
{
try
{
_employee = Employee.Get().Where(x => x.EmployeeNo == employeeNo).FirstOrDefault();
_rewardYear = rewardYear;
if (_employee != null)
{
fReportViewer form = new fReportViewer();
DataRow row = null;
string empName = string.Empty;
string empDivision = string.Empty;
string empDesignation = string.Empty;
double previousBasic = 0;
double currentBasic = 0;
double previousGross = 0;
double currentGross = 0;
double nPrevAmount = 0;
double nCurrAmount = 0;
double nServiceYear = 0;
PayrollDataSet.PayrollDataSet.dtRewardStatementDataTable dtRewardStatement = new PayrollDataSet.PayrollDataSet.dtRewardStatementDataTable();
//Loading neccessary data
LoadReportData();
//Finding minimum and maximum basic
FindPreviousCurrentBasic(ref previousBasic, ref currentBasic);
//Creating the row
row = dtRewardStatement.NewRow();
//Adding allow deduct items
CreateAllowDeductDataRow(dtRewardStatement, row, previousBasic, currentBasic, ref previousGross, ref currentGross);
//Adding festival bonus row
row["PrevYearFestivalBonus"] = (previousBasic * 2) / 12;
row["CurrYearFestivalBonus"] = (currentBasic * 2) / 12;
//Adding yearly eligible bonus row
previousGross += (previousBasic * 2) / 12;
currentGross += (currentBasic * 2) / 12;
CreateYearlyEligibleBonusDataRow(dtRewardStatement, row, previousGross, currentGross);
//Adding WPPF and WWF row
if (_employee.GradeID != null && !_employee.GradeID.IsUnassigned)
CreateWPPFDataRow(dtRewardStatement, row);
//Adding Yearly PF row
row["PrevYearPF"] = (previousBasic * 10) / 100;
row["CurrYearPF"] = (currentBasic * 10) / 100;
//Adding Provident Fund row
row["PrevYearProvidentFund"] = ((previousBasic * 10) / 100) * 2;
row["CurrYearProvidentFund"] = ((currentBasic * 10) / 100) * 2;
//Adding Gratuity row
TimeSpan ts;
ts = DateTime.Today - _employee.JoiningDate;
nServiceYear = (double)ts.Days / 365;
nServiceYear = Math.Round(nServiceYear);
if (nServiceYear >= 5 && nServiceYear < 5.5)
{
nPrevAmount = (previousBasic / 12) * nServiceYear;
nCurrAmount = (currentBasic / 12) * nServiceYear;
}
else if (nServiceYear >= 5.5 && nServiceYear < 10)
{
nPrevAmount = ((previousBasic / 12) * 1.5) * nServiceYear;
nCurrAmount = ((currentBasic / 12) * 1.5) * nServiceYear;
}
else if (nServiceYear >= 10)
{
nPrevAmount = ((previousBasic / 12) * 2) * nServiceYear;
nCurrAmount = ((currentBasic / 12) * 2) * nServiceYear;
}
row["PrevYearGratuity"] = nPrevAmount;
row["CurrYearGratuity"] = nCurrAmount;
//Adding the row
dtRewardStatement.Rows.Add(row);
empName = _employee.Name;
empDivision = _employee.Department != null ? _employee.Department.Name : string.Empty;
empDesignation = _employee.Designation != null ? _employee.Designation.Name : string.Empty;
form.ShowRewardStatementReport(empName, empDivision, empDesignation, _rewardYear.Year.ToString(), _rewardYear.AddYears(-1).Year.ToString(), dtRewardStatement);
}
else
{
MessageBox.Show("Employee not found", "Not Found", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception ex)
{
throw ex;
}
}
private void LoadReportData()
{
_currentYear = _rewardYear.Year;
_previousYear = _rewardYear.AddYears(-1).Year;
string sbonusIDs = "" + "'" + "5" + "'" + "," + "'" + "4" + "'" + "," + "'" + "3" + "'";
_dsRewardStatement = SalaryMonthly.GetRewardStatementReportData(EnumAllowOrDeduct.Allowance, _employee.ID, EnumADEmpType.AppliedToIndividual,
_previousYear, _currentYear, _employee.GradeID, sbonusIDs, EnmSetupManagerTranType.Grade);
}
private void FindPreviousCurrentBasic(ref double previousBasic, ref double currentBasic)
{
List<DataRow> basicSalaries = _dsRewardStatement.Tables["Basic"].AsEnumerable().Where(x => Convert.ToInt32(x["EmployeeId"]) == _employee.ID.Integer).ToList();
if (basicSalaries != null && basicSalaries.Count > 0)
{
if (basicSalaries.Count > 1)
{
if (Convert.ToDouble(basicSalaries.ElementAt(1).ItemArray[1]) > Convert.ToDouble(basicSalaries.ElementAt(0).ItemArray[1]))
{
previousBasic = (Convert.ToDouble(basicSalaries.ElementAt(0).ItemArray[1]) * 12);
currentBasic = (Convert.ToDouble(basicSalaries.ElementAt(1).ItemArray[1]) * 12);
}
else
{
previousBasic = (Convert.ToDouble(basicSalaries.ElementAt(1).ItemArray[1]) * 12);
currentBasic = (Convert.ToDouble(basicSalaries.ElementAt(0).ItemArray[1]) * 12);
}
}
else if (basicSalaries.ElementAt(0) != null || basicSalaries.ElementAt(1) != null)
{
if (basicSalaries.ElementAt(0) != null)
{
previousBasic = (Convert.ToDouble(basicSalaries.ElementAt(0).ItemArray[1]) * 12);
currentBasic = (Convert.ToDouble(basicSalaries.ElementAt(0).ItemArray[1]) * 12);
}
else if (basicSalaries.ElementAt(1) != null)
{
previousBasic = (Convert.ToDouble(basicSalaries.ElementAt(1).ItemArray[1]) * 12);
currentBasic = (Convert.ToDouble(basicSalaries.ElementAt(1).ItemArray[1]) * 12);
}
}
}
}
private void FindPreviousCurrentGrade(ref int previousGrade, ref int currentGrade)
{
List<DataRow> grades = _dsRewardStatement.Tables["Grade"].AsEnumerable().Where(x => Convert.ToInt32(x["EmployeeId"]) == _employee.ID.Integer).ToList();
if (grades != null)
{
if (grades.Count > 1)
{
if (Convert.ToDouble(grades.ElementAt(1).ItemArray[0]) > Convert.ToDouble(grades.ElementAt(0).ItemArray[0]))
{
previousGrade = Convert.ToInt32(grades.ElementAt(0).ItemArray[2]);
currentGrade = Convert.ToInt32(grades.ElementAt(1).ItemArray[2]);
}
else
{
previousGrade = Convert.ToInt32(grades.ElementAt(1).ItemArray[2]);
currentGrade = Convert.ToInt32(grades.ElementAt(0).ItemArray[2]);
}
}
else if (grades.ElementAt(0) != null || grades.ElementAt(1) != null)
{
if (grades.ElementAt(0) != null)
{
previousGrade = Convert.ToInt32(grades.ElementAt(0).ItemArray[2]);
currentGrade = Convert.ToInt32(grades.ElementAt(0).ItemArray[2]);
}
if (grades.ElementAt(1) != null)
{
previousGrade = Convert.ToInt32(grades.ElementAt(1).ItemArray[2]);
currentGrade = Convert.ToInt32(grades.ElementAt(1).ItemArray[2]);
}
}
}
}
private void FindPreviousCurrentADParamAmount(List<DataRow> allowDeducts, ref double previousAmount, ref double currentAmount)
{
if (allowDeducts != null && allowDeducts.Count > 0)
{
allowDeducts = allowDeducts.Take(2).ToList();
if (allowDeducts.Count > 0)
{
if (allowDeducts.Count == 1)
{
ID allowDeductID = Ease.CoreV35.Model.ID.FromInteger(Convert.ToInt32(allowDeducts.ElementAt(0).ItemArray[3]));
DateTime salaryMonth = Convert.ToDateTime(allowDeducts.ElementAt(0).ItemArray[0]).AddMonths(-1);
DataTable dtSalaryMonthlyDetail = SalaryMonthly.GetCalCulatedAmountByAllowDeductID(_employee.ID, allowDeductID, GlobalFunctions.LastDateOfMonth(salaryMonth));
if (dtSalaryMonthlyDetail != null && dtSalaryMonthlyDetail.Rows != null && dtSalaryMonthlyDetail.Rows.Count > 0)
allowDeducts.Add(dtSalaryMonthlyDetail.AsEnumerable().SingleOrDefault());
}
if (allowDeducts.Count > 1)
{
if (Convert.ToDouble(allowDeducts.ElementAt(1).ItemArray[1]) > Convert.ToDouble(allowDeducts.ElementAt(0).ItemArray[1]))
{
previousAmount = Convert.ToDouble(allowDeducts.ElementAt(0).ItemArray[8]);
currentAmount = Convert.ToDouble(allowDeducts.ElementAt(1).ItemArray[8]);
}
else
{
previousAmount = Convert.ToDouble(allowDeducts.ElementAt(1).ItemArray[8]);
currentAmount = Convert.ToDouble(allowDeducts.ElementAt(0).ItemArray[8]);
}
}
else if (allowDeducts.ElementAt(0) != null || allowDeducts.ElementAt(1) != null)
{
if (allowDeducts.ElementAt(0) != null)
{
previousAmount = Convert.ToDouble(allowDeducts.ElementAt(0).ItemArray[8]);
currentAmount = Convert.ToDouble(allowDeducts.ElementAt(0).ItemArray[8]);
}
else if (allowDeducts.ElementAt(1) != null)
{
previousAmount = Convert.ToDouble(allowDeducts.ElementAt(1).ItemArray[8]);
currentAmount = Convert.ToDouble(allowDeducts.ElementAt(1).ItemArray[8]);
}
}
}
}
}
private void CreateWPPFDataRow(PayrollDataSet.PayrollDataSet.dtRewardStatementDataTable dtRewardStatement, DataRow row)
{
try
{
DataTable dtGradeWPPF = null;
dtGradeWPPF = _dsRewardStatement.Tables["WPPF"];
if (dtGradeWPPF != null && (dtGradeWPPF.Rows != null && dtGradeWPPF.Rows.Count > 0))
{
row["PrevYearWPPF"] = Convert.ToDouble(dtGradeWPPF.AsEnumerable().Where(x => Convert.ToInt32(x["EffectYear"]) == _previousYear).Select(x => x["Amount"]).FirstOrDefault());
row["CurrYearWPPF"] = Convert.ToDouble(dtGradeWPPF.AsEnumerable().Where(x => Convert.ToInt32(x["EffectYear"]) == _currentYear).Select(x => x["Amount"]).FirstOrDefault());
}
dtGradeWPPF = _dsRewardStatement.Tables["WWF"];
if (dtGradeWPPF != null && (dtGradeWPPF.Rows != null && dtGradeWPPF.Rows.Count > 0))
{
row["PrevYearWWF"] = Convert.ToDouble(dtGradeWPPF.AsEnumerable().Where(x => Convert.ToInt32(x["EffectYear"]) == _previousYear).Select(x => x["Amount"]).FirstOrDefault());
row["CurrYearWWF"] = Convert.ToDouble(dtGradeWPPF.AsEnumerable().Where(x => Convert.ToInt32(x["EffectYear"]) == _currentYear).Select(x => x["Amount"]).FirstOrDefault());
}
dtGradeWPPF = _dsRewardStatement.Tables["WPPFClaim"];
if (dtGradeWPPF != null && (dtGradeWPPF.Rows != null && dtGradeWPPF.Rows.Count > 0))
{
row["PrevYearWPPFClaim"] = Convert.ToDouble(dtGradeWPPF.AsEnumerable().Where(x => Convert.ToInt32(x["EffectYear"]) == _previousYear).Select(x => x["Amount"]).FirstOrDefault());
row["CurrYearWPPFClaim"] = Convert.ToDouble(dtGradeWPPF.AsEnumerable().Where(x => Convert.ToInt32(x["EffectYear"]) == _currentYear).Select(x => x["Amount"]).FirstOrDefault());
}
}
catch (Exception ex)
{
throw ex;
}
}
private void CreateAllowDeductDataRow(PayrollDataSet.PayrollDataSet.dtRewardStatementDataTable dtRewardStatement, DataRow row,
double previousbasic, double currentbasic, ref double previousGross, ref double currentGross)
{
try
{
double prevYearTotal = 0;
double currYearTotal = 0;
double previousADParamAmount = 0;
double currentADParamAmount = 0;
double amount = 0;
List<DataRow> tempDataRow = null;
ObjectsTemplate<ADParameter> aDParams = ADParameter.Get(_employee.GradeID, EnumEntitleType.Grade, EnumAllowOrDeduct.Allowance);
DataTable dtADParamEmps = _dsRewardStatement.Tables["ADPARAM"];
//Creating Basic Salary Row
row["PrevYearBasic"] = previousbasic;
row["CurrYearBasic"] = currentbasic;
prevYearTotal += previousbasic;
currYearTotal += currentbasic;
previousGross += previousbasic;
currentGross += currentbasic;
foreach (ADParameter item in aDParams)
{
amount = 0;
if (item.AllowanceDeduction.Name == "House Rent")
{
amount = item.GetGradeDefinedAmount(_employee, previousbasic,
_employee.GrossSalary, new EmployeeGradeSalary());
row["PrevYearHouseRent"] = amount;
prevYearTotal += amount;
previousGross += amount;
amount = item.GetGradeDefinedAmount(_employee, currentbasic,
_employee.GrossSalary, new EmployeeGradeSalary());
row["CurrYearHouseRent"] = amount;
currYearTotal += amount;
currentGross += amount;
}
if (item.AllowanceDeduction.Name == "Medical")
{
amount = (item.GetGradeDefinedAmount(_employee, previousbasic,
_employee.GrossSalary, new EmployeeGradeSalary()) * 12);
row["PrevYearMedicalAllowance"] = amount;
prevYearTotal += amount;
previousGross += amount;
amount = (item.GetGradeDefinedAmount(_employee, currentbasic,
_employee.GrossSalary, new EmployeeGradeSalary()) * 12);
row["CurrYearMedicalAllowance"] = amount;
currYearTotal += amount;
currentGross += amount;
}
if (item.AllowanceDeduction.Name == "Transport")
{
amount = (item.GetGradeDefinedAmount(_employee, previousbasic,
_employee.GrossSalary, new EmployeeGradeSalary()) * 12);
row["PrevYearTransportAllowance"] = amount;
prevYearTotal += amount;
amount = (item.GetGradeDefinedAmount(_employee, currentbasic,
_employee.GrossSalary, new EmployeeGradeSalary()) * 12);
row["CurrYearTransportAllowance"] = amount;
currYearTotal += amount;
}
if (item.AllowanceDeduction.Name == "LFA")
{
amount = item.GetGradeDefinedAmount(_employee, previousbasic,
_employee.GrossSalary, new EmployeeGradeSalary());
row["PrevYearLFA"] = amount;
prevYearTotal += amount;
previousGross += amount;
amount = item.GetGradeDefinedAmount(_employee, currentbasic,
_employee.GrossSalary, new EmployeeGradeSalary());
row["CurrYearLFA"] = amount;
currYearTotal += amount;
currentGross += amount;
}
}
//ADParameter By Employee
if (dtADParamEmps != null && dtADParamEmps.Rows != null && dtADParamEmps.Rows.Count > 0)
{
amount = 0;
//Medical
if (row.IsNull("CurrYearMedicalAllowance"))
{
tempDataRow = dtADParamEmps.AsEnumerable().Where(x => x.Field<string>("Name") == "Medical").ToList();
this.FindPreviousCurrentADParamAmount(tempDataRow, ref previousADParamAmount, ref currentADParamAmount);
amount = (previousADParamAmount * 12);
row["PrevYearMedicalAllowance"] = amount;
prevYearTotal += amount;
previousGross += amount;
amount = (currentADParamAmount * 12);
row["CurrYearMedicalAllowance"] = amount;
currYearTotal += amount;
currentGross += amount;
}
//Transport
if (row.IsNull("CurrYearTransportAllowance"))
{
previousADParamAmount = currentADParamAmount = 0;
tempDataRow = dtADParamEmps.AsEnumerable().Where(x => x.Field<string>("Name") == "Transport").ToList();
this.FindPreviousCurrentADParamAmount(tempDataRow, ref previousADParamAmount, ref currentADParamAmount);
amount = (previousADParamAmount * 12);
row["PrevYearTransportAllowance"] = amount;
prevYearTotal += amount;
amount = (currentADParamAmount * 12);
row["CurrYearTransportAllowance"] = amount;
currYearTotal += amount;
}
}
//Creating GuarantedCash Row
row["PrevYearGuarantedCash"] = prevYearTotal;
row["CurrYearGuarantedCash"] = currYearTotal;
}
catch (Exception ex)
{
throw ex;
}
}
private void CreateYearlyEligibleBonusDataRow(PayrollDataSet.PayrollDataSet.dtRewardStatementDataTable dtRewardStatement, DataRow row, double previousGross, double currentGross)
{
try
{
//string sbonusIDs = "" + "'" + "2" + "'" + "," + "'" + "3" + "'" + "," + "'" + "5" + "'" + "," + "'" + "6" + "'" + "," + "'" + "7" + "'";
int previousGrade = 0;
int currentGrade = 0;
double quaterlyBonus = 0;
List<DataRow> bonusParam = null;
DataTable dtBonusParam = _dsRewardStatement.Tables["BONUS"];
FindPreviousCurrentGrade(ref previousGrade, ref currentGrade);
if (dtBonusParam.Rows != null && dtBonusParam.Rows.Count > 0)
{
//Individual Bonus
//For Previous Grade
bonusParam = dtBonusParam.AsEnumerable().Where(x => Convert.ToInt32(x["TranID"]) == previousGrade && Convert.ToInt32(x["BonusID"]) == 3).ToList();
if (bonusParam != null && bonusParam.Count > 0)
{
row["PrevYearIndividualBonus"] = (((previousGross * Convert.ToDouble(bonusParam.Select(x => x["PercentOfGross"]).FirstOrDefault())) / 100)
* (Convert.ToDouble(bonusParam.Select(x => x["PerformanceBonusPercent"]).FirstOrDefault())) / 100);
}
//For Current Grade
bonusParam = dtBonusParam.AsEnumerable().Where(x => Convert.ToInt32(x["TranID"]) == currentGrade && Convert.ToInt32(x["BonusID"]) == 3).ToList();
if (bonusParam != null && bonusParam.Count > 0)
{
row["CurrYearIndividualBonus"] = (((currentGross * Convert.ToDouble(bonusParam.Select(x => x["PercentOfGross"]).FirstOrDefault())) / 100)
* (Convert.ToDouble(bonusParam.Select(x => x["PerformanceBonusPercent"]).FirstOrDefault())) / 100);
}
//Quarterly Bonus
//For Previous Grade
bonusParam = dtBonusParam.AsEnumerable().Where(x => Convert.ToInt32(x["TranID"]) == previousGrade && Convert.ToInt32(x["BonusID"]) == 5).ToList();
if (bonusParam != null && bonusParam.Count > 0)
{
quaterlyBonus += (((previousGross * Convert.ToDouble(bonusParam.Select(x => x["PercentOfGross"]).FirstOrDefault())) / 100)
* (Convert.ToDouble(bonusParam.Select(x => x["PerformanceBonusPercent"]).FirstOrDefault())) / 100);
}
//bonusParam = dtBonusParam.AsEnumerable().Where(x => Convert.ToInt32(x["TranID"]) == previousGrade && Convert.ToInt32(x["BonusID"]) == 5).ToList();
//if (bonusParam != null && bonusParam.Count > 0)
//{
// dtTempBonusParam = bonusParam.CopyToDataTable();
// if (dtTempBonusParam != null && dtTempBonusParam.Rows != null && dtTempBonusParam.Rows.Count > 0)
// {
// quaterlyBonus += (((previousGross * Convert.ToDouble(dtTempBonusParam.AsEnumerable().Select(x => x["PercentOfGross"]).FirstOrDefault())) / 100)
// * (Convert.ToDouble(dtTempBonusParam.AsEnumerable().Select(x => x["PerformanceBonusPercent"]).FirstOrDefault())) / 100);
// }
//}
//bonusParam = dtBonusParam.AsEnumerable().Where(x => Convert.ToInt32(x["TranID"]) == previousGrade && Convert.ToInt32(x["BonusID"]) == 6).ToList();
//if (bonusParam != null && bonusParam.Count > 0)
//{
// dtTempBonusParam = bonusParam.CopyToDataTable();
// if (dtTempBonusParam != null && dtTempBonusParam.Rows != null && dtTempBonusParam.Rows.Count > 0)
// {
// quaterlyBonus += (((previousGross * Convert.ToDouble(dtTempBonusParam.AsEnumerable().Select(x => x["PercentOfGross"]).FirstOrDefault())) / 100)
// * (Convert.ToDouble(dtTempBonusParam.AsEnumerable().Select(x => x["PerformanceBonusPercent"]).FirstOrDefault())) / 100);
// }
//}
//bonusParam = dtBonusParam.AsEnumerable().Where(x => Convert.ToInt32(x["TranID"]) == previousGrade && Convert.ToInt32(x["BonusID"]) == 7).ToList();
//if (bonusParam != null && bonusParam.Count > 0)
//{
// dtTempBonusParam = bonusParam.CopyToDataTable();
// if (dtTempBonusParam != null && dtTempBonusParam.Rows != null && dtTempBonusParam.Rows.Count > 0)
// {
// quaterlyBonus += (((previousGross * Convert.ToDouble(dtTempBonusParam.AsEnumerable().Select(x => x["PercentOfGross"]).FirstOrDefault())) / 100)
// * (Convert.ToDouble(dtTempBonusParam.AsEnumerable().Select(x => x["PerformanceBonusPercent"]).FirstOrDefault())) / 100);
// }
//}
row["PrevYearQuarterlyBonus"] = quaterlyBonus;
//For Current Grade
quaterlyBonus = 0;
bonusParam = dtBonusParam.AsEnumerable().Where(x => Convert.ToInt32(x["TranID"]) == currentGrade && Convert.ToInt32(x["BonusID"]) == 5).ToList();
if (bonusParam != null && bonusParam.Count > 0)
{
quaterlyBonus += (((currentGross * Convert.ToDouble(bonusParam.Select(x => x["PercentOfGross"]).FirstOrDefault())) / 100)
* (Convert.ToDouble(bonusParam.Select(x => x["PerformanceBonusPercent"]).FirstOrDefault())) / 100);
}
//bonusParam = dtBonusParam.AsEnumerable().Where(x => Convert.ToInt32(x["TranID"]) == currentGrade && Convert.ToInt32(x["BonusID"]) == 5).ToList();
//if (bonusParam != null && bonusParam.Count > 0)
//{
// dtTempBonusParam = bonusParam.CopyToDataTable();
// if (dtTempBonusParam != null && dtTempBonusParam.Rows != null && dtTempBonusParam.Rows.Count > 0)
// {
// quaterlyBonus += (((currentGross * Convert.ToDouble(dtTempBonusParam.AsEnumerable().Select(x => x["PercentOfGross"]).FirstOrDefault())) / 100)
// * (Convert.ToDouble(dtTempBonusParam.AsEnumerable().Select(x => x["PerformanceBonusPercent"]).FirstOrDefault())) / 100);
// }
//}
//bonusParam = dtBonusParam.AsEnumerable().Where(x => Convert.ToInt32(x["TranID"]) == currentGrade && Convert.ToInt32(x["BonusID"]) == 6).ToList();
//if (bonusParam != null && bonusParam.Count > 0)
//{
// dtTempBonusParam = bonusParam.CopyToDataTable();
// if (dtTempBonusParam != null && dtTempBonusParam.Rows != null && dtTempBonusParam.Rows.Count > 0)
// {
// quaterlyBonus += (((currentGross * Convert.ToDouble(dtTempBonusParam.AsEnumerable().Select(x => x["PercentOfGross"]).FirstOrDefault())) / 100)
// * (Convert.ToDouble(dtTempBonusParam.AsEnumerable().Select(x => x["PerformanceBonusPercent"]).FirstOrDefault())) / 100);
// }
//}
//bonusParam = dtBonusParam.AsEnumerable().Where(x => Convert.ToInt32(x["TranID"]) == currentGrade && Convert.ToInt32(x["BonusID"]) == 7).ToList();
//if (bonusParam != null && bonusParam.Count > 0)
//{
// dtTempBonusParam = bonusParam.CopyToDataTable();
// if (dtTempBonusParam != null && dtTempBonusParam.Rows != null && dtTempBonusParam.Rows.Count > 0)
// {
// quaterlyBonus += (((currentGross * Convert.ToDouble(dtTempBonusParam.AsEnumerable().Select(x => x["PercentOfGross"]).FirstOrDefault())) / 100)
// * (Convert.ToDouble(dtTempBonusParam.AsEnumerable().Select(x => x["PerformanceBonusPercent"]).FirstOrDefault())) / 100);
// }
//}
row["CurrYearQuarterlyBonus"] = quaterlyBonus;
//Company Bonus
//For Previous Grade
bonusParam = dtBonusParam.AsEnumerable().Where(x => Convert.ToInt32(x["TranID"]) == previousGrade && Convert.ToInt32(x["BonusID"]) == 4).ToList();
if (bonusParam != null && bonusParam.Count > 0)
{
row["PrevYearCompanyBonus"] = (((previousGross * Convert.ToDouble(bonusParam.Select(x => x["PercentOfGross"]).FirstOrDefault())) / 100)
* (Convert.ToDouble(bonusParam.Select(x => x["PerformanceBonusPercent"]).FirstOrDefault())) / 100);
}
//For Current Grade
bonusParam = dtBonusParam.AsEnumerable().Where(x => Convert.ToInt32(x["TranID"]) == currentGrade && Convert.ToInt32(x["BonusID"]) == 4).ToList();
if (bonusParam != null && bonusParam.Count > 0)
{
row["CurrYearCompanyBonus"] = (((currentGross * Convert.ToDouble(bonusParam.Select(x => x["PercentOfGross"]).FirstOrDefault())) / 100)
* (Convert.ToDouble(bonusParam.Select(x => x["PerformanceBonusPercent"]).FirstOrDefault())) / 100);
}
}
}
catch (Exception ex)
{
throw ex;
}
}
}
}