HRM-10/HRM.Report/Class/ReportGlobal.cs
Mohaimen Hasan 838b8d4480 first commit
2026-11-03 13:06:00 +06:00

150 lines
4.5 KiB
C#

using HRM.BO;
using HRM.DA;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HRM.Report
{
public class ReportGlobal
{
public static double GetBalanceForBS(List<RDRowAmountCalItem> oRDRowAmountCalItems, DateTime processingDate)
{
double nBalance = 0;
foreach (RDRowAmountCalItem oItem in oRDRowAmountCalItems)
{
double GLBalance = 0;
GLBalance = Math.Abs(new GLTranService().GetBalanceForBS(oItem.GLID, processingDate));
if (oItem.Operator == EnumOperator.Addition)
{
nBalance = nBalance + GLBalance;
}
else
{
nBalance = nBalance - GLBalance;
}
}
return nBalance;
}
public static decimal GetRowSUM(DataTable dtRowSum, int nRowID)
{
decimal nAmount = 0;
DataTable dtTotalSum = dtRowSum;
List<RowSumCalcItem> oRowSumCalcItems = new List<RowSumCalcItem>();
oRowSumCalcItems = new RowSumCalcItemService().GetByRowID(nRowID);
String sRowIDs = string.Empty;
foreach (RowSumCalcItem oItem in oRowSumCalcItems)
{
if (sRowIDs == string.Empty)
{
sRowIDs = sRowIDs + oItem.OtherRowID.ToString();
}
else
{
sRowIDs = sRowIDs + ", " + oItem.OtherRowID.ToString();
}
foreach (DataRow drow in dtRowSum.Rows)
{
try
{
if (Convert.ToInt32(drow["RowID"]) == oItem.OtherRowID)
{
decimal amount = 0;
if (drow["Amount"] != DBNull.Value)
{
amount = (Convert.ToDecimal(drow["Amount"]));
}
if (oItem.Operator == EnumOperator.Subtruction)
{
nAmount += (amount * -1);
}
else
{
nAmount += amount;
}
}
}
catch (Exception e)
{
throw new Exception(e.Message);
}
}
}
return nAmount;
}
public static double GetRowSUM(List<RowSumCalcItem> rowSumCalcItems, DateTime processingDate)
{
List<RowSumCalcItem> oRowSumCalcItems = new List<RowSumCalcItem>();
oRowSumCalcItems = rowSumCalcItems;
double amount = 0;
foreach (RowSumCalcItem oItem in oRowSumCalcItems)
{
oItem.RDReportRow.RDRowAmountCalItems = new RDRowAmountCalItemService().GetByRowID(oItem.RDReportRow.ID);
try
{
if (oItem.Operator == EnumOperator.Subtruction)
{
amount = amount - Math.Abs(GetBalanceForBS(oItem.RDReportRow.RDRowAmountCalItems, processingDate.AddDays(1)));
}
else
{
amount = amount + Math.Abs(GetBalanceForBS(oItem.RDReportRow.RDRowAmountCalItems, processingDate.AddDays(1)));
}
}
catch (Exception e)
{
throw new Exception(e.Message);
}
}
return amount;
}
public static double GetBalancePL(List<RDRowAmountCalItem> oRDRowAmountCalItems, DateTime fromDate, DateTime toDate)
{
double nBalance = 0;
foreach (RDRowAmountCalItem oItem in oRDRowAmountCalItems)
{
double GLBalance = 0;
GLBalance = Math.Abs(new GLService().GetBalancePL(oItem.GLID, fromDate, toDate));
if (oItem.Operator == EnumOperator.Addition)
{
nBalance = nBalance + GLBalance;
}
else
{
nBalance = nBalance - GLBalance;
}
}
return nBalance;
}
}
}